0001
0002
0003
0004
0005
0006
0007
0008 #include "img-ir-hw.h"
0009
0010
0011 static int img_ir_sharp_scancode(int len, u64 raw, u64 enabled_protocols,
0012 struct img_ir_scancode_req *request)
0013 {
0014 unsigned int addr, cmd, exp, chk;
0015
0016 if (len != 15)
0017 return -EINVAL;
0018
0019 addr = (raw >> 0) & 0x1f;
0020 cmd = (raw >> 5) & 0xff;
0021 exp = (raw >> 13) & 0x1;
0022 chk = (raw >> 14) & 0x1;
0023
0024
0025 if (!exp)
0026 return -EINVAL;
0027 if (chk)
0028
0029 return -EINVAL;
0030
0031 request->protocol = RC_PROTO_SHARP;
0032 request->scancode = addr << 8 | cmd;
0033 return IMG_IR_SCANCODE;
0034 }
0035
0036
0037 static int img_ir_sharp_filter(const struct rc_scancode_filter *in,
0038 struct img_ir_filter *out, u64 protocols)
0039 {
0040 unsigned int addr, cmd, exp = 0, chk = 0;
0041 unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0;
0042
0043 addr = (in->data >> 8) & 0x1f;
0044 addr_m = (in->mask >> 8) & 0x1f;
0045 cmd = (in->data >> 0) & 0xff;
0046 cmd_m = (in->mask >> 0) & 0xff;
0047 if (cmd_m) {
0048
0049 exp = 1;
0050 exp_m = 1;
0051 chk = 0;
0052 chk_m = 1;
0053 }
0054
0055 out->data = addr |
0056 cmd << 5 |
0057 exp << 13 |
0058 chk << 14;
0059 out->mask = addr_m |
0060 cmd_m << 5 |
0061 exp_m << 13 |
0062 chk_m << 14;
0063
0064 return 0;
0065 }
0066
0067
0068
0069
0070
0071 struct img_ir_decoder img_ir_sharp = {
0072 .type = RC_PROTO_BIT_SHARP,
0073 .control = {
0074 .decoden = 0,
0075 .decodend2 = 1,
0076 .code_type = IMG_IR_CODETYPE_PULSEDIST,
0077 .d1validsel = 1,
0078 },
0079
0080 .tolerance = 20,
0081 .timings = {
0082
0083 .s10 = {
0084 .pulse = { 320 },
0085 .space = { 680 },
0086 },
0087
0088 .s11 = {
0089 .pulse = { 320 },
0090 .space = { 1680 },
0091 },
0092
0093 .ft = {
0094 .minlen = 15,
0095 .maxlen = 15,
0096 .ft_min = 5000,
0097 },
0098 },
0099
0100 .scancode = img_ir_sharp_scancode,
0101 .filter = img_ir_sharp_filter,
0102 };