ir-core.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Remote Controller core header
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation version 2 of the License.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _IR_CORE
  14. #define _IR_CORE
  15. #include <linux/input.h>
  16. #include <linux/spinlock.h>
  17. extern int ir_core_debug;
  18. #define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
  19. printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
  20. enum ir_type {
  21. IR_TYPE_UNKNOWN = 0,
  22. IR_TYPE_RC5 = 1L << 0, /* Philips RC5 protocol */
  23. IR_TYPE_PD = 1L << 1, /* Pulse distance encoded IR */
  24. IR_TYPE_NEC = 1L << 2,
  25. IR_TYPE_OTHER = 1L << 63,
  26. };
  27. struct ir_scancode {
  28. u16 scancode;
  29. u32 keycode;
  30. };
  31. struct ir_scancode_table {
  32. struct ir_scancode *scan;
  33. int size;
  34. enum ir_type ir_type;
  35. spinlock_t lock;
  36. };
  37. struct ir_dev_props {
  38. unsigned long allowed_protos;
  39. void *priv;
  40. int (*change_protocol)(void *priv, unsigned long protocol);
  41. };
  42. struct ir_input_dev {
  43. struct input_dev *dev; /* Input device*/
  44. struct ir_scancode_table rc_tab; /* scan/key table */
  45. unsigned long devno; /* device number */
  46. struct attribute_group attr; /* IR attributes */
  47. struct device *class_dev; /* virtual class dev */
  48. const struct ir_dev_props *props; /* Device properties */
  49. };
  50. /* Routines from ir-keytable.c */
  51. u32 ir_g_keycode_from_table(struct input_dev *input_dev,
  52. u32 scancode);
  53. int ir_set_keycode_table(struct input_dev *input_dev,
  54. struct ir_scancode_table *rc_tab);
  55. int ir_roundup_tablesize(int n_elems);
  56. int ir_input_register(struct input_dev *dev,
  57. const struct ir_scancode_table *ir_codes,
  58. const struct ir_dev_props *props);
  59. void ir_input_unregister(struct input_dev *input_dev);
  60. /* Routines from ir-sysfs.c */
  61. int ir_register_class(struct input_dev *input_dev);
  62. void ir_unregister_class(struct input_dev *input_dev);
  63. #endif