diff options
author | James Hogan <james.hogan@imgtec.com> | 2014-02-28 18:28:59 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-11 14:47:55 -0400 |
commit | 3c11305eee6a13695954dbc067234d492cb7879c (patch) | |
tree | 8b182612197bfa1bbb8ce466a31105545baad5b2 /drivers/media/rc | |
parent | e72b21abc8ec76b3e2c332e631f15d975e781e37 (diff) |
[media] rc: img-ir: add Sharp decoder module
Add an img-ir module for decoding the Sharp 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')
-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-sharp.c | 99 |
4 files changed, 111 insertions, 0 deletions
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig index ab365778b5d2..48627f9741be 100644 --- a/drivers/media/rc/img-ir/Kconfig +++ b/drivers/media/rc/img-ir/Kconfig | |||
@@ -45,3 +45,10 @@ config IR_IMG_SONY | |||
45 | help | 45 | help |
46 | Say Y here to enable support for the Sony protocol in the ImgTec | 46 | Say Y here to enable support for the Sony protocol in the ImgTec |
47 | infrared decoder block. | 47 | infrared decoder block. |
48 | |||
49 | config IR_IMG_SHARP | ||
50 | bool "Sharp protocol support" | ||
51 | depends on IR_IMG_HW | ||
52 | help | ||
53 | Say Y here to enable support for the Sharp protocol in the ImgTec | ||
54 | infrared decoder block. | ||
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile index 978c0c6713ab..792a3c4bc38f 100644 --- a/drivers/media/rc/img-ir/Makefile +++ b/drivers/media/rc/img-ir/Makefile | |||
@@ -4,6 +4,7 @@ img-ir-$(CONFIG_IR_IMG_HW) += img-ir-hw.o | |||
4 | img-ir-$(CONFIG_IR_IMG_NEC) += img-ir-nec.o | 4 | 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-objs := $(img-ir-y) | 8 | img-ir-objs := $(img-ir-y) |
8 | 9 | ||
9 | obj-$(CONFIG_IR_IMG) += img-ir.o | 10 | 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 0d4f9211f9f2..9931dfaeb6ad 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c | |||
@@ -23,6 +23,7 @@ static DEFINE_SPINLOCK(img_ir_decoders_lock); | |||
23 | extern struct img_ir_decoder img_ir_nec; | 23 | 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 | 27 | ||
27 | static bool img_ir_decoders_preprocessed; | 28 | static bool img_ir_decoders_preprocessed; |
28 | static struct img_ir_decoder *img_ir_decoders[] = { | 29 | static struct img_ir_decoder *img_ir_decoders[] = { |
@@ -35,6 +36,9 @@ static struct img_ir_decoder *img_ir_decoders[] = { | |||
35 | #ifdef CONFIG_IR_IMG_SONY | 36 | #ifdef CONFIG_IR_IMG_SONY |
36 | &img_ir_sony, | 37 | &img_ir_sony, |
37 | #endif | 38 | #endif |
39 | #ifdef CONFIG_IR_IMG_SHARP | ||
40 | &img_ir_sharp, | ||
41 | #endif | ||
38 | NULL | 42 | NULL |
39 | }; | 43 | }; |
40 | 44 | ||
diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c b/drivers/media/rc/img-ir/img-ir-sharp.c new file mode 100644 index 000000000000..3397cc5a6794 --- /dev/null +++ b/drivers/media/rc/img-ir/img-ir-sharp.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * ImgTec IR Decoder setup for Sharp protocol. | ||
3 | * | ||
4 | * Copyright 2012-2014 Imagination Technologies Ltd. | ||
5 | */ | ||
6 | |||
7 | #include "img-ir-hw.h" | ||
8 | |||
9 | /* Convert Sharp data to a scancode */ | ||
10 | static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols) | ||
11 | { | ||
12 | unsigned int addr, cmd, exp, chk; | ||
13 | |||
14 | if (len != 15) | ||
15 | return -EINVAL; | ||
16 | |||
17 | addr = (raw >> 0) & 0x1f; | ||
18 | cmd = (raw >> 5) & 0xff; | ||
19 | exp = (raw >> 13) & 0x1; | ||
20 | chk = (raw >> 14) & 0x1; | ||
21 | |||
22 | /* validate data */ | ||
23 | if (!exp) | ||
24 | return -EINVAL; | ||
25 | if (chk) | ||
26 | /* probably the second half of the message */ | ||
27 | return -EINVAL; | ||
28 | |||
29 | *scancode = addr << 8 | cmd; | ||
30 | return IMG_IR_SCANCODE; | ||
31 | } | ||
32 | |||
33 | /* Convert Sharp scancode to Sharp data filter */ | ||
34 | static int img_ir_sharp_filter(const struct rc_scancode_filter *in, | ||
35 | struct img_ir_filter *out, u64 protocols) | ||
36 | { | ||
37 | unsigned int addr, cmd, exp = 0, chk = 0; | ||
38 | unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0; | ||
39 | |||
40 | addr = (in->data >> 8) & 0x1f; | ||
41 | addr_m = (in->mask >> 8) & 0x1f; | ||
42 | cmd = (in->data >> 0) & 0xff; | ||
43 | cmd_m = (in->mask >> 0) & 0xff; | ||
44 | if (cmd_m) { | ||
45 | /* if filtering commands, we can only match the first part */ | ||
46 | exp = 1; | ||
47 | exp_m = 1; | ||
48 | chk = 0; | ||
49 | chk_m = 1; | ||
50 | } | ||
51 | |||
52 | out->data = addr | | ||
53 | cmd << 5 | | ||
54 | exp << 13 | | ||
55 | chk << 14; | ||
56 | out->mask = addr_m | | ||
57 | cmd_m << 5 | | ||
58 | exp_m << 13 | | ||
59 | chk_m << 14; | ||
60 | |||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * Sharp decoder | ||
66 | * See also http://www.sbprojects.com/knowledge/ir/sharp.php | ||
67 | */ | ||
68 | struct img_ir_decoder img_ir_sharp = { | ||
69 | .type = RC_BIT_SHARP, | ||
70 | .control = { | ||
71 | .decoden = 0, | ||
72 | .decodend2 = 1, | ||
73 | .code_type = IMG_IR_CODETYPE_PULSEDIST, | ||
74 | .d1validsel = 1, | ||
75 | }, | ||
76 | /* main timings */ | ||
77 | .tolerance = 20, /* 20% */ | ||
78 | .timings = { | ||
79 | /* 0 symbol */ | ||
80 | .s10 = { | ||
81 | .pulse = { 320 /* 320 us */ }, | ||
82 | .space = { 680 /* 1 ms period */ }, | ||
83 | }, | ||
84 | /* 1 symbol */ | ||
85 | .s11 = { | ||
86 | .pulse = { 320 /* 320 us */ }, | ||
87 | .space = { 1680 /* 2 ms period */ }, | ||
88 | }, | ||
89 | /* free time */ | ||
90 | .ft = { | ||
91 | .minlen = 15, | ||
92 | .maxlen = 15, | ||
93 | .ft_min = 5000, /* 5 ms */ | ||
94 | }, | ||
95 | }, | ||
96 | /* scancode logic */ | ||
97 | .scancode = img_ir_sharp_scancode, | ||
98 | .filter = img_ir_sharp_filter, | ||
99 | }; | ||