0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "img-ir-hw.h"
0020
0021
0022 static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
0023 struct img_ir_scancode_req *request)
0024 {
0025 unsigned int addr, addr_inv, data, data_inv;
0026
0027 if (!len)
0028 return IMG_IR_REPEATCODE;
0029 if (len != 42)
0030 return -EINVAL;
0031 addr = (raw >> 0) & 0x1fff;
0032 addr_inv = (raw >> 13) & 0x1fff;
0033 data = (raw >> 26) & 0xff;
0034 data_inv = (raw >> 34) & 0xff;
0035
0036 if ((data_inv ^ data) != 0xff)
0037 return -EINVAL;
0038
0039 if ((addr_inv ^ addr) != 0x1fff)
0040 return -EINVAL;
0041
0042
0043 request->protocol = RC_PROTO_SANYO;
0044 request->scancode = addr << 8 | data;
0045 return IMG_IR_SCANCODE;
0046 }
0047
0048
0049 static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
0050 struct img_ir_filter *out, u64 protocols)
0051 {
0052 unsigned int addr, addr_inv, data, data_inv;
0053 unsigned int addr_m, data_m;
0054
0055 data = in->data & 0xff;
0056 data_m = in->mask & 0xff;
0057 data_inv = data ^ 0xff;
0058
0059 if (in->data & 0xff700000)
0060 return -EINVAL;
0061
0062 addr = (in->data >> 8) & 0x1fff;
0063 addr_m = (in->mask >> 8) & 0x1fff;
0064 addr_inv = addr ^ 0x1fff;
0065
0066 out->data = (u64)data_inv << 34 |
0067 (u64)data << 26 |
0068 addr_inv << 13 |
0069 addr;
0070 out->mask = (u64)data_m << 34 |
0071 (u64)data_m << 26 |
0072 addr_m << 13 |
0073 addr_m;
0074 return 0;
0075 }
0076
0077
0078 struct img_ir_decoder img_ir_sanyo = {
0079 .type = RC_PROTO_BIT_SANYO,
0080 .control = {
0081 .decoden = 1,
0082 .code_type = IMG_IR_CODETYPE_PULSEDIST,
0083 },
0084
0085 .unit = 562500,
0086 .timings = {
0087
0088 .ldr = {
0089 .pulse = { 16 },
0090 .space = { 8 },
0091 },
0092
0093 .s00 = {
0094 .pulse = { 1 },
0095 .space = { 1 },
0096 },
0097
0098 .s01 = {
0099 .pulse = { 1 },
0100 .space = { 3 },
0101 },
0102
0103 .ft = {
0104 .minlen = 42,
0105 .maxlen = 42,
0106 .ft_min = 10,
0107 },
0108 },
0109
0110 .repeat = 108,
0111 .rtimings = {
0112
0113 .ldr = {
0114 .space = { 4 },
0115 },
0116
0117 .ft = {
0118 .minlen = 0,
0119 .maxlen = 0,
0120 },
0121 },
0122
0123 .scancode = img_ir_sanyo_scancode,
0124 .filter = img_ir_sanyo_filter,
0125 };