2 * ImgTec IR Decoder setup for Sharp protocol.
4 * Copyright 2012-2014 Imagination Technologies Ltd.
9 /* Convert Sharp data to a scancode */
10 static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols)
12 unsigned int addr, cmd, exp, chk;
17 addr = (raw >> 0) & 0x1f;
18 cmd = (raw >> 5) & 0xff;
19 exp = (raw >> 13) & 0x1;
20 chk = (raw >> 14) & 0x1;
26 /* probably the second half of the message */
29 *scancode = addr << 8 | cmd;
30 return IMG_IR_SCANCODE;
33 /* Convert Sharp scancode to Sharp data filter */
34 static int img_ir_sharp_filter(const struct rc_scancode_filter *in,
35 struct img_ir_filter *out, u64 protocols)
37 unsigned int addr, cmd, exp = 0, chk = 0;
38 unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0;
40 addr = (in->data >> 8) & 0x1f;
41 addr_m = (in->mask >> 8) & 0x1f;
42 cmd = (in->data >> 0) & 0xff;
43 cmd_m = (in->mask >> 0) & 0xff;
45 /* if filtering commands, we can only match the first part */
66 * See also http://www.sbprojects.com/knowledge/ir/sharp.php
68 struct img_ir_decoder img_ir_sharp = {
73 .code_type = IMG_IR_CODETYPE_PULSEDIST,
77 .tolerance = 20, /* 20% */
81 .pulse = { 320 /* 320 us */ },
82 .space = { 680 /* 1 ms period */ },
86 .pulse = { 320 /* 320 us */ },
87 .space = { 1680 /* 2 ms period */ },
93 .ft_min = 5000, /* 5 ms */
97 .scancode = img_ir_sharp_scancode,
98 .filter = img_ir_sharp_filter,