ir-common.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. u64 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. int users;
  48. u32 running:1;
  49. struct ir_dev_props props;
  50. /* Usual gpio signalling */
  51. u32 mask_keycode;
  52. u32 mask_keydown;
  53. u32 mask_keyup;
  54. u32 polling;
  55. u32 last_gpio;
  56. int shift_by;
  57. int start; // What should RC5_START() be
  58. int addr; // What RC5_ADDR() should be.
  59. int rc5_key_timeout;
  60. int rc5_remote_gap;
  61. struct work_struct work;
  62. struct timer_list timer;
  63. /* RC5 gpio */
  64. u32 rc5_gpio;
  65. struct timer_list timer_end; /* timer_end for code completion */
  66. struct timer_list timer_keyup; /* timer_end for key release */
  67. u32 last_rc5; /* last good rc5 code */
  68. u32 last_bit; /* last raw bit seen */
  69. u32 code; /* raw code under construction */
  70. struct timeval base_time; /* time of last seen code */
  71. int active; /* building raw code */
  72. /* NEC decoding */
  73. u32 nec_gpio;
  74. struct tasklet_struct tlet;
  75. /* IR core raw decoding */
  76. u32 raw_decode;
  77. };
  78. /* Routines from ir-functions.c */
  79. int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
  80. const u64 ir_type);
  81. void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
  82. void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
  83. u32 ir_key);
  84. u32 ir_extract_bits(u32 data, u32 mask);
  85. int ir_dump_samples(u32 *samples, int count);
  86. int ir_decode_biphase(u32 *samples, int count, int low, int high);
  87. int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
  88. u32 ir_rc5_decode(unsigned int code);
  89. void ir_rc5_timer_end(unsigned long data);
  90. void ir_rc5_timer_keyup(unsigned long data);
  91. /* scancode->keycode map tables from ir-keymaps.c */
  92. #define IR_KEYTABLE(a) \
  93. ir_codes_ ## a ## _table
  94. #define DECLARE_IR_KEYTABLE(a) \
  95. extern struct ir_scancode_table IR_KEYTABLE(a)
  96. #define DEFINE_IR_KEYTABLE(tabname, type) \
  97. struct ir_scancode_table IR_KEYTABLE(tabname) = { \
  98. .scan = tabname, \
  99. .size = ARRAY_SIZE(tabname), \
  100. .ir_type = type, \
  101. .name = #tabname, \
  102. }; \
  103. EXPORT_SYMBOL_GPL(IR_KEYTABLE(tabname))
  104. #define DEFINE_LEGACY_IR_KEYTABLE(tabname) \
  105. DEFINE_IR_KEYTABLE(tabname, IR_TYPE_UNKNOWN)
  106. DECLARE_IR_KEYTABLE(adstech_dvb_t_pci);
  107. DECLARE_IR_KEYTABLE(apac_viewcomp);
  108. DECLARE_IR_KEYTABLE(asus_pc39);
  109. DECLARE_IR_KEYTABLE(ati_tv_wonder_hd_600);
  110. DECLARE_IR_KEYTABLE(avermedia);
  111. DECLARE_IR_KEYTABLE(avermedia_a16d);
  112. DECLARE_IR_KEYTABLE(avermedia_cardbus);
  113. DECLARE_IR_KEYTABLE(avermedia_dvbt);
  114. DECLARE_IR_KEYTABLE(avermedia_m135a_rm_jx);
  115. DECLARE_IR_KEYTABLE(avertv_303);
  116. DECLARE_IR_KEYTABLE(behold);
  117. DECLARE_IR_KEYTABLE(behold_columbus);
  118. DECLARE_IR_KEYTABLE(budget_ci_old);
  119. DECLARE_IR_KEYTABLE(cinergy);
  120. DECLARE_IR_KEYTABLE(cinergy_1400);
  121. DECLARE_IR_KEYTABLE(dm1105_nec);
  122. DECLARE_IR_KEYTABLE(dntv_live_dvb_t);
  123. DECLARE_IR_KEYTABLE(dntv_live_dvbt_pro);
  124. DECLARE_IR_KEYTABLE(empty);
  125. DECLARE_IR_KEYTABLE(em_terratec);
  126. DECLARE_IR_KEYTABLE(encore_enltv);
  127. DECLARE_IR_KEYTABLE(encore_enltv2);
  128. DECLARE_IR_KEYTABLE(encore_enltv_fm53);
  129. DECLARE_IR_KEYTABLE(evga_indtube);
  130. DECLARE_IR_KEYTABLE(eztv);
  131. DECLARE_IR_KEYTABLE(flydvb);
  132. DECLARE_IR_KEYTABLE(flyvideo);
  133. DECLARE_IR_KEYTABLE(fusionhdtv_mce);
  134. DECLARE_IR_KEYTABLE(gadmei_rm008z);
  135. DECLARE_IR_KEYTABLE(genius_tvgo_a11mce);
  136. DECLARE_IR_KEYTABLE(gotview7135);
  137. DECLARE_IR_KEYTABLE(hauppauge_new);
  138. DECLARE_IR_KEYTABLE(iodata_bctv7e);
  139. DECLARE_IR_KEYTABLE(kaiomy);
  140. DECLARE_IR_KEYTABLE(kworld_315u);
  141. DECLARE_IR_KEYTABLE(kworld_plus_tv_analog);
  142. DECLARE_IR_KEYTABLE(manli);
  143. DECLARE_IR_KEYTABLE(msi_tvanywhere);
  144. DECLARE_IR_KEYTABLE(msi_tvanywhere_plus);
  145. DECLARE_IR_KEYTABLE(nebula);
  146. DECLARE_IR_KEYTABLE(nec_terratec_cinergy_xs);
  147. DECLARE_IR_KEYTABLE(norwood);
  148. DECLARE_IR_KEYTABLE(npgtech);
  149. DECLARE_IR_KEYTABLE(pctv_sedna);
  150. DECLARE_IR_KEYTABLE(pinnacle_color);
  151. DECLARE_IR_KEYTABLE(pinnacle_grey);
  152. DECLARE_IR_KEYTABLE(pinnacle_pctv_hd);
  153. DECLARE_IR_KEYTABLE(pixelview);
  154. DECLARE_IR_KEYTABLE(pixelview_new);
  155. DECLARE_IR_KEYTABLE(powercolor_real_angel);
  156. DECLARE_IR_KEYTABLE(proteus_2309);
  157. DECLARE_IR_KEYTABLE(purpletv);
  158. DECLARE_IR_KEYTABLE(pv951);
  159. DECLARE_IR_KEYTABLE(rc5_hauppauge_new);
  160. DECLARE_IR_KEYTABLE(rc5_tv);
  161. DECLARE_IR_KEYTABLE(real_audio_220_32_keys);
  162. DECLARE_IR_KEYTABLE(tbs_nec);
  163. DECLARE_IR_KEYTABLE(terratec_cinergy_xs);
  164. DECLARE_IR_KEYTABLE(tevii_nec);
  165. DECLARE_IR_KEYTABLE(tt_1500);
  166. DECLARE_IR_KEYTABLE(videomate_s350);
  167. DECLARE_IR_KEYTABLE(videomate_tv_pvr);
  168. DECLARE_IR_KEYTABLE(winfast);
  169. DECLARE_IR_KEYTABLE(winfast_usbii_deluxe);
  170. #endif