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


C++ drmModeGetConnector函数代码示例

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


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

示例1: drm_get_connector

bool drm_get_connector(int fd)
{
   unsigned i;
   unsigned monitor_index = 0;
   settings_t *settings   = config_get_ptr();
   unsigned monitor       = MAX(settings->video.monitor_index, 1);

   /* Enumerate all connectors. */

   RARCH_LOG("[DRM]: Found %d connectors.\n", g_drm_resources->count_connectors);

   for (i = 0; (int)i < g_drm_resources->count_connectors; i++)
   {
      drmModeConnectorPtr conn = drmModeGetConnector(
            fd, g_drm_resources->connectors[i]);

      if (conn)
      {
         bool connected = conn->connection == DRM_MODE_CONNECTED;
         RARCH_LOG("[DRM]: Connector %d connected: %s\n", i, connected ? "yes" : "no");
         RARCH_LOG("[DRM]: Connector %d has %d modes.\n", i, conn->count_modes);
         if (connected && conn->count_modes > 0)
         {
            monitor_index++;
            RARCH_LOG("[DRM]: Connector %d assigned to monitor index: #%u.\n", i, monitor_index);
         }
         drmModeFreeConnector(conn);
      }
   }

   monitor_index = 0;

   for (i = 0; (int)i < g_drm_resources->count_connectors; i++)
   {
      g_drm_connector = drmModeGetConnector(fd,
            g_drm_resources->connectors[i]);

      if (!g_drm_connector)
         continue;
      if (g_drm_connector->connection == DRM_MODE_CONNECTED
            && g_drm_connector->count_modes > 0)
      {
         monitor_index++;
         if (monitor_index == monitor)
            break;
      }

      drmModeFreeConnector(g_drm_connector);
      g_drm_connector = NULL;
   }

   if (!g_drm_connector)
   {
      RARCH_WARN("[DRM]: Couldn't get device connector.\n");
      return false;
   }
   return true;
}
开发者ID:Ezio-PS,项目名称:RetroArch,代码行数:58,代码来源:drm_common.c

示例2: output_detect

static xf86OutputStatus
output_detect(xf86OutputPtr output)
{
    modesettingPtr ms = modesettingPTR(output->scrn);
    struct output_private *priv = output->driver_private;
    drmModeConnectorPtr drm_connector;
    xf86OutputStatus status;

    drm_connector = drmModeGetConnector(ms->fd, priv->drm_connector->connector_id);
    if (drm_connector) {
	drmModeFreeConnector(priv->drm_connector);
	priv->drm_connector = drm_connector;
    } else {
	drm_connector = priv->drm_connector;
    }

    switch (drm_connector->connection) {
    case DRM_MODE_CONNECTED:
	status = XF86OutputStatusConnected;
	break;
    case DRM_MODE_DISCONNECTED:
	status = XF86OutputStatusDisconnected;
	break;
    default:
	status = XF86OutputStatusUnknown;
    }

    return status;
}
开发者ID:CSRedRat,项目名称:mesa-1,代码行数:29,代码来源:xorg_output.c

示例3: drmModeGetConnector

int DrmConnector::UpdateModes() {
  int fd = drm_->fd();

  drmModeConnectorPtr c = drmModeGetConnector(fd, id_);
  if (!c) {
    ALOGE("Failed to get connector %d", id_);
    return -ENODEV;
  }

  std::vector<DrmMode> new_modes;
  for (int i = 0; i < c->count_modes; ++i) {
    bool exists = false;
    for (std::vector<DrmMode>::iterator iter = modes_.begin();
         iter != modes_.end(); ++iter) {
      if (*iter == c->modes[i]) {
        new_modes.push_back(*iter);
        exists = true;
        break;
      }
    }
    if (exists)
      continue;

    DrmMode m(&c->modes[i]);
    m.set_id(drm_->next_mode_id());
    new_modes.push_back(m);
  }
  modes_.swap(new_modes);
  return 0;
}
开发者ID:vlinhd11,项目名称:external_drm_hwcomposer,代码行数:30,代码来源:drmconnector.cpp

示例4: drmmode_output_detect

