85 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/*3 * ImgTec IR Decoder setup for Philips RC-5 protocol.4 *5 * Copyright 2012-2014 Imagination Technologies Ltd.6 */7 8#include "img-ir-hw.h"9 10/* Convert RC5 data to a scancode */11static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols,12 struct img_ir_scancode_req *request)13{14 unsigned int addr, cmd, tgl, start;15 16 /* Quirk in the decoder shifts everything by 2 to the left. */17 raw >>= 2;18 19 start = (raw >> 13) & 0x01;20 tgl = (raw >> 11) & 0x01;21 addr = (raw >> 6) & 0x1f;22 cmd = raw & 0x3f;23 /*24 * 12th bit is used to extend the command in extended RC5 and has25 * no effect on standard RC5.26 */27 cmd += ((raw >> 12) & 0x01) ? 0 : 0x40;28 29 if (!start)30 return -EINVAL;31 32 request->protocol = RC_PROTO_RC5;33 request->scancode = addr << 8 | cmd;34 request->toggle = tgl;35 return IMG_IR_SCANCODE;36}37 38/* Convert RC5 scancode to RC5 data filter */39static int img_ir_rc5_filter(const struct rc_scancode_filter *in,40 struct img_ir_filter *out, u64 protocols)41{42 /* Not supported by the hw. */43 return -EINVAL;44}45 46/*47 * RC-5 decoder48 * see http://www.sbprojects.com/knowledge/ir/rc5.php49 */50struct img_ir_decoder img_ir_rc5 = {51 .type = RC_PROTO_BIT_RC5,52 .control = {53 .bitoriend2 = 1,54 .code_type = IMG_IR_CODETYPE_BIPHASE,55 .decodend2 = 1,56 },57 /* main timings */58 .tolerance = 16,59 .unit = 888888, /* 1/36k*32=888.888microseconds */60 .timings = {61 /* 10 symbol */62 .s10 = {63 .pulse = { 1 },64 .space = { 1 },65 },66 67 /* 11 symbol */68 .s11 = {69 .pulse = { 1 },70 .space = { 1 },71 },72 73 /* free time */74 .ft = {75 .minlen = 14,76 .maxlen = 14,77 .ft_min = 5,78 },79 },80 81 /* scancode logic */82 .scancode = img_ir_rc5_scancode,83 .filter = img_ir_rc5_filter,84};85