ir-common.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #define IR_TYPE_RC5 1
  26. #define IR_TYPE_PD 2 /* Pulse distance encoded IR */
  27. #define IR_TYPE_OTHER 99
  28. #define IR_KEYTAB_TYPE u32
  29. #define IR_KEYTAB_SIZE 128 // enougth for rc5, probably need more some day ...
  30. #define IR_KEYCODE(tab,code) (((unsigned)code < IR_KEYTAB_SIZE) \
  31. ? tab[code] : KEY_RESERVED)
  32. struct ir_input_state {
  33. /* configuration */
  34. int ir_type;
  35. IR_KEYTAB_TYPE ir_codes[IR_KEYTAB_SIZE];
  36. /* key info */
  37. u32 ir_raw; /* raw data */
  38. u32 ir_key; /* ir key code */
  39. u32 keycode; /* linux key code */
  40. int keypressed; /* current state */
  41. };
  42. extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
  43. extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE];
  44. extern IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE];
  45. extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
  46. extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE];
  47. extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
  48. void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
  49. int ir_type, IR_KEYTAB_TYPE *ir_codes);
  50. void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
  51. void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
  52. u32 ir_key, u32 ir_raw);
  53. u32 ir_extract_bits(u32 data, u32 mask);
  54. int ir_dump_samples(u32 *samples, int count);
  55. int ir_decode_biphase(u32 *samples, int count, int low, int high);
  56. int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
  57. #endif
  58. /*
  59. * Local variables:
  60. * c-basic-offset: 8
  61. * End:
  62. */