static xf86OutputStatus
drmmode_output_detect(xf86OutputPtr output)
{
	/* go to the hw and retrieve a new output struct */
	drmmode_output_private_ptr drmmode_output = output->driver_private;
	drmmode_ptr drmmode = drmmode_output->drmmode;
	xf86OutputStatus status;
	drmModeFreeConnector(drmmode_output->mode_output);

	drmmode_output->mode_output =
		drmModeGetConnector(drmmode->fd, drmmode_output->output_id);

	switch (drmmode_output->mode_output->connection) {
	case DRM_MODE_CONNECTED:
		status = XF86OutputStatusConnected;
		break;
	case DRM_MODE_DISCONNECTED:
		status = XF86OutputStatusDisconnected;
		break;
	default:
	case DRM_MODE_UNKNOWNCONNECTION:
		status = XF86OutputStatusUnknown;
		break;
	}
	return status;
}
开发者ID:adegroote,项目名称:netbsd-drmgem,代码行数:26,代码来源:drmmode_display.c

示例5: printConnectors

static void printConnectors(int fd, uint32_t* ids, uint32_t count) {
	drmModeConnector *conn;
	int i;

	for (i = 0; i < count; i++) {
		conn = drmModeGetConnector(fd, ids[i]);
		if (!conn) {
			fprintf(stdout, "      Connector %u: cannot retrieve (%d): %m\n\n", ids[i], errno);
			continue;
		}

		fprintf(stdout, "      Connector %u:\n", conn->connector_id);
		fprintf(stdout, "        Type: %s\n", getConnectorType(conn->connector_type));
		fprintf(stdout, "        Dimensions: %umm x %umm\n", conn->mmWidth, conn->mmHeight);
		fprintf(stdout, "        SubPixel: %s\n", getConnectorSubPixel(conn->subpixel));
		fprintf(stdout, "        Connection: %s\n", getConnectorConnection(conn->connection));
		fprintf(stdout, "        Encoders: %d: %s\n", conn->count_encoders, getList32(conn->encoders, conn->count_encoders));
		fprintf(stdout, "        Properties: %d:\n", conn->count_props);
		printProperties(fd, conn->props, conn->prop_values, conn->count_props);
		fprintf(stdout, "        Modes: %d:\n", conn->count_modes);
		printModes(conn->modes, conn->count_modes);

		fprintf(stdout, "\n");

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

示例6: drmModeGetConnector

bool CDRMUtils::GetConnector()
{
  for(auto i = 0; i < m_drm_resources->count_connectors; i++)
  {
    m_connector->connector = drmModeGetConnector(m_fd,
                                                      m_drm_resources->connectors[i]);
    if(m_connector->connector->connection == DRM_MODE_CONNECTED)
    {
      CLog::Log(LOGDEBUG, "CDRMUtils::%s - found connector: %d", __FUNCTION__,
                                                                 m_connector->connector->connector_id);
      break;
    }
    drmModeFreeConnector(m_connector->connector);
    m_connector->connector = nullptr;
  }

  if(!m_connector->connector)
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get connector: %s", __FUNCTION__, strerror(errno));
    return false;
  }

  if (!GetProperties(m_fd, m_connector->connector->connector_id, DRM_MODE_OBJECT_CONNECTOR, m_connector))
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get connector %u properties: %s", __FUNCTION__, m_connector->connector->connector_id, strerror(errno));
    return false;
  }

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

示例7: 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

示例8: get_connector

static drmModeConnector *
get_connector(int fd, drmModeRes *res,
              const struct gbm_options *options)
{
        drmModeConnector *conn;
        int i;

        for (i = 0; i < res->count_connectors; i++) {
                conn = drmModeGetConnector(fd, res->connectors[i]);

                if (conn == NULL) {
                        fprintf(stderr,
                                "cannot retrieve DRM connector "
                                "%u:%u (%d): %m\n",
                                i, res->connectors[i], errno);
                        return NULL;
                }

                if (options->connector == -1 ||
                    conn->connector_id == options->connector)
                        return conn;
                drmModeFreeConnector(conn);
        }

        fprintf(stderr,
                "couldn't find connector with id %i\n",
                options->connector);

        return NULL;
}
开发者ID:bpeel,项目名称:stereo-cube,代码行数:30,代码来源:gbm-winsys.c

示例9: blueshift_drm_open_connector

/**
 * Acquire information about a connector
 * 
 * @param  connection       The identifier for the connection to the card
 * @param  connector_index  The index of the connector
 */
void blueshift_drm_open_connector(int connection, int connector_index)
{
  card_connection* card = card_connections + connection;
  
  if (card->connectors == NULL)
    card->connectors = malloc((size_t)(card->res->count_connectors) * sizeof(drmModeConnector*));
  *(card->connectors + connector_index) = drmModeGetConnector(card->fd, *(card->res->connectors + connector_index));
}
开发者ID:prodigeni,项目名称:blueshift,代码行数:14,代码来源:blueshift_drm_c.c

示例10: 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

示例11: 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

示例12: 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

示例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: drm_display_choose_crtc

/**
 * Choose a CRTC that supports all given connectors.
 */
static uint32_t
drm_display_choose_crtc(struct native_display *ndpy,
                        uint32_t *connectors, int num_connectors)
{
   struct drm_display *drmdpy = drm_display(ndpy);
   int idx;

   for (idx = 0; idx < drmdpy->resources->count_crtcs; idx++) {
      boolean found_crtc = TRUE;
      int i, j;

      for (i = 0; i < num_connectors; i++) {
         drmModeConnectorPtr connector;
         int encoder_idx = -1;

         connector = drmModeGetConnector(drmdpy->fd, connectors[i]);
         if (!connector) {
            found_crtc = FALSE;
            break;
         }

         /* find an encoder the CRTC supports */
         for (j = 0; j < connector->count_encoders; j++) {
            drmModeEncoderPtr encoder =
               drmModeGetEncoder(drmdpy->fd, connector->encoders[j]);
            if (encoder->possible_crtcs & (1 << idx)) {
               encoder_idx = j;
               break;
            }
            drmModeFreeEncoder(encoder);
         }

         drmModeFreeConnector(connector);
         if (encoder_idx < 0) {
            found_crtc = FALSE;
            break;
         }
      }

      if (found_crtc)
         break;
   }

   if (idx >= drmdpy->resources->count_crtcs) {
      _eglLog(_EGL_WARNING,
            "failed to find a CRTC that supports the given %d connectors",
            num_connectors);
      return 0;
   }

   return drmdpy->resources->crtcs[idx];
}
开发者ID:nikai3d,项目名称:mesa,代码行数:55,代码来源:modeset.c

示例15: drmModeGetResources

void QKmsScreen::initializeScreenMode()
{
    //Determine optimal mode for screen
    drmModeRes *resources = drmModeGetResources(m_device->fd());
    if (!resources)
        qFatal("drmModeGetResources failed");

    drmModeConnector *connector = drmModeGetConnector(m_device->fd(), m_connectorId);
    drmModeModeInfo *mode = 0;
    for (int i = 0; i < connector->count_modes; ++i) {
        if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) {
            mode = &connector->modes[i];
            break;
        }
    }
    if (!mode)
        mode = &builtin_1024x768;

    drmModeEncoder *encoder = drmModeGetEncoder(m_device->fd(), connector->encoders[0]);
    if (encoder == 0)
        qFatal("No encoder for connector.");

    int i;
    for (i = 0; i < resources->count_crtcs; i++) {
        if (encoder->possible_crtcs & (1 << i))
            break;
    }
    if (i == resources->count_crtcs)
        qFatal("No usable crtc for encoder.");

    m_oldCrtc = drmModeGetCrtc(m_device->fd(), encoder->crtc_id);

    m_crtcId = resources->crtcs[i];
    m_mode = *mode;
    m_geometry = QRect(0, 0, m_mode.hdisplay, m_mode.vdisplay);
    qDebug() << "kms initialized with geometry" << m_geometry;
    m_depth = 32;
    m_format = QImage::Format_RGB32;
    m_physicalSize = QSizeF(connector->mmWidth, connector->mmHeight);

    m_gbmSurface = gbm_surface_create(m_device->gbmDevice(),
                                      m_mode.hdisplay, m_mode.vdisplay,
                                      GBM_BO_FORMAT_XRGB8888,
                                      GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);

    qDebug() << "created gbm surface" << m_gbmSurface << m_mode.hdisplay << m_mode.vdisplay;
    //Cleanup
    drmModeFreeEncoder(encoder);
    drmModeFreeConnector(connector);
    drmModeFreeResources(resources);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:51,代码来源:qkmsscreen.cpp


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