本文整理汇总了C++中drmModeSetCrtc函数的典型用法代码示例。如果您正苦于以下问题:C++ drmModeSetCrtc函数的具体用法?C++ drmModeSetCrtc怎么用?C++ drmModeSetCrtc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drmModeSetCrtc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drmkmsSetRegion
static DFBResult
drmkmsSetRegion( CoreLayer *layer,
void *driver_data,
void *layer_data,
void *region_data,
CoreLayerRegionConfig *config,
CoreLayerRegionConfigFlags updated,
CoreSurface *surface,
CorePalette *palette,
CoreSurfaceBufferLock *left_lock,
CoreSurfaceBufferLock *right_lock )
{
int ret;
DRMKMSData *drmkms = driver_data;
DRMKMSDataShared *shared = drmkms->shared;
DRMKMSLayerData *data = layer_data;
D_DEBUG_AT( DRMKMS_Layer, "%s()\n", __FUNCTION__ );
if (!drmkms->resources)
return DFB_OK;
if (updated & (CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_BUFFERMODE | CLRCF_SOURCE)) {
int i, index = data->layer_index;
for (i=0; i<shared->enabled_crtcs; i++) {
if (shared->mirror_outputs)
index = i;
if (shared->clone_outputs) {
ret = drmModeSetCrtc( drmkms->fd, drmkms->encoder[index]->crtc_id, (u32)(long)left_lock->handle, config->source.x, config->source.y,
shared->cloned_connectors, shared->cloned_count, &shared->mode[index] );
}
else {
ret = drmModeSetCrtc( drmkms->fd, drmkms->encoder[index]->crtc_id, (u32)(long)left_lock->handle, config->source.x, config->source.y,
&drmkms->connector[index]->connector_id, 1, &shared->mode[index] );
}
if (ret) {
D_PERROR( "DirectFB/DRMKMS: drmModeSetCrtc( fd %d, index %d, crtc 0x%x, fb_id 0x%lx, xy %d,%d, cloned %p, count %d ) failed! (%d)\n",
drmkms->fd, index, drmkms->encoder[index]->crtc_id, (long) left_lock->handle, config->source.x, config->source.y,
shared->cloned_connectors, shared->cloned_count, ret );
D_DEBUG_AT( DRMKMS_Mode, " crtc_id: %d connector_id %d, mode %dx%d\n",
drmkms->encoder[index]->crtc_id, drmkms->connector[index]->connector_id,
shared->mode[index].hdisplay, shared->mode[index].vdisplay );
return DFB_FAILURE;
}
if (!shared->mirror_outputs)
break;
}
shared->primary_dimension[data->layer_index] = surface->config.size;
shared->primary_rect = config->source;
shared->primary_fb = (u32)(long)left_lock->handle;
}
return DFB_OK;
}
示例2: 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);
}
示例3: drm_display_set_crtc
/**
* Remember the original CRTC status and set the CRTC
*/
static boolean
drm_display_set_crtc(struct native_display *ndpy, int crtc_idx,
uint32_t buffer_id, uint32_t x, uint32_t y,
uint32_t *connectors, int num_connectors,
drmModeModeInfoPtr mode)
{
struct drm_display *drmdpy = drm_display(ndpy);
struct drm_crtc *drmcrtc = &drmdpy->saved_crtcs[crtc_idx];
uint32_t crtc_id;
int err;
if (drmcrtc->crtc) {
crtc_id = drmcrtc->crtc->crtc_id;
}
else {
int count = 0, i;
/*
* Choose the CRTC once. It could be more dynamic, but let's keep it
* simple for now.
*/
crtc_id = drm_display_choose_crtc(&drmdpy->base,
connectors, num_connectors);
/* save the original CRTC status */
drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
if (!drmcrtc->crtc)
return FALSE;
for (i = 0; i < drmdpy->num_connectors; i++) {
struct drm_connector *drmconn = &drmdpy->connectors[i];
drmModeConnectorPtr connector = drmconn->connector;
drmModeEncoderPtr encoder;
encoder = drmModeGetEncoder(drmdpy->fd, connector->encoder_id);
if (encoder) {
if (encoder->crtc_id == crtc_id) {
drmcrtc->connectors[count++] = connector->connector_id;
if (count >= Elements(drmcrtc->connectors))
break;
}
drmModeFreeEncoder(encoder);
}
}
drmcrtc->num_connectors = count;
}
err = drmModeSetCrtc(drmdpy->fd, crtc_id, buffer_id, x, y,
connectors, num_connectors, mode);
if (err) {
drmModeFreeCrtc(drmcrtc->crtc);
drmcrtc->crtc = NULL;
drmcrtc->num_connectors = 0;
return FALSE;
}
return TRUE;
}
示例4: gfx_ctx_drm_egl_destroy_resources
static void gfx_ctx_drm_egl_destroy_resources(gfx_ctx_drm_egl_data_t *drm)
{
if (!drm)
return;
/* Make sure we acknowledge all page-flips. */
if (waiting_for_flip)
wait_flip(true);
if (drm->g_egl_dpy)
{
if (drm->g_egl_ctx)
{
eglMakeCurrent(drm->g_egl_dpy,
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(drm->g_egl_dpy, drm->g_egl_ctx);
}
if (drm->g_egl_hw_ctx)
eglDestroyContext(drm->g_egl_dpy, drm->g_egl_hw_ctx);
if (drm->g_egl_surf)
eglDestroySurface(drm->g_egl_dpy, drm->g_egl_surf);
eglTerminate(drm->g_egl_dpy);
}
/* Be as careful as possible in deinit.
* If we screw up, the KMS tty will not restore.
*/
drm->g_egl_ctx = NULL;
drm->g_egl_hw_ctx = NULL;
drm->g_egl_surf = NULL;
drm->g_egl_dpy = NULL;
drm->g_config = 0;
/* Restore original CRTC. */
if (drm->g_orig_crtc)
{
drmModeSetCrtc(drm->g_drm_fd, drm->g_orig_crtc->crtc_id,
drm->g_orig_crtc->buffer_id,
drm->g_orig_crtc->x,
drm->g_orig_crtc->y,
&drm->g_connector_id, 1, &drm->g_orig_crtc->mode);
}
free_drm_resources(drm);
drm->g_drm_mode = NULL;
g_quit = 0;
drm->g_crtc_id = 0;
drm->g_connector_id = 0;
drm->g_fb_width = 0;
drm->g_fb_height = 0;
drm->g_bo = NULL;
drm->g_next_bo = NULL;
}
示例5: crtc_release
static void crtc_release(struct MPGLContext *ctx)
{
struct priv *p = ctx->priv;
if (!p->active)
return;
p->active = false;
// wait for current page flip
while (p->waiting_for_flip) {
int ret = drmHandleEvent(p->kms->fd, &p->ev);
if (ret) {
MP_ERR(ctx->vo, "drmHandleEvent failed: %i\n", ret);
break;
}
}
if (p->old_crtc) {
drmModeSetCrtc(p->kms->fd,
p->old_crtc->crtc_id, p->old_crtc->buffer_id,
p->old_crtc->x, p->old_crtc->y,
&p->kms->connector->connector_id, 1,
&p->old_crtc->mode);
drmModeFreeCrtc(p->old_crtc);
p->old_crtc = NULL;
}
}
示例6: mesaSetRegion
static DFBResult
mesaSetRegion( CoreLayer *layer,
void *driver_data,
void *layer_data,
void *region_data,
CoreLayerRegionConfig *config,
CoreLayerRegionConfigFlags updated,
CoreSurface *surface,
CorePalette *palette,
CoreSurfaceBufferLock *left_lock,
CoreSurfaceBufferLock *right_lock )
{
int ret;
MesaData *mesa = driver_data;
D_DEBUG_AT( Mesa_Layer, "%s()\n", __FUNCTION__ );
ret = drmModeSetCrtc( mesa->fd, mesa->encoder->crtc_id, (u32)(long)left_lock->handle, 0, 0,
&mesa->connector->connector_id, 1, &mesa->mode );
if (ret) {
D_PERROR( "DirectFB/Mesa: drmModeSetCrtc() failed! (%d)\n", ret );
return DFB_FAILURE;
}
return DFB_OK;
}
示例7: display_deactivate
static void display_deactivate(struct uterm_display *disp)
{
if (!display_is_online(disp))
return;
if (disp->dumb.saved_crtc) {
if (disp->video->flags & VIDEO_AWAKE) {
drmModeSetCrtc(disp->video->dumb.fd,
disp->dumb.saved_crtc->crtc_id,
disp->dumb.saved_crtc->buffer_id,
disp->dumb.saved_crtc->x,
disp->dumb.saved_crtc->y,
&disp->dumb.conn_id,
1,
&disp->dumb.saved_crtc->mode);
}
drmModeFreeCrtc(disp->dumb.saved_crtc);
disp->dumb.saved_crtc = NULL;
}
destroy_rb(disp, &disp->dumb.rb[1]);
destroy_rb(disp, &disp->dumb.rb[0]);
disp->current_mode = NULL;
disp->flags &= ~(DISPLAY_ONLINE | DISPLAY_VSYNC);
log_info("deactivating display %p", disp);
}
示例8: _cogl_winsys_egl_cleanup_context
static void
_cogl_winsys_egl_cleanup_context (CoglDisplay *display)
{
CoglDisplayEGL *egl_display = display->winsys;
CoglDisplayKMS *kms_display = egl_display->platform;
CoglRenderer *renderer = display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
CoglRendererKMS *kms_renderer = egl_renderer->platform;
/* Restore the saved CRTC - this failing should not propagate an error */
if (kms_display->saved_crtc)
{
int ret = drmModeSetCrtc (kms_renderer->fd,
kms_display->saved_crtc->crtc_id,
kms_display->saved_crtc->buffer_id,
kms_display->saved_crtc->x,
kms_display->saved_crtc->y,
&kms_display->connector->connector_id, 1,
&kms_display->saved_crtc->mode);
if (ret)
g_critical (G_STRLOC ": Error restoring saved CRTC");
drmModeFreeCrtc (kms_display->saved_crtc);
}
}
示例9: modeset_cleanup
static void modeset_cleanup(int fd)
{
struct modeset_dev *iter;
while (modeset_list) {
/* remove from global list */
iter = modeset_list;
modeset_list = iter->next;
/* restore saved CRTC configuration */
drmModeSetCrtc(fd,
iter->saved_crtc->crtc_id,
iter->saved_crtc->buffer_id,
iter->saved_crtc->x,
iter->saved_crtc->y,
&iter->conn,
1,
&iter->saved_crtc->mode);
drmModeFreeCrtc(iter->saved_crtc);
/* destroy framebuffers */
modeset_destroy_fb(fd, &iter->bufs[1]);
modeset_destroy_fb(fd, &iter->bufs[0]);
/* free allocated memory */
free(iter);
}
}
示例10: drmModeSetCrtc
bool CDRMUtils::RestoreOriginalMode()
{
if(!m_orig_crtc)
{
return false;
}
auto ret = drmModeSetCrtc(m_fd,
m_orig_crtc->crtc_id,
m_orig_crtc->buffer_id,
m_orig_crtc->x,
m_orig_crtc->y,
&m_connector->connector->connector_id,
1,
&m_orig_crtc->mode);
if(ret)
{
CLog::Log(LOGERROR, "CDRMUtils::%s - failed to set original crtc mode", __FUNCTION__);
return false;
}
CLog::Log(LOGDEBUG, "CDRMUtils::%s - set original crtc mode", __FUNCTION__);
drmModeFreeCrtc(m_orig_crtc);
m_orig_crtc = nullptr;
return true;
}
示例11: ply_renderer_head_set_scan_out_buffer
static bool
ply_renderer_head_set_scan_out_buffer (ply_renderer_backend_t *backend,
ply_renderer_head_t *head,
uint32_t buffer_id)
{
drmModeModeInfo *mode;
uint32_t *connector_ids;
int number_of_connectors;
connector_ids = (uint32_t *) ply_array_get_uint32_elements (head->connector_ids);
number_of_connectors = ply_array_get_size (head->connector_ids);
mode = &head->connector0->modes[head->connector0_mode_index];
ply_trace ("Setting scan out buffer of %ldx%ld head to our buffer",
head->area.width, head->area.height);
/* Tell the controller to use the allocated scan out buffer on each connectors
*/
if (drmModeSetCrtc (backend->device_fd, head->controller_id, buffer_id,
0, 0, connector_ids, number_of_connectors, mode) < 0)
{
ply_trace ("Couldn't set scan out buffer for head with controller id %d",
head->controller_id);
return false;
}
return true;
}
示例12: drmkmsSetEncoderConfig
static DFBResult
drmkmsSetEncoderConfig( CoreScreen *screen,
void *driver_data,
void *screen_data,
int encoder,
const DFBScreenEncoderConfig *config )
{
int ret = 0;
DRMKMSData *drmkms = driver_data;
DRMKMSDataShared *shared = drmkms->shared;
DFBScreenEncoderFrequency dse_freq;
DFBScreenOutputResolution dso_res;
D_DEBUG_AT( DRMKMS_Screen, "%s()\n", __FUNCTION__ );
if (!(config->flags & (DSECONF_FREQUENCY | DSECONF_RESOLUTION)))
return DFB_INVARG;
drmkms_mode_to_dsor_dsef( &shared->mode[encoder], &dso_res, &dse_freq );
if (config->flags & DSECONF_FREQUENCY) {
D_DEBUG_AT( DRMKMS_Screen, " -> requested frequency change \n" );
dse_freq = config->frequency;
}
if (config->flags & DSECONF_RESOLUTION) {
D_DEBUG_AT( DRMKMS_Screen, " -> requested resolution change \n" );
dso_res = config->resolution;
}
drmModeModeInfo *videomode = drmkms_dsor_freq_to_mode( encoder, dso_res, dse_freq );
if (!videomode)
return DFB_INVARG;
if ((shared->primary_dimension[encoder].w && (shared->primary_dimension[encoder].w < videomode->hdisplay) ) ||
(shared->primary_dimension[encoder].h && (shared->primary_dimension[encoder].h < videomode->vdisplay ))) {
D_DEBUG_AT( DRMKMS_Screen, " -> cannot switch to mode to something that is bigger than the current primary layer\n" );
return DFB_INVARG;
}
if (shared->primary_fb)
ret = drmModeSetCrtc( drmkms->fd, drmkms->encoder[encoder]->crtc_id, shared->primary_fb, shared->primary_rect.x, shared->primary_rect.y,
&drmkms->connector[encoder]->connector_id, 1, videomode );
if (ret) {
D_DEBUG_AT( DRMKMS_Screen, " crtc_id: %d connector_id %d, mode %dx%d\n", drmkms->encoder[encoder]->crtc_id, drmkms->connector[encoder]->connector_id, shared->mode[encoder].hdisplay, shared->mode[encoder].vdisplay );
D_PERROR( "DirectFB/DRMKMS: drmModeSetCrtc() failed! (%d)\n", ret );
return DFB_FAILURE;
}
shared->mode[encoder] = *videomode;
return DFB_OK;
}
示例13: gfx_ctx_drm_egl_destroy
static void gfx_ctx_drm_egl_destroy(void *data)
{
(void)data;
// Make sure we acknowledge all page-flips.
if (waiting_for_flip)
wait_flip(true);
if (g_egl_dpy)
{
if (g_egl_ctx)
{
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(g_egl_dpy, g_egl_ctx);
}
if (g_egl_hw_ctx)
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
if (g_egl_surf)
eglDestroySurface(g_egl_dpy, g_egl_surf);
eglTerminate(g_egl_dpy);
}
// Be as careful as possible in deinit.
// If we screw up, the KMS tty will not restore.
g_egl_ctx = NULL;
g_egl_hw_ctx = NULL;
g_egl_surf = NULL;
g_egl_dpy = NULL;
g_config = 0;
// Restore original CRTC.
if (g_orig_crtc)
{
drmModeSetCrtc(g_drm_fd, g_orig_crtc->crtc_id,
g_orig_crtc->buffer_id,
g_orig_crtc->x,
g_orig_crtc->y,
&g_connector_id, 1, &g_orig_crtc->mode);
}
free_drm_resources();
g_drm_mode = NULL;
g_quit = 0;
g_crtc_id = 0;
g_connector_id = 0;
g_fb_width = 0;
g_fb_height = 0;
g_bo = NULL;
g_next_bo = NULL;
g_inited = false;
}
示例14: crtc_commit_legacy
static void crtc_commit_legacy(struct kms_atomic_crtc_state *crtc,
struct kms_atomic_plane_state *plane,
enum kms_atomic_check_relax relax)
{
drmModeObjectPropertiesPtr props;
uint32_t *connectors;
int num_connectors = 0;
int i;
if (!crtc->active) {
do_or_die(drmModeSetCrtc(crtc->state->desc->fd,
crtc->obj, 0, 0, 0, NULL, 0, NULL));
return;
}
connectors = calloc(crtc->state->num_connectors,
sizeof(*connectors));
igt_assert(connectors);
igt_assert_neq_u32(crtc->mode.id, 0);
for (i = 0; i < crtc->state->num_connectors; i++) {
struct kms_atomic_connector_state *connector =
&crtc->state->connectors[i];
if (connector->crtc_id != crtc->obj)
continue;
connectors[num_connectors++] = connector->obj;
}
do_or_die(drmModeSetCrtc(crtc->state->desc->fd, crtc->obj,
plane->fb_id,
plane->src_x >> 16, plane->src_y >> 16,
(num_connectors) ? connectors : NULL,
num_connectors,
crtc->mode.data));
/* When doing a legacy commit, the core may update MODE_ID to be a new
* blob implicitly created by the legacy request. Hence we backfill
* the value in the state object to ensure they match. */
props = drmModeObjectGetProperties(crtc->state->desc->fd, crtc->obj,
DRM_MODE_OBJECT_CRTC);
igt_assert(props);
for (i = 0; i < props->count_props; i++) {
if (props->props[i] !=
crtc->state->desc->props_crtc[CRTC_MODE_ID])
continue;
crtc->mode.id = props->prop_values[i];
break;
}
drmModeFreeObjectProperties(props);
crtc_check_current_state(crtc, plane, relax);
plane_check_current_state(plane, relax);
}
示例15: crtc_set_mode_major
static Bool
crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
Rotation rotation, int x, int y)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
modesettingPtr ms = modesettingPTR(crtc->scrn);
xf86OutputPtr output = NULL;
struct crtc_private *crtcp = crtc->driver_private;
drmModeCrtcPtr drm_crtc = crtcp->drm_crtc;
drmModeModeInfo drm_mode;
int i, ret;
unsigned int connector_id;
for (i = 0; i < config->num_output; output = NULL, i++) {
output = config->output[i];
if (output->crtc == crtc)
break;
}
if (!output)
return FALSE;
connector_id = xorg_output_get_id(output);
drm_mode.clock = mode->Clock;
drm_mode.hdisplay = mode->HDisplay;
drm_mode.hsync_start = mode->HSyncStart;
drm_mode.hsync_end = mode->HSyncEnd;
drm_mode.htotal = mode->HTotal;
drm_mode.vdisplay = mode->VDisplay;
drm_mode.vsync_start = mode->VSyncStart;
drm_mode.vsync_end = mode->VSyncEnd;
drm_mode.vtotal = mode->VTotal;
drm_mode.flags = mode->Flags;
drm_mode.hskew = mode->HSkew;
drm_mode.vscan = mode->VScan;
drm_mode.vrefresh = mode->VRefresh;
if (!mode->name)
xf86SetModeDefaultName(mode);
strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN - 1);
drm_mode.name[DRM_DISPLAY_MODE_LEN - 1] = '\0';
ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
&connector_id, 1, &drm_mode);
if (ret)
return FALSE;
crtc->x = x;
crtc->y = y;
crtc->mode = *mode;
crtc->rotation = rotation;
return TRUE;
}