[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#512802: xserver-xorg-input-evdev: Bluetooth mouse goes idle and evdev driver doesn't reconnect



Package: xserver-xorg-input-evdev
Version: 1:2.0.8-1
Severity: normal


I've configured xorg to access my bluetooth mouse with evdev, but each time the mouse goes idle 
(after a few minutes of inactivity), the driver try to reconnect N times each 100ms and then 
definitly close the device.

The attached patch allow infinite attempts, and allow set the delay between attempts in xorg.conf

Maybe there is a better way to do achieve this bluetooth mouse reconnection ?


-- working InputDevice section from my xorg.conf
Section "InputDevice"
        Identifier "Configured Mouse"
        Driver "evdev"
        Option "CorePointer"
        Option "Device" "/dev/input/by-path/pci-0000:00:1d.7-usb-0:acl000xxxxxxxx-event-"
        Option "SendCoreEvents" "true"
        Option "ReopenAttempts" "0"
        Option "ReopenDelay" "1000"
EndSection


-- System Information:
Debian Release: 5.0
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages xserver-xorg-input-evdev depends on:
ii  libc6                         2.7-16     GNU C Library: Shared libraries
ii  xserver-xorg-core             2:1.4.2-9  Xorg X server - core server

xserver-xorg-input-evdev recommends no packages.

xserver-xorg-input-evdev suggests no packages.

-- no debconf information
diff --git a/src/evdev.c b/src/evdev.c
index d186be0..6b7d71e 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -182,8 +182,13 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
     {
         if (EvdevCacheCompare(pInfo, TRUE) == Success)
         {
-            xf86Msg(X_INFO, "%s: Device reopened after %d attempts.\n", pInfo->name,
-                    pEvdev->reopen_attempts - pEvdev->reopen_left + 1);
+            if (pEvdev->reopen_attempts>0) 
+            {
+                xf86Msg(X_INFO, "%s: Device reopened after %d attempts.\n", pInfo->name,
+                        pEvdev->reopen_attempts - pEvdev->reopen_left + 1);
+            } else {
+                xf86Msg(X_INFO, "%s: Device reopened.\n", pInfo->name);
+            }
             EvdevOn(pInfo->dev);
         } else
         {
@@ -197,9 +202,12 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
         return 0;
     }
 
-    pEvdev->reopen_left--;
+    if (pEvdev->reopen_attempts)
+    {
+        pEvdev->reopen_left--;
+    }
 
-    if (!pEvdev->reopen_left)
+    if (!pEvdev->reopen_left && (pEvdev->reopen_attempts>0))
     {
         xf86Msg(X_ERROR, "%s: Failed to reopen device after %d attempts.\n",
                 pInfo->name, pEvdev->reopen_attempts);
@@ -230,13 +238,13 @@ EvdevReadInput(InputInfoPtr pInfo)
              * event, so len != sizeof ev is an error. */
             xf86Msg(X_ERROR, "%s: Read error: %s\n", pInfo->name, strerror(errno));
 
-            if (errno == ENODEV) /* May happen after resume */
+            if (errno == ENODEV) /* May happen after resume (or when the device goes idle)*/
             {
                 xf86RemoveEnabledDevice(pInfo);
                 close(pInfo->fd);
                 pInfo->fd = -1;
                 pEvdev->reopen_left = pEvdev->reopen_attempts;
-                pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo);
+                pEvdev->reopen_timer = TimerSet(NULL, 0, pEvdev->reopen_delay, EvdevReopenTimer, pInfo);
             }
             break;
         }
@@ -932,7 +940,7 @@ EvdevOn(DeviceIntPtr device)
     if (pInfo->fd == -1)
     {
         pEvdev->reopen_left = pEvdev->reopen_attempts;
-        pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo);
+        pEvdev->reopen_timer = TimerSet(NULL, 0, pEvdev->reopen_delay, EvdevReopenTimer, pInfo);
     } else
     {
         xf86AddEnabledDevice(pInfo);
@@ -1302,6 +1310,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
 
     pEvdev->reopen_attempts = xf86SetIntOption(pInfo->options, "ReopenAttempts", 10);
+    pEvdev->reopen_delay = xf86SetIntOption(pInfo->options, "ReopenDelay", 100);
 
     pEvdev->noXkb = noXkbExtension;
     /* parse the XKB options during kbd setup */
diff --git a/src/evdev.h b/src/evdev.h
index 9f16b81..1554ee3 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -71,7 +70,8 @@ typedef struct {
         Time                expires;     /* time of expiry */
         Time                timeout;
     } emulateMB;
-    int reopen_attempts; /* max attempts to re-open after read failure */
+    int reopen_delay;    /* delay between attempts to re-open after read failure */
+    int reopen_attempts; /* max attempts to re-open after read failure (0 = infinite) */
     int reopen_left;     /* number of attempts left to re-open the device */
     OsTimerPtr reopen_timer;
 

Reply to: