treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / rc / img-ir / img-ir-jvc.c
blob0fc5e6e45df4f84761deaa914326b66d4c69d3a5
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * ImgTec IR Decoder setup for JVC protocol.
5 * Copyright 2012-2014 Imagination Technologies Ltd.
6 */
8 #include "img-ir-hw.h"
10 /* Convert JVC data to a scancode */
11 static int img_ir_jvc_scancode(int len, u64 raw, u64 enabled_protocols,
12 struct img_ir_scancode_req *request)
14 unsigned int cust, data;
16 if (len != 16)
17 return -EINVAL;
19 cust = (raw >> 0) & 0xff;
20 data = (raw >> 8) & 0xff;
22 request->protocol = RC_PROTO_JVC;
23 request->scancode = cust << 8 | data;
24 return IMG_IR_SCANCODE;
27 /* Convert JVC scancode to JVC data filter */
28 static int img_ir_jvc_filter(const struct rc_scancode_filter *in,
29 struct img_ir_filter *out, u64 protocols)
31 unsigned int cust, data;
32 unsigned int cust_m, data_m;
34 cust = (in->data >> 8) & 0xff;
35 cust_m = (in->mask >> 8) & 0xff;
36 data = (in->data >> 0) & 0xff;
37 data_m = (in->mask >> 0) & 0xff;
39 out->data = cust | data << 8;
40 out->mask = cust_m | data_m << 8;
42 return 0;
46 * JVC decoder
47 * See also http://www.sbprojects.com/knowledge/ir/jvc.php
48 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf
50 struct img_ir_decoder img_ir_jvc = {
51 .type = RC_PROTO_BIT_JVC,
52 .control = {
53 .decoden = 1,
54 .code_type = IMG_IR_CODETYPE_PULSEDIST,
56 /* main timings */
57 .unit = 527500, /* 527.5 us */
58 .timings = {
59 /* leader symbol */
60 .ldr = {
61 .pulse = { 16 /* 8.44 ms */ },
62 .space = { 8 /* 4.22 ms */ },
64 /* 0 symbol */
65 .s00 = {
66 .pulse = { 1 /* 527.5 us +-60 us */ },
67 .space = { 1 /* 527.5 us */ },
69 /* 1 symbol */
70 .s01 = {
71 .pulse = { 1 /* 527.5 us +-60 us */ },
72 .space = { 3 /* 1.5825 ms +-40 us */ },
74 /* free time */
75 .ft = {
76 .minlen = 16,
77 .maxlen = 16,
78 .ft_min = 10, /* 5.275 ms */
81 /* scancode logic */
82 .scancode = img_ir_jvc_scancode,
83 .filter = img_ir_jvc_filter,