From a7b51f43ac1f92399fd041d30dc0340d9c00d48c Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 12 Sep 2008 20:08:52 +0000 Subject: [PATCH] - evdev-2.0.4-reopen-device.patch: When arming the reopen timer, stash it in the driver private, and explicitly cancel it if the server decides to close the device for real. - evdev-2.0.4-cache-info.patch: Rebase to account for same. --- evdev-2.0.4-cache-info.patch | 49 ++++++---------------- evdev-2.0.4-reopen-device.patch | 73 +++++++++++---------------------- xorg-x11-drv-evdev.spec | 12 ++++-- 3 files changed, 47 insertions(+), 87 deletions(-) diff --git a/evdev-2.0.4-cache-info.patch b/evdev-2.0.4-cache-info.patch index 35b4a4c..d089878 100644 --- a/evdev-2.0.4-cache-info.patch +++ b/evdev-2.0.4-cache-info.patch @@ -1,25 +1,6 @@ -From 441a97c22933db462dd53e000d1cb269dab6e825 Mon Sep 17 00:00:00 2001 -From: Peter Hutterer -Date: Thu, 28 Aug 2008 10:29:26 +0930 -Subject: [PATCH] Cache device information and compare against info after re-open. - -This way we ensure that if the topology changes under us, we don't open a -completely different device. If a device has changed, we disable it. -(cherry picked from commit 3bb7d100570134058eb4c906d4902c655148a8be) - -Conflicts: - - src/evdev.c - src/evdev.h ---- - src/evdev.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- - src/evdev.h | 12 +++++ - 2 files changed, 137 insertions(+), 6 deletions(-) - -diff --git a/src/evdev.c b/src/evdev.c -index 16cf67f..ca6da6e 100644 ---- a/src/evdev.c -+++ b/src/evdev.c +diff -up xf86-input-evdev-2.0.4/src/evdev.c.jx xf86-input-evdev-2.0.4/src/evdev.c +--- xf86-input-evdev-2.0.4/src/evdev.c.jx 2008-09-12 16:04:34.000000000 -0400 ++++ xf86-input-evdev-2.0.4/src/evdev.c 2008-09-12 16:04:56.000000000 -0400 @@ -98,6 +98,7 @@ static const char *evdevDefaults[] = { }; @@ -28,7 +9,7 @@ index 16cf67f..ca6da6e 100644 static void SetXkbOption(InputInfoPtr pInfo, char *name, char **option) -@@ -176,11 +177,19 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg) +@@ -176,12 +177,19 @@ EvdevReopenTimer(OsTimerPtr timer, CARD3 if (pInfo->fd != -1) { @@ -36,8 +17,8 @@ index 16cf67f..ca6da6e 100644 - pEvdev->reopen_attempts - pEvdev->reopen_left); - pEvdev->reopen_left = 0; + pEvdev->reopen_timer = NULL; - EvdevOn(pInfo->dev); -+ + if (EvdevCacheCompare(pInfo, TRUE) == Success) + { + xf86Msg(X_INFO, "%s: Device reopened after %d attempts.\n", pInfo->name, @@ -52,7 +33,7 @@ index 16cf67f..ca6da6e 100644 return 0; } -@@ -368,8 +377,6 @@ EvdevReadInput(InputInfoPtr pInfo) +@@ -370,8 +378,6 @@ EvdevReadInput(InputInfoPtr pInfo) } } @@ -61,7 +42,7 @@ index 16cf67f..ca6da6e 100644 #define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1 << ((bit) % LONG_BITS)) static void -@@ -994,6 +1001,116 @@ EvdevConvert(InputInfoPtr pInfo, int first, int num, int v0, int v1, int v2, +@@ -1000,6 +1006,116 @@ EvdevConvert(InputInfoPtr pInfo, int fir return TRUE; } @@ -178,7 +159,7 @@ index 16cf67f..ca6da6e 100644 static int EvdevProbe(InputInfoPtr pInfo) { -@@ -1173,6 +1290,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +@@ -1179,6 +1295,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr return NULL; } @@ -187,10 +168,9 @@ index 16cf67f..ca6da6e 100644 return pInfo; } -diff --git a/src/evdev.h b/src/evdev.h -index 0f8cf4b..47bbff2 100644 ---- a/src/evdev.h -+++ b/src/evdev.h +diff -up xf86-input-evdev-2.0.4/src/evdev.h.jx xf86-input-evdev-2.0.4/src/evdev.h +--- xf86-input-evdev-2.0.4/src/evdev.h.jx 2008-09-12 16:04:34.000000000 -0400 ++++ xf86-input-evdev-2.0.4/src/evdev.h 2008-09-12 16:04:56.000000000 -0400 @@ -40,6 +40,9 @@ #include #endif @@ -201,10 +181,10 @@ index 0f8cf4b..47bbff2 100644 typedef struct { const char *device; int kernel24; -@@ -71,6 +74,15 @@ typedef struct { - +@@ -72,6 +75,15 @@ typedef struct { int reopen_attempts; /* max attempts to re-open after read failure */ int reopen_left; /* number of attempts left to re-open the device */ + OsTimerPtr reopen_timer; + + /* Cached info from device. */ + char name[1024]; @@ -217,6 +197,3 @@ index 0f8cf4b..47bbff2 100644 } EvdevRec, *EvdevPtr; /* Middle Button emulation */ --- -1.5.6.4 - diff --git a/evdev-2.0.4-reopen-device.patch b/evdev-2.0.4-reopen-device.patch index 9fd6a0e..a712bf8 100644 --- a/evdev-2.0.4-reopen-device.patch +++ b/evdev-2.0.4-reopen-device.patch @@ -1,31 +1,6 @@ -From 188f07089d9c91d503391d05f0c3776360d7446b Mon Sep 17 00:00:00 2001 -From: Peter Hutterer -Date: Thu, 28 Aug 2008 10:24:33 +0930 -Subject: [PATCH] Attempt to re-open devices on read errors. - -Coming back from resume may leave us with a file descriptor that can be opened -but fails on the first read (ENODEV). -In this case, try to open the device until it becomes available or until the -predefined count expires. - -Adds option "ReopenAttempts" -(cherry picked from commit b41d39a745cce9e91241453935ea4c702772c5da) - -Conflicts: - - man/evdev.man - src/evdev.c - src/evdev.h ---- - man/evdev.man | 5 ++ - src/evdev.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++-------- - src/evdev.h | 4 ++ - 3 files changed, 120 insertions(+), 19 deletions(-) - -diff --git a/man/evdev.man b/man/evdev.man -index f438f78..530f979 100644 ---- a/man/evdev.man -+++ b/man/evdev.man +diff -up xf86-input-evdev-2.0.4/man/evdev.man.reopen-device xf86-input-evdev-2.0.4/man/evdev.man +--- xf86-input-evdev-2.0.4/man/evdev.man.reopen-device 2008-08-14 22:27:13.000000000 -0400 ++++ xf86-input-evdev-2.0.4/man/evdev.man 2008-09-12 15:45:50.000000000 -0400 @@ -67,6 +67,11 @@ button event is registered. Sets the timeout (in milliseconds) that the driver waits before deciding if two buttons where pressed "simultaneously" when 3 button emulation is @@ -38,10 +13,9 @@ index f438f78..530f979 100644 .SH AUTHORS Kristian Høgsberg. .SH "SEE ALSO" -diff --git a/src/evdev.c b/src/evdev.c -index a857db3..16cf67f 100644 ---- a/src/evdev.c -+++ b/src/evdev.c +diff -up xf86-input-evdev-2.0.4/src/evdev.c.reopen-device xf86-input-evdev-2.0.4/src/evdev.c +--- xf86-input-evdev-2.0.4/src/evdev.c.reopen-device 2008-08-14 22:27:13.000000000 -0400 ++++ xf86-input-evdev-2.0.4/src/evdev.c 2008-09-12 15:55:42.000000000 -0400 @@ -73,6 +73,7 @@ #define EVDEV_RELATIVE_EVENTS (1 << 2) #define EVDEV_ABSOLUTE_EVENTS (1 << 3) @@ -59,7 +33,7 @@ index a857db3..16cf67f 100644 static void SetXkbOption(InputInfoPtr pInfo, char *name, char **option) { -@@ -154,6 +157,46 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) +@@ -154,6 +157,48 @@ PostKbdEvent(InputInfoPtr pInfo, struct xf86PostKeyboardEvent(pInfo->dev, code, value); } @@ -86,6 +60,7 @@ index a857db3..16cf67f 100644 + pEvdev->reopen_attempts - pEvdev->reopen_left); + + pEvdev->reopen_left = 0; ++ pEvdev->reopen_timer = NULL; + EvdevOn(pInfo->dev); + return 0; + } @@ -97,6 +72,7 @@ index a857db3..16cf67f 100644 + xf86Msg(X_ERROR, "%s: Failed to reopen device after %d attempts.\n", + pInfo->name, pEvdev->reopen_attempts); + DisableDevice(pInfo->dev); ++ pEvdev->reopen_timer = NULL; + return 0; + } + @@ -106,7 +82,7 @@ index a857db3..16cf67f 100644 static void EvdevReadInput(InputInfoPtr pInfo) { -@@ -173,6 +216,15 @@ EvdevReadInput(InputInfoPtr pInfo) +@@ -173,6 +218,15 @@ EvdevReadInput(InputInfoPtr pInfo) /* The kernel promises that we always only read a complete * event, so len != sizeof ev is an error. */ xf86Msg(X_ERROR, "%s: Read error: %s\n", pInfo->name, strerror(errno)); @@ -117,12 +93,12 @@ index a857db3..16cf67f 100644 + close(pInfo->fd); + pInfo->fd = -1; + pEvdev->reopen_left = pEvdev->reopen_attempts; -+ TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo); ++ pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo); + } break; } -@@ -836,6 +888,47 @@ EvdevInit(DeviceIntPtr device) +@@ -836,6 +890,47 @@ EvdevInit(DeviceIntPtr device) return Success; } @@ -150,7 +126,7 @@ index a857db3..16cf67f 100644 + close(pInfo->fd); + pInfo->fd = -1; + pEvdev->reopen_left = pEvdev->reopen_attempts; -+ TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo); ++ pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo); + } else + { + xf86AddEnabledDevice(pInfo); @@ -170,7 +146,7 @@ index a857db3..16cf67f 100644 static int EvdevProc(DeviceIntPtr device, int what) { -@@ -851,30 +944,26 @@ EvdevProc(DeviceIntPtr device, int what) +@@ -851,30 +946,30 @@ EvdevProc(DeviceIntPtr device, int what) return EvdevInit(device); case DEVICE_ON: @@ -209,12 +185,16 @@ index a857db3..16cf67f 100644 case DEVICE_CLOSE: xf86Msg(X_INFO, "%s: Close\n", pInfo->name); - close(pInfo->fd); ++ if (pEvdev->reopen_timer) { ++ TimerCancel(pEvdev->reopen_timer); ++ pEvdev->reopen_timer = NULL; ++ } + if (pInfo->fd != -1) + close(pInfo->fd); break; } -@@ -1060,11 +1149,12 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +@@ -1060,11 +1155,12 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr return NULL; } @@ -229,7 +209,7 @@ index a857db3..16cf67f 100644 if (pInfo->fd < 0) { xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", device); -@@ -1072,6 +1162,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +@@ -1072,6 +1168,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr return NULL; } @@ -238,10 +218,9 @@ index a857db3..16cf67f 100644 pEvdev->noXkb = noXkbExtension; /* parse the XKB options during kbd setup */ -diff --git a/src/evdev.h b/src/evdev.h -index cad1eed..0f8cf4b 100644 ---- a/src/evdev.h -+++ b/src/evdev.h +diff -up xf86-input-evdev-2.0.4/src/evdev.h.reopen-device xf86-input-evdev-2.0.4/src/evdev.h +--- xf86-input-evdev-2.0.4/src/evdev.h.reopen-device 2008-08-14 22:27:13.000000000 -0400 ++++ xf86-input-evdev-2.0.4/src/evdev.h 2008-09-12 15:55:44.000000000 -0400 @@ -41,6 +41,7 @@ #endif @@ -250,16 +229,14 @@ index cad1eed..0f8cf4b 100644 int kernel24; int screen; int min_x, min_y, max_x, max_y; -@@ -67,6 +68,9 @@ typedef struct { +@@ -67,6 +68,10 @@ typedef struct { Time expires; /* time of expiry */ Time timeout; } emulateMB; + + int reopen_attempts; /* max attempts to re-open after read failure */ + int reopen_left; /* number of attempts left to re-open the device */ ++ OsTimerPtr reopen_timer; } EvdevRec, *EvdevPtr; /* Middle Button emulation */ --- -1.5.6.4 - diff --git a/xorg-x11-drv-evdev.spec b/xorg-x11-drv-evdev.spec index 05df848..58d90ff 100644 --- a/xorg-x11-drv-evdev.spec +++ b/xorg-x11-drv-evdev.spec @@ -7,7 +7,7 @@ Summary: Xorg X11 evdev input driver Name: xorg-x11-drv-evdev Version: 2.0.4 -Release: 2%{?dist} +Release: 3%{?dist} URL: http://www.x.org License: MIT Group: User Interface/X Hardware Support @@ -35,8 +35,8 @@ X.Org X11 evdev input driver. %setup -q -n %{tarball}-%{version} # apply patches -%patch1 -p1 -b .reopen-device.patch -%patch2 -p1 -b .cache-info.patch +%patch1 -p1 -b .reopen-device +%patch2 -p1 -b .cache-info %build autoreconf -v --install || exit 1 @@ -61,6 +61,12 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man4/evdev.4* %changelog +* Fri Sep 12 2008 Adam Jackson 2.0.4-3 +- evdev-2.0.4-reopen-device.patch: When arming the reopen timer, stash it in + the driver private, and explicitly cancel it if the server decides to + close the device for real. +- evdev-2.0.4-cache-info.patch: Rebase to account for same. + * Thu Aug 28 2008 Peter Hutterer 2.0.4-2 - evdev-2.0.4-reopen-device.patch: try to reopen devices if a read error occurs on the fd.