summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSultan Alsawaf <sultan@kerneltoast.com>2023-02-14 19:30:08 -0800
committerSultan Alsawaf <sultan@kerneltoast.com>2023-02-28 22:43:37 -0800
commit18b14ea1f68b0acac4bfb48d51e749db4ec417e4 (patch)
treec74e14e5220ceabe6a9970704adb72863bd4f543 /hw
parent8b5fd556582ba040aad5beeeb4c024e5dae40eba (diff)
downloadxserver-18b14ea1f68b0acac4bfb48d51e749db4ec417e4.tar.gz
modesetting: Introduce ms_tearfree_is_active_on_crtc helper
There is more than one place with the confusing TearFree state check for a CRTC. Instead of open-coding the TearFree check everywhere, introduce a helper, ms_tearfree_is_active_on_crtc, to cover the TearFree state checks. Suggested-by: Martin Roukala <martin.roukala@mupuf.org> Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com> Reviewed-by: Martin Roukala <martin.roukala@mupuf.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c3
-rw-r--r--hw/xfree86/drivers/modesetting/driver.h1
-rw-r--r--hw/xfree86/drivers/modesetting/pageflip.c10
-rw-r--r--hw/xfree86/drivers/modesetting/present.c3
4 files changed, 13 insertions, 4 deletions
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 3f185489e..5176b6d40 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -655,8 +655,7 @@ ms_tearfree_do_flips(ScreenPtr pScreen)
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
- /* Skip disabled CRTCs and those which aren't using TearFree */
- if (!trf->buf[0].px || !crtc->scrn->vtSema || !xf86_crtc_on(crtc))
+ if (!ms_tearfree_is_active_on_crtc(crtc))
continue;
/* Skip if the last flip is still pending, a DRI client is flipping, or
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 605fd8530..a54bf28ff 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -249,3 +249,4 @@ Bool ms_do_tearfree_flip(ScreenPtr screen, xf86CrtcPtr crtc);
int ms_flush_drm_events(ScreenPtr screen);
Bool ms_window_has_variable_refresh(modesettingPtr ms, WindowPtr win);
void ms_present_set_screen_vrr(ScrnInfoPtr scrn, Bool vrr_enabled);
+Bool ms_tearfree_is_active_on_crtc(xf86CrtcPtr crtc);
diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c
index 94437c0f3..a804841fa 100644
--- a/hw/xfree86/drivers/modesetting/pageflip.c
+++ b/hw/xfree86/drivers/modesetting/pageflip.c
@@ -529,3 +529,13 @@ no_flip:
return TRUE;
}
#endif
+
+Bool
+ms_tearfree_is_active_on_crtc(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
+
+ /* If TearFree is enabled, XServer owns the VT, and the CRTC is active */
+ return trf->buf[0].px && crtc->scrn->vtSema && xf86_crtc_on(crtc);
+}
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
index acc299f3b..89fca1a9c 100644
--- a/hw/xfree86/drivers/modesetting/present.c
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -334,8 +334,7 @@ no_flip:
drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree;
- /* Check if TearFree is active on this CRTC and tell Present about it */
- if (trf->buf[0].px && scrn->vtSema && xf86_crtc_on(xf86_crtc)) {
+ if (ms_tearfree_is_active_on_crtc(xf86_crtc)) {
if (trf->flip_seq)
/* The driver has a TearFree flip pending */
*reason = PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING;