[PATCH xserver] modesetting: Do not use function local static variables

Hans de Goede hdegoede at redhat.com
Wed Aug 31 14:11:11 UTC 2016


The modesetting driver may be driving 2 screens (slave and master
gpu), which may have different behavior wrt hardware cursor support.

So stop using static variables and instead store the hw-cursor support
related data in a per screen struct. While at it actually make it per
crtc data as in theory different crtc's could have different hw-cursor
support.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 10 ++++------
 hw/xfree86/drivers/modesetting/drmmode_display.h |  2 ++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 429c0fd..7ab6d4f 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -756,10 +756,9 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
     drmmode_ptr drmmode = drmmode_crtc->drmmode;
     uint32_t handle = drmmode_crtc->cursor_bo->handle;
     modesettingPtr ms = modesettingPTR(crtc->scrn);
-    static Bool use_set_cursor2 = TRUE;
     int ret;
 
-    if (use_set_cursor2) {
+    if (!drmmode_crtc->set_cursor2_failed) {
         CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen);
 
         ret =
@@ -769,7 +768,7 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
         if (!ret)
             return TRUE;
 
-        use_set_cursor2 = FALSE;
+        drmmode_crtc->set_cursor2_failed = TRUE;
     }
 
     ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
@@ -803,7 +802,6 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image)
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
     int i;
     uint32_t *ptr;
-    static Bool first_time = TRUE;
 
     /* cursor should be mapped already */
     ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
@@ -811,11 +809,11 @@ drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image)
     for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
         ptr[i] = image[i];      // cpu_to_le32(image[i]);
 
-    if (drmmode_crtc->cursor_up || first_time) {
+    if (drmmode_crtc->cursor_up || !drmmode_crtc->first_cursor_load_done) {
         Bool ret = drmmode_set_cursor(crtc);
         if (!drmmode_crtc->cursor_up)
             drmmode_hide_cursor(crtc);
-        first_time = FALSE;
+        drmmode_crtc->first_cursor_load_done = TRUE;
         return ret;
     }
     return TRUE;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index f774250..50976b8 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -92,6 +92,8 @@ typedef struct {
     int dpms_mode;
     struct dumb_bo *cursor_bo;
     Bool cursor_up;
+    Bool set_cursor2_failed;
+    Bool first_cursor_load_done;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
 
     drmmode_bo rotate_bo;
-- 
2.9.3



More information about the xorg-devel mailing list