treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / rc / img-ir / img-ir-rc5.c
blob23c8e2397ba74ef8f2d288b1c2997635c7fafdbf
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * ImgTec IR Decoder setup for Philips RC-5 protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
6 */
8 #include "img-ir-hw.h"
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. */
17 raw >>= 2;
19 start = (raw >> 13) & 0x01;
20 tgl = (raw >> 11) & 0x01;
21 addr = (raw >> 6) & 0x1f;
22 cmd = raw & 0x3f;
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;
29 if (!start)
30 return -EINVAL;
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. */
43 return -EINVAL;
47 * RC-5 decoder
48 * see http://www.sbprojects.com/knowledge/ir/rc5.php
50 struct 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,
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 },
67 /* 11 symbol */
68 .s11 = {
69 .pulse = { 1 },
70 .space = { 1 },
73 /* free time */
74 .ft = {
75 .minlen = 14,
76 .maxlen = 14,
77 .ft_min = 5,
81 /* scancode logic */
82 .scancode = img_ir_rc5_scancode,
83 .filter = img_ir_rc5_filter,