1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Revised support for kernel based LIRC driver

This commit is contained in:
Klaus Schmidinger 2023-02-16 17:15:06 +01:00
parent d53e0fd5c3
commit 468dc1115e
2 changed files with 25 additions and 14 deletions

View File

@ -9850,3 +9850,4 @@ Video Disk Recorder Revision History
is being replayed (new solution). is being replayed (new solution).
- Fixed unnecessary interruption of ongoing recordings if timers avoided the transfer - Fixed unnecessary interruption of ongoing recordings if timers avoided the transfer
mode receiver device (thanks to Markus Ehrnsperger). mode receiver device (thanks to Markus Ehrnsperger).
- Revised support for kernel based LIRC driver (thanks to Marko Mäkelä).

34
lirc.c
View File

@ -6,7 +6,7 @@
* *
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16. * LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
* *
* $Id: lirc.c 5.1 2022/11/26 13:37:06 kls Exp $ * $Id: lirc.c 5.2 2023/02/16 17:15:06 kls Exp $
*/ */
#include "lirc.h" #include "lirc.h"
@ -37,10 +37,10 @@ public:
#if HAVE_KERNEL_LIRC #if HAVE_KERNEL_LIRC
class cLircDevRemote : public cLircRemote { class cLircDevRemote : public cLircRemote {
private: private:
void Connect(const char *DeviceName);
virtual void Action(void); virtual void Action(void);
public: public:
cLircDevRemote(const char *DeviceName); cLircDevRemote(void);
bool Connect(const char *DeviceName);
}; };
#endif #endif
@ -64,9 +64,10 @@ cLircRemote::~cLircRemote()
void cLircRemote::NewLircRemote(const char *Name) void cLircRemote::NewLircRemote(const char *Name)
{ {
#if HAVE_KERNEL_LIRC #if HAVE_KERNEL_LIRC
if (startswith(Name, "/dev/")) cLircDevRemote *r = new cLircDevRemote();
new cLircDevRemote(Name); if (r->Connect(Name))
else return;
delete r;
#endif #endif
new cLircUsrRemote(Name); new cLircUsrRemote(Name);
} }
@ -179,24 +180,33 @@ void cLircUsrRemote::Action(void)
// --- cLircDevRemote -------------------------------------------------------- // --- cLircDevRemote --------------------------------------------------------
#if HAVE_KERNEL_LIRC #if HAVE_KERNEL_LIRC
inline void cLircDevRemote::Connect(const char *DeviceName) bool cLircDevRemote::Connect(const char *DeviceName)
{ {
unsigned mode = LIRC_MODE_SCANCODE; unsigned mode = LIRC_MODE_SCANCODE;
f = open(DeviceName, O_RDONLY, 0); f = open(DeviceName, O_RDONLY, 0);
if (f < 0) if (f < 0) {
switch (errno) {
case ENXIO:
case ENODEV:
// Do not complain about an attempt to open a lircd socket file.
break;
default:
LOG_ERROR_STR(DeviceName); LOG_ERROR_STR(DeviceName);
}
}
else if (ioctl(f, LIRC_SET_REC_MODE, &mode)) { else if (ioctl(f, LIRC_SET_REC_MODE, &mode)) {
LOG_ERROR_STR(DeviceName); LOG_ERROR_STR(DeviceName);
close(f); close(f);
f = -1; f = -1;
} }
if (f >= 0)
Start();
return f >= 0;
} }
cLircDevRemote::cLircDevRemote(const char *DeviceName) cLircDevRemote::cLircDevRemote(void)
: cLircRemote("DEV_LIRC") :cLircRemote("DEV_LIRC")
{ {
Connect(DeviceName);
Start();
} }
void cLircDevRemote::Action(void) void cLircDevRemote::Action(void)