ir-core.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #include <linux/kfifo.h>
  18. #include <linux/time.h>
  19. extern int ir_core_debug;
  20. #define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
  21. printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
  22. #define IR_TYPE_UNKNOWN 0
  23. #define IR_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */
  24. #define IR_TYPE_PD (1 << 1) /* Pulse distance encoded IR */
  25. #define IR_TYPE_NEC (1 << 2)
  26. #define IR_TYPE_OTHER (((u64)1) << 63l)
  27. enum raw_event_type {
  28. IR_SPACE = (1 << 0),
  29. IR_PULSE = (1 << 1),
  30. IR_START_EVENT = (1 << 2),
  31. IR_STOP_EVENT = (1 << 3),
  32. };
  33. struct ir_scancode {
  34. u16 scancode;
  35. u32 keycode;
  36. };
  37. struct ir_scancode_table {
  38. struct ir_scancode *scan;
  39. int size;
  40. u64 ir_type;
  41. char *name;
  42. spinlock_t lock;
  43. };
  44. struct ir_dev_props {
  45. unsigned long allowed_protos;
  46. void *priv;
  47. int (*change_protocol)(void *priv, u64 ir_type);
  48. };
  49. struct ir_raw_event {
  50. struct timespec delta; /* Time spent before event */
  51. enum raw_event_type type; /* event type */
  52. };
  53. struct ir_raw_event_ctrl {
  54. struct kfifo kfifo; /* fifo for the pulse/space events */
  55. struct timespec last_event; /* when last event occurred */
  56. };
  57. struct ir_input_dev {
  58. struct device dev; /* device */
  59. char *driver_name; /* Name of the driver module */
  60. struct ir_scancode_table rc_tab; /* scan/key table */
  61. unsigned long devno; /* device number */
  62. const struct ir_dev_props *props; /* Device properties */
  63. struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */
  64. /* key info - needed by IR keycode handlers */
  65. u32 keycode; /* linux key code */
  66. int keypressed; /* current state */
  67. };
  68. #define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
  69. /* Routines from ir-keytable.c */
  70. u32 ir_g_keycode_from_table(struct input_dev *input_dev,
  71. u32 scancode);
  72. void ir_keyup(struct input_dev *dev);
  73. void ir_keydown(struct input_dev *dev, int scancode);
  74. int ir_input_register(struct input_dev *dev,
  75. const struct ir_scancode_table *ir_codes,
  76. const struct ir_dev_props *props,
  77. const char *driver_name);
  78. void ir_input_unregister(struct input_dev *input_dev);
  79. /* Routines from ir-sysfs.c */
  80. int ir_register_class(struct input_dev *input_dev);
  81. void ir_unregister_class(struct input_dev *input_dev);
  82. /* Routines from ir-raw-event.c */
  83. int ir_raw_event_register(struct input_dev *input_dev);
  84. void ir_raw_event_unregister(struct input_dev *input_dev);
  85. int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type);
  86. int ir_raw_event_handle(struct input_dev *input_dev);
  87. /* from ir-nec-decoder.c */
  88. int ir_nec_decode(struct input_dev *input_dev,
  89. struct ir_raw_event *evs,
  90. int len);
  91. #endif