1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ImgTec IR Decoder setup for Sharp protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
10 /* Convert Sharp data to a scancode */
11 static int img_ir_sharp_scancode(int len
, u64 raw
, u64 enabled_protocols
,
12 struct img_ir_scancode_req
*request
)
14 unsigned int addr
, cmd
, exp
, chk
;
19 addr
= (raw
>> 0) & 0x1f;
20 cmd
= (raw
>> 5) & 0xff;
21 exp
= (raw
>> 13) & 0x1;
22 chk
= (raw
>> 14) & 0x1;
28 /* probably the second half of the message */
31 request
->protocol
= RC_PROTO_SHARP
;
32 request
->scancode
= addr
<< 8 | cmd
;
33 return IMG_IR_SCANCODE
;
36 /* Convert Sharp scancode to Sharp data filter */
37 static int img_ir_sharp_filter(const struct rc_scancode_filter
*in
,
38 struct img_ir_filter
*out
, u64 protocols
)
40 unsigned int addr
, cmd
, exp
= 0, chk
= 0;
41 unsigned int addr_m
, cmd_m
, exp_m
= 0, chk_m
= 0;
43 addr
= (in
->data
>> 8) & 0x1f;
44 addr_m
= (in
->mask
>> 8) & 0x1f;
45 cmd
= (in
->data
>> 0) & 0xff;
46 cmd_m
= (in
->mask
>> 0) & 0xff;
48 /* if filtering commands, we can only match the first part */
69 * See also http://www.sbprojects.com/knowledge/ir/sharp.php
71 struct img_ir_decoder img_ir_sharp
= {
72 .type
= RC_PROTO_BIT_SHARP
,
76 .code_type
= IMG_IR_CODETYPE_PULSEDIST
,
80 .tolerance
= 20, /* 20% */
84 .pulse
= { 320 /* 320 us */ },
85 .space
= { 680 /* 1 ms period */ },
89 .pulse
= { 320 /* 320 us */ },
90 .space
= { 1680 /* 2 ms period */ },
96 .ft_min
= 5000, /* 5 ms */
100 .scancode
= img_ir_sharp_scancode
,
101 .filter
= img_ir_sharp_filter
,