1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ImgTec IR Decoder setup for Sanyo protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
7 * From ir-sanyo-decoder.c:
9 * This protocol uses the NEC protocol timings. However, data is formatted as:
11 * 13 bits NOT(Custom Code)
13 * 8 bits NOT(Key data)
15 * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon
16 * Information for this protocol is available at the Sanyo LC7461 datasheet.
19 #include "img-ir-hw.h"
21 /* Convert Sanyo data to a scancode */
22 static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
23 struct img_ir_scancode_req *request)
25 unsigned int addr, addr_inv, data, data_inv;
26 /* a repeat code has no data */
28 return IMG_IR_REPEATCODE;
31 addr = (raw >> 0) & 0x1fff;
32 addr_inv = (raw >> 13) & 0x1fff;
33 data = (raw >> 26) & 0xff;
34 data_inv = (raw >> 34) & 0xff;
36 if ((data_inv ^ data) != 0xff)
38 /* Validate address */
39 if ((addr_inv ^ addr) != 0x1fff)
43 request->protocol = RC_PROTO_SANYO;
44 request->scancode = addr << 8 | data;
45 return IMG_IR_SCANCODE;
48 /* Convert Sanyo scancode to Sanyo data filter */
49 static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
50 struct img_ir_filter *out, u64 protocols)
52 unsigned int addr, addr_inv, data, data_inv;
53 unsigned int addr_m, data_m;
55 data = in->data & 0xff;
56 data_m = in->mask & 0xff;
57 data_inv = data ^ 0xff;
59 if (in->data & 0xff700000)
62 addr = (in->data >> 8) & 0x1fff;
63 addr_m = (in->mask >> 8) & 0x1fff;
64 addr_inv = addr ^ 0x1fff;
66 out->data = (u64)data_inv << 34 |
70 out->mask = (u64)data_m << 34 |
78 struct img_ir_decoder img_ir_sanyo = {
79 .type = RC_PROTO_BIT_SANYO,
82 .code_type = IMG_IR_CODETYPE_PULSEDIST,
85 .unit = 562500, /* 562.5 us */
89 .pulse = { 16 /* 9ms */ },
90 .space = { 8 /* 4.5ms */ },
94 .pulse = { 1 /* 562.5 us */ },
95 .space = { 1 /* 562.5 us */ },
99 .pulse = { 1 /* 562.5 us */ },
100 .space = { 3 /* 1687.5 us */ },
106 .ft_min = 10, /* 5.625 ms */
110 .repeat = 108, /* 108 ms */
114 .space = { 4 /* 2.25 ms */ },
118 .minlen = 0, /* repeat code has no data */
123 .scancode = img_ir_sanyo_scancode,
124 .filter = img_ir_sanyo_filter,