1 /* 2 * ImgTec IR Decoder setup for JVC protocol. 3 * 4 * Copyright 2012-2014 Imagination Technologies Ltd. 5 * 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. 10 */ 11 12 #include "img-ir-hw.h" 13 14 /* Convert JVC data to a scancode */ 15 static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol, 16 u32 *scancode, u64 enabled_protocols) 17 { 18 unsigned int cust, data; 19 20 if (len != 16) 21 return -EINVAL; 22 23 cust = (raw >> 0) & 0xff; 24 data = (raw >> 8) & 0xff; 25 26 *protocol = RC_TYPE_JVC; 27 *scancode = cust << 8 | data; 28 return IMG_IR_SCANCODE; 29 } 30 31 /* Convert JVC scancode to JVC data filter */ 32 static int img_ir_jvc_filter(const struct rc_scancode_filter *in, 33 struct img_ir_filter *out, u64 protocols) 34 { 35 unsigned int cust, data; 36 unsigned int cust_m, data_m; 37 38 cust = (in->data >> 8) & 0xff; 39 cust_m = (in->mask >> 8) & 0xff; 40 data = (in->data >> 0) & 0xff; 41 data_m = (in->mask >> 0) & 0xff; 42 43 out->data = cust | data << 8; 44 out->mask = cust_m | data_m << 8; 45 46 return 0; 47 } 48 49 /* 50 * JVC decoder 51 * See also http://www.sbprojects.com/knowledge/ir/jvc.php 52 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf 53 */ 54 struct img_ir_decoder img_ir_jvc = { 55 .type = RC_BIT_JVC, 56 .control = { 57 .decoden = 1, 58 .code_type = IMG_IR_CODETYPE_PULSEDIST, 59 }, 60 /* main timings */ 61 .unit = 527500, /* 527.5 us */ 62 .timings = { 63 /* leader symbol */ 64 .ldr = { 65 .pulse = { 16 /* 8.44 ms */ }, 66 .space = { 8 /* 4.22 ms */ }, 67 }, 68 /* 0 symbol */ 69 .s00 = { 70 .pulse = { 1 /* 527.5 us +-60 us */ }, 71 .space = { 1 /* 527.5 us */ }, 72 }, 73 /* 1 symbol */ 74 .s01 = { 75 .pulse = { 1 /* 527.5 us +-60 us */ }, 76 .space = { 3 /* 1.5825 ms +-40 us */ }, 77 }, 78 /* free time */ 79 .ft = { 80 .minlen = 16, 81 .maxlen = 16, 82 .ft_min = 10, /* 5.275 ms */ 83 }, 84 }, 85 /* scancode logic */ 86 .scancode = img_ir_jvc_scancode, 87 .filter = img_ir_jvc_filter, 88 }; 89