summaryrefslogtreecommitdiffstats
path: root/drivers/media/IR/ir-nec-decoder.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-03-25 00:47:53 +0100
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-18 05:52:59 +0200
commit995187bed30c0545e8da88372e9807da0a85911e (patch)
treee3e28eff10f8f01f1bfd7ff865a29076bf6700dc /drivers/media/IR/ir-nec-decoder.c
parentV4L/DVB: saa7134: don't wait too much to generate an IR event on raw_decode (diff)
downloadlinux-995187bed30c0545e8da88372e9807da0a85911e.tar.xz
linux-995187bed30c0545e8da88372e9807da0a85911e.zip
V4L/DVB: ir-core: dynamically load the compiled IR protocols
Instead of hardcoding the protocols into ir-core, add a register interface for the IR protocol decoders, and convert ir-nec-decoder into a client of ir-core. With this approach, it is possible to dynamically load the needed IR protocols, and to add a RAW IR interface module, registered as one IR raw protocol decoder. This patch opens a way to register a lirc_dev interface to work as an userspace IR protocol decoder. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR/ir-nec-decoder.c')
-rw-r--r--drivers/media/IR/ir-nec-decoder.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c
index 104482a6991e..c9a986dd57fd 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -1,4 +1,4 @@
-/* ir-raw-event.c - handle IR Pulse/Space event
+/* ir-nec-decoder.c - handle NEC IR Pulse/Space protocol
*
* Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
*
@@ -147,7 +147,7 @@ static int __ir_nec_decode(struct input_dev *input_dev,
if (++count == 32)
break;
}
- *pos++;
+ (*pos)++;
/*
* Fixme: may need to accept Extended NEC protocol?
@@ -181,9 +181,9 @@ err:
* This function returns the number of decoded pulses or -EINVAL if no
* pulse got decoded
*/
-int ir_nec_decode(struct input_dev *input_dev,
- struct ir_raw_event *evs,
- int len)
+static int ir_nec_decode(struct input_dev *input_dev,
+ struct ir_raw_event *evs,
+ int len)
{
int pos = 0;
int rc = 0;
@@ -198,4 +198,27 @@ int ir_nec_decode(struct input_dev *input_dev,
return rc;
}
-EXPORT_SYMBOL_GPL(ir_nec_decode);
+static struct ir_raw_handler nec_handler = {
+ .decode = ir_nec_decode,
+};
+
+static int __init ir_nec_decode_init(void)
+{
+ ir_raw_handler_register(&nec_handler);
+
+ printk(KERN_INFO "IR NEC protocol handler initialized\n");
+ return 0;
+}
+
+static void __exit ir_nec_decode_exit(void)
+{
+ ir_raw_handler_unregister(&nec_handler);
+}
+
+module_init(ir_nec_decode_init);
+module_exit(ir_nec_decode_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
+MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
+MODULE_DESCRIPTION("NEC IR protocol decoder");