mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 19:43:43 -04:00
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>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
a6ddd4fecb
commit
de142c3241
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user