blob: faf50d2b3c8cc958e0c10ded7c44f940270d433b [file] [log] [blame]
Lior Barenboim69539fb2013-12-25 18:38:31 +02001/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +02002 *
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
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +020036#define US_SET_DETECTION _IOWR(USF_IOCTL_MAGIC, 8, \
37 struct us_detect_info_type)
38
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +020039#define US_GET_VERSION _IOWR(USF_IOCTL_MAGIC, 9, \
40 struct us_version_info_type)
41
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +020042/* 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
49/* US detection place (HW|FW) */
50enum us_detect_place_enum {
51/* US is detected in HW */
52 US_DETECT_HW,
53/* US is detected in FW */
54 US_DETECT_FW
55};
56
57/* US detection mode */
58enum us_detect_mode_enum {
59/* US detection is disabled */
60 US_DETECT_DISABLED_MODE,
61/* US detection is enabled in continue mode */
62 US_DETECT_CONTINUE_MODE,
63/* US detection is enabled in one shot mode */
64 US_DETECT_SHOT_MODE
65};
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020066
67/* Encoder (TX), decoder (RX) supported US data formats */
68#define USF_POINT_EPOS_FORMAT 0
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +020069#define USF_RAW_FORMAT 1
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020070
Baruch Eruchimovitchcf5a4d12012-05-31 21:48:18 +030071/* Indexes of event types, produced by the calculators */
72#define USF_TSC_EVENT_IND 0
73#define USF_TSC_PTR_EVENT_IND 1
74#define USF_MOUSE_EVENT_IND 2
75#define USF_KEYBOARD_EVENT_IND 3
Ravit Dennis0c7e6032013-10-01 17:26:48 +030076#define USF_TSC_EXT_EVENT_IND 4
77#define USF_MAX_EVENT_IND 5
Baruch Eruchimovitchcf5a4d12012-05-31 21:48:18 +030078
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020079/* Types of events, produced by the calculators */
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +020080#define USF_NO_EVENT 0
Baruch Eruchimovitchcf5a4d12012-05-31 21:48:18 +030081#define USF_TSC_EVENT (1 << USF_TSC_EVENT_IND)
82#define USF_TSC_PTR_EVENT (1 << USF_TSC_PTR_EVENT_IND)
83#define USF_MOUSE_EVENT (1 << USF_MOUSE_EVENT_IND)
84#define USF_KEYBOARD_EVENT (1 << USF_KEYBOARD_EVENT_IND)
Ravit Dennis0c7e6032013-10-01 17:26:48 +030085#define USF_TSC_EXT_EVENT (1 << USF_TSC_EXT_EVENT_IND)
Baruch Eruchimovitchcf5a4d12012-05-31 21:48:18 +030086#define USF_ALL_EVENTS (USF_TSC_EVENT |\
87 USF_TSC_PTR_EVENT |\
88 USF_MOUSE_EVENT |\
Ravit Dennis0c7e6032013-10-01 17:26:48 +030089 USF_KEYBOARD_EVENT |\
90 USF_TSC_EXT_EVENT)
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020091
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +020092/* min, max array dimension */
93#define MIN_MAX_DIM 2
94
95/* coordinates (x,y,z) array dimension */
96#define COORDINATES_DIM 3
97
98/* tilts (x,y) array dimension */
99#define TILTS_DIM 2
100
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200101/* Max size of the client name */
102#define USF_MAX_CLIENT_NAME_SIZE 20
Baruch Eruchimovitch64eb8da2013-04-08 14:33:17 +0300103
104/* Max number of the ports (mics/speakers) */
105#define USF_MAX_PORT_NUM 8
106
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200107/* Info structure common for TX and RX */
108struct us_xx_info_type {
109/* Input: general info */
110/* Name of the client - event calculator */
111 const char *client_name;
112/* Selected device identification, accepted in the kernel's CAD */
113 uint32_t dev_id;
114/* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
115 uint32_t stream_format;
116/* Required sample rate in Hz */
117 uint32_t sample_rate;
118/* Size of a buffer (bytes) for US data transfer between the module and USF */
119 uint32_t buf_size;
120/* Number of the buffers for the US data transfer */
121 uint16_t buf_num;
122/* Number of the microphones (TX) or speakers(RX) */
123 uint16_t port_cnt;
124/* Microphones(TX) or speakers(RX) indexes in their enumeration */
Baruch Eruchimovitch64eb8da2013-04-08 14:33:17 +0300125 uint8_t port_id[USF_MAX_PORT_NUM];
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200126/* Bits per sample 16 or 32 */
127 uint16_t bits_per_sample;
128/* Input: Transparent info for encoder in the LPASS */
129/* Parameters data size in bytes */
130 uint16_t params_data_size;
131/* Pointer to the parameters */
132 uint8_t *params_data;
133};
134
135struct us_input_info_type {
136 /* Touch screen dimensions: min & max;for input module */
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +0200137 int tsc_x_dim[MIN_MAX_DIM];
138 int tsc_y_dim[MIN_MAX_DIM];
139 int tsc_z_dim[MIN_MAX_DIM];
140 /* Touch screen tilt dimensions: min & max;for input module */
141 int tsc_x_tilt[MIN_MAX_DIM];
142 int tsc_y_tilt[MIN_MAX_DIM];
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200143 /* Touch screen pressure limits: min & max; for input module */
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +0200144 int tsc_pressure[MIN_MAX_DIM];
Lior Barenboim69539fb2013-12-25 18:38:31 +0200145 /* The requested buttons bitmap */
146 uint16_t req_buttons_bitmap;
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200147 /* Bitmap of types of events (USF_X_EVENT), produced by calculator */
148 uint16_t event_types;
Baruch Eruchimovitch1221b852012-04-02 11:21:30 +0300149 /* Bitmap of types of events from devs, conflicting with USF */
150 uint16_t conflicting_event_types;
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200151};
152
153struct us_tx_info_type {
154 /* Common info */
155 struct us_xx_info_type us_xx_info;
156 /* Info specific for TX*/
157 struct us_input_info_type input_info;
158};
159
160struct us_rx_info_type {
161 /* Common info */
162 struct us_xx_info_type us_xx_info;
163 /* Info specific for RX*/
164};
165
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200166struct point_event_type {
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +0200167/* Pen coordinates (x, y, z) in units, defined by <coordinates_type> */
168 int coordinates[COORDINATES_DIM];
169 /* {x;y} in transparent units */
170 int inclinations[TILTS_DIM];
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200171/* [0-1023] (10bits); 0 - pen up */
172 uint32_t pressure;
Lior Barenboim69539fb2013-12-25 18:38:31 +0200173/* Bitmap for button state. 1 - down, 0 - up */
174 uint16_t buttons_state_bitmap;
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200175};
176
177/* Mouse buttons, supported by USF */
178#define USF_BUTTON_LEFT_MASK 1
179#define USF_BUTTON_MIDDLE_MASK 2
180#define USF_BUTTON_RIGHT_MASK 4
181struct mouse_event_type {
182/* The mouse relative movement (dX, dY, dZ) */
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +0200183 int rels[COORDINATES_DIM];
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200184/* Bitmap of mouse buttons states: 1 - down, 0 - up; */
185 uint16_t buttons_states;
186};
187
188struct key_event_type {
189/* Calculated MS key- see input.h. */
190 uint32_t key;
191/* Keyboard's key state: 1 - down, 0 - up; */
192 uint8_t key_state;
193};
194
195struct usf_event_type {
196/* Event sequence number */
197 uint32_t seq_num;
198/* Event generation system time */
199 uint32_t timestamp;
Baruch Eruchimovitchcf5a4d12012-05-31 21:48:18 +0300200/* Destination input event type index (e.g. touch screen, mouse, key) */
201 uint16_t event_type_ind;
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200202 union {
203 struct point_event_type point_event;
204 struct mouse_event_type mouse_event;
205 struct key_event_type key_event;
206 } event_data;
207};
208
209struct us_tx_update_info_type {
210/* Input general: */
211/* Number of calculated events */
212 uint16_t event_counter;
213/* Calculated events or NULL */
214 struct usf_event_type *event;
215/* Pointer (read index) to the end of available region */
216/* in the shared US data memory */
217 uint32_t free_region;
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +0200218/* Time (sec) to wait for data or special values: */
219/* USF_NO_WAIT_TIMEOUT, USF_INFINITIVE_TIMEOUT, USF_DEFAULT_TIMEOUT */
220 uint32_t timeout;
Baruch Eruchimovitch1221b852012-04-02 11:21:30 +0300221/* Events (from conflicting devs) to be disabled/enabled */
222 uint16_t event_filters;
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +0200223
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200224/* Input transparent data: */
225/* Parameters size */
226 uint16_t params_data_size;
227/* Pointer to the parameters */
228 uint8_t *params_data;
229/* Output parameters: */
230/* Pointer (write index) to the end of ready US data region */
231/* in the shared memory */
232 uint32_t ready_region;
233};
234
235struct us_rx_update_info_type {
236/* Input general: */
237/* Pointer (write index) to the end of ready US data region */
238/* in the shared memory */
239 uint32_t ready_region;
240/* Input transparent data: */
241/* Parameters size */
242 uint16_t params_data_size;
243/* pPointer to the parameters */
244 uint8_t *params_data;
245/* Output parameters: */
246/* Pointer (read index) to the end of available region */
247/* in the shared US data memory */
248 uint32_t free_region;
249};
250
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +0200251struct us_detect_info_type {
252/* US detection place (HW|FW) */
253/* NA in the Active and OFF states */
254 enum us_detect_place_enum us_detector;
255/* US detection mode */
256 enum us_detect_mode_enum us_detect_mode;
257/* US data dropped during this time (msec) */
258 uint32_t skip_time;
259/* Transparent data size */
260 uint16_t params_data_size;
261/* Pointer to the transparent data */
262 uint8_t *params_data;
263/* Time (sec) to wait for US presence event */
264 uint32_t detect_timeout;
265/* Out parameter: US presence */
266 bool is_us;
267};
268
Baruch Eruchimovitchdac24742012-02-01 15:29:29 +0200269struct us_version_info_type {
270/* Size of memory for the version string */
271 uint16_t buf_size;
272/* Pointer to the memory for the version string */
273 char *pbuf;
274};
275
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200276#endif /* __USF_H__ */