1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ImgTec IR Decoder setup for Philips RC-5 protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
10 /* Convert RC5 data to a scancode */
11 static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols,
12 struct img_ir_scancode_req *request)
14 unsigned int addr, cmd, tgl, start;
16 /* Quirk in the decoder shifts everything by 2 to the left. */
19 start = (raw >> 13) & 0x01;
20 tgl = (raw >> 11) & 0x01;
21 addr = (raw >> 6) & 0x1f;
24 * 12th bit is used to extend the command in extended RC5 and has
25 * no effect on standard RC5.
27 cmd += ((raw >> 12) & 0x01) ? 0 : 0x40;
32 request->protocol = RC_PROTO_RC5;
33 request->scancode = addr << 8 | cmd;
34 request->toggle = tgl;
35 return IMG_IR_SCANCODE;
38 /* Convert RC5 scancode to RC5 data filter */
39 static int img_ir_rc5_filter(const struct rc_scancode_filter *in,
40 struct img_ir_filter *out, u64 protocols)
42 /* Not supported by the hw. */
48 * see http://www.sbprojects.com/knowledge/ir/rc5.php
50 struct img_ir_decoder img_ir_rc5 = {
51 .type = RC_PROTO_BIT_RC5,
54 .code_type = IMG_IR_CODETYPE_BIPHASE,
59 .unit = 888888, /* 1/36k*32=888.888microseconds */
82 .scancode = img_ir_rc5_scancode,
83 .filter = img_ir_rc5_filter,