diff options
author | James Hogan <james.hogan@imgtec.com> | 2014-02-28 18:29:00 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-11 14:48:12 -0400 |
commit | 46b35083ce24c1a2a721df605815978f75ca3b66 (patch) | |
tree | 50bac1651152a195548e1f131933d115646052be /drivers/media/rc/img-ir | |
parent | 3c11305eee6a13695954dbc067234d492cb7879c (diff) |
[media] rc: img-ir: add Sanyo decoder module
Add an img-ir module for decoding the Sanyo infrared protocol.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/rc/img-ir')
-rw-r--r-- | drivers/media/rc/img-ir/Kconfig | 7 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-hw.c | 4 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-sanyo.c | 122 |
4 files changed, 134 insertions, 0 deletions
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig index 48627f9741be..03ba9fc170fb 100644 --- a/drivers/media/rc/img-ir/Kconfig +++ b/drivers/media/rc/img-ir/Kconfig | |||
@@ -52,3 +52,10 @@ config IR_IMG_SHARP | |||
52 | help | 52 | help |
53 | Say Y here to enable support for the Sharp protocol in the ImgTec | 53 | Say Y here to enable support for the Sharp protocol in the ImgTec |
54 | infrared decoder block. | 54 | infrared decoder block. |
55 | |||
56 | config IR_IMG_SANYO | ||
57 | bool "Sanyo protocol support" | ||
58 | depends on IR_IMG_HW | ||
59 | help | ||
60 | Say Y here to enable support for the Sanyo protocol (used by Sanyo, | ||
61 | Aiwa, Chinon remotes) in the ImgTec infrared decoder block. | ||
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile index 792a3c4bc38f..92a459d99509 100644 --- a/drivers/media/rc/img-ir/Makefile +++ b/drivers/media/rc/img-ir/Makefile | |||
@@ -5,6 +5,7 @@ img-ir-$(CONFIG_IR_IMG_NEC) += img-ir-nec.o | |||
5 | img-ir-$(CONFIG_IR_IMG_JVC) += img-ir-jvc.o | 5 | img-ir-$(CONFIG_IR_IMG_JVC) += img-ir-jvc.o |
6 | img-ir-$(CONFIG_IR_IMG_SONY) += img-ir-sony.o | 6 | img-ir-$(CONFIG_IR_IMG_SONY) += img-ir-sony.o |
7 | img-ir-$(CONFIG_IR_IMG_SHARP) += img-ir-sharp.o | 7 | img-ir-$(CONFIG_IR_IMG_SHARP) += img-ir-sharp.o |
8 | img-ir-$(CONFIG_IR_IMG_SANYO) += img-ir-sanyo.o | ||
8 | img-ir-objs := $(img-ir-y) | 9 | img-ir-objs := $(img-ir-y) |
9 | 10 | ||
10 | obj-$(CONFIG_IR_IMG) += img-ir.o | 11 | obj-$(CONFIG_IR_IMG) += img-ir.o |
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c index 9931dfaeb6ad..cbbfd7df649f 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c | |||
@@ -24,6 +24,7 @@ extern struct img_ir_decoder img_ir_nec; | |||
24 | extern struct img_ir_decoder img_ir_jvc; | 24 | extern struct img_ir_decoder img_ir_jvc; |
25 | extern struct img_ir_decoder img_ir_sony; | 25 | extern struct img_ir_decoder img_ir_sony; |
26 | extern struct img_ir_decoder img_ir_sharp; | 26 | extern struct img_ir_decoder img_ir_sharp; |
27 | extern struct img_ir_decoder img_ir_sanyo; | ||
27 | 28 | ||
28 | static bool img_ir_decoders_preprocessed; | 29 | static bool img_ir_decoders_preprocessed; |
29 | static struct img_ir_decoder *img_ir_decoders[] = { | 30 | static struct img_ir_decoder *img_ir_decoders[] = { |
@@ -39,6 +40,9 @@ static struct img_ir_decoder *img_ir_decoders[] = { | |||
39 | #ifdef CONFIG_IR_IMG_SHARP | 40 | #ifdef CONFIG_IR_IMG_SHARP |
40 | &img_ir_sharp, | 41 | &img_ir_sharp, |
41 | #endif | 42 | #endif |
43 | #ifdef CONFIG_IR_IMG_SANYO | ||
44 | &img_ir_sanyo, | ||
45 | #endif | ||
42 | NULL | 46 | NULL |
43 | }; | 47 | }; |
44 | 48 | ||
diff --git a/drivers/media/rc/img-ir/img-ir-sanyo.c b/drivers/media/rc/img-ir/img-ir-sanyo.c new file mode 100644 index 000000000000..c2c763e08a41 --- /dev/null +++ b/drivers/media/rc/img-ir/img-ir-sanyo.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * ImgTec IR Decoder setup for Sanyo protocol. | ||
3 | * | ||
4 | * Copyright 2012-2014 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * From ir-sanyo-decoder.c: | ||
7 | * | ||
8 | * This protocol uses the NEC protocol timings. However, data is formatted as: | ||
9 | * 13 bits Custom Code | ||
10 | * 13 bits NOT(Custom Code) | ||
11 | * 8 bits Key data | ||
12 | * 8 bits NOT(Key data) | ||
13 | * | ||
14 | * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon | ||
15 | * Information for this protocol is available at the Sanyo LC7461 datasheet. | ||
16 | */ | ||
17 | |||
18 | #include "img-ir-hw.h" | ||
19 | |||
20 | /* Convert Sanyo data to a scancode */ | ||
21 | static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols) | ||
22 | { | ||
23 | unsigned int addr, addr_inv, data, data_inv; | ||
24 | /* a repeat code has no data */ | ||
25 | if (!len) | ||
26 | return IMG_IR_REPEATCODE; | ||
27 | if (len != 42) | ||
28 | return -EINVAL; | ||
29 | addr = (raw >> 0) & 0x1fff; | ||
30 | addr_inv = (raw >> 13) & 0x1fff; | ||
31 | data = (raw >> 26) & 0xff; | ||
32 | data_inv = (raw >> 34) & 0xff; | ||
33 | /* Validate data */ | ||
34 | if ((data_inv ^ data) != 0xff) | ||
35 | return -EINVAL; | ||
36 | /* Validate address */ | ||
37 | if ((addr_inv ^ addr) != 0x1fff) | ||
38 | return -EINVAL; | ||
39 | |||
40 | /* Normal Sanyo */ | ||
41 | *scancode = addr << 8 | data; | ||
42 | return IMG_IR_SCANCODE; | ||
43 | } | ||
44 | |||
45 | /* Convert Sanyo scancode to Sanyo data filter */ | ||
46 | static int img_ir_sanyo_filter(const struct rc_scancode_filter *in, | ||
47 | struct img_ir_filter *out, u64 protocols) | ||
48 | { | ||
49 | unsigned int addr, addr_inv, data, data_inv; | ||
50 | unsigned int addr_m, data_m; | ||
51 | |||
52 | data = in->data & 0xff; | ||
53 | data_m = in->mask & 0xff; | ||
54 | data_inv = data ^ 0xff; | ||
55 | |||
56 | if (in->data & 0xff700000) | ||
57 | return -EINVAL; | ||
58 | |||
59 | addr = (in->data >> 8) & 0x1fff; | ||
60 | addr_m = (in->mask >> 8) & 0x1fff; | ||
61 | addr_inv = addr ^ 0x1fff; | ||
62 | |||
63 | out->data = (u64)data_inv << 34 | | ||
64 | (u64)data << 26 | | ||
65 | addr_inv << 13 | | ||
66 | addr; | ||
67 | out->mask = (u64)data_m << 34 | | ||
68 | (u64)data_m << 26 | | ||
69 | addr_m << 13 | | ||
70 | addr_m; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | /* Sanyo decoder */ | ||
75 | struct img_ir_decoder img_ir_sanyo = { | ||
76 | .type = RC_BIT_SANYO, | ||
77 | .control = { | ||
78 | .decoden = 1, | ||
79 | .code_type = IMG_IR_CODETYPE_PULSEDIST, | ||
80 | }, | ||
81 | /* main timings */ | ||
82 | .unit = 562500, /* 562.5 us */ | ||
83 | .timings = { | ||
84 | /* leader symbol */ | ||
85 | .ldr = { | ||
86 | .pulse = { 16 /* 9ms */ }, | ||
87 | .space = { 8 /* 4.5ms */ }, | ||
88 | }, | ||
89 | /* 0 symbol */ | ||
90 | .s00 = { | ||
91 | .pulse = { 1 /* 562.5 us */ }, | ||
92 | .space = { 1 /* 562.5 us */ }, | ||
93 | }, | ||
94 | /* 1 symbol */ | ||
95 | .s01 = { | ||
96 | .pulse = { 1 /* 562.5 us */ }, | ||
97 | .space = { 3 /* 1687.5 us */ }, | ||
98 | }, | ||
99 | /* free time */ | ||
100 | .ft = { | ||
101 | .minlen = 42, | ||
102 | .maxlen = 42, | ||
103 | .ft_min = 10, /* 5.625 ms */ | ||
104 | }, | ||
105 | }, | ||
106 | /* repeat codes */ | ||
107 | .repeat = 108, /* 108 ms */ | ||
108 | .rtimings = { | ||
109 | /* leader symbol */ | ||
110 | .ldr = { | ||
111 | .space = { 4 /* 2.25 ms */ }, | ||
112 | }, | ||
113 | /* free time */ | ||
114 | .ft = { | ||
115 | .minlen = 0, /* repeat code has no data */ | ||
116 | .maxlen = 0, | ||
117 | }, | ||
118 | }, | ||
119 | /* scancode logic */ | ||
120 | .scancode = img_ir_sanyo_scancode, | ||
121 | .filter = img_ir_sanyo_filter, | ||
122 | }; | ||