Hi Michael,

Since the posting of this patch, the underlying code has
changed, e.g. the modesetting driver does use the
load_cursor_argb_check hook already now.

Can you check if this patch is still necessary,
and if so rebase it please ?

Thanks & Regards,

Hans



On 06-03-16 12:56, Michael Thayer wrote:

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 0d34ca1..36c3093 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -485,44 +485,36 @@ drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int 
y)
     drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
 }

-static void
+static Bool
 drmmode_set_cursor(xf86CrtcPtr crtc)
 {
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
     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) {
-        xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-        CursorPtr cursor = xf86_config->cursor;
-
-        ret =
-            drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-                              handle, ms->cursor_width, ms->cursor_height,
-                              cursor->bits->xhot, cursor->bits->yhot);
-        if (!ret)
-            return;
-        if (ret == -EINVAL)
-            use_set_cursor2 = FALSE;
-    }
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+    CursorPtr cursor = xf86_config->cursor;

-    ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 
handle,
-                           ms->cursor_width, ms->cursor_height);
+    ret =
+        drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                          handle, ms->cursor_width, ms->cursor_height,
+                          cursor->bits->xhot, cursor->bits->yhot);
+    if (!ret)
+        return TRUE;

-    if (ret) {
-        xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-        xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+    /* -EINVAL can mean bad cursor parameters or Cursor2 API not supported. */
+    if (ret == -EINVAL)
+        ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                               handle, ms->cursor_width, ms->cursor_height);

-        cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
-        drmmode_crtc->drmmode->sw_cursor = TRUE;
-        /* fallback to swcursor */
-    }
+    if (ret)
+        return FALSE; /* fallback to swcursor */
+    return TRUE;
 }

-static void
+static Bool
 drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 {
     modesettingPtr ms = modesettingPTR(crtc->scrn);
@@ -537,7 +529,8 @@ drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
         ptr[i] = image[i];      // cpu_to_le32(image[i]);

     if (drmmode_crtc->cursor_up)
-        drmmode_set_cursor(crtc);
+        return drmmode_set_cursor(crtc);
+    return TRUE;
 }

 static void
@@ -799,7 +792,7 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .set_cursor_position = drmmode_set_cursor_position,
     .show_cursor = drmmode_show_cursor,
     .hide_cursor = drmmode_hide_cursor,
-    .load_cursor_argb = drmmode_load_cursor_argb,
+    .load_cursor_argb_check = drmmode_load_cursor_argb,

     .gamma_set = drmmode_crtc_gamma_set,
     .destroy = NULL,            /* XXX */

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

Reply via email to