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

> Shouldn't this be done at a higher level instead?

Thanks for a really good question.

The X server doesn't touch cursors when turning off crtcs that aren't in
use any more. That's because xf86DisableUnusedFunctions doesn't touch
the cursor for disabled crtcs, it only sets the cursor for enabled ones.

I think a better patch is to just disable the cursor whenever we're
turning the crtc off during mode setting. After the mode setting is
finished, xf86DisableUnusedFunctions will get called and that will call
xf86CursorResetCursor to make sure the cursor is enabled everywhere it
should be.

Here's a replacement for the modesetting patch which does this up in
xfree86/modes:

From b89547cd4611cfc82c218575f9f8c3a9cc901737 Mon Sep 17 00:00:00 2001
From: Keith Packard <[email protected]>
Date: Wed, 2 Aug 2017 20:42:07 -0700
Subject: [PATCH xserver] xfree86: Disable cursor whenever turning off CRTC
 during modeset

This makes sure the CRTC's cursor is hidden before we hand the CRTC
over to some other application.

Signed-off-by: Keith Packard <[email protected]>
---
 hw/xfree86/modes/xf86Crtc.c    | 16 ++++++++++++----
 hw/xfree86/modes/xf86Crtc.h    |  6 ++++++
 hw/xfree86/modes/xf86Cursors.c |  2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index fa404d9d4..94933a4a5 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2651,6 +2651,14 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
     return success;
 }
 
+/* Turn a CRTC off, using the DPMS function and disabling the cursor */
+static void
+xf86DisableCrtc(xf86CrtcPtr crtc)
+{
+    crtc->funcs->dpms(crtc, DPMSModeOff);
+    xf86_crtc_hide_cursor(crtc);
+}
+
 /*
  * Check the CRTC we're going to map each output to vs. it's current
  * CRTC.  If they don't match, we have to disable the output and the CRTC
@@ -2706,9 +2714,9 @@ xf86PrepareCrtcs(ScrnInfoPtr scrn)
          * we need to disable it
          */
         if (desired_outputs != current_outputs || !desired_outputs)
-            (*crtc->funcs->dpms) (crtc, DPMSModeOff);
+            xf86DisableCrtc(crtc);
 #else
-        (*crtc->funcs->dpms) (crtc, DPMSModeOff);
+        xf86DisableCrtc(crtc);
 #endif
     }
 }
@@ -3004,7 +3012,7 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
         xf86CrtcPtr crtc = xf86_config->crtc[c];
 
         if (!crtc->enabled) {
-            crtc->funcs->dpms(crtc, DPMSModeOff);
+            xf86DisableCrtc(crtc);
             memset(&crtc->mode, 0, sizeof(crtc->mode));
             xf86RotateDestroy(crtc);
             crtc->active = FALSE;
@@ -3455,7 +3463,7 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn)
                 RRCrtcDetachScanoutPixmap(crtc->randr_crtc);
 
             /* dpms off */
-            (*crtc->funcs->dpms) (crtc, DPMSModeOff);
+            xf86DisableCrtc(crtc);
             /* force a reset the next time its used */
             crtc->randr_crtc->mode = NULL;
             crtc->mode.HDisplay = 0;
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 215eb2a04..e6ae9cc4d 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -999,6 +999,12 @@ extern _X_EXPORT Bool
  xf86_show_cursors(ScrnInfoPtr scrn);
 
 /**
+ * Called by the driver to turn a single crtc's cursor off
+ */
+extern _X_EXPORT void
+xf86_crtc_hide_cursor(xf86CrtcPtr crtc);
+
+/**
  * Called by the driver to turn cursors off
  */
 extern _X_EXPORT void
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 26969efb2..ae2137d80 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -320,7 +320,7 @@ xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
     }
 }
 
-static void
+void
 xf86_crtc_hide_cursor(xf86CrtcPtr crtc)
 {
     if (crtc->cursor_shown) {
-- 
2.13.3

-- 
-keith

Attachment: signature.asc
Description: PGP signature

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to