From patchwork Mon Nov 14 03:30:03 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Salt X-Patchwork-Id: 12090 Received: from anchor-post-36.mail.demon.net ([194.217.242.86]) by www.linuxtv.org with esmtp (Exim 4.50) id 1EbVAn-0004pT-Ub for vdr@linuxtv.org; Mon, 14 Nov 2005 04:38:25 +0100 Received: from youmustbejoking.demon.co.uk ([212.228.127.8] helo=pentagram.youmustbejoking.demon.co.uk) by anchor-post-36.mail.demon.net with esmtp (Exim 4.42) id 1EbVAj-000Pff-Jr for vdr@linuxtv.org; Mon, 14 Nov 2005 03:38:23 +0000 Received: from [192.168.0.2] (helo=riscpc) by pentagram.youmustbejoking.demon.co.uk with esmtp (Exim 4.50) id 1EbVAh-0007YP-P5 for vdr@linuxtv.org; Mon, 14 Nov 2005 03:38:19 +0000 Date: Mon, 14 Nov 2005 03:30:03 +0000 From: Darren Salt To: vdr@linuxtv.org Subject: Re: [vdr] Remote plugin breakage with 2.6.15-rc1+ kernel Message-ID: <4DC97B4361%linux@youmustbejoking.demon.co.uk> References: <4377165F.3010105@syphir.sytes.net> <43771BE1.5020508@syphir.sytes.net> In-Reply-To: <43771BE1.5020508@syphir.sytes.net> User-Agent: Messenger-Pro/3.30b7 (MsgServe/3.10) (RISC-OS/4.02) POPstar/2.06+cvs X-Editor: Zap 1.47 (17 Oct 2005) [TEST], ZapEmail 0.28.3 (25 Mar 2005) (32) X-SDate: Mon, 4458 Sep 1993 03:30:03 +0000 X-Message-Flag: Outlook Express is broken. Upgrade to mail(1). MIME-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.0.2 X-SA-Exim-Mail-From: linux@youmustbejoking.demon.co.uk X-SA-Exim-Scanned: No (on pentagram.youmustbejoking.demon.co.uk); SAEximRunCond expanded to false X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Nov 2005 03:38:26 -0000 Status: O X-Status: X-Keywords: X-UID: 6086 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.) --- 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 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++)