2 * ImgTec IR Decoder setup for Philips RC-5 protocol.
4 * Copyright 2012-2014 Imagination Technologies Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 #include "img-ir-hw.h"
14 /* Convert RC5 data to a scancode */
15 static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols,
16 struct img_ir_scancode_req *request)
18 unsigned int addr, cmd, tgl, start;
20 /* Quirk in the decoder shifts everything by 2 to the left. */
23 start = (raw >> 13) & 0x01;
24 tgl = (raw >> 11) & 0x01;
25 addr = (raw >> 6) & 0x1f;
28 * 12th bit is used to extend the command in extended RC5 and has
29 * no effect on standard RC5.
31 cmd += ((raw >> 12) & 0x01) ? 0 : 0x40;
36 request->protocol = RC_PROTO_RC5;
37 request->scancode = addr << 8 | cmd;
38 request->toggle = tgl;
39 return IMG_IR_SCANCODE;
42 /* Convert RC5 scancode to RC5 data filter */
43 static int img_ir_rc5_filter(const struct rc_scancode_filter *in,
44 struct img_ir_filter *out, u64 protocols)
46 /* Not supported by the hw. */
52 * see http://www.sbprojects.com/knowledge/ir/rc5.php
54 struct img_ir_decoder img_ir_rc5 = {
55 .type = RC_PROTO_BIT_RC5,
58 .code_type = IMG_IR_CODETYPE_BIPHASE,
63 .unit = 888888, /* 1/36k*32=888.888microseconds */
86 .scancode = img_ir_rc5_scancode,
87 .filter = img_ir_rc5_filter,