1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include "img-ir-hw.h"
24
25
26static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
27 struct img_ir_scancode_req *request)
28{
29 unsigned int addr, addr_inv, data, data_inv;
30
31 if (!len)
32 return IMG_IR_REPEATCODE;
33 if (len != 42)
34 return -EINVAL;
35 addr = (raw >> 0) & 0x1fff;
36 addr_inv = (raw >> 13) & 0x1fff;
37 data = (raw >> 26) & 0xff;
38 data_inv = (raw >> 34) & 0xff;
39
40 if ((data_inv ^ data) != 0xff)
41 return -EINVAL;
42
43 if ((addr_inv ^ addr) != 0x1fff)
44 return -EINVAL;
45
46
47 request->protocol = RC_TYPE_SANYO;
48 request->scancode = addr << 8 | data;
49 return IMG_IR_SCANCODE;
50}
51
52
53static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
54 struct img_ir_filter *out, u64 protocols)
55{
56 unsigned int addr, addr_inv, data, data_inv;
57 unsigned int addr_m, data_m;
58
59 data = in->data & 0xff;
60 data_m = in->mask & 0xff;
61 data_inv = data ^ 0xff;
62
63 if (in->data & 0xff700000)
64 return -EINVAL;
65
66 addr = (in->data >> 8) & 0x1fff;
67 addr_m = (in->mask >> 8) & 0x1fff;
68 addr_inv = addr ^ 0x1fff;
69
70 out->data = (u64)data_inv << 34 |
71 (u64)data << 26 |
72 addr_inv << 13 |
73 addr;
74 out->mask = (u64)data_m << 34 |
75 (u64)data_m << 26 |
76 addr_m << 13 |
77 addr_m;
78 return 0;
79}
80
81
82struct img_ir_decoder img_ir_sanyo = {
83 .type = RC_BIT_SANYO,
84 .control = {
85 .decoden = 1,
86 .code_type = IMG_IR_CODETYPE_PULSEDIST,
87 },
88
89 .unit = 562500,
90 .timings = {
91
92 .ldr = {
93 .pulse = { 16 },
94 .space = { 8 },
95 },
96
97 .s00 = {
98 .pulse = { 1 },
99 .space = { 1 },
100 },
101
102 .s01 = {
103 .pulse = { 1 },
104 .space = { 3 },
105 },
106
107 .ft = {
108 .minlen = 42,
109 .maxlen = 42,
110 .ft_min = 10,
111 },
112 },
113
114 .repeat = 108,
115 .rtimings = {
116
117 .ldr = {
118 .space = { 4 },
119 },
120
121 .ft = {
122 .minlen = 0,
123 .maxlen = 0,
124 },
125 },
126
127 .scancode = img_ir_sanyo_scancode,
128 .filter = img_ir_sanyo_filter,
129};
130