[media] rc: img-ir: add JVC decoder module
authorJames Hogan <james.hogan@imgtec.com>
Fri, 28 Feb 2014 23:28:57 +0000 (20:28 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 11 Mar 2014 18:47:10 +0000 (15:47 -0300)
Add an img-ir module for decoding the JVC infrared protocol.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/rc/img-ir/Kconfig
drivers/media/rc/img-ir/Makefile
drivers/media/rc/img-ir/img-ir-hw.c
drivers/media/rc/img-ir/img-ir-jvc.c [new file with mode: 0644]

index 28498a294daa6c9c9955963be6964ab29bc740d7..96006fbfb0d67a352b2aa8a2fc382ac648688807 100644 (file)
@@ -31,3 +31,10 @@ config IR_IMG_NEC
        help
           Say Y here to enable support for the NEC, extended NEC, and 32-bit
           NEC protocols in the ImgTec infrared decoder block.
+
+config IR_IMG_JVC
+       bool "JVC protocol support"
+       depends on IR_IMG_HW
+       help
+          Say Y here to enable support for the JVC protocol in the ImgTec
+          infrared decoder block.
index c4091973b35d169446f290f06021d4234c64e089..c5f8f06c89eb13f96e04c2203116f7422b8aaca7 100644 (file)
@@ -2,6 +2,7 @@ img-ir-y                        := img-ir-core.o
 img-ir-$(CONFIG_IR_IMG_RAW)    += img-ir-raw.o
 img-ir-$(CONFIG_IR_IMG_HW)     += img-ir-hw.o
 img-ir-$(CONFIG_IR_IMG_NEC)    += img-ir-nec.o
+img-ir-$(CONFIG_IR_IMG_JVC)    += img-ir-jvc.o
 img-ir-objs                    := $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)           += img-ir.o
index 139f2c70e3826eb44ceeb2062c7f8cba65e3f7be..81c50e3f88d920d178d7894d7ad6a7f7536ee2ae 100644 (file)
 static DEFINE_SPINLOCK(img_ir_decoders_lock);
 
 extern struct img_ir_decoder img_ir_nec;
+extern struct img_ir_decoder img_ir_jvc;
 
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
 #ifdef CONFIG_IR_IMG_NEC
        &img_ir_nec,
+#endif
+#ifdef CONFIG_IR_IMG_JVC
+       &img_ir_jvc,
 #endif
        NULL
 };
diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c b/drivers/media/rc/img-ir/img-ir-jvc.c
new file mode 100644 (file)
index 0000000..ae55867
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * ImgTec IR Decoder setup for JVC protocol.
+ *
+ * Copyright 2012-2014 Imagination Technologies Ltd.
+ */
+
+#include "img-ir-hw.h"
+
+/* Convert JVC data to a scancode */
+static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
+{
+       unsigned int cust, data;
+
+       if (len != 16)
+               return -EINVAL;
+
+       cust = (raw >> 0) & 0xff;
+       data = (raw >> 8) & 0xff;
+
+       *scancode = cust << 8 | data;
+       return IMG_IR_SCANCODE;
+}
+
+/* Convert JVC scancode to JVC data filter */
+static int img_ir_jvc_filter(const struct rc_scancode_filter *in,
+                            struct img_ir_filter *out, u64 protocols)
+{
+       unsigned int cust, data;
+       unsigned int cust_m, data_m;
+
+       cust   = (in->data >> 8) & 0xff;
+       cust_m = (in->mask >> 8) & 0xff;
+       data   = (in->data >> 0) & 0xff;
+       data_m = (in->mask >> 0) & 0xff;
+
+       out->data = cust   | data << 8;
+       out->mask = cust_m | data_m << 8;
+
+       return 0;
+}
+
+/*
+ * JVC decoder
+ * See also http://www.sbprojects.com/knowledge/ir/jvc.php
+ *          http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf
+ */
+struct img_ir_decoder img_ir_jvc = {
+       .type = RC_BIT_JVC,
+       .control = {
+               .decoden = 1,
+               .code_type = IMG_IR_CODETYPE_PULSEDIST,
+               .decodend2 = 1,
+       },
+       /* main timings */
+       .unit = 527500, /* 527.5 us */
+       .timings = {
+               /* leader symbol */
+               .ldr = {
+                       .pulse = { 16   /* 8.44 ms */ },
+                       .space = { 8    /* 4.22 ms */ },
+               },
+               /* 0 symbol */
+               .s00 = {
+                       .pulse = { 1    /* 527.5 us +-60 us */ },
+                       .space = { 1    /* 527.5 us */ },
+               },
+               /* 1 symbol */
+               .s01 = {
+                       .pulse = { 1    /* 527.5 us +-60 us */ },
+                       .space = { 3    /* 1.5825 ms +-40 us */ },
+               },
+               /* 0 symbol (no leader) */
+               .s00 = {
+                       .pulse = { 1    /* 527.5 us +-60 us */ },
+                       .space = { 1    /* 527.5 us */ },
+               },
+               /* 1 symbol (no leader) */
+               .s01 = {
+                       .pulse = { 1    /* 527.5 us +-60 us */ },
+                       .space = { 3    /* 1.5825 ms +-40 us */ },
+               },
+               /* free time */
+               .ft = {
+                       .minlen = 16,
+                       .maxlen = 16,
+                       .ft_min = 10,   /* 5.275 ms */
+               },
+       },
+       /* scancode logic */
+       .scancode = img_ir_jvc_scancode,
+       .filter = img_ir_jvc_filter,
+};