Submitted By: Pierre Labastie <pierre at linuxfromscratch dot org>
Date: 2015-02-28
Initial Package Version: 1.17.1
Upstream Status: submitted and partly reviewed
Origin: Takashi Iwai <tiwai at suse.de>
Description: Fix 32 bit breakage and mouse pointer disappearing.

diff -Naur xorg-server-1.17.1.old/hw/xfree86/drivers/modesetting/drmmode_display.c xorg-server-1.17.1.new/hw/xfree86/drivers/modesetting/drmmode_display.c
--- xorg-server-1.17.1.old/hw/xfree86/drivers/modesetting/drmmode_display.c	2015-01-30 14:09:13.000000000 +0100
+++ xorg-server-1.17.1.new/hw/xfree86/drivers/modesetting/drmmode_display.c	2015-02-28 17:57:23.932964255 +0100
@@ -409,7 +409,7 @@
     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;
@@ -427,10 +427,10 @@
             drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
                               handle, ms->cursor_width, ms->cursor_height,
                               cursor->bits->xhot, cursor->bits->yhot);
-        if (ret == -EINVAL)
+        if (ret)
             use_set_cursor2 = FALSE;
         else
-            return;
+            return TRUE;
     }
 
     ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
@@ -443,16 +443,21 @@
         cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
         drmmode_crtc->drmmode->sw_cursor = TRUE;
         /* fallback to swcursor */
+        return FALSE;
     }
+    return TRUE;
 }
 
-static void
-drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
+static void drmmode_hide_cursor(xf86CrtcPtr crtc);
+
+static Bool
+drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 *image)
 {
     modesettingPtr ms = modesettingPTR(crtc->scrn);
     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);
@@ -460,8 +465,14 @@
     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)
-        drmmode_set_cursor(crtc);
+    if (drmmode_crtc->cursor_up || first_time) {
+        Bool ret = drmmode_set_cursor(crtc);
+        if (!drmmode_crtc->cursor_up)
+            drmmode_hide_cursor(crtc);
+        first_time = FALSE;
+        return ret;
+    }
+    return TRUE;
 }
 
 static void
@@ -665,7 +676,7 @@
     .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_check,
 
     .gamma_set = drmmode_crtc_gamma_set,
     .destroy = NULL,            /* XXX */
diff -Naur xorg-server-1.17.1.old/hw/xfree86/drivers/modesetting/dumb_bo.c xorg-server-1.17.1.new/hw/xfree86/drivers/modesetting/dumb_bo.c
--- xorg-server-1.17.1.old/hw/xfree86/drivers/modesetting/dumb_bo.c	2015-01-18 00:42:52.000000000 +0100
+++ xorg-server-1.17.1.new/hw/xfree86/drivers/modesetting/dumb_bo.c	2015-02-28 17:53:22.028967314 +0100
@@ -25,6 +25,8 @@
  *
  */
 
+#define _FILE_OFFSET_BITS	64
+
 #include "dumb_bo.h"
 
 #include <errno.h>
