usf.h 8.3 KB

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