usf.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef __USF_H__
  14. #define __USF_H__
  15. #include <linux/types.h>
  16. #include <linux/ioctl.h>
  17. #define USF_IOCTL_MAGIC 'U'
  18. #define US_SET_TX_INFO _IOW(USF_IOCTL_MAGIC, 0, \
  19. struct us_tx_info_type)
  20. #define US_START_TX _IO(USF_IOCTL_MAGIC, 1)
  21. #define US_GET_TX_UPDATE _IOWR(USF_IOCTL_MAGIC, 2, \
  22. struct us_tx_update_info_type)
  23. #define US_SET_RX_INFO _IOW(USF_IOCTL_MAGIC, 3, \
  24. struct us_rx_info_type)
  25. #define US_SET_RX_UPDATE _IOWR(USF_IOCTL_MAGIC, 4, \
  26. struct us_rx_update_info_type)
  27. #define US_START_RX _IO(USF_IOCTL_MAGIC, 5)
  28. #define US_STOP_TX _IO(USF_IOCTL_MAGIC, 6)
  29. #define US_STOP_RX _IO(USF_IOCTL_MAGIC, 7)
  30. #define US_SET_DETECTION _IOWR(USF_IOCTL_MAGIC, 8, \
  31. struct us_detect_info_type)
  32. #define US_GET_VERSION _IOWR(USF_IOCTL_MAGIC, 9, \
  33. struct us_version_info_type)
  34. #define US_SET_TX_STREAM_PARAM _IOW(USF_IOCTL_MAGIC, 10, \
  35. struct us_stream_param_type)
  36. #define US_GET_TX_STREAM_PARAM _IOWR(USF_IOCTL_MAGIC, 11, \
  37. struct us_stream_param_type)
  38. #define US_SET_RX_STREAM_PARAM _IOW(USF_IOCTL_MAGIC, 12, \
  39. struct us_stream_param_type)
  40. #define US_GET_RX_STREAM_PARAM _IOWR(USF_IOCTL_MAGIC, 13, \
  41. struct us_stream_param_type)
  42. /* Special timeout values */
  43. #define USF_NO_WAIT_TIMEOUT 0x00000000
  44. /* Infinitive */
  45. #define USF_INFINITIVE_TIMEOUT 0xffffffff
  46. /* Default value, used by the driver */
  47. #define USF_DEFAULT_TIMEOUT 0xfffffffe
  48. /* US detection place (HW|FW) */
  49. enum us_detect_place_enum {
  50. /* US is detected in HW */
  51. US_DETECT_HW,
  52. /* US is detected in FW */
  53. US_DETECT_FW
  54. };
  55. /* US detection mode */
  56. enum us_detect_mode_enum {
  57. /* US detection is disabled */
  58. US_DETECT_DISABLED_MODE,
  59. /* US detection is enabled in continue mode */
  60. US_DETECT_CONTINUE_MODE,
  61. /* US detection is enabled in one shot mode */
  62. US_DETECT_SHOT_MODE
  63. };
  64. /* Encoder (TX), decoder (RX) supported US data formats */
  65. #define USF_POINT_EPOS_FORMAT 0
  66. #define USF_RAW_FORMAT 1
  67. /* Indexes of event types, produced by the calculators */
  68. #define USF_TSC_EVENT_IND 0
  69. #define USF_TSC_PTR_EVENT_IND 1
  70. #define USF_MOUSE_EVENT_IND 2
  71. #define USF_KEYBOARD_EVENT_IND 3
  72. #define USF_TSC_EXT_EVENT_IND 4
  73. #define USF_MAX_EVENT_IND 5
  74. /* Types of events, produced by the calculators */
  75. #define USF_NO_EVENT 0
  76. #define USF_TSC_EVENT (1 << USF_TSC_EVENT_IND)
  77. #define USF_TSC_PTR_EVENT (1 << USF_TSC_PTR_EVENT_IND)
  78. #define USF_MOUSE_EVENT (1 << USF_MOUSE_EVENT_IND)
  79. #define USF_KEYBOARD_EVENT (1 << USF_KEYBOARD_EVENT_IND)
  80. #define USF_TSC_EXT_EVENT (1 << USF_TSC_EXT_EVENT_IND)
  81. #define USF_ALL_EVENTS (USF_TSC_EVENT |\
  82. USF_TSC_PTR_EVENT |\
  83. USF_MOUSE_EVENT |\
  84. USF_KEYBOARD_EVENT |\
  85. USF_TSC_EXT_EVENT)
  86. /* min, max array dimension */
  87. #define MIN_MAX_DIM 2
  88. /* coordinates (x,y,z) array dimension */
  89. #define COORDINATES_DIM 3
  90. /* tilts (x,y) array dimension */
  91. #define TILTS_DIM 2
  92. /* Max size of the client name */
  93. #define USF_MAX_CLIENT_NAME_SIZE 20
  94. /* Max number of the ports (mics/speakers) */
  95. #define USF_MAX_PORT_NUM 8
  96. /* Info structure common for TX and RX */
  97. struct us_xx_info_type {
  98. /* Input: general info */
  99. /* Name of the client - event calculator */
  100. const char __user *client_name;
  101. /* Selected device identification, accepted in the kernel's CAD */
  102. uint32_t dev_id;
  103. /* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
  104. uint32_t stream_format;
  105. /* Required sample rate in Hz */
  106. uint32_t sample_rate;
  107. /* Size of a buffer (bytes) for US data transfer between the module and USF */
  108. uint32_t buf_size;
  109. /* Number of the buffers for the US data transfer */
  110. uint16_t buf_num;
  111. /* Number of the microphones (TX) or speakers(RX) */
  112. uint16_t port_cnt;
  113. /* Microphones(TX) or speakers(RX) indexes in their enumeration */
  114. uint8_t port_id[USF_MAX_PORT_NUM];
  115. /* Bits per sample 16 or 32 */
  116. uint16_t bits_per_sample;
  117. /* Input: Transparent info for encoder in the LPASS */
  118. /* Parameters data size in bytes */
  119. uint16_t params_data_size;
  120. /* Pointer to the parameters */
  121. uint8_t __user *params_data;
  122. /* Max size of buffer for get and set parameter */
  123. uint32_t max_get_set_param_buf_size;
  124. };
  125. struct us_input_info_type {
  126. /* Touch screen dimensions: min & max;for input module */
  127. int tsc_x_dim[MIN_MAX_DIM];
  128. int tsc_y_dim[MIN_MAX_DIM];
  129. int tsc_z_dim[MIN_MAX_DIM];
  130. /* Touch screen tilt dimensions: min & max;for input module */
  131. int tsc_x_tilt[MIN_MAX_DIM];
  132. int tsc_y_tilt[MIN_MAX_DIM];
  133. /* Touch screen pressure limits: min & max; for input module */
  134. int tsc_pressure[MIN_MAX_DIM];
  135. /* The requested buttons bitmap */
  136. uint16_t req_buttons_bitmap;
  137. /* Bitmap of types of events (USF_X_EVENT), produced by calculator */
  138. uint16_t event_types;
  139. /* Bitmap of types of events from devs, conflicting with USF */
  140. uint16_t conflicting_event_types;
  141. };
  142. struct us_tx_info_type {
  143. /* Common info */
  144. struct us_xx_info_type us_xx_info;
  145. /* Info specific for TX*/
  146. struct us_input_info_type input_info;
  147. };
  148. struct us_rx_info_type {
  149. /* Common info */
  150. struct us_xx_info_type us_xx_info;
  151. /* Info specific for RX*/
  152. };
  153. struct point_event_type {
  154. /* Pen coordinates (x, y, z) in units, defined by <coordinates_type> */
  155. int coordinates[COORDINATES_DIM];
  156. /* {x;y} in transparent units */
  157. int inclinations[TILTS_DIM];
  158. /* [0-1023] (10bits); 0 - pen up */
  159. uint32_t pressure;
  160. /* Bitmap for button state. 1 - down, 0 - up */
  161. uint16_t buttons_state_bitmap;
  162. };
  163. /* Mouse buttons, supported by USF */
  164. #define USF_BUTTON_LEFT_MASK 1
  165. #define USF_BUTTON_MIDDLE_MASK 2
  166. #define USF_BUTTON_RIGHT_MASK 4
  167. struct mouse_event_type {
  168. /* The mouse relative movement (dX, dY, dZ) */
  169. int rels[COORDINATES_DIM];
  170. /* Bitmap of mouse buttons states: 1 - down, 0 - up; */
  171. uint16_t buttons_states;
  172. };
  173. struct key_event_type {
  174. /* Calculated MS key- see input.h. */
  175. uint32_t key;
  176. /* Keyboard's key state: 1 - down, 0 - up; */
  177. uint8_t key_state;
  178. };
  179. struct usf_event_type {
  180. /* Event sequence number */
  181. uint32_t seq_num;
  182. /* Event generation system time */
  183. uint32_t timestamp;
  184. /* Destination input event type index (e.g. touch screen, mouse, key) */
  185. uint16_t event_type_ind;
  186. union {
  187. struct point_event_type point_event;
  188. struct mouse_event_type mouse_event;
  189. struct key_event_type key_event;
  190. } event_data;
  191. };
  192. struct us_tx_update_info_type {
  193. /* Input general: */
  194. /* Number of calculated events */
  195. uint16_t event_counter;
  196. /* Calculated events or NULL */
  197. struct usf_event_type __user *event;
  198. /* Pointer (read index) to the end of available region */
  199. /* in the shared US data memory */
  200. uint32_t free_region;
  201. /* Time (sec) to wait for data or special values: */
  202. /* USF_NO_WAIT_TIMEOUT, USF_INFINITIVE_TIMEOUT, USF_DEFAULT_TIMEOUT */
  203. uint32_t timeout;
  204. /* Events (from conflicting devs) to be disabled/enabled */
  205. uint16_t event_filters;
  206. /* Input transparent data: */
  207. /* Parameters size */
  208. uint16_t params_data_size;
  209. /* Pointer to the parameters */
  210. uint8_t __user *params_data;
  211. /* Output parameters: */
  212. /* Pointer (write index) to the end of ready US data region */
  213. /* in the shared memory */
  214. uint32_t ready_region;
  215. };
  216. struct us_rx_update_info_type {
  217. /* Input general: */
  218. /* Pointer (write index) to the end of ready US data region */
  219. /* in the shared memory */
  220. uint32_t ready_region;
  221. /* Input transparent data: */
  222. /* Parameters size */
  223. uint16_t params_data_size;
  224. /* pPointer to the parameters */
  225. uint8_t __user *params_data;
  226. /* Output parameters: */
  227. /* Pointer (read index) to the end of available region */
  228. /* in the shared US data memory */
  229. uint32_t free_region;
  230. };
  231. struct us_detect_info_type {
  232. /* US detection place (HW|FW) */
  233. /* NA in the Active and OFF states */
  234. enum us_detect_place_enum us_detector;
  235. /* US detection mode */
  236. enum us_detect_mode_enum us_detect_mode;
  237. /* US data dropped during this time (msec) */
  238. uint32_t skip_time;
  239. /* Transparent data size */
  240. uint16_t params_data_size;
  241. /* Pointer to the transparent data */
  242. uint8_t __user *params_data;
  243. /* Time (sec) to wait for US presence event */
  244. uint32_t detect_timeout;
  245. /* Out parameter: US presence */
  246. bool is_us;
  247. };
  248. struct us_version_info_type {
  249. /* Size of memory for the version string */
  250. uint16_t buf_size;
  251. /* Pointer to the memory for the version string */
  252. char __user *pbuf;
  253. };
  254. struct us_stream_param_type {
  255. /* Id of module */
  256. uint32_t module_id;
  257. /* Id of parameter */
  258. uint32_t param_id;
  259. /* Size of memory of the parameter buffer */
  260. uint32_t buf_size;
  261. /* Pointer to the memory of the parameter buffer */
  262. uint8_t __user *pbuf;
  263. };
  264. #endif /* __USF_H__ */