ir-common.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #define RC5_START(x) (((x)>>12)&3)
  29. #define RC5_TOGGLE(x) (((x)>>11)&1)
  30. #define RC5_ADDR(x) (((x)>>6)&31)
  31. #define RC5_INSTR(x) ((x)&63)
  32. struct ir_input_state {
  33. /* configuration */
  34. int ir_type;
  35. /* key info */
  36. u32 ir_key; /* ir scancode */
  37. u32 keycode; /* linux key code */
  38. int keypressed; /* current state */
  39. };
  40. /* this was saa7134_ir and bttv_ir, moved here for
  41. * rc5 decoding. */
  42. struct card_ir {
  43. struct input_dev *dev;
  44. struct ir_input_state ir;
  45. char name[32];
  46. char phys[32];
  47. /* Usual gpio signalling */
  48. u32 mask_keycode;
  49. u32 mask_keydown;
  50. u32 mask_keyup;
  51. u32 polling;
  52. u32 last_gpio;
  53. int shift_by;
  54. int start; // What should RC5_START() be
  55. int addr; // What RC5_ADDR() should be.
  56. int rc5_key_timeout;
  57. int rc5_remote_gap;
  58. struct work_struct work;
  59. struct timer_list timer;
  60. /* RC5 gpio */
  61. u32 rc5_gpio;
  62. struct timer_list timer_end; /* timer_end for code completion */
  63. struct timer_list timer_keyup; /* timer_end for key release */
  64. u32 last_rc5; /* last good rc5 code */
  65. u32 last_bit; /* last raw bit seen */
  66. u32 code; /* raw code under construction */
  67. struct timeval base_time; /* time of last seen code */
  68. int active; /* building raw code */
  69. /* NEC decoding */
  70. u32 nec_gpio;
  71. struct tasklet_struct tlet;
  72. };
  73. /* Routines from ir-functions.c */
  74. int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
  75. int ir_type);
  76. void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
  77. void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
  78. u32 ir_key);
  79. u32 ir_extract_bits(u32 data, u32 mask);
  80. int ir_dump_samples(u32 *samples, int count);
  81. int ir_decode_biphase(u32 *samples, int count, int low, int high);
  82. int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
  83. u32 ir_rc5_decode(unsigned int code);
  84. void ir_rc5_timer_end(unsigned long data);
  85. void ir_rc5_timer_keyup(unsigned long data);
  86. /* scancode->keycode map tables from ir-keymaps.c */
  87. extern struct ir_scancode_table ir_codes_empty_table;
  88. extern struct ir_scancode_table ir_codes_avermedia_table;
  89. extern struct ir_scancode_table ir_codes_avermedia_dvbt_table;
  90. extern struct ir_scancode_table ir_codes_avermedia_m135a_table;
  91. extern struct ir_scancode_table ir_codes_avermedia_cardbus_table;
  92. extern struct ir_scancode_table ir_codes_apac_viewcomp_table;
  93. extern struct ir_scancode_table ir_codes_pixelview_table;
  94. extern struct ir_scancode_table ir_codes_pixelview_new_table;
  95. extern struct ir_scancode_table ir_codes_nebula_table;
  96. extern struct ir_scancode_table ir_codes_dntv_live_dvb_t_table;
  97. extern struct ir_scancode_table ir_codes_iodata_bctv7e_table;
  98. extern struct ir_scancode_table ir_codes_adstech_dvb_t_pci_table;
  99. extern struct ir_scancode_table ir_codes_msi_tvanywhere_table;
  100. extern struct ir_scancode_table ir_codes_cinergy_1400_table;
  101. extern struct ir_scancode_table ir_codes_avertv_303_table;
  102. extern struct ir_scancode_table ir_codes_dntv_live_dvbt_pro_table;
  103. extern struct ir_scancode_table ir_codes_em_terratec_table;
  104. extern struct ir_scancode_table ir_codes_pinnacle_grey_table;
  105. extern struct ir_scancode_table ir_codes_flyvideo_table;
  106. extern struct ir_scancode_table ir_codes_flydvb_table;
  107. extern struct ir_scancode_table ir_codes_cinergy_table;
  108. extern struct ir_scancode_table ir_codes_eztv_table;
  109. extern struct ir_scancode_table ir_codes_avermedia_table;
  110. extern struct ir_scancode_table ir_codes_videomate_tv_pvr_table;
  111. extern struct ir_scancode_table ir_codes_manli_table;
  112. extern struct ir_scancode_table ir_codes_gotview7135_table;
  113. extern struct ir_scancode_table ir_codes_purpletv_table;
  114. extern struct ir_scancode_table ir_codes_pctv_sedna_table;
  115. extern struct ir_scancode_table ir_codes_pv951_table;
  116. extern struct ir_scancode_table ir_codes_rc5_tv_table;
  117. extern struct ir_scancode_table ir_codes_winfast_table;
  118. extern struct ir_scancode_table ir_codes_pinnacle_color_table;
  119. extern struct ir_scancode_table ir_codes_hauppauge_new_table;
  120. extern struct ir_scancode_table ir_codes_rc5_hauppauge_new_table;
  121. extern struct ir_scancode_table ir_codes_npgtech_table;
  122. extern struct ir_scancode_table ir_codes_norwood_table;
  123. extern struct ir_scancode_table ir_codes_proteus_2309_table;
  124. extern struct ir_scancode_table ir_codes_budget_ci_old_table;
  125. extern struct ir_scancode_table ir_codes_asus_pc39_table;
  126. extern struct ir_scancode_table ir_codes_encore_enltv_table;
  127. extern struct ir_scancode_table ir_codes_encore_enltv2_table;
  128. extern struct ir_scancode_table ir_codes_tt_1500_table;
  129. extern struct ir_scancode_table ir_codes_fusionhdtv_mce_table;
  130. extern struct ir_scancode_table ir_codes_behold_table;
  131. extern struct ir_scancode_table ir_codes_behold_columbus_table;
  132. extern struct ir_scancode_table ir_codes_pinnacle_pctv_hd_table;
  133. extern struct ir_scancode_table ir_codes_genius_tvgo_a11mce_table;
  134. extern struct ir_scancode_table ir_codes_powercolor_real_angel_table;
  135. extern struct ir_scancode_table ir_codes_avermedia_a16d_table;
  136. extern struct ir_scancode_table ir_codes_encore_enltv_fm53_table;
  137. extern struct ir_scancode_table ir_codes_real_audio_220_32_keys_table;
  138. extern struct ir_scancode_table ir_codes_msi_tvanywhere_plus_table;
  139. extern struct ir_scancode_table ir_codes_ati_tv_wonder_hd_600_table;
  140. extern struct ir_scancode_table ir_codes_kworld_plus_tv_analog_table;
  141. extern struct ir_scancode_table ir_codes_kaiomy_table;
  142. extern struct ir_scancode_table ir_codes_dm1105_nec_table;
  143. extern struct ir_scancode_table ir_codes_tevii_nec_table;
  144. extern struct ir_scancode_table ir_codes_tbs_nec_table;
  145. extern struct ir_scancode_table ir_codes_evga_indtube_table;
  146. extern struct ir_scancode_table ir_codes_terratec_cinergy_xs_table;
  147. extern struct ir_scancode_table ir_codes_videomate_s350_table;
  148. extern struct ir_scancode_table ir_codes_gadmei_rm008z_table;
  149. extern struct ir_scancode_table ir_codes_nec_terratec_cinergy_xs_table;
  150. #endif