2 * ImgTec IR Decoder setup for Sanyo protocol.
4 * Copyright 2012-2014 Imagination Technologies Ltd.
6 * From ir-sanyo-decoder.c:
8 * This protocol uses the NEC protocol timings. However, data is formatted as:
10 * 13 bits NOT(Custom Code)
12 * 8 bits NOT(Key data)
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.
18 #include "img-ir-hw.h"
20 /* Convert Sanyo data to a scancode */
21 static int img_ir_sanyo_scancode(int len
, u64 raw
, int *scancode
, u64 protocols
)
23 unsigned int addr
, addr_inv
, data
, data_inv
;
24 /* a repeat code has no data */
26 return IMG_IR_REPEATCODE
;
29 addr
= (raw
>> 0) & 0x1fff;
30 addr_inv
= (raw
>> 13) & 0x1fff;
31 data
= (raw
>> 26) & 0xff;
32 data_inv
= (raw
>> 34) & 0xff;
34 if ((data_inv
^ data
) != 0xff)
36 /* Validate address */
37 if ((addr_inv
^ addr
) != 0x1fff)
41 *scancode
= addr
<< 8 | data
;
42 return IMG_IR_SCANCODE
;
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
)
49 unsigned int addr
, addr_inv
, data
, data_inv
;
50 unsigned int addr_m
, data_m
;
52 data
= in
->data
& 0xff;
53 data_m
= in
->mask
& 0xff;
54 data_inv
= data
^ 0xff;
56 if (in
->data
& 0xff700000)
59 addr
= (in
->data
>> 8) & 0x1fff;
60 addr_m
= (in
->mask
>> 8) & 0x1fff;
61 addr_inv
= addr
^ 0x1fff;
63 out
->data
= (u64
)data_inv
<< 34 |
67 out
->mask
= (u64
)data_m
<< 34 |
75 struct img_ir_decoder img_ir_sanyo
= {
79 .code_type
= IMG_IR_CODETYPE_PULSEDIST
,
82 .unit
= 562500, /* 562.5 us */
86 .pulse
= { 16 /* 9ms */ },
87 .space
= { 8 /* 4.5ms */ },
91 .pulse
= { 1 /* 562.5 us */ },
92 .space
= { 1 /* 562.5 us */ },
96 .pulse
= { 1 /* 562.5 us */ },
97 .space
= { 3 /* 1687.5 us */ },
103 .ft_min
= 10, /* 5.625 ms */
107 .repeat
= 108, /* 108 ms */
111 .space
= { 4 /* 2.25 ms */ },
115 .minlen
= 0, /* repeat code has no data */
120 .scancode
= img_ir_sanyo_scancode
,
121 .filter
= img_ir_sanyo_filter
,