ir-common.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. *
  3. * some common structs and functions to handle infrared remotes via
  4. * input layer ...
  5. *
  6. * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef _IR_COMMON
  23. #define _IR_COMMON
  24. #include <linux/input.h>
  25. #include <linux/workqueue.h>
  26. #include <linux/interrupt.h>
  27. #include <media/ir-core.h>
  28. #include <media/keycodes/adstech-dvb-t-pci.h>
  29. #include <media/keycodes/apac-viewcomp.h>
  30. #include <media/keycodes/asus-pc39.h>
  31. #include <media/keycodes/ati-tv-wonder-hd-600.h>
  32. #include <media/keycodes/avermedia-a16d.h>
  33. #include <media/keycodes/avermedia-cardbus.h>
  34. #include <media/keycodes/avermedia-dvbt.h>
  35. #include <media/keycodes/avermedia.h>
  36. #include <media/keycodes/avermedia-m135a-rm-jx.h>
  37. #include <media/keycodes/avertv-303.h>
  38. #include <media/keycodes/behold-columbus.h>
  39. #include <media/keycodes/behold.h>
  40. #include <media/keycodes/budget-ci-old.h>
  41. #include <media/keycodes/cinergy-1400.h>
  42. #include <media/keycodes/cinergy.h>
  43. #include <media/keycodes/dm1105-nec.h>
  44. #include <media/keycodes/dntv-live-dvb-t.h>
  45. #include <media/keycodes/dntv-live-dvbt-pro.h>
  46. #include <media/keycodes/empty.h>
  47. #include <media/keycodes/em-terratec.h>
  48. #include <media/keycodes/encore-enltv2.h>
  49. #include <media/keycodes/encore-enltv-fm53.h>
  50. #include <media/keycodes/encore-enltv.h>
  51. #include <media/keycodes/evga-indtube.h>
  52. #include <media/keycodes/eztv.h>
  53. #include <media/keycodes/flydvb.h>
  54. #include <media/keycodes/flyvideo.h>
  55. #include <media/keycodes/fusionhdtv-mce.h>
  56. #include <media/keycodes/gadmei-rm008z.h>
  57. #include <media/keycodes/genius-tvgo-a11mce.h>
  58. #include <media/keycodes/gotview7135.h>
  59. #include <media/keycodes/hauppauge-new.h>
  60. #include <media/keycodes/iodata-bctv7e.h>
  61. #include <media/keycodes/kaiomy.h>
  62. #include <media/keycodes/kworld-315u.h>
  63. #include <media/keycodes/kworld-plus-tv-analog.h>
  64. #include <media/keycodes/manli.h>
  65. #include <media/keycodes/msi-tvanywhere.h>
  66. #include <media/keycodes/msi-tvanywhere-plus.h>
  67. #include <media/keycodes/nebula.h>
  68. #include <media/keycodes/nec-terratec-cinergy-xs.h>
  69. #include <media/keycodes/norwood.h>
  70. #include <media/keycodes/npgtech.h>
  71. #include <media/keycodes/pctv-sedna.h>
  72. #include <media/keycodes/pinnacle-color.h>
  73. #include <media/keycodes/pinnacle-grey.h>
  74. #include <media/keycodes/pinnacle-pctv-hd.h>
  75. #include <media/keycodes/pixelview.h>
  76. #include <media/keycodes/pixelview-new.h>
  77. #include <media/keycodes/powercolor-real-angel.h>
  78. #include <media/keycodes/proteus-2309.h>
  79. #include <media/keycodes/purpletv.h>
  80. #include <media/keycodes/pv951.h>
  81. #include <media/keycodes/rc5-hauppauge-new.h>
  82. #include <media/keycodes/rc5-tv.h>
  83. #include <media/keycodes/real-audio-220-32-keys.h>
  84. #include <media/keycodes/tbs-nec.h>
  85. #include <media/keycodes/terratec-cinergy-xs.h>
  86. #include <media/keycodes/tevii-nec.h>
  87. #include <media/keycodes/tt-1500.h>
  88. #include <media/keycodes/videomate-s350.h>
  89. #include <media/keycodes/videomate-tv-pvr.h>
  90. #include <media/keycodes/winfast.h>
  91. #include <media/keycodes/winfast-usbii-deluxe.h>
  92. #define RC5_START(x) (((x)>>12)&3)
  93. #define RC5_TOGGLE(x) (((x)>>11)&1)
  94. #define RC5_ADDR(x) (((x)>>6)&31)
  95. #define RC5_INSTR(x) ((x)&63)
  96. struct ir_input_state {
  97. /* configuration */
  98. u64 ir_type;
  99. /* key info */
  100. u32 ir_key; /* ir scancode */
  101. u32 keycode; /* linux key code */
  102. int keypressed; /* current state */
  103. };
  104. /* this was saa7134_ir and bttv_ir, moved here for
  105. * rc5 decoding. */
  106. struct card_ir {
  107. struct input_dev *dev;
  108. struct ir_input_state ir;
  109. char name[32];
  110. char phys[32];
  111. int users;
  112. u32 running:1;
  113. struct ir_dev_props props;
  114. /* Usual gpio signalling */
  115. u32 mask_keycode;
  116. u32 mask_keydown;
  117. u32 mask_keyup;
  118. u32 polling;
  119. u32 last_gpio;
  120. int shift_by;
  121. int start; // What should RC5_START() be
  122. int addr; // What RC5_ADDR() should be.
  123. int rc5_key_timeout;
  124. int rc5_remote_gap;
  125. struct work_struct work;
  126. struct timer_list timer;
  127. /* RC5 gpio */
  128. u32 rc5_gpio;
  129. struct timer_list timer_end; /* timer_end for code completion */
  130. struct timer_list timer_keyup; /* timer_end for key release */
  131. u32 last_rc5; /* last good rc5 code */
  132. u32 last_bit; /* last raw bit seen */
  133. u32 code; /* raw code under construction */
  134. struct timeval base_time; /* time of last seen code */
  135. int active; /* building raw code */
  136. /* NEC decoding */
  137. u32 nec_gpio;
  138. struct tasklet_struct tlet;
  139. /* IR core raw decoding */
  140. u32 raw_decode;
  141. };
  142. /* Routines from ir-functions.c */
  143. int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
  144. const u64 ir_type);
  145. void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
  146. void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
  147. u32 ir_key);
  148. u32 ir_extract_bits(u32 data, u32 mask);
  149. int ir_dump_samples(u32 *samples, int count);
  150. int ir_decode_biphase(u32 *samples, int count, int low, int high);
  151. int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
  152. u32 ir_rc5_decode(unsigned int code);
  153. void ir_rc5_timer_end(unsigned long data);
  154. void ir_rc5_timer_keyup(unsigned long data);
  155. #endif