1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ImgTec IR Decoder setup for Philips RC-6 protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
10 /* Convert RC6 data to a scancode */
11 static int img_ir_rc6_scancode(int len
, u64 raw
, u64 enabled_protocols
,
12 struct img_ir_scancode_req
*request
)
14 unsigned int addr
, cmd
, mode
, trl1
, trl2
;
17 * Due to a side effect of the decoder handling the double length
18 * Trailer bit, the header information is a bit scrambled, and the
19 * raw data is shifted incorrectly.
20 * This workaround effectively recovers the header bits.
22 * The Header field should look like this:
24 * StartBit ModeBit2 ModeBit1 ModeBit0 TrailerBit
28 * ModeBit2 ModeBit1 ModeBit0 TrailerBit1 TrailerBit2
30 * The start bit is not important to recover the scancode.
35 trl1
= (raw
>> 17) & 0x01;
36 trl2
= (raw
>> 16) & 0x01;
38 mode
= (raw
>> 18) & 0x07;
39 addr
= (raw
>> 8) & 0xff;
43 * Due to the above explained irregularity the trailer bits cannot
44 * have the same value.
49 /* Only mode 0 supported for now */
53 request
->protocol
= RC_PROTO_RC6_0
;
54 request
->scancode
= addr
<< 8 | cmd
;
55 request
->toggle
= trl2
;
56 return IMG_IR_SCANCODE
;
59 /* Convert RC6 scancode to RC6 data filter */
60 static int img_ir_rc6_filter(const struct rc_scancode_filter
*in
,
61 struct img_ir_filter
*out
, u64 protocols
)
63 /* Not supported by the hw. */
69 * see http://www.sbprojects.com/knowledge/ir/rc6.php
71 struct img_ir_decoder img_ir_rc6
= {
72 .type
= RC_PROTO_BIT_RC6_0
,
75 .code_type
= IMG_IR_CODETYPE_BIPHASE
,
82 * Due to a quirk in the img-ir decoder, default header values do
83 * not work, the values described below were extracted from
84 * successful RTL test cases.
106 .ft_min
= 2666, /* 2.666 ms */
111 .scancode
= img_ir_rc6_scancode
,
112 .filter
= img_ir_rc6_filter
,