本文整理汇总了C++中drmModeFreeConnector函数的典型用法代码示例。如果您正苦于以下问题:C++ drmModeFreeConnector函数的具体用法?C++ drmModeFreeConnector怎么用?C++ drmModeFreeConnector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drmModeFreeConnector函数的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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: drm_init
bool drm_init()
{
union drm_psb_extension_arg video_getparam_arg;
const char video_getparam_ext[] = "lnc_video_getparam";
memset(&gDrmCxt,0,sizeof(drmContext));
gDrmCxt.hdmiConnector = NULL;
gDrmCxt.drmFD = open(DRM_DEVICE_NAME, O_RDWR, 0);
if (gDrmCxt.drmFD <= 0) {
LOGE("%s: Failed to open %s", __func__, DRM_DEVICE_NAME);
return false;
}
strncpy(video_getparam_arg.extension,
video_getparam_ext, sizeof(video_getparam_arg.extension));
int ret = drmCommandWriteRead(gDrmCxt.drmFD, DRM_PSB_EXTENSION,
&video_getparam_arg, sizeof(video_getparam_arg));
if (ret != 0) {
LOGE("Failed to get ioctl offset.");
drm_cleanup();
return false;
}
gDrmCxt.ioctlOffset = video_getparam_arg.rep.driver_ioctl_offset;
drmModeConnectorPtr connector = getConnector(gDrmCxt.drmFD, DRM_MODE_CONNECTOR_DVID);
gDrmCxt.hdmiSupported = (connector != NULL);
if (connector) {
drmModeFreeConnector(connector);
connector = NULL;
}
return true;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: drmOpen
bool CDRMUtils::OpenDrm()
{
std::vector<const char*>modules =
{
"i915",
"amdgpu",
"radeon",
"nouveau",
"vmwgfx",
"msm",
"imx-drm",
"rockchip",
"vc4",
"virtio_gpu",
"sun4i-drm",
};
for(int i = 0; i < 10; ++i)
{
std::string device = "/dev/dri/card";
device.append(std::to_string(i));
for (auto module : modules)
{
m_fd = drmOpen(module, device.c_str());
if (m_fd >= 0)
{
if(!GetResources())
{
continue;
}
if(!GetConnector())
{
continue;
}
drmModeFreeResources(m_drm_resources);
m_drm_resources = nullptr;
drmModeFreeConnector(m_connector->connector);
m_connector->connector = nullptr;
drmModeFreeObjectProperties(m_connector->props);
m_connector->props = nullptr;
drmModeFreeProperty(*m_connector->props_info);
*m_connector->props_info = nullptr;
CLog::Log(LOGDEBUG, "CDRMUtils::%s - opened device: %s using module: %s", __FUNCTION__, device.c_str(), module);
return true;
}
drmClose(m_fd);
m_fd = -1;
}
}
return false;
}
示例10: free_drm_resources
static void free_drm_resources(void)
{
if (g_gbm_surface)
gbm_surface_destroy(g_gbm_surface);
if (g_gbm_dev)
gbm_device_destroy(g_gbm_dev);
if (g_encoder)
drmModeFreeEncoder(g_encoder);
if (g_connector)
drmModeFreeConnector(g_connector);
if (g_resources)
drmModeFreeResources(g_resources);
if (g_orig_crtc)
drmModeFreeCrtc(g_orig_crtc);
if (g_drm_fd >= 0)
close(g_drm_fd);
g_gbm_surface = NULL;
g_gbm_dev = NULL;
g_encoder = NULL;
g_connector = NULL;
g_resources = NULL;
g_orig_crtc = NULL;
g_drm_fd = -1;
}
示例11: memset
void Drm::resetOutput(int index)
{
DrmOutput *output = &mOutputs[index];
output->connected = false;
memset(&output->mode, 0, sizeof(drmModeModeInfo));
if (output->connector) {
drmModeFreeConnector(output->connector);
output->connector = 0;
}
if (output->encoder) {
drmModeFreeEncoder(output->encoder);
output->encoder = 0;
}
if (output->crtc) {
drmModeFreeCrtc(output->crtc);
output->crtc = 0;
}
if (output->fbId) {
drmModeRmFB(mDrmFd, output->fbId);
output->fbId = 0;
}
if (output->fbHandle) {
Hwcomposer::getInstance().getBufferManager()->freeFrameBuffer(output->fbHandle);
output->fbHandle = 0;
}
}
示例12: free_drm_resources
static void free_drm_resources(gfx_ctx_drm_egl_data_t *drm)
{
if (!drm)
return;
if (drm->g_gbm_surface)
gbm_surface_destroy(drm->g_gbm_surface);
if (drm->g_gbm_dev)
gbm_device_destroy(drm->g_gbm_dev);
if (drm->g_encoder)
drmModeFreeEncoder(drm->g_encoder);
if (drm->g_connector)
drmModeFreeConnector(drm->g_connector);
if (drm->g_resources)
drmModeFreeResources(drm->g_resources);
if (drm->g_orig_crtc)
drmModeFreeCrtc(drm->g_orig_crtc);
if (drm->g_drm_fd >= 0)
close(drm->g_drm_fd);
drm->g_gbm_surface = NULL;
drm->g_gbm_dev = NULL;
drm->g_encoder = NULL;
drm->g_connector = NULL;
drm->g_resources = NULL;
drm->g_orig_crtc = NULL;
drm->g_drm_fd = -1;
}
示例13: 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;
}
示例14: drm_terminate
EGLBoolean
drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct drm_device *dev = lookup_drm_device(dpy);
struct drm_screen *screen;
int i = 0;
_eglReleaseDisplayResources(drv, dpy);
_eglCleanupDisplay(dpy);
drmFreeVersion(dev->version);
for (i = 0; i < dev->count_screens; i++) {
screen = dev->screens[i];
if (screen->shown)
drm_takedown_shown_screen(dpy, screen);
drmModeFreeProperty(screen->dpms);
drmModeFreeConnector(screen->connector);
_eglDestroyScreen(&screen->base);
dev->screens[i] = NULL;
}
dev->screen->destroy(dev->screen);
dev->winsys = NULL;
drmClose(dev->drmFD);
dev->api->destroy(dev->api);
free(dev);
dpy->DriverData = NULL;
return EGL_TRUE;
}
示例15: output_free
static void
output_free (int fd, CoglOutputKMS *output)
{
if (output->modes)
g_free (output->modes);
if (output->encoder)
drmModeFreeEncoder (output->encoder);
if (output->connector)
{
if (output->saved_crtc)
{
int ret = drmModeSetCrtc (fd,
output->saved_crtc->crtc_id,
output->saved_crtc->buffer_id,
output->saved_crtc->x,
output->saved_crtc->y,
&output->connector->connector_id, 1,
&output->saved_crtc->mode);
if (ret)
g_warning (G_STRLOC ": Error restoring saved CRTC");
}
drmModeFreeConnector (output->connector);
}
g_slice_free (CoglOutputKMS, output);
}