diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2017-03-02 17:15:03 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2017-03-03 16:11:32 +0900 |
commit | d25cc3b2b3b2d257aea247b85fea405d7e84e5b1 (patch) | |
tree | baab423f6b20da2714270a2dbb843274a525def5 /src/amdgpu_kms.c | |
parent | a6d363008e2b55f0aa6151be1a99f01b97870e91 (diff) |
Factor out amdgpu_prime_dirty_to_crtc helper
Cleanup in preparation for the following change, no functional change
intended.
(Ported from radeon commit 649644a88347a6d03de68f8c41db03a82deeb23b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/amdgpu_kms.c')
-rw-r--r-- | src/amdgpu_kms.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index b2d098a..10a68fb 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -549,6 +549,27 @@ call_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty) #endif /* HAS_SYNC_SHARED_PIXMAPS */ +static xf86CrtcPtr +amdgpu_prime_dirty_to_crtc(PixmapDirtyUpdatePtr dirty) +{ + ScreenPtr screen = dirty->slave_dst->drawable.pScreen; + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* Find the CRTC which is scanning out from this slave pixmap */ + for (c = 0; c < xf86_config->num_crtc; c++) { + xf86CrtcPtr xf86_crtc = xf86_config->crtc[c]; + drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; + + if (drmmode_crtc->scanout[0].pixmap == dirty->slave_dst || + drmmode_crtc->scanout[1].pixmap == dirty->slave_dst) + return xf86_crtc; + } + + return NULL; +} + static Bool amdgpu_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id) { @@ -608,24 +629,16 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty) ScreenPtr screen = dirty->slave_dst->drawable.pScreen; ScrnInfoPtr scrn = xf86ScreenToScrn(screen); AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn); - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CrtcPtr xf86_crtc = NULL; - drmmode_crtc_private_ptr drmmode_crtc = NULL; + xf86CrtcPtr xf86_crtc = amdgpu_prime_dirty_to_crtc(dirty); + drmmode_crtc_private_ptr drmmode_crtc; uintptr_t drm_queue_seq; drmVBlank vbl; - int c; - /* Find the CRTC which is scanning out from this slave pixmap */ - for (c = 0; c < xf86_config->num_crtc; c++) { - xf86_crtc = xf86_config->crtc[c]; - drmmode_crtc = xf86_crtc->driver_private; - if (drmmode_crtc->scanout[0].pixmap == dirty->slave_dst) - break; - } + if (!xf86_crtc || !xf86_crtc->enabled) + return; - if (c == xf86_config->num_crtc || - !xf86_crtc->enabled || - drmmode_crtc->scanout_update_pending || + drmmode_crtc = xf86_crtc->driver_private; + if (drmmode_crtc->scanout_update_pending || !drmmode_crtc->scanout[0].pixmap || drmmode_crtc->pending_dpms_mode != DPMSModeOn) return; @@ -671,25 +684,16 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent) ScreenPtr screen = ent->slave_dst->drawable.pScreen; ScrnInfoPtr scrn = xf86ScreenToScrn(screen); AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn); - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CrtcPtr crtc = NULL; - drmmode_crtc_private_ptr drmmode_crtc = NULL; + xf86CrtcPtr crtc = amdgpu_prime_dirty_to_crtc(ent); + drmmode_crtc_private_ptr drmmode_crtc; uintptr_t drm_queue_seq; unsigned scanout_id; - int c; - /* Find the CRTC which is scanning out from this slave pixmap */ - for (c = 0; c < xf86_config->num_crtc; c++) { - crtc = xf86_config->crtc[c]; - drmmode_crtc = crtc->driver_private; - scanout_id = drmmode_crtc->scanout_id; - if (drmmode_crtc->scanout[scanout_id].pixmap == ent->slave_dst) - break; - } + if (!crtc || !crtc->enabled) + return; - if (c == xf86_config->num_crtc || - !crtc->enabled || - drmmode_crtc->scanout_update_pending || + drmmode_crtc = crtc->driver_private; + if (drmmode_crtc->scanout_update_pending || !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap || drmmode_crtc->pending_dpms_mode != DPMSModeOn) return; |