Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "[media] rc: ir-rc5-decoder: Add encode capability"

This reverts commit a0466f15b4654cf1ac9e387d7c1a401eff494b4f.

The current code is not mature enough, the API should allow a single
protocol to be specified. Also, the current code contains heuristics
that will depend on module load order.

Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

David Härdeman and committed by
Mauro Carvalho Chehab
e49b361d 70e7112e

-116
-116
drivers/media/rc/ir-rc5-decoder.c
··· 184 184 return -EINVAL; 185 185 } 186 186 187 - static struct ir_raw_timings_manchester ir_rc5_timings = { 188 - .leader = RC5_UNIT, 189 - .pulse_space_start = 0, 190 - .clock = RC5_UNIT, 191 - .trailer_space = RC5_UNIT * 10, 192 - }; 193 - 194 - static struct ir_raw_timings_manchester ir_rc5x_timings[2] = { 195 - { 196 - .leader = RC5_UNIT, 197 - .pulse_space_start = 0, 198 - .clock = RC5_UNIT, 199 - .trailer_space = RC5X_SPACE, 200 - }, 201 - { 202 - .clock = RC5_UNIT, 203 - .trailer_space = RC5_UNIT * 10, 204 - }, 205 - }; 206 - 207 - static struct ir_raw_timings_manchester ir_rc5_sz_timings = { 208 - .leader = RC5_UNIT, 209 - .pulse_space_start = 0, 210 - .clock = RC5_UNIT, 211 - .trailer_space = RC5_UNIT * 10, 212 - }; 213 - 214 - static int ir_rc5_validate_filter(const struct rc_scancode_filter *scancode, 215 - unsigned int important_bits) 216 - { 217 - /* all important bits of scancode should be set in mask */ 218 - if (~scancode->mask & important_bits) 219 - return -EINVAL; 220 - /* extra bits in mask should be zero in data */ 221 - if (scancode->mask & scancode->data & ~important_bits) 222 - return -EINVAL; 223 - return 0; 224 - } 225 - 226 - /** 227 - * ir_rc5_encode() - Encode a scancode as a stream of raw events 228 - * 229 - * @protocols: allowed protocols 230 - * @scancode: scancode filter describing scancode (helps distinguish between 231 - * protocol subtypes when scancode is ambiguous) 232 - * @events: array of raw ir events to write into 233 - * @max: maximum size of @events 234 - * 235 - * Returns: The number of events written. 236 - * -ENOBUFS if there isn't enough space in the array to fit the 237 - * encoding. In this case all @max events will have been written. 238 - * -EINVAL if the scancode is ambiguous or invalid. 239 - */ 240 - static int ir_rc5_encode(u64 protocols, 241 - const struct rc_scancode_filter *scancode, 242 - struct ir_raw_event *events, unsigned int max) 243 - { 244 - int ret; 245 - struct ir_raw_event *e = events; 246 - unsigned int data, xdata, command, commandx, system; 247 - 248 - /* Detect protocol and convert scancode to raw data */ 249 - if (protocols & RC_BIT_RC5 && 250 - !ir_rc5_validate_filter(scancode, 0x1f7f)) { 251 - /* decode scancode */ 252 - command = (scancode->data & 0x003f) >> 0; 253 - commandx = (scancode->data & 0x0040) >> 6; 254 - system = (scancode->data & 0x1f00) >> 8; 255 - /* encode data */ 256 - data = !commandx << 12 | system << 6 | command; 257 - 258 - /* Modulate the data */ 259 - ret = ir_raw_gen_manchester(&e, max, &ir_rc5_timings, RC5_NBITS, 260 - data); 261 - if (ret < 0) 262 - return ret; 263 - } else if (protocols & RC_BIT_RC5X && 264 - !ir_rc5_validate_filter(scancode, 0x1f7f3f)) { 265 - /* decode scancode */ 266 - xdata = (scancode->data & 0x00003f) >> 0; 267 - command = (scancode->data & 0x003f00) >> 8; 268 - commandx = (scancode->data & 0x004000) >> 14; 269 - system = (scancode->data & 0x1f0000) >> 16; 270 - /* commandx and system overlap, bits must match when encoded */ 271 - if (commandx == (system & 0x1)) 272 - return -EINVAL; 273 - /* encode data */ 274 - data = 1 << 18 | system << 12 | command << 6 | xdata; 275 - 276 - /* Modulate the data */ 277 - ret = ir_raw_gen_manchester(&e, max, &ir_rc5x_timings[0], 278 - CHECK_RC5X_NBITS, 279 - data >> (RC5X_NBITS-CHECK_RC5X_NBITS)); 280 - if (ret < 0) 281 - return ret; 282 - ret = ir_raw_gen_manchester(&e, max - (e - events), 283 - &ir_rc5x_timings[1], 284 - RC5X_NBITS - CHECK_RC5X_NBITS, 285 - data); 286 - if (ret < 0) 287 - return ret; 288 - } else if (protocols & RC_BIT_RC5_SZ && 289 - !ir_rc5_validate_filter(scancode, 0x2fff)) { 290 - /* RC5-SZ scancode is raw enough for Manchester as it is */ 291 - ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings, 292 - RC5_SZ_NBITS, scancode->data & 0x2fff); 293 - if (ret < 0) 294 - return ret; 295 - } else { 296 - return -EINVAL; 297 - } 298 - 299 - return e - events; 300 - } 301 - 302 187 static struct ir_raw_handler rc5_handler = { 303 188 .protocols = RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ, 304 189 .decode = ir_rc5_decode, 305 - .encode = ir_rc5_encode, 306 190 }; 307 191 308 192 static int __init ir_rc5_decode_init(void)