From 9dfe4e8339499bfe8e9a362fefc290b4cb9c3803 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 4 Apr 2010 14:06:55 -0300 Subject: V4L/DVB: ir-core: Add support for badly-implemented hardware decoders A few hardware Remote Controller decoders, even using a standard protocol, aren't able to provide the entire scancode. Due to that, the capability of using other IR's are limited on those hardware. Adds a way to indicate to ir-core what are the bits that the hardware provides, from a scancode, allowing the addition of a complete IR table to the kernel and allowing a limited support for changing the Remote Controller on those devices. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/IR/ir-keytable.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'drivers/media/IR/ir-keytable.c') diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c index a89456932f7c..af7400bc906f 100644 --- a/drivers/media/IR/ir-keytable.c +++ b/drivers/media/IR/ir-keytable.c @@ -89,6 +89,18 @@ static int ir_do_setkeycode(struct input_dev *dev, { unsigned int i; int old_keycode = KEY_RESERVED; + struct ir_input_dev *ir_dev = input_get_drvdata(dev); + + /* + * Unfortunately, some hardware-based IR decoders don't provide + * all bits for the complete IR code. In general, they provide only + * the command part of the IR code. Yet, as it is possible to replace + * the provided IR with another one, it is needed to allow loading + * IR tables from other remotes. So, + */ + if (ir_dev->props && ir_dev->props->scanmask) { + scancode &= ir_dev->props->scanmask; + } /* First check if we already have a mapping for this ir command */ for (i = 0; i < rc_tab->len; i++) { @@ -448,6 +460,13 @@ int __ir_input_register(struct input_dev *input_dev, sizeof(struct ir_scancode)); ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL); ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode); + if (props) { + ir_dev->props = props; + if (props->open) + input_dev->open = ir_open; + if (props->close) + input_dev->close = ir_close; + } if (!ir_dev->rc_tab.scan) { rc = -ENOMEM; @@ -465,12 +484,6 @@ int __ir_input_register(struct input_dev *input_dev, goto out_table; } - ir_dev->props = props; - if (props && props->open) - input_dev->open = ir_open; - if (props && props->close) - input_dev->close = ir_close; - rc = ir_register_class(input_dev); if (rc < 0) goto out_table; -- cgit v1.2.3