diff options
author | Sifan Naeem <sifan.naeem@imgtec.com> | 2014-12-11 15:06:25 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-12-23 12:16:40 -0500 |
commit | aa7383db35aec23906868a632a964b5783a5254d (patch) | |
tree | 89f1029c6838b4e7e60e3d4eb081533010cb2459 | |
parent | 02744c8c9a11a64bce740528077cf5223ab60e31 (diff) |
[media] rc: img-ir: add philips rc5 decoder module
Add img-ir module for decoding Philips rc5 protocol.
Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-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 | 3 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-hw.h | 1 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-rc5.c | 88 |
5 files changed, 100 insertions, 0 deletions
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig index 580715c7fc5e..b20b3e9b441e 100644 --- a/drivers/media/rc/img-ir/Kconfig +++ b/drivers/media/rc/img-ir/Kconfig | |||
@@ -60,3 +60,10 @@ config IR_IMG_SANYO | |||
60 | help | 60 | help |
61 | Say Y here to enable support for the Sanyo protocol (used by Sanyo, | 61 | Say Y here to enable support for the Sanyo protocol (used by Sanyo, |
62 | Aiwa, Chinon remotes) in the ImgTec infrared decoder block. | 62 | Aiwa, Chinon remotes) in the ImgTec infrared decoder block. |
63 | |||
64 | config IR_IMG_RC5 | ||
65 | bool "Philips RC5 protocol support" | ||
66 | depends on IR_IMG_HW | ||
67 | help | ||
68 | Say Y here to enable support for the RC5 protocol in the ImgTec | ||
69 | infrared decoder block. | ||
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile index 92a459d99509..898b1b8086d0 100644 --- a/drivers/media/rc/img-ir/Makefile +++ b/drivers/media/rc/img-ir/Makefile | |||
@@ -6,6 +6,7 @@ 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-$(CONFIG_IR_IMG_SANYO) += img-ir-sanyo.o |
9 | img-ir-$(CONFIG_IR_IMG_RC5) += img-ir-rc5.o | ||
9 | img-ir-objs := $(img-ir-y) | 10 | img-ir-objs := $(img-ir-y) |
10 | 11 | ||
11 | obj-$(CONFIG_IR_IMG) += img-ir.o | 12 | 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 5c32f05b32ec..13f0b1e0e211 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c | |||
@@ -42,6 +42,9 @@ static struct img_ir_decoder *img_ir_decoders[] = { | |||
42 | #ifdef CONFIG_IR_IMG_SANYO | 42 | #ifdef CONFIG_IR_IMG_SANYO |
43 | &img_ir_sanyo, | 43 | &img_ir_sanyo, |
44 | #endif | 44 | #endif |
45 | #ifdef CONFIG_IR_IMG_RC5 | ||
46 | &img_ir_rc5, | ||
47 | #endif | ||
45 | NULL | 48 | NULL |
46 | }; | 49 | }; |
47 | 50 | ||
diff --git a/drivers/media/rc/img-ir/img-ir-hw.h b/drivers/media/rc/img-ir/img-ir-hw.h index b31ffc947e41..b9e799d57d99 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.h +++ b/drivers/media/rc/img-ir/img-ir-hw.h | |||
@@ -187,6 +187,7 @@ extern struct img_ir_decoder img_ir_jvc; | |||
187 | extern struct img_ir_decoder img_ir_sony; | 187 | extern struct img_ir_decoder img_ir_sony; |
188 | extern struct img_ir_decoder img_ir_sharp; | 188 | extern struct img_ir_decoder img_ir_sharp; |
189 | extern struct img_ir_decoder img_ir_sanyo; | 189 | extern struct img_ir_decoder img_ir_sanyo; |
190 | extern struct img_ir_decoder img_ir_rc5; | ||
190 | 191 | ||
191 | /** | 192 | /** |
192 | * struct img_ir_reg_timings - Reg values for decoder timings at clock rate. | 193 | * struct img_ir_reg_timings - Reg values for decoder timings at clock rate. |
diff --git a/drivers/media/rc/img-ir/img-ir-rc5.c b/drivers/media/rc/img-ir/img-ir-rc5.c new file mode 100644 index 000000000000..a8a28a377eee --- /dev/null +++ b/drivers/media/rc/img-ir/img-ir-rc5.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * ImgTec IR Decoder setup for Philips RC-5 protocol. | ||
3 | * | ||
4 | * Copyright 2012-2014 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include "img-ir-hw.h" | ||
13 | |||
14 | /* Convert RC5 data to a scancode */ | ||
15 | static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols, | ||
16 | struct img_ir_scancode_req *request) | ||
17 | { | ||
18 | unsigned int addr, cmd, tgl, start; | ||
19 | |||
20 | /* Quirk in the decoder shifts everything by 2 to the left. */ | ||
21 | raw >>= 2; | ||
22 | |||
23 | start = (raw >> 13) & 0x01; | ||
24 | tgl = (raw >> 11) & 0x01; | ||
25 | addr = (raw >> 6) & 0x1f; | ||
26 | cmd = raw & 0x3f; | ||
27 | /* | ||
28 | * 12th bit is used to extend the command in extended RC5 and has | ||
29 | * no effect on standard RC5. | ||
30 | */ | ||
31 | cmd += ((raw >> 12) & 0x01) ? 0 : 0x40; | ||
32 | |||
33 | if (!start) | ||
34 | return -EINVAL; | ||
35 | |||
36 | request->protocol = RC_TYPE_RC5; | ||
37 | request->scancode = addr << 8 | cmd; | ||
38 | request->toggle = tgl; | ||
39 | return IMG_IR_SCANCODE; | ||
40 | } | ||
41 | |||
42 | /* Convert RC5 scancode to RC5 data filter */ | ||
43 | static int img_ir_rc5_filter(const struct rc_scancode_filter *in, | ||
44 | struct img_ir_filter *out, u64 protocols) | ||
45 | { | ||
46 | /* Not supported by the hw. */ | ||
47 | return -EINVAL; | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * RC-5 decoder | ||
52 | * see http://www.sbprojects.com/knowledge/ir/rc5.php | ||
53 | */ | ||
54 | struct img_ir_decoder img_ir_rc5 = { | ||
55 | .type = RC_BIT_RC5, | ||
56 | .control = { | ||
57 | .bitoriend2 = 1, | ||
58 | .code_type = IMG_IR_CODETYPE_BIPHASE, | ||
59 | .decodend2 = 1, | ||
60 | }, | ||
61 | /* main timings */ | ||
62 | .tolerance = 16, | ||
63 | .unit = 888888, /* 1/36k*32=888.888microseconds */ | ||
64 | .timings = { | ||
65 | /* 10 symbol */ | ||
66 | .s10 = { | ||
67 | .pulse = { 1 }, | ||
68 | .space = { 1 }, | ||
69 | }, | ||
70 | |||
71 | /* 11 symbol */ | ||
72 | .s11 = { | ||
73 | .pulse = { 1 }, | ||
74 | .space = { 1 }, | ||
75 | }, | ||
76 | |||
77 | /* free time */ | ||
78 | .ft = { | ||
79 | .minlen = 14, | ||
80 | .maxlen = 14, | ||
81 | .ft_min = 5, | ||
82 | }, | ||
83 | }, | ||
84 | |||
85 | /* scancode logic */ | ||
86 | .scancode = img_ir_rc5_scancode, | ||
87 | .filter = img_ir_rc5_filter, | ||
88 | }; | ||