当前位置: 首页>>代码示例>>C++>>正文


C++ drmModeGetResources函数代码示例

本文整理汇总了C++中drmModeGetResources函数的典型用法代码示例。如果您正苦于以下问题:C++ drmModeGetResources函数的具体用法?C++ drmModeGetResources怎么用?C++ drmModeGetResources使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drmModeGetResources函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: query_device

static bool
query_device (ply_renderer_backend_t *backend)
{
  assert (backend != NULL);
  assert (backend->device_fd >= 0);

  backend->resources = drmModeGetResources (backend->device_fd);

  if (backend->resources == NULL)
    {
      ply_trace ("Could not get card resources");
      return false;
    }

  if (!create_heads_for_active_connectors (backend))
    {
      ply_trace ("Could not initialize heads");
      return false;
    }

  if (!has_32bpp_support (backend))
    {
      ply_trace ("Device doesn't support 32bpp framebuffer");
      return false;
    }

  return true;
}
开发者ID:AtsKiYsPoYl,项目名称:plymouth,代码行数:28,代码来源:plugin.c

示例2: drm_display_init_modeset

boolean
drm_display_init_modeset(struct native_display *ndpy)
{
   struct drm_display *drmdpy = drm_display(ndpy);

   /* resources are fixed, unlike crtc, connector, or encoder */
   drmdpy->resources = drmModeGetResources(drmdpy->fd);
   if (!drmdpy->resources) {
      _eglLog(_EGL_DEBUG, "Failed to get KMS resources.  Disable modeset.");
      return FALSE;
   }

   drmdpy->saved_crtcs =
      CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->saved_crtcs));
   if (!drmdpy->saved_crtcs) {
      drm_display_fini_modeset(&drmdpy->base);
      return FALSE;
   }

   drmdpy->shown_surfaces =
      CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->shown_surfaces));
   if (!drmdpy->shown_surfaces) {
      drm_display_fini_modeset(&drmdpy->base);
      return FALSE;
   }

   drmdpy->base.modeset = &drm_display_modeset;

   return TRUE;
}
开发者ID:nikai3d,项目名称:mesa,代码行数:30,代码来源:modeset.c

示例3: run_test

static int run_test(const char *test_name, enum test_flags flags)
{
	int i;

	resources = drmModeGetResources(drm_fd);
	igt_assert(resources);

	/* Find any connected displays */
	for (i = 0; i < resources->count_connectors; i++) {
		uint32_t connector_id;
		int j;

		connector_id = resources->connectors[i];
		for (j = 0; j < resources->count_crtcs; j++) {
			struct kmstest_connector_config cconf;

			if (!kmstest_get_connector_config(drm_fd, connector_id,
							   1 << j, &cconf))
				continue;

			test_connector(test_name, &cconf, flags);

			kmstest_free_connector_config(&cconf);
		}
	}

	drmModeFreeResources(resources);

	return 1;
}
开发者ID:Acidburn0zzz,项目名称:intel-gpu-tools,代码行数:30,代码来源:kms_render.c

示例4: ResourcesDeleter

mgg::DRMModeResources::DRMModeResources(int drm_fd)
    : drm_fd{drm_fd},
      resources{DRMModeResUPtr{drmModeGetResources(drm_fd), ResourcesDeleter()}}
{
    if (!resources)
        BOOST_THROW_EXCEPTION(std::runtime_error("Couldn't get DRM resources\n"));
}
开发者ID:TomasMM,项目名称:emir,代码行数:7,代码来源:drm_mode_resources.cpp

示例5: drmmode_pre_init

Bool drmmode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
{
	xf86CrtcConfigPtr   xf86_config;
	drmmode_ptr drmmode;
	int i;

	drmmode = xnfalloc(sizeof *drmmode);
	drmmode->fd = fd;
	drmmode->fb_id = 0;

	xf86CrtcConfigInit(scrn, &drmmode_xf86crtc_config_funcs);
	xf86_config = XF86_CRTC_CONFIG_PTR(scrn);

	drmmode->cpp = cpp;
	drmmode->mode_res = drmModeGetResources(drmmode->fd);
	if (!drmmode->mode_res) {
		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
			   "failed to get resources: %s\n", strerror(errno));
		return FALSE;
	}

	xf86CrtcSetSizeRange(scrn, 320, 200, drmmode->mode_res->max_width,
			     drmmode->mode_res->max_height);
	for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
		drmmode_crtc_init(scrn, drmmode, i);

	for (i = 0; i < drmmode->mode_res->count_connectors; i++)
		drmmode_output_init(scrn, drmmode, i);

	xf86InitialConfiguration(scrn, TRUE);

	return TRUE;
}
开发者ID:adegroote,项目名称:netbsd-drmgem,代码行数:33,代码来源:drmmode_display.c

示例6: getConnector

