| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "img-ir-hw.h" |
| 9 |
|
| 10 |
|
| 11 |
static int img_ir_sony_scancode(int len, u64 raw, u64 enabled_protocols, |
| 12 |
struct img_ir_scancode_req *request) |
| 13 |
{ |
| 14 |
unsigned int dev, subdev, func; |
| 15 |
|
| 16 |
switch (len) { |
| 17 |
case 12: |
| 18 |
if (!(enabled_protocols & RC_PROTO_BIT_SONY12)) |
| 19 |
return -EINVAL; |
| 20 |
func = raw & 0x7f; |
| 21 |
raw >>= 7; |
| 22 |
dev = raw & 0x1f; |
| 23 |
subdev = 0; |
| 24 |
request->protocol = RC_PROTO_SONY12; |
| 25 |
break; |
| 26 |
case 15: |
| 27 |
if (!(enabled_protocols & RC_PROTO_BIT_SONY15)) |
| 28 |
return -EINVAL; |
| 29 |
func = raw & 0x7f; |
| 30 |
raw >>= 7; |
| 31 |
dev = raw & 0xff; |
| 32 |
subdev = 0; |
| 33 |
request->protocol = RC_PROTO_SONY15; |
| 34 |
break; |
| 35 |
case 20: |
| 36 |
if (!(enabled_protocols & RC_PROTO_BIT_SONY20)) |
| 37 |
return -EINVAL; |
| 38 |
func = raw & 0x7f; |
| 39 |
raw >>= 7; |
| 40 |
dev = raw & 0x1f; |
| 41 |
raw >>= 5; |
| 42 |
subdev = raw & 0xff; |
| 43 |
request->protocol = RC_PROTO_SONY20; |
| 44 |
break; |
| 45 |
default: |
| 46 |
return -EINVAL; |
| 47 |
} |
| 48 |
request->scancode = dev << 16 | subdev << 8 | func; |
| 49 |
return IMG_IR_SCANCODE; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
static int img_ir_sony_filter(const struct rc_scancode_filter *in, |
| 54 |
struct img_ir_filter *out, u64 protocols) |
| 55 |
{ |
| 56 |
unsigned int dev, subdev, func; |
| 57 |
unsigned int dev_m, subdev_m, func_m; |
| 58 |
unsigned int len = 0; |
| 59 |
|
| 60 |
dev = (in->data >> 16) & 0xff; |
| 61 |
dev_m = (in->mask >> 16) & 0xff; |
| 62 |
subdev = (in->data >> 8) & 0xff; |
| 63 |
subdev_m = (in->mask >> 8) & 0xff; |
| 64 |
func = (in->data >> 0) & 0x7f; |
| 65 |
func_m = (in->mask >> 0) & 0x7f; |
| 66 |
|
| 67 |
protocols &= RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | |
| 68 |
RC_PROTO_BIT_SONY20; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
if (!is_power_of_2(protocols)) { |
| 76 |
if (subdev & subdev_m) |
| 77 |
protocols = RC_PROTO_BIT_SONY20; |
| 78 |
else if (dev & dev_m & 0xe0) |
| 79 |
protocols = RC_PROTO_BIT_SONY15; |
| 80 |
else |
| 81 |
protocols = RC_PROTO_BIT_SONY12; |
| 82 |
} |
| 83 |
|
| 84 |
if (protocols == RC_PROTO_BIT_SONY20) { |
| 85 |
|
| 86 |
if (dev & dev_m & 0xe0) |
| 87 |
return -EINVAL; |
| 88 |
len = 20; |
| 89 |
dev_m &= 0x1f; |
| 90 |
} else if (protocols == RC_PROTO_BIT_SONY15) { |
| 91 |
len = 15; |
| 92 |
subdev_m = 0; |
| 93 |
} else { |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
subdev_m &= (dev_m >> 5) | 0xf8; |
| 100 |
dev_m &= 0x1f; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
dev &= dev_m; |
| 105 |
subdev &= subdev_m; |
| 106 |
|
| 107 |
|
| 108 |
out->data = func | |
| 109 |
dev << 7 | |
| 110 |
subdev << 15; |
| 111 |
out->mask = func_m | |
| 112 |
dev_m << 7 | |
| 113 |
subdev_m << 15; |
| 114 |
|
| 115 |
if (len) { |
| 116 |
out->minlen = len; |
| 117 |
out->maxlen = len; |
| 118 |
} |
| 119 |
return 0; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
struct img_ir_decoder img_ir_sony = { |
| 128 |
.type = RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | RC_PROTO_BIT_SONY20, |
| 129 |
.control = { |
| 130 |
.decoden = 1, |
| 131 |
.code_type = IMG_IR_CODETYPE_PULSELEN, |
| 132 |
}, |
| 133 |
|
| 134 |
.unit = 600000, |
| 135 |
.timings = { |
| 136 |
|
| 137 |
.ldr = { |
| 138 |
.pulse = { 4 }, |
| 139 |
.space = { 1 }, |
| 140 |
}, |
| 141 |
|
| 142 |
.s00 = { |
| 143 |
.pulse = { 1 }, |
| 144 |
.space = { 1 }, |
| 145 |
}, |
| 146 |
|
| 147 |
.s01 = { |
| 148 |
.pulse = { 2 }, |
| 149 |
.space = { 1 }, |
| 150 |
}, |
| 151 |
|
| 152 |
.ft = { |
| 153 |
.minlen = 12, |
| 154 |
.maxlen = 20, |
| 155 |
.ft_min = 10, |
| 156 |
}, |
| 157 |
}, |
| 158 |
|
| 159 |
.scancode = img_ir_sony_scancode, |
| 160 |
.filter = img_ir_sony_filter, |
| 161 |
}; |