commit 9c900dd98f93b2cc873dfd2009c3b97f80462bd3
Author: Peter Hutterer <peter.hutterer(a)who-t.net>
Date: Wed Jun 1 10:19:19 2011 +1000
Export vendor/model and device node through properties (#709543)
...port-product-vendor-ID-through-a-property.patch | 123 ++++++++++++++++++++
0002-Export-device-node-as-property.patch | 116 ++++++++++++++++++
xorg-x11-drv-evdev.spec | 9 ++-
3 files changed, 247 insertions(+), 1 deletions(-)
---
diff --git a/0001-Export-product-vendor-ID-through-a-property.patch
b/0001-Export-product-vendor-ID-through-a-property.patch
new file mode 100644
index 0000000..abc632b
--- /dev/null
+++ b/0001-Export-product-vendor-ID-through-a-property.patch
@@ -0,0 +1,123 @@
+From bf9cbd2a66e8767bb423fb37f758322a60bc68fe Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer(a)who-t.net>
+Date: Wed, 18 May 2011 12:20:00 +1000
+Subject: [PATCH 1/2] Export product/vendor ID through a property.
+
+Signed-off-by: Peter Hutterer <peter.hutterer(a)who-t.net>
+Reviewed-by: Daniel Stone <daniel(a)fooishbar.org>
+(cherry picked from commit bb15bac149411a2066eca6ddd50e2ca2cc38f7c8)
+
+Conflicts:
+
+ src/evdev.c
+ src/evdev.h
+---
+ src/evdev.c | 35 +++++++++++++++++++++++++++++++++--
+ src/evdev.h | 3 +++
+ 2 files changed, 36 insertions(+), 2 deletions(-)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index 45873c1..bddfb6d 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -61,6 +61,10 @@
+
+ #endif
+
++#ifndef XI_PROP_PRODUCT_ID
++#define XI_PROP_PRODUCT_ID "Device Product ID"
++#endif
++
+ #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+ /* removed from server, purge when dropping support for server 1.10 */
+ #define XI86_SEND_DRAG_EVENTS 0x08
+@@ -120,6 +124,7 @@ static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom
*atoms);
+ static void EvdevInitProperty(DeviceIntPtr dev);
+ static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkonly);
++static Atom prop_product_id = 0;
+ static Atom prop_invert = 0;
+ static Atom prop_calibration = 0;
+ static Atom prop_swap = 0;
+@@ -1777,6 +1782,7 @@ EvdevCache(InputInfoPtr pInfo)
+ {
+ EvdevPtr pEvdev = pInfo->private;
+ int i, len;
++ struct input_id id;
+
+ char name[1024] = {0};
+ unsigned long bitmask[NLONGS(EV_CNT)] = {0};
+@@ -1785,6 +1791,16 @@ EvdevCache(InputInfoPtr pInfo)
+ unsigned long abs_bitmask[NLONGS(ABS_CNT)] = {0};
+ unsigned long led_bitmask[NLONGS(LED_CNT)] = {0};
+
++
++ if (ioctl(pInfo->fd, EVIOCGID, &id) < 0)
++ {
++ xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGID failed: %s\n",
strerror(errno));
++ goto error;
++ }
++
++ pEvdev->id_vendor = id.vendor;
++ pEvdev->id_product = id.product;
++
+ if (ioctl(pInfo->fd, EVIOCGNAME(sizeof(name) - 1), name) < 0) {
+ xf86Msg(X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
+ goto error;
+@@ -1894,6 +1910,9 @@ EvdevProbe(InputInfoPtr pInfo)
+ EvdevPtr pEvdev = pInfo->private;
+ int rc = 1;
+
++ xf86IDrvMsg(pInfo, X_PROBED, "Vendor %#hx Product %#hx\n",
++ pEvdev->id_vendor, pEvdev->id_product);
++
+ /* Trinary state for ignoring axes:
+ - unset: do the normal thing.
+ - TRUE: explicitly ignore them.
+@@ -2610,6 +2629,17 @@ EvdevInitProperty(DeviceIntPtr dev)
+ EvdevPtr pEvdev = pInfo->private;
+ int rc;
+ BOOL invert[2];
++ CARD32 product[2];
++
++ prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, strlen(XI_PROP_PRODUCT_ID), TRUE);
++ product[0] = pEvdev->id_vendor;
++ product[1] = pEvdev->id_product;
++ rc = XIChangeDeviceProperty(dev, prop_product_id, XA_INTEGER, 32,
++ PropModeReplace, 2, product, FALSE);
++ if (rc != Success)
++ return;
++
++ XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
+
+ if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
+ {
+@@ -2718,8 +2748,9 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr
val,
+
+ if (!checkonly)
+ pEvdev->swap_axes = *((BOOL*)val->data);
+- } else if (atom == prop_axis_label || atom == prop_btn_label)
+- return BadAccess; /* Axis/Button labels can't be changed */
++ } else if (atom == prop_axis_label || atom == prop_btn_label ||
++ atom == prop_product_id)
++ return BadAccess; /* Read-only properties */
+
+ return Success;
+ }
+diff --git a/src/evdev.h b/src/evdev.h
+index f640fdd..441b340 100644
+--- a/src/evdev.h
++++ b/src/evdev.h
+@@ -116,6 +116,9 @@ typedef struct {
+ } EventQueueRec, *EventQueuePtr;
+
+ typedef struct {
++ unsigned short id_vendor;
++ unsigned short id_product;
++
+ const char *device;
+ int grabDevice; /* grab the event device? */
+
+--
+1.7.5.1
+
diff --git a/0002-Export-device-node-as-property.patch
b/0002-Export-device-node-as-property.patch
new file mode 100644
index 0000000..55684af
--- /dev/null
+++ b/0002-Export-device-node-as-property.patch
@@ -0,0 +1,116 @@
+From 80face5a8c61f7fe99ba1c2aaed9c944bb45ebac Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer(a)who-t.net>
+Date: Mon, 31 Jan 2011 14:11:44 +1000
+Subject: [PATCH 2/2] Export device node as property.
+
+There is currently no mapping between XI devices and physical devices other
+than what can be extracted by parsing the Xorg logfile. Add new property
+"Device Node" to the driver to export the open device file.
+
+Server 1.11 and later standardises on this property name.
+
+The client is responsible for detecting if the device is on the same host
+and converting the data into a more useful format (e.g. sysfs path).
+
+Signed-off-by: Peter Hutterer <peter.hutterer(a)who-t.net>
+(cherry picked from commit eaf202531f2bb2b3da6d4769769f76da5489ae68)
+
+Conflicts:
+
+ src/evdev.c
+ src/evdev.h
+---
+ man/evdev.man | 3 ++-
+ src/evdev.c | 20 +++++++++++++++++++-
+ src/evdev.h | 3 +++
+ 3 files changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/man/evdev.man b/man/evdev.man
+index adb3f8d..a202ae8 100644
+--- a/man/evdev.man
++++ b/man/evdev.man
+@@ -66,7 +66,8 @@ is used. Buttons not specified in the user's mapping use the
default mapping.
+ .BI "Option \*qDevice\*q \*q" string \*q
+ Specifies the device through which the device can be accessed. This will
+ generally be of the form \*q/dev/input/eventX\*q, where X is some integer.
+-The mapping from device node to hardware is system-dependent.
++The mapping from device node to hardware is system-dependent. Property:
++"Device Node" (read-only).
+ .TP 7
+ .BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q
+ Sets \*qdrag lock buttons\*q that simulate holding a button down, so
+diff --git a/src/evdev.c b/src/evdev.c
+index bddfb6d..9d3d385 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -124,12 +124,14 @@ static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom
*atoms);
+ static void EvdevInitProperty(DeviceIntPtr dev);
+ static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkonly);
++
+ static Atom prop_product_id = 0;
+ static Atom prop_invert = 0;
+ static Atom prop_calibration = 0;
+ static Atom prop_swap = 0;
+ static Atom prop_axis_label = 0;
+ static Atom prop_btn_label = 0;
++static Atom prop_device = 0;
+ #endif
+
+ /* All devices the evdev driver has allocated and knows about.
+@@ -2629,6 +2631,7 @@ EvdevInitProperty(DeviceIntPtr dev)
+ EvdevPtr pEvdev = pInfo->private;
+ int rc;
+ BOOL invert[2];
++ char *device_node;
+ CARD32 product[2];
+
+ prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, strlen(XI_PROP_PRODUCT_ID), TRUE);
+@@ -2641,6 +2644,21 @@ EvdevInitProperty(DeviceIntPtr dev)
+
+ XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
+
++ /* Device node property */
++ device_node = strdup(pEvdev->device);
++ prop_device = MakeAtom(XI_PROP_DEVICE_NODE,
++ strlen(XI_PROP_DEVICE_NODE), TRUE);
++ rc = XIChangeDeviceProperty(dev, prop_device, XA_STRING, 8,
++ PropModeReplace,
++ strlen(device_node), device_node,
++ FALSE);
++ free(device_node);
++
++ if (rc != Success)
++ return;
++
++ XISetDevicePropertyDeletable(dev, prop_device, FALSE);
++
+ if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
+ {
+ invert[0] = pEvdev->invert_x;
+@@ -2749,7 +2767,7 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr
val,
+ if (!checkonly)
+ pEvdev->swap_axes = *((BOOL*)val->data);
+ } else if (atom == prop_axis_label || atom == prop_btn_label ||
+- atom == prop_product_id)
++ atom == prop_product_id || atom == prop_device)
+ return BadAccess; /* Read-only properties */
+
+ return Success;
+diff --git a/src/evdev.h b/src/evdev.h
+index 441b340..1bb1e7f 100644
+--- a/src/evdev.h
++++ b/src/evdev.h
+@@ -91,6 +91,9 @@ typedef struct {
+ } XkbRMLVOSet;
+ #endif
+
++#ifndef XI_PROP_DEVICE_NODE
++#define XI_PROP_DEVICE_NODE "Device Node"
++#endif
+
+ #define LONG_BITS (sizeof(long) * 8)
+
+--
+1.7.5.1
+
diff --git a/xorg-x11-drv-evdev.spec b/xorg-x11-drv-evdev.spec
index 4872b14..c860b3e 100644
--- a/xorg-x11-drv-evdev.spec
+++ b/xorg-x11-drv-evdev.spec
@@ -8,7 +8,7 @@
Summary: Xorg X11 evdev input driver
Name: xorg-x11-drv-evdev
Version: 2.6.0
-Release: 3%{?gitdate:.%{gitdate}git%{gitversion}}%{dist}
+Release: 4%{?gitdate:.%{gitdate}git%{gitversion}}%{dist}
URL:
http://www.x.org
License: MIT
Group: User Interface/X Hardware Support
@@ -20,6 +20,8 @@ Source2: commitid
%else
Source0:
ftp://ftp.x.org/pub/individual/driver/%{tarball}-%{version}.tar.bz2
%endif
+Patch01: 0001-Export-product-vendor-ID-through-a-property.patch
+Patch02: 0002-Export-device-node-as-property.patch
ExcludeArch: s390 s390x
@@ -37,6 +39,8 @@ X.Org X11 evdev input driver.
%prep
%setup -q -n %{tarball}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
+%patch01 -p1
+%patch02 -p1
%build
autoreconf -v --install || exit 1
@@ -77,6 +81,9 @@ X.Org X11 evdev input driver development files.
%changelog
+* Wed Jun 01 2011 Peter Hutterer <peter.hutterer(a)redhat.com> 2.6.0-4
+- Export vendor/model and device node through properties (#709543)
+
* Thu Mar 10 2011 Adam Jackson <ajax(a)redhat.com> - 2.6.0-3
- xserver 1.10 ABI rebuild