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