[PATCH 2/4] X server: dricursor implementation using the X server as application.

Tiago Vignatti vignatti at c3sl.ufpr.br
Mon Jan 5 12:59:18 PST 2009


This implementation gives two ioctls APIs (DRICursorSetDev, DRICursorHotspot)
to interface with the DRM modesetting cursors. For now this patch disables
the pointer acceleration scheme.

Signed-off-by: Tiago Vignatti <vignatti at c3sl.ufpr.br>
---
 Makefile.am                    |    1 +
 configure.ac                   |    4 ++-
 dix/getevents.c                |    2 +
 dricursor/Makefile.am          |    9 +++++++
 dricursor/dricursor.c          |   51 ++++++++++++++++++++++++++++++++++++++++
 hw/xfree86/common/xf86Xinput.c |    8 ++++++
 hw/xfree86/ramdac/xf86Cursor.c |    3 ++
 include/Makefile.am            |    1 +
 include/dricursor.h            |    3 ++
 9 files changed, 81 insertions(+), 1 deletions(-)
 create mode 100644 dricursor/Makefile.am
 create mode 100644 dricursor/dricursor.c
 create mode 100644 include/dricursor.h

diff --git a/Makefile.am b/Makefile.am
index aa9c8b6..c641710 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ endif
 
 SUBDIRS = \
 	doc \
+	dricursor \
 	include \
 	dix  \
 	fb \
diff --git a/configure.ac b/configure.ac
index 93e3a60..a83da6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -842,6 +842,7 @@ AC_SUBST([GLX_DEFINES])
 
 AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
 if test "x$DRI" = xyes; then
+    DRICURSOR_LIB='$(top_builddir)/dricursor/libdricursor.la'
 	AC_DEFINE(XF86DRI, 1, [Build DRI extension])
 	PKG_CHECK_MODULES([DRIPROTO], [xf86driproto])
 	PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0])
@@ -1228,7 +1229,7 @@ if test "x$XORG" = xyes; then
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
 	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
-	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $SELINUX_LIB"
+	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $SELINUX_LIB $DRICURSOR_LIB"
 
 	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
 	SAVE_LIBS=$LIBS
@@ -1803,6 +1804,7 @@ damageext/Makefile
 dbe/Makefile
 dix/Makefile
 doc/Makefile
+dricursor/Makefile
 fb/Makefile
 record/Makefile
 config/Makefile
diff --git a/dix/getevents.c b/dix/getevents.c
index 4770a69..8d24075 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -880,12 +880,14 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
         }
     }
     else {
+#if 0
         if (flags & POINTER_ACCELERATE &&
             pDev->valuator->accelScheme.AccelSchemeProc){
             pDev->valuator->accelScheme.AccelSchemeProc(
                       pDev, first_valuator, num_valuators, valuators, ms);
         }
 
+#endif
         if(v0) x += *v0;
         if(v1) y += *v1;
 
diff --git a/dricursor/Makefile.am b/dricursor/Makefile.am
new file mode 100644
index 0000000..017a861
--- /dev/null
+++ b/dricursor/Makefile.am
@@ -0,0 +1,9 @@
+noinst_LTLIBRARIES = libdricursor.la
+
+AM_CFLAGS = @DIX_CFLAGS@ @LIBDRM_CFLAGS@
+
+INCLUDES = $(XORG_INCS) \
+	       -I$(top_srcdir)/include 
+
+libdricursor_la_SOURCES = dricursor.c
+libdricursor_la_LIBADD = @LIBDRM_LIBS@
diff --git a/dricursor/dricursor.c b/dricursor/dricursor.c
new file mode 100644
index 0000000..933baac
--- /dev/null
+++ b/dricursor/dricursor.c
@@ -0,0 +1,51 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <xf86drm.h>
+#include "dricursor.h"
+
+
+int drmFD = -1;
+
+/**
+ * Save the DRM fd. Called by the DRM user, i.e. the video driver.
+ *
+ * @param The drm file-descriptor
+ */
+void
+DRICursorSaveFD(int fd) {
+    fprintf(stderr, "%s: %d\n", __FUNCTION__, fd);
+    drmFD = fd;
+}
+
+/**
+ * drmCursorSetDev ioctl interface.
+ *
+ * Notify DRM about which devices are responsible for cursor updates.
+ *
+ * @param The device path (e.g. /dev/input/event0)
+ * @return On success zero is returned.
+ */
+int
+DRICursorSetDev(char *path)
+{
+    fprintf(stderr, "%s: %d: %s\n", __FUNCTION__, drmFD, path);
+    return drmCursorSetDev(drmFD, path);
+}
+
+/**
+ * drmCursorHotspot ioctl interface.
+ *
+ * When the application updates the sprite, DRM must be notified by the
+ * changes.
+ *
+ * @param The hotspot of the cursor.
+ * @return On success zero is returned.
+ */
+int
+DRICursorHotspot(int hotx, int hoty)
+{
+    return drmCursorHotspot(drmFD, hotx, hoty);
+}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 8eaa118..c4f3f30 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -89,6 +89,7 @@
 #endif
 
 #include "os.h"
+#include "dricursor.h"
 
 EventListPtr xf86Events = NULL;
 
@@ -471,6 +472,7 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
     DeviceIntPtr dev = NULL;
     int rval = Success;
     int is_auto = 0;
+    char *path;
 
     idev = xcalloc(sizeof(*idev), 1);
     if (!idev)
@@ -514,6 +516,9 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
             }
         }
 
+        if (strcasecmp(option->key, "path") == 0)
+            path = xstrdup(option->value);
+
         /* Right now, the only automatic config we know of is HAL. */
         if (strcmp(option->key, "_source") == 0 &&
             strcmp(option->value, "server/hal") == 0) {
@@ -582,6 +587,9 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
         (!is_auto || xf86Info.autoEnableDevices))
         EnableDevice(dev);
 
+    if (IsPointerDevice(dev))
+        DRICursorSetDev(path);
+
     /* send enter/leave event, update sprite window */
     CheckMotion(NULL, dev);
 
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 592eaad..93bee64 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -7,6 +7,7 @@
 #include "xf86CursorPriv.h"
 #include "colormapst.h"
 #include "cursorstr.h"
+#include "dricursor.h"
 
 /* FIXME: This was added with the ABI change of the miPointerSpriteFuncs for
  * MPX.
@@ -323,6 +324,8 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
 	ScreenPriv->HotX = pCurs->bits->xhot;
 	ScreenPriv->HotY = pCurs->bits->yhot;
 
+    DRICursorHotspot(ScreenPriv->HotX, ScreenPriv->HotY);
+
         if (!infoPtr->pScrn->vtSema)
             ScreenPriv->SavedCursor = pCurs;
 
diff --git a/include/Makefile.am b/include/Makefile.am
index f639048..75123b0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -17,6 +17,7 @@ sdk_HEADERS =		\
 	dixfontstr.h	\
 	dixgrabs.h	\
 	dixstruct.h	\
+	dricursor.h	\
 	exevents.h	\
 	extension.h	\
 	extinit.h	\
diff --git a/include/dricursor.h b/include/dricursor.h
new file mode 100644
index 0000000..48ba40e
--- /dev/null
+++ b/include/dricursor.h
@@ -0,0 +1,3 @@
+void DRICursorSaveFD(int);
+int  DRICursorSetDev(char *);
+int  DRICursorHotspot(int hotx, int hoty);
-- 
1.5.6.3

-- 
Tiago Vignatti
C3SL - Centro de Computação Científica e Software Livre
www.c3sl.ufpr.br



More information about the xorg mailing list