static drmModeConnector* getConnector(int fd, uint32_t connector_type)
{
    LOGV("Entering %s, %d", __func__, connector_type);
    drmModeRes *resources = drmModeGetResources(fd);
    drmModeConnector *connector = NULL;
    int i;

    if (resources == NULL || resources->connectors == NULL) {
        LOGE("%s: drmModeGetResources failed.", __func__);
        return NULL;
    }
    for (i = 0; i < resources->count_connectors; i++) {
        connector = drmModeGetConnector(fd, resources->connectors[i]);
        if (connector == NULL)
            continue;
        if (connector->connector_type == connector_type)
            break;

        drmModeFreeConnector(connector);
        connector = NULL;
    }
    drmModeFreeResources(resources);
    if (connector == NULL) {
        LOGE("%s: Failed to get conector", __func__);
    }
    LOGV("Leaving %s, %d", __func__, connector_type);
    return connector;
}
开发者ID:bju2000,项目名称:android_hardware_intel,代码行数:28,代码来源:drm_hdmi.cpp

示例7: blueshift_drm_update_card

/**
 * Update the resource, required after `blueshift_drm_open_card`
 * 
 * @param  connection  The identifier for the connection to the card
 */
void blueshift_drm_update_card(int connection)
{
  card_connection* card = card_connections + connection;
  
  if (card->res)
    drmModeFreeResources(card->res);
  
  card->res = drmModeGetResources(card->fd);
}
开发者ID:prodigeni,项目名称:blueshift,代码行数:14,代码来源:blueshift_drm_c.c

示例8: swc_drm_create_screens

bool swc_drm_create_screens(struct wl_list * screens)
{
    drmModeRes * resources;
    drmModeConnector * connector;
    uint32_t index;
    struct swc_output * output;
    uint32_t taken_crtcs = 0;

    if (!(resources = drmModeGetResources(swc.drm->fd)))
    {
        ERROR("Could not get DRM resources\n");
        return false;
    }

    for (index = 0; index < resources->count_connectors;
         ++index, drmModeFreeConnector(connector))
    {
        connector = drmModeGetConnector(swc.drm->fd,
                                        resources->connectors[index]);

        if (connector->connection == DRM_MODE_CONNECTED)
        {
            uint32_t crtc_index;
            uint32_t id;

            if (!find_available_crtc(resources, connector, taken_crtcs,
                                     &crtc_index))
            {
                WARNING("Could not find CRTC for connector %u\n", index);
                continue;
            }

            if (!find_available_id(&id))
            {
                WARNING("No more available output IDs\n");
                drmModeFreeConnector(connector);
                break;
            }

            if (!(output = swc_output_new(connector)))
                continue;

            output->screen = screen_new(resources->crtcs[crtc_index], output);
            output->screen->id = id;

            taken_crtcs |= 1 << crtc_index;
            drm.taken_ids |= 1 << id;

            wl_list_insert(screens, &output->screen->link);
        }
    }

    drmModeFreeResources(resources);

    return true;
}
开发者ID:ibab,项目名称:swc,代码行数:56,代码来源:drm.c

示例9: drmModeGetResources

