img-ir-jvc.c 2.0 KB

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