• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #ifndef _TOUCH_OFFLOAD_H
3 #define _TOUCH_OFFLOAD_H
4 
5 #define TOUCH_OFFLOAD_MAGIC '7'
6 
7 /* Bus interface type */
8 #define BUS_TYPE_I2C 0
9 #define BUS_TYPE_SPI 1
10 #define BUS_TYPE_I3C 2
11 
12 /* Indicates full heatmap frame vs. partial */
13 #define HEATMAP_SIZE_PARTIAL  0
14 #define HEATMAP_SIZE_FULL     1
15 
16 /* Touch channel data types */
17 #define TOUCH_DATA_TYPE_COORD	  0x01
18 #define TOUCH_DATA_TYPE_RAW	  0x02
19 #define TOUCH_DATA_TYPE_FILTERED  0x04
20 #define TOUCH_DATA_TYPE_BASELINE  0x08
21 #define TOUCH_DATA_TYPE_STRENGTH  0x10
22 
23 /* Touch channel scan types */
24 #define TOUCH_SCAN_TYPE_MUTUAL	  0x40
25 #define TOUCH_SCAN_TYPE_SELF	  0x80
26 
27 
28 //////////////////////////////////////////////////////////////
29 
30 /* TouchOffloadCaps
31  *
32  * touch_offload_major_version - Major version for breaking changes
33  * touch_offload_minor_version - Minor version for small, compatible changes
34  * device_id - device-specific identifier
35  * display_width - width of device display in pixels
36  * display_height - height of device display in pixels
37  * tx_size - number of TX channels
38  * rx_size - number of RX channels
39  * bus_type - bus interface type
40  * bus_speed_hz - bus frequency
41  * heatmap_size - partial or full heatmap
42  * touch_data_scan_types - channel data types available
43  * touch_scan_types - channel scan types available
44  * continuous_reporting - driver supports continuous touch reports
45  * noise_reporting - driver supports noise status messages
46  * cancel_reporting - driver supports sending cancel events
47  * size_reporting - driver supports size information
48  * filter_grip - driver supports disabling underlying grip suppression
49  * filter_palm - driver supports disabling underlying palm rejection
50  * num_sensitivity_settings - number of sensitivity options provided
51  */
52 struct TouchOffloadCaps {
53 	/* Version info */
54 	__u32 touch_offload_major_version;
55 	__u32 touch_offload_minor_version;
56 	__u8 reserved1[8];
57 
58 	/* Device info */
59 	__u32 device_id;
60 	__u16 display_width;
61 	__u16 display_height;
62 	__u16 tx_size;
63 	__u16 rx_size;
64 	__u8 bus_type;
65 	__u32 bus_speed_hz;
66 	__u8 reserved2[16];
67 
68 	/* Algorithm info */
69 	__u8 heatmap_size;
70 	__u16 touch_data_types;
71 	__u16 touch_scan_types;
72 	__u8 reserved3[16];
73 
74 	/* Feature flags */
75 	__u8 continuous_reporting;
76 	__u8 noise_reporting;
77 	__u8 cancel_reporting;
78 	__u8 size_reporting;
79 	__u8 filter_grip;
80 	__u8 filter_palm;
81 	__u8 num_sensitivity_settings;
82 	__u8 reserved4[32];
83 };
84 
85 /* TouchOffloadConfig
86  *
87  * continuous_reporting - enable continuous touch reports
88  * noise_reporting - enable noise status messages
89  * cancel_reporting - enable cancel events
90  * filter_grip - enable underlying grip suppression
91  * filter_palm - enable underlying palm rejection
92  * num_sensitivity_settings - number of sensitivity options provided
93  * read_coords - allocate a channel to coordinate data
94  * mutual_data_types - bitfield of mutual data types to collect
95  * self_data_types - bitfield of self data types to collect
96  */
97 struct TouchOffloadConfig {
98 	/* Feature flags */
99 	__u8 continuous_reporting;
100 	__u8 noise_reporting;
101 	__u8 cancel_reporting;
102 	__u8 filter_grip;
103 	__u8 filter_palm;
104 	__u8 sensitivity_setting;
105 	__u8 reserved1[16];
106 
107 	/* Data to read */
108 	__u8 read_coords;
109 	__u16 mutual_data_types;
110 	__u16 self_data_types;
111 	__u8 reserved2[16];
112 };
113 
114 /* TouchOffloadFrameHeader
115  *
116  * frame_size - number of bytes in the frame
117  * index - unique, sequential frame index
118  * timestamp - frame timestamp in nanoseconds
119  * num_channels - number of channels included in the frame
120  */
121 struct TouchOffloadFrameHeader {
122 	__u32 frame_size;
123 	__u64 index;
124 	__u64 timestamp;
125 	__u8 num_channels;
126 } __attribute__((packed));
127 
128 /* TouchOffloadChannelHeader
129  *
130  * channel_type - touch type stored in the channel
131  * channel_size - size in bytes of the channel sample
132  */
133 struct TouchOffloadChannelHeader {
134 	__u8 channel_type;
135 	__u32 channel_size;
136 } __attribute__((packed));
137 
138 /* CoordStatus
139  *
140  * COORD_STATUS_INACTIVE - slot is unused
141  * COORD_STATUS_FINGER - normal finger touch
142  * COORD_STATUS_EDGE - edge touch
143  * COORD_STATUS_PALM - palm touch
144  * COORD_STATUS_CANCEL - canceled touch
145  */
146 enum CoordStatus {
147 	COORD_STATUS_INACTIVE = 0x00,
148 	COORD_STATUS_FINGER = 0x01,
149 	COORD_STATUS_EDGE = 0x02,
150 	COORD_STATUS_PALM = 0x03,
151 	COORD_STATUS_CANCEL = 0x04
152 };
153 
154 /* Maximum number of touches that are tracked simultaneously */
155 #define MAX_COORDS 10
156 
157 /* TouchOffloadCoord
158  *
159  * x - x component of touch location
160  * y - y component of touch location
161  * status - type of touch
162  * major - size of the larger axis of the touch blob
163  * minor - size of the smaller axis of the touch blob
164  * pressure - z-axis or force exerted on touch touch point
165  */
166 struct TouchOffloadCoord {
167 	__u16 x;
168 	__u16 y;
169 	enum CoordStatus status;
170 	__u32 major;
171 	__u32 minor;
172 	__u32 pressure;
173 	__u8 reserved1[16];
174 } __attribute__((packed));
175 
176 /* TouchOffloadDataCoord
177  *
178  * header - header shared by all channels in a frame
179  * coords - array of MAX_COORD coordinates
180  */
181 struct TouchOffloadDataCoord {
182 	struct TouchOffloadChannelHeader header;
183 	struct TouchOffloadCoord coords[MAX_COORDS];
184 	__u8 reserved1[16];
185 } __attribute__((packed));
186 #define TOUCH_OFFLOAD_FRAME_SIZE_COORD (sizeof(struct TouchOffloadDataCoord))
187 
188 /* TouchOffloadData2d
189  *
190  * header - header shared by all channels in a frame
191  * tx_size - number of tx channels
192  * rx_size - number of rx channels
193  * data - pointer to raw touch data buffer
194  */
195 struct TouchOffloadData2d {
196 	struct TouchOffloadChannelHeader header;
197 	__u16 tx_size;
198 	__u16 rx_size;
199 	__u8 reserved1[16];
200 	__u8 data[1];
201 } __attribute__((packed));
202 #define TOUCH_OFFLOAD_DATA_SIZE_2D(rx, tx) (sizeof(__u16)*(rx)*(tx))
203 #define TOUCH_OFFLOAD_FRAME_SIZE_2D(rx, tx) \
204 	(sizeof(struct TouchOffloadData2d) - 1 + \
205 	TOUCH_OFFLOAD_DATA_SIZE_2D((rx), (tx)))
206 
207 /* TouchOffloadData1d
208  *
209  * header - header shared by all channels in a frame
210  * tx_size - number of tx channels
211  * rx_size - number of rx channels
212  * data - pointer to raw touch data buffer
213  */
214 struct TouchOffloadData1d {
215 	struct TouchOffloadChannelHeader header;
216 	__u16 tx_size;
217 	__u16 rx_size;
218 	__u8 reserved1[16];
219 	__u8 data[1];
220 } __attribute__((packed));
221 #define TOUCH_OFFLOAD_DATA_SIZE_1D(rx, tx) (sizeof(__u16)*((rx)+(tx)))
222 #define TOUCH_OFFLOAD_FRAME_SIZE_1D(rx, tx) \
223 	(sizeof(struct TouchOffloadData1d) - 1 + \
224 	TOUCH_OFFLOAD_DATA_SIZE_1D((rx), (tx)))
225 
226 ////////////////////////////////////////////////////////////
227 
228 /* TouchOffloadIocGetCaps
229  *
230  * caps - capabilities provided by the touch driver
231  */
232 struct TouchOffloadIocGetCaps {
233 	struct TouchOffloadCaps caps;
234 	__u8 reserved1[16];
235 };
236 
237 /* TouchOffloadIocConfigure
238  *
239  * config - features to be used by the touch_offload client
240  */
241 struct TouchOffloadIocConfigure {
242 	struct TouchOffloadConfig config;
243 	__u8 reserved1[16];
244 };
245 
246 /* TouchOffloadIocReport
247  *
248  * index - unique, sequential frame index
249  * timestamp - frame timestamp in nanoseconds
250  * num_coords - number of coordinates contained in "coords"
251  * coords - array of coordinates to be reported to the driver
252  */
253 struct TouchOffloadIocReport {
254 	__u64 index;
255 	__u64 timestamp;
256 	__u8 num_coords;
257 	__u8 reserved1[16];
258 	struct TouchOffloadCoord coords[MAX_COORDS];
259 };
260 
261 /* Ioctl to retrieve the capabilities of the touch driver */
262 #define TOUCH_OFFLOAD_IOC_RD_GETCAPS \
263 	_IOR(TOUCH_OFFLOAD_MAGIC, 0, struct TouchOffloadIocGetCaps)
264 
265 /* Ioctl to set the configuration of the touch driver */
266 #define TOUCH_OFFLOAD_IOC_WR_CONFIGURE \
267 	_IOW(TOUCH_OFFLOAD_MAGIC, 1, struct TouchOffloadIocConfigure)
268 
269 /* Ioctl to start the touch_offload pipeline */
270 #define TOUCH_OFFLOAD_IOC_START _IOC(TOUCH_OFFLOAD_MAGIC, 2)
271 
272 /* Ioctl to report coordinates to the driver */
273 #define TOUCH_OFFLOAD_IOC_WR_REPORT \
274 	_IOW(TOUCH_OFFLOAD_MAGIC, 3, struct TouchOffloadIocReport)
275 
276 /* Ioctl to stop the touch_offload pipeline */
277 #define TOUCH_OFFLOAD_IOC_STOP _IOC(TOUCH_OFFLOAD_MAGIC, 4)
278 
279 #endif /* _TOUCH_OFFLOAD_H */
280