2 * ImgTec IR Decoder setup for Sanyo 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.
11 * From ir-sanyo-decoder.c:
13 * This protocol uses the NEC protocol timings. However, data is formatted as:
15 * 13 bits NOT(Custom Code)
17 * 8 bits NOT(Key data)
19 * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon
20 * Information for this protocol is available at the Sanyo LC7461 datasheet.
23 #include "img-ir-hw.h"
25 /* Convert Sanyo data to a scancode */
26 static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
27 struct img_ir_scancode_req *request)
29 unsigned int addr, addr_inv, data, data_inv;
30 /* a repeat code has no data */
32 return IMG_IR_REPEATCODE;
35 addr = (raw >> 0) & 0x1fff;
36 addr_inv = (raw >> 13) & 0x1fff;
37 data = (raw >> 26) & 0xff;
38 data_inv = (raw >> 34) & 0xff;
40 if ((data_inv ^ data) != 0xff)
42 /* Validate address */
43 if ((addr_inv ^ addr) != 0x1fff)
47 request->protocol = RC_TYPE_SANYO;
48 request->scancode = addr << 8 | data;
49 return IMG_IR_SCANCODE;
52 /* Convert Sanyo scancode to Sanyo data filter */
53 static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
54 struct img_ir_filter *out, u64 protocols)
56 unsigned int addr, addr_inv, data, data_inv;
57 unsigned int addr_m, data_m;
59 data = in->data & 0xff;
60 data_m = in->mask & 0xff;
61 data_inv = data ^ 0xff;
63 if (in->data & 0xff700000)
66 addr = (in->data >> 8) & 0x1fff;
67 addr_m = (in->mask >> 8) & 0x1fff;
68 addr_inv = addr ^ 0x1fff;
70 out->data = (u64)data_inv << 34 |
74 out->mask = (u64)data_m << 34 |
82 struct img_ir_decoder img_ir_sanyo = {
86 .code_type = IMG_IR_CODETYPE_PULSEDIST,
89 .unit = 562500, /* 562.5 us */
93 .pulse = { 16 /* 9ms */ },
94 .space = { 8 /* 4.5ms */ },
98 .pulse = { 1 /* 562.5 us */ },
99 .space = { 1 /* 562.5 us */ },
103 .pulse = { 1 /* 562.5 us */ },
104 .space = { 3 /* 1687.5 us */ },
110 .ft_min = 10, /* 5.625 ms */
114 .repeat = 108, /* 108 ms */
118 .space = { 4 /* 2.25 ms */ },
122 .minlen = 0, /* repeat code has no data */
127 .scancode = img_ir_sanyo_scancode,
128 .filter = img_ir_sanyo_filter,