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