bool CDRMUtils::GetResources()
{
  m_drm_resources = drmModeGetResources(m_fd);
  if(!m_drm_resources)
  {
    return false;
  }

  return true;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:10,代码来源:DRMUtils.cpp

示例10: ALOGE

drmModeConnectorPtr
IntelHWComposerDrm::getConnector(int disp)
{
    if (mDrmFd < 0) {
        ALOGE("%s: invalid drm FD\n", __func__);
        return NULL;
    }
    uint32_t req_connector_type = 0;
    uint32_t req_connector_type_id = 1;

    switch (disp) {
        case OUTPUT_MIPI0:
        case OUTPUT_MIPI1:
            req_connector_type = DRM_MODE_CONNECTOR_MIPI;
            req_connector_type_id = disp ? 2 : 1;
            break;
        case OUTPUT_HDMI:
            req_connector_type = DRM_MODE_CONNECTOR_DVID;
            break;
        default:
            ALOGW("%s: invalid device number: %d\n", __func__, disp);
            return NULL;
    }

    drmModeResPtr resources = drmModeGetResources(mDrmFd);
    if (!resources || !resources->connectors) {
        ALOGE("%s: fail to get drm resources. %s\n", __func__, strerror(errno));
        return NULL;
    }

    drmModeConnectorPtr connector = NULL;
    // get requested connector type and id
    // search connector
    for (int i = 0; i < resources->count_connectors; i++) {
        connector = drmModeGetConnector(mDrmFd, resources->connectors[i]);
        if (!connector) {
            ALOGW("%s: fail to get drm connector\n", __func__);
            continue;
        }

        if (connector->connector_type == req_connector_type &&
            connector->connector_type_id == req_connector_type_id)
            break;

        drmModeFreeConnector(connector);
        connector = NULL;
    }

    drmModeFreeResources(resources);

    if (connector == NULL)
        ALOGW("%s: fail to get required connector\n", __func__);

    return connector;
}
开发者ID:yutokt,项目名称:android_vendor_intel,代码行数:55,代码来源:IntelHWComposerDrm.cpp

示例11: modeset_prepare

static int modeset_prepare(int fd)
{
	drmModeRes *res;
	drmModeConnector *conn;
	unsigned int i;
	struct modeset_dev *dev;
	int ret;

	/* retrieve resources */
	res = drmModeGetResources(fd);
	if (!res) {
		fprintf(stderr, "cannot retrieve DRM resources (%d): %m\n",
			errno);
		return -errno;
	}

	/* iterate all connectors */
	for (i = 0; i < res->count_connectors; ++i) {
		/* get information for each connector */
		conn = drmModeGetConnector(fd, res->connectors[i]);
		if (!conn) {
			fprintf(stderr, "cannot retrieve DRM connector %u:%u (%d): %m\n",
				i, res->connectors[i], errno);
			continue;
		}

		/* create a device structure */
		dev = malloc(sizeof(*dev));
		memset(dev, 0, sizeof(*dev));
		dev->conn = conn->connector_id;

		/* call helper function to prepare this connector */
		ret = modeset_setup_dev(fd, res, conn, dev);
		if (ret) {
			if (ret != -ENOENT) {
				errno = -ret;
				fprintf(stderr, "cannot setup device for connector %u:%u (%d): %m\n",
					i, res->connectors[i], errno);
			}
			free(dev);
			drmModeFreeConnector(conn);
			continue;
		}

		/* free connector data and link device into global list */
		drmModeFreeConnector(conn);
		dev->next = modeset_list;
		modeset_list = dev;
	}

	/* free resources again */
	drmModeFreeResources(res);
	return 0;
}
开发者ID:AlphaPerfect,项目名称:docs,代码行数:54,代码来源:modeset-double-buffered.c

示例12: drm_get_resources

bool drm_get_resources(int fd)
{
   g_drm_resources = drmModeGetResources(fd);
   if (!g_drm_resources)
   {
      RARCH_WARN("[DRM]: Couldn't get device resources.\n");
      return false;
   }

   return true;
}
开发者ID:DSkywalk,项目名称:RetroArch,代码行数:11,代码来源:drm_common.c

示例13: device_find_crtc

static gboolean
device_find_crtc (Device *device)
{
  gboolean ret = FALSE;
  drmModeRes *resources;
  drmModeConnector *connector;
  drmModeEncoder *encoder;
  drmModeCrtc *crtc;
  int i;

  resources = drmModeGetResources (device->fd);
  if (resources == NULL)
    {
      g_warning ("Unable to get DRI device resources fd=%d: %m", device->fd);
      goto out;
    }

  /* Find the first active connector to display on. */
  for (i = 0; i < resources->count_connectors; i++)
    {
      connector = drmModeGetConnector (device->fd,
                                       resources->connectors[i]);
      if (connector == NULL)
        continue;

      if (connector->connection == DRM_MODE_CONNECTED &&
          connector->count_modes > 0)
        break;

      drmModeFreeConnector(connector);
    }

  if (i == resources->count_connectors)
    {
      g_warning ("Could not find an active connector");
      goto out;
    }

  /* Find an associated encoder for that connector. */
  encoder = drmModeGetEncoder (device->fd, connector->encoder_id);

  /* Now grab the CRTC for that encoder. */
  crtc = drmModeGetCrtc (device->fd, encoder->crtc_id);

  device->resources = resources;
  device->connector = connector;
  device->crtc = crtc;

  ret = TRUE;

 out:
  return ret;
}
开发者ID:magcius,项目名称:drmdemo,代码行数:53,代码来源:device.c

示例14: stereo_prepare_dev

static struct gbm_dev *
stereo_prepare_dev(int fd, const struct gbm_options *options)
{
        drmModeRes *res;
        drmModeConnector *conn;
        struct gbm_dev *dev;
        int ret;

        /* retrieve resources */
        res = drmModeGetResources(fd);
        if (!res) {
                fprintf(stderr, "cannot retrieve DRM resources (%d): %m\n",
                        errno);
                goto error;
        }

        conn = get_connector(fd, res, options);
        if (!conn)
                goto error_resources;

        /* create a device structure */
        dev = xmalloc(sizeof(*dev));
        memset(dev, 0, sizeof(*dev));
        dev->conn = conn->connector_id;
        dev->fd = fd;

        /* call helper function to prepare this connector */
        ret = stereo_setup_dev(res, conn, options, dev);
        if (ret) {
                if (ret != -ENOENT) {
                        errno = -ret;
                        fprintf(stderr,
                                "cannot setup device for connector "
                                "%u:%u (%d): %m\n",
                                0, res->connectors[0], errno);
                }
                goto error_dev;
        }

        drmModeFreeConnector(conn);
        drmModeFreeResources(res);

        return dev;

error_dev:
        free(dev);
        drmModeFreeConnector(conn);
error_resources:
        drmModeFreeResources(res);
error:
        return NULL;
}
开发者ID:bpeel,项目名称:stereo-cube,代码行数:52,代码来源:gbm-winsys.c

示例15: printResources

static void printResources(int fd) {
	drmModeRes *res;

	res = drmModeGetResources(fd);
	if (!res) {
		fprintf(stdout, "cannot retrieve DRM resources (%d): %m\n", errno);
		return;
	}

	printResources0(fd, res);

	drmModeFreeResources(res);
}
开发者ID:fritschy,项目名称:drm-utils,代码行数:13,代码来源:drm-info.c


注:本文中的drmModeGetResources函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。