diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2017-08-29 16:54:10 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2017-08-30 17:08:57 +0900 |
commit | 5af396253f6a03fa3f8f92e81da231dd581b50c9 (patch) | |
tree | 6c72b95a1f8a7bbc57ab660db9cf3565a1169e7b | |
parent | 1afd4a526c97e77ec882988e35d4977880b9d16c (diff) |
Create drmmode_set_mode helper
Preparatory, no functional change intended yet.
(Ported from radeon commit 4bc992c31059eb50e22df4ebf5b92d08411f41ef)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | src/drmmode_display.c | 82 | ||||
-rw-r--r-- | src/drmmode_display.h | 3 |
2 files changed, 52 insertions, 33 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 285eb0a..6092805 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -796,6 +796,52 @@ drmmode_crtc_gamma_do_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green, size, red, green, blue); } +Bool +drmmode_set_mode(xf86CrtcPtr crtc, struct drmmode_fb *fb, DisplayModePtr mode, + int x, int y) +{ + ScrnInfoPtr scrn = crtc->scrn; + AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + uint32_t *output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); + int output_count = 0; + drmModeModeInfo kmode; + Bool ret; + int i; + + if (!output_ids) + return FALSE; + + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + drmmode_output_private_ptr drmmode_output = output->driver_private; + + if (output->crtc != crtc) + continue; + + output_ids[output_count] = drmmode_output->mode_output->connector_id; + output_count++; + } + + drmmode_ConvertToKMode(scrn, &kmode, mode); + + ret = drmModeSetCrtc(pAMDGPUEnt->fd, + drmmode_crtc->mode_crtc->crtc_id, + fb->handle, x, y, output_ids, + output_count, &kmode) == 0; + + if (ret) { + drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb, fb); + } else { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, + "failed to set mode: %s\n", strerror(errno)); + } + + free(output_ids); + return ret; +} + static Bool drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int x, int y) @@ -811,12 +857,9 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, int saved_x, saved_y; Rotation saved_rotation; DisplayModeRec saved_mode; - uint32_t *output_ids = NULL; - int output_count = 0; Bool ret = FALSE; int i; struct drmmode_fb *fb = NULL; - drmModeModeInfo kmode; /* The root window contents may be undefined before the WindowExposures * hook is called for it, so bail if we get here before that @@ -835,23 +878,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, crtc->y = y; crtc->rotation = rotation; - output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); - if (!output_ids) - goto done; - - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - drmmode_output_private_ptr drmmode_output; - - if (output->crtc != crtc) - continue; - - drmmode_output = output->driver_private; - output_ids[output_count] = - drmmode_output->mode_output->connector_id; - output_count++; - } - if (!drmmode_handle_transform(crtc)) goto done; @@ -862,8 +888,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, drmmode_crtc_gamma_do_set(crtc, crtc->gamma_red, crtc->gamma_green, crtc->gamma_blue, crtc->gamma_size); - drmmode_ConvertToKMode(crtc->scrn, &kmode, mode); - #ifdef AMDGPU_PIXMAP_SHARING if (drmmode_crtc->prime_scanout_pixmap) { drmmode_crtc_prime_scanout_update(crtc, mode, scanout_id, @@ -907,17 +931,10 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, drmmode_crtc_wait_pending_event(drmmode_crtc, pAMDGPUEnt->fd, drmmode_crtc->flip_pending); - if (drmModeSetCrtc(pAMDGPUEnt->fd, - drmmode_crtc->mode_crtc->crtc_id, - fb->handle, x, y, output_ids, - output_count, &kmode) != 0) { - xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, - "failed to set mode: %s\n", strerror(errno)); + if (!drmmode_set_mode(crtc, fb, mode, x, y)) goto done; - } else { - ret = TRUE; - drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb, fb); - } + + ret = TRUE; if (pScreen) xf86CrtcSetScreenSubpixelOrder(pScreen); @@ -954,7 +971,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, #endif done: - free(output_ids); if (!ret) { crtc->x = saved_x; crtc->y = saved_y; diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 1a6454c..372a539 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -213,6 +213,9 @@ extern void drmmode_scanout_free(ScrnInfoPtr scrn); extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); +Bool drmmode_set_mode(xf86CrtcPtr crtc, struct drmmode_fb *fb, + DisplayModePtr mode, int x, int y); + extern int drmmode_get_crtc_id(xf86CrtcPtr crtc); extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe); Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, |