summaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/lirc_dev.c
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2017-02-25 12:51:32 +0100
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-14 16:35:20 +0100
commitde142c32410649e64d44928505ffad2176a96a9e (patch)
treefe6334fd19c3279bfb40eb273cc05a2d7cd36e91 /drivers/media/rc/lirc_dev.c
parentmedia: lirc: remove last remnants of lirc kapi (diff)
downloadlinux-de142c32410649e64d44928505ffad2176a96a9e.tar.xz
linux-de142c32410649e64d44928505ffad2176a96a9e.zip
media: lirc: implement reading scancode
This implements LIRC_MODE_SCANCODE reading from the lirc device. The scancode can be read from the input device too, but with this interface you get the rc protocol, keycode, toggle and repeat status in addition to just the scancode. int main() { int fd, mode, rc; fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode; while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) { printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n", scancode.rc_proto, scancode.scancode, !!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE), !!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT)); } close(fd); } Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc/lirc_dev.c')
-rw-r--r--drivers/media/rc/lirc_dev.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 155a4de249a0..d766abcffeac 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -42,6 +42,8 @@ static void lirc_release_device(struct device *ld)
if (rcdev->driver_type == RC_DRIVER_IR_RAW)
kfifo_free(&rcdev->rawir);
+ if (rcdev->driver_type != RC_DRIVER_IR_RAW_TX)
+ kfifo_free(&rcdev->scancodes);
put_device(&rcdev->dev);
}
@@ -55,11 +57,20 @@ int ir_lirc_register(struct rc_dev *dev)
dev->lirc_dev.release = lirc_release_device;
dev->send_mode = LIRC_MODE_PULSE;
+ dev->rec_mode = LIRC_MODE_MODE2;
+
if (dev->driver_type == RC_DRIVER_IR_RAW) {
if (kfifo_alloc(&dev->rawir, MAX_IR_EVENT_SIZE, GFP_KERNEL))
return -ENOMEM;
}
+ if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
+ if (kfifo_alloc(&dev->scancodes, 32, GFP_KERNEL)) {
+ kfifo_free(&dev->rawir);
+ return -ENOMEM;
+ }
+ }
+
init_waitqueue_head(&dev->wait_poll);
minor = ida_simple_get(&lirc_ida, 0, RC_DEV_MAX, GFP_KERNEL);
@@ -90,6 +101,8 @@ out_ida:
out_kfifo:
if (dev->driver_type == RC_DRIVER_IR_RAW)
kfifo_free(&dev->rawir);
+ if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
+ kfifo_free(&dev->scancodes);
return err;
}