am_remote.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef _REMOTE_H
  2. #define _REMOTE_H
  3. #include <asm/ioctl.h>
  4. #include <plat/fiq_bridge.h>
  5. //remote config ioctl cmd
  6. #define REMOTE_IOC_RESET_KEY_MAPPING _IOW_BAD('I',3,sizeof(short))
  7. #define REMOTE_IOC_SET_KEY_MAPPING _IOW_BAD('I',4,sizeof(short))
  8. #define REMOTE_IOC_SET_MOUSE_MAPPING _IOW_BAD('I',5,sizeof(short))
  9. #define REMOTE_IOC_SET_REPEAT_DELAY _IOW_BAD('I',6,sizeof(short))
  10. #define REMOTE_IOC_SET_REPEAT_PERIOD _IOW_BAD('I',7,sizeof(short))
  11. #define REMOTE_IOC_SET_REPEAT_ENABLE _IOW_BAD('I',8,sizeof(short))
  12. #define REMOTE_IOC_SET_DEBUG_ENABLE _IOW_BAD('I',9,sizeof(short))
  13. #define REMOTE_IOC_SET_MODE _IOW_BAD('I',10,sizeof(short))
  14. #define REMOTE_IOC_SET_RELEASE_DELAY _IOW_BAD('I',99,sizeof(short))
  15. #define REMOTE_IOC_SET_CUSTOMCODE _IOW_BAD('I',100,sizeof(short))
  16. //reg
  17. #define REMOTE_IOC_SET_REG_BASE_GEN _IOW_BAD('I',101,sizeof(short))
  18. #define REMOTE_IOC_SET_REG_CONTROL _IOW_BAD('I',102,sizeof(short))
  19. #define REMOTE_IOC_SET_REG_LEADER_ACT _IOW_BAD('I',103,sizeof(short))
  20. #define REMOTE_IOC_SET_REG_LEADER_IDLE _IOW_BAD('I',104,sizeof(short))
  21. #define REMOTE_IOC_SET_REG_REPEAT_LEADER _IOW_BAD('I',105,sizeof(short))
  22. #define REMOTE_IOC_SET_REG_BIT0_TIME _IOW_BAD('I',106,sizeof(short))
  23. //sw
  24. #define REMOTE_IOC_SET_BIT_COUNT _IOW_BAD('I',107,sizeof(short))
  25. #define REMOTE_IOC_SET_TW_LEADER_ACT _IOW_BAD('I',108,sizeof(short))
  26. #define REMOTE_IOC_SET_TW_BIT0_TIME _IOW_BAD('I',109,sizeof(short))
  27. #define REMOTE_IOC_SET_TW_BIT1_TIME _IOW_BAD('I',110,sizeof(short))
  28. #define REMOTE_IOC_SET_TW_REPEATE_LEADER _IOW_BAD('I',111,sizeof(short))
  29. #define REMOTE_IOC_GET_TW_LEADER_ACT _IOR_BAD('I',112,sizeof(short))
  30. #define REMOTE_IOC_GET_TW_BIT0_TIME _IOR_BAD('I',113,sizeof(short))
  31. #define REMOTE_IOC_GET_TW_BIT1_TIME _IOR_BAD('I',114,sizeof(short))
  32. #define REMOTE_IOC_GET_TW_REPEATE_LEADER _IOR_BAD('I',115,sizeof(short))
  33. #define REMOTE_IOC_GET_REG_BASE_GEN _IOR_BAD('I',121,sizeof(short))
  34. #define REMOTE_IOC_GET_REG_CONTROL _IOR_BAD('I',122,sizeof(short))
  35. #define REMOTE_IOC_GET_REG_LEADER_ACT _IOR_BAD('I',123,sizeof(short))
  36. #define REMOTE_IOC_GET_REG_LEADER_IDLE _IOR_BAD('I',124,sizeof(short))
  37. #define REMOTE_IOC_GET_REG_REPEAT_LEADER _IOR_BAD('I',125,sizeof(short))
  38. #define REMOTE_IOC_GET_REG_BIT0_TIME _IOR_BAD('I',126,sizeof(short))
  39. #define REMOTE_IOC_GET_REG_FRAME_DATA _IOR_BAD('I',127,sizeof(short))
  40. #define REMOTE_IOC_GET_REG_FRAME_STATUS _IOR_BAD('I',128,sizeof(short))
  41. #define REMOTE_IOC_SET_TW_BIT2_TIME _IOW_BAD('I',129,sizeof(short))
  42. #define REMOTE_IOC_SET_TW_BIT3_TIME _IOW_BAD('I',130,sizeof(short))
  43. #define REMOTE_HW_DECODER_STATUS_MASK (0xf<<4)
  44. #define REMOTE_HW_DECODER_STATUS_OK (0<<4)
  45. #define REMOTE_HW_DECODER_STATUS_TIMEOUT (1<<4)
  46. #define REMOTE_HW_DECODER_STATUS_LEADERERR (2<<4)
  47. #define REMOTE_HW_DECODER_STATUS_REPEATERR (3<<4)
  48. #define REMOTE_HW_PATTERN_MASK (0xf<<4)
  49. #define REMOTE_HW_NEC_PATTERN (0x0<<4)
  50. #define REMOTE_HW_TOSHIBA_PATTERN (0x1<<4)
  51. #define REMOTE_SW_RC6_PATTERN (0x2<<4)
  52. #define REMOTE_SW_RC5_PATTERN (0x3<<4)
  53. #define REMOTE_WORK_MODE_SW (0)
  54. #define REMOTE_WORK_MODE_HW (1)
  55. #define REMOTE_WORK_MODE_FIQ (2)
  56. #define REMOTE_WORK_MODE_INV (3)
  57. #define REMOTE_WORK_MODE_MASK (7)
  58. #define REMOTE_WORK_MODE_FIQ_RCMM (4)
  59. #define REMOTE_TOSHIBA_HW (REMOTE_HW_TOSHIBA_PATTERN|REMOTE_WORK_MODE_HW)
  60. #define REMOTE_NEC_HW (REMOTE_HW_NEC_PATTERN|REMOTE_WORK_MODE_HW)
  61. #define REMOTE_WORK_MODE_RC6 (REMOTE_SW_RC6_PATTERN|REMOTE_WORK_MODE_FIQ)
  62. #define REMOTE_WORK_MODE_RC5 (REMOTE_SW_RC5_PATTERN|REMOTE_WORK_MODE_FIQ)
  63. #define REMOTE_STATUS_WAIT 0
  64. #define REMOTE_STATUS_LEADER 1
  65. #define REMOTE_STATUS_DATA 2
  66. #define REMOTE_STATUS_SYNC 3
  67. #define REMOTE_LOG_BUF_LEN 8192
  68. #define REMOTE_LOG_BUF_ORDER 1
  69. static unsigned int g_remote_base;
  70. #define AM_IR_DEC_LDR_ACTIVE 0x0
  71. #define AM_IR_DEC_LDR_IDLE 0x4
  72. #define AM_IR_DEC_LDR_REPEAT 0x8
  73. #define AM_IR_DEC_BIT_0 0xc
  74. #define AM_IR_DEC_REG0 0x10
  75. #define AM_IR_DEC_FRAME 0x14
  76. #define AM_IR_DEC_STATUS 0x18
  77. #define AM_IR_DEC_REG1 0x1c
  78. #define am_remote_write_reg(x,val) aml_write_reg32(g_remote_base +x ,val)
  79. #define am_remote_read_reg(x) aml_read_reg32(g_remote_base +x)
  80. #define am_remote_set_mask(x,val) aml_set_reg32_mask(g_remote_base +x,val)
  81. #define am_remote_clear_mask(x,val) aml_clr_reg32_mask(g_remote_base +x,val)
  82. typedef int (*type_printk)(const char *fmt, ...);
  83. struct remote {
  84. struct input_dev *input;
  85. struct timer_list timer;
  86. struct timer_list repeat_timer;
  87. unsigned long repeat_tick;
  88. int irq;
  89. int work_mode;
  90. unsigned int cur_keycode;
  91. unsigned int repeate_flag;
  92. unsigned int repeat_enable;
  93. unsigned int debounce;
  94. unsigned int custom_code;
  95. unsigned int release_delay;
  96. unsigned int debug_enable;
  97. //sw
  98. unsigned int delay;
  99. unsigned int step;
  100. unsigned int send_data;
  101. bridge_item_t fiq_handle_item;
  102. unsigned int bit_count;
  103. unsigned int bit_num;
  104. unsigned int last_jiffies;
  105. unsigned int time_window[12];
  106. int last_pulse_width;
  107. int repeat_time_count;
  108. //config
  109. int config_major;
  110. char config_name[20];
  111. struct class *config_class;
  112. struct device *config_dev;
  113. unsigned int repeat_delay;
  114. unsigned int repeat_peroid;
  115. };
  116. extern type_printk input_dbg;
  117. extern irqreturn_t remote_bridge_isr(int irq, void *dev_id);
  118. extern irqreturn_t remote_rc5_bridge_isr(int irq, void *dev_id);
  119. extern irqreturn_t remote_rc6_bridge_isr(int irq, void *dev_id);
  120. extern int register_fiq_bridge_handle(bridge_item_t * c_item);
  121. extern int unregister_fiq_bridge_handle(bridge_item_t * c_item);
  122. extern int fiq_bridge_pulse_trigger(bridge_item_t * c_item);
  123. void remote_sw_reprot_key(unsigned long data);
  124. extern void remote_rc5_reprot_key(unsigned long data);
  125. extern void remote_rc6_reprot_key(unsigned long data);
  126. void remote_send_key(struct input_dev *dev, unsigned int scancode,
  127. unsigned int type);
  128. #endif //_REMOTE_H