1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * ImgTec IR Decoder setup for JVC protocol. 4 * 5 * Copyright 2012-2014 Imagination Technologies Ltd. 6 */ 7 8 #include "img-ir-hw.h" 9 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) 13 { 14 unsigned int cust, data; 15 16 if (len != 16) 17 return -EINVAL; 18 19 cust = (raw >> 0) & 0xff; 20 data = (raw >> 8) & 0xff; 21 22 request->protocol = RC_PROTO_JVC; 23 request->scancode = cust << 8 | data; 24 return IMG_IR_SCANCODE; 25 } 26 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) 30 { 31 unsigned int cust, data; 32 unsigned int cust_m, data_m; 33 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; 38 39 out->data = cust | data << 8; 40 out->mask = cust_m | data_m << 8; 41 42 return 0; 43 } 44 45 /* 46 * JVC decoder 47 * See also http://www.sbprojects.com/knowledge/ir/jvc.php 48 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf 49 */ 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, 55 }, 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 */ }, 63 }, 64 /* 0 symbol */ 65 .s00 = { 66 .pulse = { 1 /* 527.5 us +-60 us */ }, 67 .space = { 1 /* 527.5 us */ }, 68 }, 69 /* 1 symbol */ 70 .s01 = { 71 .pulse = { 1 /* 527.5 us +-60 us */ }, 72 .space = { 3 /* 1.5825 ms +-40 us */ }, 73 }, 74 /* free time */ 75 .ft = { 76 .minlen = 16, 77 .maxlen = 16, 78 .ft_min = 10, /* 5.275 ms */ 79 }, 80 }, 81 /* scancode logic */ 82 .scancode = img_ir_jvc_scancode, 83 .filter = img_ir_jvc_filter, 84 }; 85