本文整理汇总了C++中drmModeGetResources函数的典型用法代码示例。如果您正苦于以下问题:C++ drmModeGetResources函数的具体用法?C++ drmModeGetResources怎么用?C++ drmModeGetResources使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drmModeGetResources函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: main
int main(int argc, char *argv[])
{
static const char optstr[] = "D:M:";
int c, args, ret = 0;
char *device = NULL;
char *module = NULL;
while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
case 'D':
device = optarg;
break;
case 'M':
module = optarg;
break;
default:
usage(argv[0]);
break;
}
}
args = argc - optind;
fd = util_open(device, module);
if (fd < 0)
return 1;
res = drmModeGetResources(fd);
if (!res) {
fprintf(stderr, "Failed to get resources: %s\n",
strerror(errno));
ret = 1;
goto done;
}
if (args < 1) {
listAllProperties();
} else if (args == 4) {
ret = setProperty(&argv[optind]);
} else {
usage(argv[0]);
ret = 1;
}
drmModeFreeResources(res);
done:
drmClose(fd);
return ret;
}
开发者ID:01org,项目名称:iotg-lin-gfx-libdrm,代码行数:51,代码来源:proptest.c
示例18: setup_kms
static EGLBoolean
setup_kms(int fd, struct kms *kms)
{
drmModeRes *resources;
drmModeConnector *connector;
drmModeEncoder *encoder;
int i;
resources = drmModeGetResources(fd);
if (!resources) {
fprintf(stderr, "drmModeGetResources failed\n");
return EGL_FALSE;
}
for (i = 0; i < resources->count_connectors; i++) {
connector = drmModeGetConnector(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) {
fprintf(stderr, "No currently active connector found.\n");
return EGL_FALSE;
}
for (i = 0; i < resources->count_encoders; i++) {
encoder = drmModeGetEncoder(fd, resources->encoders[i]);
if (encoder == NULL)
continue;
if (encoder->encoder_id == connector->encoder_id)
break;
drmModeFreeEncoder(encoder);
}
kms->connector = connector;
kms->encoder = encoder;
kms->mode = connector->modes[0];
return EGL_TRUE;
}
开发者ID:Distrotech,项目名称:mesa-demos,代码行数:49,代码来源:eglkms.c
示例19: main
int main(int argc, char * argv[])
{
int control_minor = 64;
int c = drmOpenControl(control_minor);
if (!c) {
printf("DRM open device %d failed\n", control_minor);
abort();
}
int render_minor = 128;
int r = drmOpenRender(render_minor);
if (!r) {
printf("DRM open render node %d failed\n", render_minor);
}
drmVersionPtr v = drmGetVersion(r);
if (!v) {
printf("Couldn't get DRM version\n");
abort();
}
printf("%s %s %s\n", v->name, v->date, v->desc);
drmModeResPtr moderes = drmModeGetResources(c);
if (!moderes) {
printf("Couldn't get DRM modesetting resources\n");
abort();
}
printf("fbs: %d crtcs: %d connectors: %d encoders: %d\n",
moderes->count_fbs, moderes->count_crtcs, moderes->count_connectors, moderes->count_encoders);
for (int i = 0; i < moderes->count_connectors; i++) {
printf("Connector %d\n", moderes->connectors[i]);
drmModeConnectorPtr connector = drmModeGetConnector(c, moderes->connectors[i]);
if (connector->connection == DRM_MODE_CONNECTED) {
printf("\tConnected\n");
printf("\tSize: %d x %d mm\n", connector->mmWidth, connector->mmHeight);
printf("\tModes:\n");
for (int j = 0; j < connector->count_modes; j++) {
printf("\t\t%s\n", connector->modes[j].name);
}
printf("\tProperties:\n");
for (int j = 0; j < connector->count_props; j++) {
drmModePropertyPtr property = drmModeGetProperty(c, connector->props[j]);
printf("\t\t%s\n", property->name);
}
} else {
printf("\tDisconnected\n");
}
}
}
开发者ID:tdaede,项目名称:drm10bit,代码行数:46,代码来源:main.c
示例20: setup_drm
static void setup_drm(void)
{
int i;
drm.fd = drm_open_driver_master(DRIVER_INTEL);
drm.res = drmModeGetResources(drm.fd);
igt_assert(drm.res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm.res->count_connectors; i++)
drm.connectors[i] = drmModeGetConnector(drm.fd,
drm.res->connectors[i]);
drm.bufmgr = drm_intel_bufmgr_gem_init(drm.fd, 4096);
igt_assert(drm.bufmgr);
drm_intel_bufmgr_gem_enable_reuse(drm.bufmgr);
}
开发者ID:joshloo,项目名称:intel-gpu-tools,代码行数:17,代码来源:intel_residency.c
注:本文中的drmModeGetResources函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论