From: Michel Dänzer <[email protected]>

To reduce code duplication between DRI2 and Present. No functional
change intended yet.

(Ported from radeon commit 9bc3eef74452d924f9101c024f66ad9b14c404c8)

Signed-off-by: Michel Dänzer <[email protected]>
---
 src/amdgpu_dri2.c     |  5 +----
 src/amdgpu_present.c  |  8 +++-----
 src/drmmode_display.h | 11 +++++++++++
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index a854ce50b..b4cb1ecc7 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -655,14 +655,11 @@ can_flip(ScrnInfoPtr pScrn, DrawablePtr draw,
                xf86CrtcPtr crtc = config->crtc[i];
                drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-               if (!crtc->enabled)
-                       continue;
-
                if (!drmmode_crtc || drmmode_crtc->rotate.bo ||
                    drmmode_crtc->scanout[drmmode_crtc->scanout_id].bo)
                        return FALSE;
 
-               if (drmmode_crtc->pending_dpms_mode == DPMSModeOn)
+               if (drmmode_crtc_can_flip(crtc))
                        num_crtcs_on++;
        }
 
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index cf11d2b7a..375456976 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -228,16 +228,14 @@ amdgpu_present_check_unflip(ScrnInfoPtr scrn)
                return FALSE;
 
        for (i = 0, num_crtcs_on = 0; i < config->num_crtc; i++) {
-               drmmode_crtc_private_ptr drmmode_crtc = 
config->crtc[i]->driver_private;
-
-               if (!config->crtc[i]->enabled)
-                       continue;
+               xf86CrtcPtr crtc = config->crtc[i];
+               drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
                if (!drmmode_crtc || drmmode_crtc->rotate.bo ||
                    drmmode_crtc->scanout[drmmode_crtc->scanout_id].bo)
                        return FALSE;
 
-               if (drmmode_crtc->pending_dpms_mode == DPMSModeOn)
+               if (drmmode_crtc_can_flip(crtc))
                        num_crtcs_on++;
        }
 
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 309ec6704..677f796b1 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -132,6 +132,17 @@ enum drmmode_flip_sync {
 };
 
 
+/* Can the page flip ioctl be used for this CRTC? */
+static inline Bool
+drmmode_crtc_can_flip(xf86CrtcPtr crtc)
+{
+       drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+       return crtc->enabled &&
+               drmmode_crtc->pending_dpms_mode == DPMSModeOn;
+}
+
+
 static inline void
 drmmode_fb_reference_loc(int drm_fd, struct drmmode_fb **old, struct 
drmmode_fb *new,
                         const char *caller, unsigned line)
-- 
2.13.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to