Remote plugin breakage with 2.6.15-rc1+ kernel

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

 



I demand that C.Y.M may or may not have written...

> C.Y.M wrote:
>> As of 2.6.15-rc1 (actually the change was originally made in 2.6.14-git8),
>> there is no more /dev/input/event0 node.  The nodes now start at event1
>> and up.  This breaks the autodetect feature in the remote plugin for VDR. 
>> I was able to kludge a fix by hacking the default to the event I am
>> currently using, but a real fix should be made instead.

>> This is *hacked* fix for a remote that is using event3.  This only a
>> kludge.

> OK, this seems like a much better fix for 2.6.15-rc1+ kernels and the
> remote plugin.  Now autodetect works again for the events.

There could be gaps in the list due to some other device (probably USB)
having been unplugged, leaving, for example, event0, event1 and event3. Now
imagine that event3 is for the DVB remote control.

The attached patch *should* fix this.

(For completeness, I'm also attaching my older patches.)

-- 
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian,     | Northumberland | s zap,tartarus,org
| RISC OS     | Toon Army      | @
|   Kill all extremists!

You are so narrow-minded that you can see through a keyhole with two eyes.
-------------- next part --------------
--- vdr-plugin-remote-0.3.3.orig/remote.c
+++ vdr-plugin-remote-0.3.3/remote.c
@@ -174,7 +174,7 @@
 //          -1 - error
 //
 // ---------------------------------------------------------------------------
-int identifyInputDevice(const int fh, char *name)
+int identifyInputDevice(const int fh, const char *name)
 // ---------------------------------------------------------------------------
 {
     char description[256];
@@ -651,6 +651,23 @@
 }
 
 
+class cListString : public cListObject
+{
+private:
+  cString *content;
+public:
+  cListString (const char *obj) { content = new cString (obj); }
+  ~cListString () { delete content; }
+  int Compare (const cListObject &obj) const;
+  const cString& Get () { return *content; }
+};
+
+int cListString::Compare (const cListObject &obj) const
+{
+  return strcmp (**content, **((const cListString &)obj).content);
+}
+
+
 // ---------------------------------------------------------------------------
 bool cPluginRemote::Start(void)
 // ---------------------------------------------------------------------------
@@ -668,17 +685,59 @@
         devcnt = 1;
     }
 
+    cList<cListString> devices;
+
+    DIR *dir = opendir ("/dev/input");
+    if (!dir)
+    {
+        esyslog ("%s: unable to open '%s': %s",
+                 Name (), "/dev/input", strerror (errno));
+        return false;
+    }
+
+    long devmin = INT_MAX;
+    for (;;)
+    {
+        dirent obj, *ret;
+        int err = readdir_r (dir, &obj, &ret);
+        if (err)
+        {
+            esyslog ("%s: unable to read '%s': %s",
+                     Name (), "/dev/input", strerror (errno));
+            closedir (dir);
+            return false;
+        }
+        if (!ret)
+            break;
+
+        if (strncmp (obj.d_name, "event", 5))
+            continue;
+
+        long j;
+        char *end;
+        j = strtol (obj.d_name + 5, &end, 10);
+        if (j < 0 || end == obj.d_name || *end)
+            continue;
+
+        // keep track of the lowest device number (in case it's not 0)
+        if (j < devmin)
+            devmin = j;
+
+        devices.Add (new cListString (cString::sprintf ("/dev/input/%s", obj.d_name)));
+    }
+    closedir (dir);
+
+    devices.Sort ();
+
     /* probe eventX devices */
     for (int i = 0; i < devcnt; i++)
     {
         if (devtyp[i] == 'i' && strcmp(devnam[i], "autodetect") == 0)
         {
-            char nam[80];
 
-            for (int j = 0; ; j++)
+            for (cListString *dev = devices.First (); dev; dev = devices.Next (dev))
             {
-                sprintf(nam, "/dev/input/event%d", j);
-                fh[i] = open(nam, O_RDONLY);
+                fh[i] = open(dev->Get (), O_RDONLY);
                 if (fh[i] < 0)
                 {
                     switch (errno)
@@ -691,22 +750,23 @@
                     break;
                 }
 		
-                if (identifyInputDevice(fh[i], nam) >= 1)
+                if (identifyInputDevice(fh[i], dev->Get ()) >= 1)
                 {
                     // found DVB card receiver
-                    devnam[i] = strdup(nam);
+                    devnam[i] = strdup(dev->Get ());
                     close(fh[i]);
+                    devices.Del (dev);
                     break;
                 }
 
                 // unknown device, try next one
                 close(fh[i]);
-            } // for j
+            } // for each (remaining) eventX
         } // if autodetect
 
         // use default device if nothing could be identified
         if (devtyp[i] == 'i' && strcmp(devnam[i], "autodetect") == 0)
-            devnam[i] = "/dev/input/event0";
+            asprintf (&devnam[i], "/dev/input/event%ld", devmin);
     } // for i
 
     for (int i = 0; i < devcnt; i++)
-------------- next part --------------
diff -urNad vdr-plugin-remote-0.3.3/remote.c /tmp/dpep.Gy94KY/vdr-plugin-remote-0.3.3/remote.c
--- vdr-plugin-remote-0.3.3/remote.c	2005-02-13 19:38:32.000000000 +0000
+++ /tmp/dpep.Gy94KY/vdr-plugin-remote-0.3.3/remote.c	2005-02-23 23:09:14.000000000 +0000
@@ -783,9 +783,9 @@
     } // for
     
     if (!ok)
-        esyslog("%s: fatal error - unable to open input device", Name());
+        esyslog("%s: warning: unable to open input device", Name());
 
-    return ok;
+    return true;
 }
 
 
-------------- next part --------------
--- vdr-plugin-remote-0.3.2.orig/README
+++ vdr-plugin-remote-0.3.2/README
@@ -25,6 +25,9 @@
     - other input devices (not tested, please report success!)
     See file FAQ for a list of cards which have been reported to work.
 
+    This option requires that your kernel has event interface support
+    (INPUT_EVDEV).
+
 (b) keyboard (tty driver): /dev/console, /dev/ttyX
 
 (c) TCP connection (telnet)
-------------- next part --------------
--- vdr-plugin-remote-0.3.2.orig/remote.c
+++ vdr-plugin-remote-0.3.2/remote.c
@@ -165,6 +165,9 @@
     if (strstr(description, "DVB") || strstr(description, "dvb"))
         return 2;
 
+    if (!strncmp(description, "saa7146", 7))
+        return 2;
+
     return 0;
 }
 

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux