2 * ImgTec IR Decoder setup for Philips RC-6 protocol.
4 * Copyright 2012-2014 Imagination Technologies Ltd.
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.
12 #include "img-ir-hw.h"
14 /* Convert RC6 data to a scancode */
15 static int img_ir_rc6_scancode(int len
, u64 raw
, u64 enabled_protocols
,
16 struct img_ir_scancode_req
*request
)
18 unsigned int addr
, cmd
, mode
, trl1
, trl2
;
21 * Due to a side effect of the decoder handling the double length
22 * Trailer bit, the header information is a bit scrambled, and the
23 * raw data is shifted incorrectly.
24 * This workaround effectively recovers the header bits.
26 * The Header field should look like this:
28 * StartBit ModeBit2 ModeBit1 ModeBit0 TrailerBit
32 * ModeBit2 ModeBit1 ModeBit0 TrailerBit1 TrailerBit2
34 * The start bit is not important to recover the scancode.
39 trl1
= (raw
>> 17) & 0x01;
40 trl2
= (raw
>> 16) & 0x01;
42 mode
= (raw
>> 18) & 0x07;
43 addr
= (raw
>> 8) & 0xff;
47 * Due to the above explained irregularity the trailer bits cannot
48 * have the same value.
53 /* Only mode 0 supported for now */
57 request
->protocol
= RC_PROTO_RC6_0
;
58 request
->scancode
= addr
<< 8 | cmd
;
59 request
->toggle
= trl2
;
60 return IMG_IR_SCANCODE
;
63 /* Convert RC6 scancode to RC6 data filter */
64 static int img_ir_rc6_filter(const struct rc_scancode_filter
*in
,
65 struct img_ir_filter
*out
, u64 protocols
)
67 /* Not supported by the hw. */
73 * see http://www.sbprojects.com/knowledge/ir/rc6.php
75 struct img_ir_decoder img_ir_rc6
= {
76 .type
= RC_PROTO_BIT_RC6_0
,
79 .code_type
= IMG_IR_CODETYPE_BIPHASE
,
86 * Due to a quirk in the img-ir decoder, default header values do
87 * not work, the values described below were extracted from
88 * successful RTL test cases.
110 .ft_min
= 2666, /* 2.666 ms */
115 .scancode
= img_ir_rc6_scancode
,
116 .filter
= img_ir_rc6_filter
,