diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2017-08-18 16:13:17 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2017-08-22 18:33:09 +0900 |
commit | 2cbe7f2dff5eef159486f875b3ec67516c85862d (patch) | |
tree | ec03cd73775bb47557f41d2b78d801498bbc06f2 /src/drmmode_display.c | |
parent | e8d0bfab276d47338c337955b9d2fcbff3af225f (diff) |
Wait for pending flips synchronously before turning off a CRTC
Allows removing drmmode_clear_pending_flip and the pending_dpms_mode
field and cleaning up the code considerably.
(Ported from radeon commit e6d7dc2070f4d21a6900916bb70a31839112882c)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/drmmode_display.c')
-rw-r--r-- | src/drmmode_display.c | 60 |
1 files changed, 11 insertions, 49 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index bdd3866..0d5aa26 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -284,14 +284,11 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode) CARD64 ust; int ret; - drmmode_crtc->pending_dpms_mode = mode; - if (drmmode_crtc->dpms_mode == DPMSModeOn && mode != DPMSModeOn) { uint32_t seq; - /* Wait for any pending flip to finish */ - if (drmmode_crtc->flip_pending) - return; + drmmode_crtc_wait_pending_event(drmmode_crtc, pAMDGPUEnt->fd, + drmmode_crtc->flip_pending); /* * On->Off transition: record the last vblank time, @@ -345,10 +342,8 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode) /* Disable unused CRTCs and enable/disable active CRTCs */ if (!crtc->enabled || mode != DPMSModeOn) { - /* Wait for any pending flip to finish */ - if (drmmode_crtc->flip_pending) - return; - + drmmode_crtc_wait_pending_event(drmmode_crtc, pAMDGPUEnt->fd, + drmmode_crtc->flip_pending); drmModeSetCrtc(pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, 0, 0, 0, NULL, 0, NULL); drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb, NULL); @@ -1369,7 +1364,6 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res drmModeGetCrtc(pAMDGPUEnt->fd, mode_res->crtcs[num]); drmmode_crtc->drmmode = drmmode; drmmode_crtc->dpms_mode = DPMSModeOff; - drmmode_crtc->pending_dpms_mode = DPMSModeOff; crtc->driver_private = drmmode_crtc; drmmode_crtc_hw_id(crtc); @@ -1497,16 +1491,9 @@ static void drmmode_output_dpms(xf86OutputPtr output, int mode) if (!koutput) return; - if (mode != DPMSModeOn && crtc) { - drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; - + if (mode != DPMSModeOn && crtc) drmmode_do_crtc_dpms(crtc, mode); - /* Wait for any pending flip to finish */ - if (drmmode_crtc->flip_pending) - return; - } - drmModeConnectorSetProperty(pAMDGPUEnt->fd, koutput->connector_id, drmmode_output->dpms_enum_id, mode); @@ -2229,38 +2216,11 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { drmmode_xf86crtc_resize }; -void -drmmode_clear_pending_flip(xf86CrtcPtr crtc) -{ - drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; - ScrnInfoPtr scrn = crtc->scrn; - AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn); - - drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, - NULL); - - if (!crtc->enabled || - (drmmode_crtc->pending_dpms_mode != DPMSModeOn && - drmmode_crtc->dpms_mode != drmmode_crtc->pending_dpms_mode)) { - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); - int o; - - for (o = 0; o < xf86_config->num_output; o++) { - xf86OutputPtr output = xf86_config->output[o]; - - if (output->crtc != crtc) - continue; - - drmmode_output_dpms(output, drmmode_crtc->pending_dpms_mode); - } - - drmmode_crtc_dpms(crtc, drmmode_crtc->pending_dpms_mode); - } -} - static void drmmode_flip_abort(xf86CrtcPtr crtc, void *event_data) { + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn); drmmode_flipdata_ptr flipdata = event_data; if (--flipdata->flip_count == 0) { @@ -2270,7 +2230,8 @@ drmmode_flip_abort(xf86CrtcPtr crtc, void *event_data) free(flipdata); } - drmmode_clear_pending_flip(crtc); + drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, + NULL); } static void @@ -2302,7 +2263,8 @@ drmmode_flip_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec, void *even drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb, drmmode_crtc->flip_pending); - drmmode_clear_pending_flip(crtc); + drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, + NULL); } #if HAVE_NOTIFY_FD |