si_mdt_inputdev.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. SiI8348 Linux Driver
  3. Copyright (C) 2013 Silicon Image, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as
  6. published by the Free Software Foundation version 2.
  7. This program is distributed AS-IS WITHOUT ANY WARRANTY of any
  8. kind, whether express or implied; INCLUDING without the implied warranty
  9. of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE or NON-INFRINGEMENT. See
  10. the GNU General Public License for more details at http://www.gnu.org/licenses/gpl-2.0.html.
  11. */
  12. /*
  13. @file si_mdt_inputdev.h
  14. */
  15. #ifndef _SI_MDT_INPUTDEV_H_
  16. #define _SI_MDT_INPUTDEV_H_
  17. #define HID_INPUT_REPORT 7
  18. #define MAX_TOUCH_CONTACTS 4
  19. /* MDT header byte bit definitions */
  20. #define REGISTRATION_SUCCESS 0
  21. #define REGISTRATION_ERROR 1
  22. #define KEY_PRESSED 1
  23. #define KEY_RELEASED 0
  24. #define MDT_TOUCH_INACTIVE 1
  25. #define MDT_TOUCH_ACTIVE 2
  26. /* Common header bit definitions */
  27. #define MDT_HDR_IS_HID 0x80
  28. #define MDT_HDR_IS_PORT_B 0x40
  29. #define MDT_HDR_IS_KEYBOARD 0x20
  30. #define MDT_HDR_IS_NOT_LAST 0x10
  31. #define MDT_HDR_IS_NOT_MOUSE 0x08
  32. /* Keyboard event specific header bit definitions */
  33. #define MDT_HDR_KBD_LEFT_ALT 0x04
  34. #define MDT_HDR_KBD_LEFT_SHIFT 0x02
  35. #define MDT_HDR_KBD_LEFT_CTRL 0x01
  36. /* Mouse event specific header bit definitions */
  37. #define MDT_HDR_MOUSE_BUTTON_3 0x04
  38. #define MDT_HDR_MOUSE_BUTTON_2 0x02
  39. #define MDT_HDR_MOUSE_BUTTON_1 0x01
  40. #define MDT_HDR_MOUSE_BUTTON_MASK 0x07
  41. /* Touch pad event specific header bit definitions */
  42. #define MDT_HDR_TOUCH_IS_TOUCHED 0x01
  43. #define MDT_HDR_TOUCH_CONTACT_ID_MASK 0x06
  44. /* Game controller event specific header bit definitions */
  45. #define MDT_HDR_GAME_BUTTON_3 0x04
  46. #define MDT_HDR_GAME_BUTTON_2 0x02
  47. #define MDT_HDR_GAME_BUTTON_1 0x01
  48. /* MDT hot-plug prefix and event information */
  49. #define MDT_VERSION 1
  50. #define M_CHAR 'M'
  51. #define D_CHAR 'D'
  52. #define T_CHAR 'T'
  53. #define NOTICE_DEV_PLUG 'R'
  54. #define NOTICE_DEV_UNPLUG 'U'
  55. #define RESPONSE_ACK 'A'
  56. #define RESPONSE_NACK 'N'
  57. /* MDT Touch screen resources and parameters */
  58. #define MDT_TOUCH_X 0
  59. #define MDT_TOUCH_Y 1
  60. #define BYTE_LOW 0
  61. #define BYTE_HIGH 1
  62. #define MDT_TOUCH_X_LOW BYTE_LOW
  63. #define MDT_TOUCH_X_HIGH BYTE_HIGH
  64. #define MDT_TOUCH_Y_LOW BYTE_LOW
  65. #define MDT_TOUCH_Y_HIGH BYTE_HIGH
  66. /* support 11 bit absolute addressing */
  67. #define X_CORNER_RIGHT_LOWER 1870
  68. #define Y_CORNER_RIGHT_LOWER 1870
  69. #define ICS_BeagleboardxM 1
  70. #define X_MAX 1920
  71. #define Y_MAX 1920
  72. #define SCALE_X_RAW 0
  73. #define SCALE_X_SCREEN 0
  74. #define SCALE_Y_RAW 0
  75. #define SCALE_Y_SCREEN 0
  76. #define X_SHIFT 0
  77. #define Y_SHIFT 0
  78. #define SWAP_LEFTRIGHT 0
  79. #define SWAP_UPDOWN 0
  80. #define SWAP_XY 0
  81. #define SINGLE_TOUCH 1
  82. #define CORNER_BUTTON 1
  83. #define ICS_BAR 0
  84. #define RIGHT_MOUSE_BUTTON_IS_ESC 1
  85. /* requires installation of IDC file */
  86. //#define KERNEL_2_6_38_AND_LATER
  87. /* as of JB the IDC file is needed but, doesn't
  88. guarantee acess to virtual buttons. */
  89. #define JB_421 0
  90. #if (JB_421 == 1)
  91. #define X_BUTTON_BAR_START 0x4F0
  92. #define Y_BUTTON_RECENTAPPS_TOP 0x050
  93. #define Y_BUTTON_RECENTAPPS_BOTTOM 0x165
  94. #define Y_BUTTON_HOME_TOP 0x185
  95. #define Y_BUTTON_HOME_BOTTOM 0x2C0
  96. #define Y_BUTTON_BACK_TOP 0x2E0
  97. #define Y_BUTTON_BACK_BOTTOM 0x3E0
  98. #endif
  99. enum mdt_dev_state_e {
  100. INPUT_DISABLED
  101. , INPUT_WAITING_FOR_REGISTRATION
  102. , INPUT_ACTIVE
  103. };
  104. enum mdt_dev_types_e {
  105. MDT_TYPE_MOUSE
  106. , MDT_TYPE_KEYBOARD
  107. , MDT_TYPE_TOUCHSCREEN
  108. #if 0
  109. , MDT_TYPE_GAME
  110. #endif
  111. , MDT_TYPE_COUNT
  112. };
  113. struct mdt_touch_history_t{
  114. uint32_t abs_x;
  115. uint32_t abs_y;
  116. uint8_t isTouched;
  117. uint8_t state;
  118. };
  119. struct mdt_inputdevs {
  120. uint8_t keycodes_old[HID_INPUT_REPORT]; /* Prior HID input report */
  121. uint8_t keycodes_new[HID_INPUT_REPORT]; /* Current HID input report */
  122. struct input_dev *dev_keyboard;
  123. struct input_dev *dev_mouse;
  124. struct input_dev *dev_touchscreen;
  125. uint8_t is_dev_registered[MDT_TYPE_COUNT]; /*Instance tracking variable*/
  126. struct mdt_touch_history_t prior_touch_events[MAX_TOUCH_CONTACTS];
  127. unsigned char prior_touch_button;
  128. #if (RIGHT_MOUSE_BUTTON_IS_ESC == 1)
  129. unsigned char prior_right_button;
  130. #endif
  131. /* ser overrides to allow runtime calibration*/
  132. uint32_t x_max, y_max;
  133. uint32_t x_screen, x_raw, x_shift;
  134. uint32_t y_screen, y_raw, y_shift;
  135. uint32_t swap_xy, swap_updown, swap_leftright;
  136. };
  137. struct keyboard_event_data {
  138. uint8_t first_key[3];
  139. uint8_t second_key[3];
  140. };
  141. struct mouse_event_data {
  142. int8_t x_displacement;
  143. int8_t y_displacement;
  144. int8_t z_displacement;
  145. uint8_t vendor_specific[2];
  146. uint8_t vendor_specific_game_flag;
  147. };
  148. struct touch_pad_event_data {
  149. uint8_t x_abs_coordinate[2];
  150. uint8_t y_abs_coordinate[2];
  151. uint8_t vendor_specific;
  152. uint8_t vendor_specific_game_flag;
  153. };
  154. struct gaming_controller {
  155. int8_t x_rel_displacement;
  156. int8_t y_rel_displacement;
  157. int8_t z_rel_displacement;
  158. int8_t y2_rel_displacement;
  159. uint8_t buttons_ext;
  160. uint8_t id_dpad;
  161. };
  162. struct mdt_hotplug_data {
  163. uint8_t sub_header_d;
  164. uint8_t sub_header_t;
  165. uint8_t event_code;
  166. uint8_t device_type;
  167. uint8_t mdt_version;
  168. uint8_t reserved;
  169. };
  170. struct mdt_packet {
  171. uint8_t adopter_id_h;
  172. uint8_t adopter_id_l;
  173. uint8_t header;
  174. union {
  175. struct keyboard_event_data keyboard;
  176. struct mouse_event_data mouse;
  177. struct touch_pad_event_data touch_pad;
  178. struct gaming_controller game_controller;
  179. struct mdt_hotplug_data hotplug;
  180. uint8_t bytes[6];
  181. } event;
  182. };
  183. struct mhl_dev_context;
  184. extern struct attribute_group mdt_attr_group;
  185. void mdt_toggle_keyboard_keycode(struct mhl_dev_context *dev_context
  186. ,unsigned char keycode);
  187. bool si_mhl_tx_mdt_process_packet(struct mhl_dev_context *dev_context,void *packet);
  188. //int mdt_init(struct mhl_dev_context *dev_context);
  189. void mdt_destroy(struct mhl_dev_context *dev_context);
  190. #endif /* #ifndef _SI_MDT_INPUTDEV_H_ */