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>
This commit is contained in:
Sultan Alsawaf 2023-02-14 19:30:08 -08:00
parent 8b5fd55658
commit 18b14ea1f6
4 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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;