]>
Commit | Line | Data |
---|---|---|
5519cab4 BT |
1 | /* |
2 | * HID driver for multitouch panels | |
3 | * | |
c2ef8f21 | 4 | * Copyright (c) 2010-2012 Stephane Chatty <[email protected]> |
b0a78681 | 5 | * Copyright (c) 2010-2013 Benjamin Tissoires <[email protected]> |
c2ef8f21 | 6 | * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France |
b0a78681 | 7 | * Copyright (c) 2012-2013 Red Hat, Inc |
5519cab4 | 8 | * |
4875ac11 RN |
9 | * This code is partly based on hid-egalax.c: |
10 | * | |
11 | * Copyright (c) 2010 Stephane Chatty <[email protected]> | |
12 | * Copyright (c) 2010 Henrik Rydberg <[email protected]> | |
13 | * Copyright (c) 2010 Canonical, Ltd. | |
14 | * | |
f786bba4 BT |
15 | * This code is partly based on hid-3m-pct.c: |
16 | * | |
17 | * Copyright (c) 2009-2010 Stephane Chatty <[email protected]> | |
18 | * Copyright (c) 2010 Henrik Rydberg <[email protected]> | |
19 | * Copyright (c) 2010 Canonical, Ltd. | |
20 | * | |
5519cab4 BT |
21 | */ |
22 | ||
23 | /* | |
24 | * This program is free software; you can redistribute it and/or modify it | |
25 | * under the terms of the GNU General Public License as published by the Free | |
26 | * Software Foundation; either version 2 of the License, or (at your option) | |
27 | * any later version. | |
28 | */ | |
29 | ||
b0a78681 | 30 | /* |
f146d1c4 | 31 | * This driver is regularly tested thanks to the test suite in hid-tools[1]. |
b0a78681 BT |
32 | * Please run these regression tests before patching this module so that |
33 | * your patch won't break existing known devices. | |
34 | * | |
f146d1c4 | 35 | * [1] https://gitlab.freedesktop.org/libevdev/hid-tools |
b0a78681 BT |
36 | */ |
37 | ||
5519cab4 BT |
38 | #include <linux/device.h> |
39 | #include <linux/hid.h> | |
40 | #include <linux/module.h> | |
41 | #include <linux/slab.h> | |
5519cab4 | 42 | #include <linux/input/mt.h> |
29cc309d | 43 | #include <linux/jiffies.h> |
49a5a827 | 44 | #include <linux/string.h> |
4f4001bc | 45 | #include <linux/timer.h> |
5519cab4 BT |
46 | |
47 | ||
48 | MODULE_AUTHOR("Stephane Chatty <[email protected]>"); | |
ef2fafb3 | 49 | MODULE_AUTHOR("Benjamin Tissoires <[email protected]>"); |
5519cab4 BT |
50 | MODULE_DESCRIPTION("HID multitouch panels"); |
51 | MODULE_LICENSE("GPL"); | |
52 | ||
53 | #include "hid-ids.h" | |
54 | ||
55 | /* quirks to control the device */ | |
fd911896 BT |
56 | #define MT_QUIRK_NOT_SEEN_MEANS_UP BIT(0) |
57 | #define MT_QUIRK_SLOT_IS_CONTACTID BIT(1) | |
58 | #define MT_QUIRK_CYPRESS BIT(2) | |
59 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER BIT(3) | |
60 | #define MT_QUIRK_ALWAYS_VALID BIT(4) | |
61 | #define MT_QUIRK_VALID_IS_INRANGE BIT(5) | |
62 | #define MT_QUIRK_VALID_IS_CONFIDENCE BIT(6) | |
63 | #define MT_QUIRK_CONFIDENCE BIT(7) | |
64 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE BIT(8) | |
65 | #define MT_QUIRK_NO_AREA BIT(9) | |
66 | #define MT_QUIRK_IGNORE_DUPLICATES BIT(10) | |
67 | #define MT_QUIRK_HOVERING BIT(11) | |
68 | #define MT_QUIRK_CONTACT_CNT_ACCURATE BIT(12) | |
69 | #define MT_QUIRK_FORCE_GET_FEATURE BIT(13) | |
70 | #define MT_QUIRK_FIX_CONST_CONTACT_ID BIT(14) | |
71 | #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) | |
4f4001bc | 72 | #define MT_QUIRK_STICKY_FINGERS BIT(16) |
957b8dff | 73 | #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) |
d9c57a70 | 74 | #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) |
5519cab4 | 75 | |
9abebedb AD |
76 | #define MT_INPUTMODE_TOUCHSCREEN 0x02 |
77 | #define MT_INPUTMODE_TOUCHPAD 0x03 | |
78 | ||
2c6e0277 SF |
79 | #define MT_BUTTONTYPE_CLICKPAD 0 |
80 | ||
02946f4b BT |
81 | enum latency_mode { |
82 | HID_LATENCY_NORMAL = 0, | |
83 | HID_LATENCY_HIGH = 1, | |
84 | }; | |
85 | ||
4f4001bc | 86 | #define MT_IO_FLAGS_RUNNING 0 |
96098274 BT |
87 | #define MT_IO_FLAGS_ACTIVE_SLOTS 1 |
88 | #define MT_IO_FLAGS_PENDING_SLOTS 2 | |
4f4001bc | 89 | |
01eaac7e BT |
90 | static const bool mtrue = true; /* default for true */ |
91 | static const bool mfalse; /* default for false */ | |
92 | static const __s32 mzero; /* default for 0 */ | |
93 | ||
94 | #define DEFAULT_TRUE ((void *)&mtrue) | |
95 | #define DEFAULT_FALSE ((void *)&mfalse) | |
96 | #define DEFAULT_ZERO ((void *)&mzero) | |
97 | ||
98 | struct mt_usages { | |
99 | struct list_head list; | |
100 | __s32 *x, *y, *cx, *cy, *p, *w, *h, *a; | |
101 | __s32 *contactid; /* the device ContactID assigned to this slot */ | |
102 | bool *tip_state; /* is the touch valid? */ | |
103 | bool *inrange_state; /* is the finger in proximity of the sensor? */ | |
104 | bool *confidence_state; /* is the touch made by a finger? */ | |
5519cab4 BT |
105 | }; |
106 | ||
f146d1c4 BT |
107 | struct mt_application { |
108 | struct list_head list; | |
109 | unsigned int application; | |
01eaac7e | 110 | struct list_head mt_usages; /* mt usages list */ |
3ceb3826 BT |
111 | |
112 | __s32 quirks; | |
113 | ||
01eaac7e BT |
114 | __s32 *scantime; /* scantime reported */ |
115 | __s32 scantime_logical_max; /* max value for raw scantime */ | |
f146d1c4 | 116 | |
01eaac7e | 117 | __s32 *raw_cc; /* contact count in the report */ |
f146d1c4 BT |
118 | int left_button_state; /* left button state */ |
119 | unsigned int mt_flags; /* flags to pass to input-mt */ | |
120 | ||
28a042a3 DT |
121 | unsigned long *pending_palm_slots; /* slots where we reported palm |
122 | * and need to release */ | |
123 | ||
f146d1c4 BT |
124 | __u8 num_received; /* how many contacts we received */ |
125 | __u8 num_expected; /* expected last contact index */ | |
126 | __u8 buttons_count; /* number of physical buttons per touchpad */ | |
127 | __u8 touches_by_report; /* how many touches are present in one report: | |
128 | * 1 means we should use a serial protocol | |
129 | * > 1 means hybrid (multitouch) protocol | |
130 | */ | |
131 | ||
132 | __s32 dev_time; /* the scan time provided by the device */ | |
133 | unsigned long jiffies; /* the frame's jiffies */ | |
134 | int timestamp; /* the timestamp to be sent */ | |
135 | int prev_scantime; /* scantime reported previously */ | |
136 | ||
137 | bool have_contact_count; | |
138 | }; | |
139 | ||
eec29e3d BT |
140 | struct mt_class { |
141 | __s32 name; /* MT_CLS */ | |
142 | __s32 quirks; | |
143 | __s32 sn_move; /* Signal/noise ratio for move events */ | |
144 | __s32 sn_width; /* Signal/noise ratio for width events */ | |
145 | __s32 sn_height; /* Signal/noise ratio for height events */ | |
146 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ | |
147 | __u8 maxcontacts; | |
c2ef8f21 | 148 | bool is_indirect; /* true for touchpads */ |
6aef704e | 149 | bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ |
eec29e3d BT |
150 | }; |
151 | ||
8dfe14b3 BT |
152 | struct mt_report_data { |
153 | struct list_head list; | |
154 | struct hid_report *report; | |
155 | struct mt_application *application; | |
156 | bool is_mt_collection; | |
157 | }; | |
158 | ||
5519cab4 | 159 | struct mt_device { |
eec29e3d | 160 | struct mt_class mtclass; /* our mt device class */ |
4f4001bc | 161 | struct timer_list release_timer; /* to release sticky fingers */ |
0ee32774 | 162 | struct hid_device *hdev; /* hid_device we're attached to */ |
4f4001bc | 163 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ |
7f81c8db | 164 | __u8 inputmode_value; /* InputMode HID feature value */ |
9498f954 | 165 | __u8 maxcontacts; |
2c6e0277 | 166 | bool is_buttonpad; /* is this device a button pad? */ |
76f5902a | 167 | bool serial_maybe; /* need to check for serial protocol */ |
f146d1c4 BT |
168 | |
169 | struct list_head applications; | |
8dfe14b3 | 170 | struct list_head reports; |
5519cab4 BT |
171 | }; |
172 | ||
f146d1c4 BT |
173 | static void mt_post_parse_default_settings(struct mt_device *td, |
174 | struct mt_application *app); | |
175 | static void mt_post_parse(struct mt_device *td, struct mt_application *app); | |
a69c5f8b | 176 | |
5519cab4 | 177 | /* classes of device behavior */ |
22408283 BT |
178 | #define MT_CLS_DEFAULT 0x0001 |
179 | ||
a062cc5a SC |
180 | #define MT_CLS_SERIAL 0x0002 |
181 | #define MT_CLS_CONFIDENCE 0x0003 | |
5e7ea11f BT |
182 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
183 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 | |
184 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 | |
185 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 | |
0fa9c616 | 186 | /* reserved 0x0008 */ |
b7ea95ff | 187 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
dc3e1d80 | 188 | #define MT_CLS_NSMU 0x000a |
0fa9c616 BT |
189 | /* reserved 0x0010 */ |
190 | /* reserved 0x0011 */ | |
f961bd35 | 191 | #define MT_CLS_WIN_8 0x0012 |
6aef704e | 192 | #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 |
504c932c | 193 | #define MT_CLS_WIN_8_DUAL 0x0014 |
22408283 BT |
194 | |
195 | /* vendor specific classes */ | |
196 | #define MT_CLS_3M 0x0101 | |
0fa9c616 | 197 | /* reserved 0x0102 */ |
22408283 | 198 | #define MT_CLS_EGALAX 0x0103 |
1b723e8d | 199 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
847672cd | 200 | #define MT_CLS_TOPSEED 0x0105 |
2258e863 | 201 | #define MT_CLS_PANASONIC 0x0106 |
77723e3b | 202 | #define MT_CLS_FLATFROG 0x0107 |
cdcd3ac4 JK |
203 | #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 |
204 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 | |
f3287a99 | 205 | #define MT_CLS_LG 0x010a |
957b8dff | 206 | #define MT_CLS_ASUS 0x010b |
da10bc25 | 207 | #define MT_CLS_VTL 0x0110 |
0e82232c | 208 | #define MT_CLS_GOOGLE 0x0111 |
843e475f | 209 | #define MT_CLS_RAZER_BLADE_STEALTH 0x0112 |
5519cab4 | 210 | |
9498f954 | 211 | #define MT_DEFAULT_MAXCONTACT 10 |
afbcb04c | 212 | #define MT_MAX_MAXCONTACT 250 |
9498f954 | 213 | |
29cc309d NB |
214 | /* |
215 | * Resync device and local timestamps after that many microseconds without | |
216 | * receiving data. | |
217 | */ | |
218 | #define MAX_TIMESTAMP_INTERVAL 1000000 | |
219 | ||
2c2110e9 HR |
220 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
221 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) | |
222 | ||
5519cab4 BT |
223 | /* |
224 | * these device-dependent functions determine what slot corresponds | |
225 | * to a valid contact that was just read. | |
226 | */ | |
227 | ||
01eaac7e BT |
228 | static int cypress_compute_slot(struct mt_application *application, |
229 | struct mt_usages *slot) | |
a3b5e577 | 230 | { |
01eaac7e BT |
231 | if (*slot->contactid != 0 || application->num_received == 0) |
232 | return *slot->contactid; | |
a3b5e577 BT |
233 | else |
234 | return -1; | |
235 | } | |
236 | ||
cf6d15d7 | 237 | static const struct mt_class mt_classes[] = { |
2d93666e | 238 | { .name = MT_CLS_DEFAULT, |
dc3e1d80 BT |
239 | .quirks = MT_QUIRK_ALWAYS_VALID | |
240 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
241 | { .name = MT_CLS_NSMU, | |
9498f954 | 242 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
a062cc5a SC |
243 | { .name = MT_CLS_SERIAL, |
244 | .quirks = MT_QUIRK_ALWAYS_VALID}, | |
22408283 BT |
245 | { .name = MT_CLS_CONFIDENCE, |
246 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, | |
5e7ea11f BT |
247 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
248 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
249 | MT_QUIRK_SLOT_IS_CONTACTID }, | |
22408283 BT |
250 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
251 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
252 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, | |
1e9cf35b | 253 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
2d93666e BT |
254 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
255 | MT_QUIRK_SLOT_IS_CONTACTID, | |
256 | .maxcontacts = 2 }, | |
1e9cf35b | 257 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2d93666e BT |
258 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
259 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | |
260 | .maxcontacts = 2 }, | |
b7ea95ff AT |
261 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
262 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | |
263 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, | |
f961bd35 BT |
264 | { .name = MT_CLS_WIN_8, |
265 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
266 | MT_QUIRK_IGNORE_DUPLICATES | | |
267 | MT_QUIRK_HOVERING | | |
4f4001bc | 268 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
d9c57a70 BT |
269 | MT_QUIRK_STICKY_FINGERS | |
270 | MT_QUIRK_WIN8_PTP_BUTTONS }, | |
6aef704e BT |
271 | { .name = MT_CLS_EXPORT_ALL_INPUTS, |
272 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
273 | MT_QUIRK_CONTACT_CNT_ACCURATE, | |
274 | .export_all_inputs = true }, | |
504c932c MO |
275 | { .name = MT_CLS_WIN_8_DUAL, |
276 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
277 | MT_QUIRK_IGNORE_DUPLICATES | | |
278 | MT_QUIRK_HOVERING | | |
d9c57a70 BT |
279 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
280 | MT_QUIRK_WIN8_PTP_BUTTONS, | |
504c932c | 281 | .export_all_inputs = true }, |
22408283 BT |
282 | |
283 | /* | |
284 | * vendor specific classes | |
285 | */ | |
286 | { .name = MT_CLS_3M, | |
287 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
e9d0a26d HC |
288 | MT_QUIRK_SLOT_IS_CONTACTID | |
289 | MT_QUIRK_TOUCH_SIZE_SCALING, | |
22408283 BT |
290 | .sn_move = 2048, |
291 | .sn_width = 128, | |
c5d40be5 HR |
292 | .sn_height = 128, |
293 | .maxcontacts = 60, | |
294 | }, | |
4875ac11 RN |
295 | { .name = MT_CLS_EGALAX, |
296 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
2261bb9f | 297 | MT_QUIRK_VALID_IS_INRANGE, |
4875ac11 RN |
298 | .sn_move = 4096, |
299 | .sn_pressure = 32, | |
300 | }, | |
1b723e8d BT |
301 | { .name = MT_CLS_EGALAX_SERIAL, |
302 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
303 | MT_QUIRK_ALWAYS_VALID, | |
4875ac11 RN |
304 | .sn_move = 4096, |
305 | .sn_pressure = 32, | |
306 | }, | |
847672cd BT |
307 | { .name = MT_CLS_TOPSEED, |
308 | .quirks = MT_QUIRK_ALWAYS_VALID, | |
309 | .is_indirect = true, | |
310 | .maxcontacts = 2, | |
311 | }, | |
2258e863 DK |
312 | { .name = MT_CLS_PANASONIC, |
313 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, | |
314 | .maxcontacts = 4 }, | |
f5ff4e1e XY |
315 | { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, |
316 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
317 | MT_QUIRK_VALID_IS_INRANGE | | |
7b226292 | 318 | MT_QUIRK_SLOT_IS_CONTACTID, |
f5ff4e1e XY |
319 | .maxcontacts = 2 |
320 | }, | |
321 | { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
322 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
7b226292 | 323 | MT_QUIRK_SLOT_IS_CONTACTID |
f5ff4e1e | 324 | }, |
043b403a | 325 | |
77723e3b HR |
326 | { .name = MT_CLS_FLATFROG, |
327 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
328 | MT_QUIRK_NO_AREA, | |
329 | .sn_move = 2048, | |
330 | .maxcontacts = 40, | |
331 | }, | |
f3287a99 BT |
332 | { .name = MT_CLS_LG, |
333 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
334 | MT_QUIRK_FIX_CONST_CONTACT_ID | | |
335 | MT_QUIRK_IGNORE_DUPLICATES | | |
336 | MT_QUIRK_HOVERING | | |
337 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
957b8dff JPRV |
338 | { .name = MT_CLS_ASUS, |
339 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
340 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
341 | MT_QUIRK_ASUS_CUSTOM_UP }, | |
da10bc25 MM |
342 | { .name = MT_CLS_VTL, |
343 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
344 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
345 | MT_QUIRK_FORCE_GET_FEATURE, | |
346 | }, | |
0e82232c WNH |
347 | { .name = MT_CLS_GOOGLE, |
348 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
349 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
350 | MT_QUIRK_SLOT_IS_CONTACTID | | |
351 | MT_QUIRK_HOVERING | |
352 | }, | |
843e475f BT |
353 | { .name = MT_CLS_RAZER_BLADE_STEALTH, |
354 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
355 | MT_QUIRK_IGNORE_DUPLICATES | | |
356 | MT_QUIRK_HOVERING | | |
357 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
358 | MT_QUIRK_WIN8_PTP_BUTTONS, | |
359 | }, | |
2d93666e | 360 | { } |
5519cab4 BT |
361 | }; |
362 | ||
eec29e3d BT |
363 | static ssize_t mt_show_quirks(struct device *dev, |
364 | struct device_attribute *attr, | |
365 | char *buf) | |
366 | { | |
ee79a8f8 | 367 | struct hid_device *hdev = to_hid_device(dev); |
eec29e3d BT |
368 | struct mt_device *td = hid_get_drvdata(hdev); |
369 | ||
370 | return sprintf(buf, "%u\n", td->mtclass.quirks); | |
371 | } | |
372 | ||
373 | static ssize_t mt_set_quirks(struct device *dev, | |
374 | struct device_attribute *attr, | |
375 | const char *buf, size_t count) | |
376 | { | |
ee79a8f8 | 377 | struct hid_device *hdev = to_hid_device(dev); |
eec29e3d | 378 | struct mt_device *td = hid_get_drvdata(hdev); |
f146d1c4 | 379 | struct mt_application *application; |
eec29e3d BT |
380 | |
381 | unsigned long val; | |
382 | ||
383 | if (kstrtoul(buf, 0, &val)) | |
384 | return -EINVAL; | |
385 | ||
386 | td->mtclass.quirks = val; | |
387 | ||
f146d1c4 | 388 | list_for_each_entry(application, &td->applications, list) { |
3ceb3826 BT |
389 | application->quirks = val; |
390 | if (!application->have_contact_count) | |
391 | application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; | |
f146d1c4 BT |
392 | } |
393 | ||
eec29e3d BT |
394 | return count; |
395 | } | |
396 | ||
397 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); | |
398 | ||
399 | static struct attribute *sysfs_attrs[] = { | |
400 | &dev_attr_quirks.attr, | |
401 | NULL | |
402 | }; | |
403 | ||
9182fb98 | 404 | static const struct attribute_group mt_attribute_group = { |
eec29e3d BT |
405 | .attrs = sysfs_attrs |
406 | }; | |
407 | ||
6d4f5440 MW |
408 | static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) |
409 | { | |
3064a03b AM |
410 | int ret; |
411 | u32 size = hid_report_len(report); | |
6d4f5440 MW |
412 | u8 *buf; |
413 | ||
414 | /* | |
b897f6db BT |
415 | * Do not fetch the feature report if the device has been explicitly |
416 | * marked as non-capable. | |
6d4f5440 | 417 | */ |
adaabbf4 | 418 | if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) |
6d4f5440 MW |
419 | return; |
420 | ||
421 | buf = hid_alloc_report_buf(report, GFP_KERNEL); | |
422 | if (!buf) | |
423 | return; | |
424 | ||
425 | ret = hid_hw_raw_request(hdev, report->id, buf, size, | |
426 | HID_FEATURE_REPORT, HID_REQ_GET_REPORT); | |
427 | if (ret < 0) { | |
428 | dev_warn(&hdev->dev, "failed to fetch feature %d\n", | |
429 | report->id); | |
430 | } else { | |
431 | ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf, | |
432 | size, 0); | |
433 | if (ret) | |
434 | dev_warn(&hdev->dev, "failed to report feature\n"); | |
435 | } | |
436 | ||
437 | kfree(buf); | |
438 | } | |
439 | ||
f635bd11 | 440 | static void mt_feature_mapping(struct hid_device *hdev, |
5519cab4 BT |
441 | struct hid_field *field, struct hid_usage *usage) |
442 | { | |
9498f954 BT |
443 | struct mt_device *td = hid_get_drvdata(hdev); |
444 | ||
445 | switch (usage->hid) { | |
9498f954 | 446 | case HID_DG_CONTACTMAX: |
6d4f5440 MW |
447 | mt_get_feature(hdev, field->report); |
448 | ||
9498f954 | 449 | td->maxcontacts = field->value[0]; |
afbcb04c BT |
450 | if (!td->maxcontacts && |
451 | field->logical_maximum <= MT_MAX_MAXCONTACT) | |
452 | td->maxcontacts = field->logical_maximum; | |
eec29e3d | 453 | if (td->mtclass.maxcontacts) |
9498f954 | 454 | /* check if the maxcontacts is given by the class */ |
eec29e3d | 455 | td->maxcontacts = td->mtclass.maxcontacts; |
9498f954 | 456 | |
2c6e0277 SF |
457 | break; |
458 | case HID_DG_BUTTONTYPE: | |
459 | if (usage->usage_index >= field->report_count) { | |
460 | dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); | |
461 | break; | |
462 | } | |
463 | ||
6d4f5440 | 464 | mt_get_feature(hdev, field->report); |
2c6e0277 SF |
465 | if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) |
466 | td->is_buttonpad = true; | |
467 | ||
9498f954 | 468 | break; |
45c5c682 BT |
469 | case 0xff0000c5: |
470 | /* Retrieve the Win8 blob once to enable some devices */ | |
471 | if (usage->usage_index == 0) | |
472 | mt_get_feature(hdev, field->report); | |
473 | break; | |
5519cab4 BT |
474 | } |
475 | } | |
476 | ||
477 | static void set_abs(struct input_dev *input, unsigned int code, | |
478 | struct hid_field *field, int snratio) | |
479 | { | |
480 | int fmin = field->logical_minimum; | |
481 | int fmax = field->logical_maximum; | |
482 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | |
483 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | |
37cf6e6f | 484 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
5519cab4 BT |
485 | } |
486 | ||
01eaac7e BT |
487 | static struct mt_usages *mt_allocate_usage(struct hid_device *hdev, |
488 | struct mt_application *application) | |
489 | { | |
490 | struct mt_usages *usage; | |
491 | ||
492 | usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); | |
493 | if (!usage) | |
494 | return NULL; | |
495 | ||
496 | /* set some defaults so we do not need to check for null pointers */ | |
497 | usage->x = DEFAULT_ZERO; | |
498 | usage->y = DEFAULT_ZERO; | |
499 | usage->cx = DEFAULT_ZERO; | |
500 | usage->cy = DEFAULT_ZERO; | |
501 | usage->p = DEFAULT_ZERO; | |
502 | usage->w = DEFAULT_ZERO; | |
503 | usage->h = DEFAULT_ZERO; | |
504 | usage->a = DEFAULT_ZERO; | |
505 | usage->contactid = DEFAULT_ZERO; | |
506 | usage->tip_state = DEFAULT_FALSE; | |
507 | usage->inrange_state = DEFAULT_FALSE; | |
508 | usage->confidence_state = DEFAULT_TRUE; | |
509 | ||
510 | list_add_tail(&usage->list, &application->mt_usages); | |
511 | ||
512 | return usage; | |
513 | } | |
514 | ||
f146d1c4 BT |
515 | static struct mt_application *mt_allocate_application(struct mt_device *td, |
516 | unsigned int application) | |
517 | { | |
518 | struct mt_application *mt_application; | |
519 | ||
520 | mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), | |
521 | GFP_KERNEL); | |
522 | if (!mt_application) | |
523 | return NULL; | |
524 | ||
525 | mt_application->application = application; | |
01eaac7e | 526 | INIT_LIST_HEAD(&mt_application->mt_usages); |
f146d1c4 BT |
527 | |
528 | if (application == HID_DG_TOUCHSCREEN) | |
529 | mt_application->mt_flags |= INPUT_MT_DIRECT; | |
530 | ||
531 | /* | |
532 | * Model touchscreens providing buttons as touchpads. | |
533 | */ | |
534 | if (application == HID_DG_TOUCHPAD) { | |
535 | mt_application->mt_flags |= INPUT_MT_POINTER; | |
536 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; | |
537 | } | |
538 | ||
01eaac7e BT |
539 | mt_application->scantime = DEFAULT_ZERO; |
540 | mt_application->raw_cc = DEFAULT_ZERO; | |
3ceb3826 | 541 | mt_application->quirks = td->mtclass.quirks; |
f146d1c4 BT |
542 | |
543 | list_add_tail(&mt_application->list, &td->applications); | |
544 | ||
545 | return mt_application; | |
546 | } | |
547 | ||
548 | static struct mt_application *mt_find_application(struct mt_device *td, | |
549 | unsigned int application) | |
550 | { | |
551 | struct mt_application *tmp, *mt_application = NULL; | |
552 | ||
553 | list_for_each_entry(tmp, &td->applications, list) { | |
554 | if (application == tmp->application) { | |
555 | mt_application = tmp; | |
556 | break; | |
557 | } | |
558 | } | |
559 | ||
560 | if (!mt_application) | |
561 | mt_application = mt_allocate_application(td, application); | |
562 | ||
563 | return mt_application; | |
564 | } | |
565 | ||
8dfe14b3 BT |
566 | static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, |
567 | struct hid_report *report) | |
568 | { | |
569 | struct mt_report_data *rdata; | |
570 | struct hid_field *field; | |
571 | int r, n; | |
572 | ||
573 | rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); | |
574 | if (!rdata) | |
575 | return NULL; | |
576 | ||
577 | rdata->report = report; | |
578 | rdata->application = mt_find_application(td, report->application); | |
579 | ||
580 | if (!rdata->application) { | |
581 | devm_kfree(&td->hdev->dev, rdata); | |
582 | return NULL; | |
583 | } | |
584 | ||
585 | for (r = 0; r < report->maxfield; r++) { | |
586 | field = report->field[r]; | |
587 | ||
588 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) | |
589 | continue; | |
590 | ||
591 | for (n = 0; n < field->report_count; n++) { | |
592 | if (field->usage[n].hid == HID_DG_CONTACTID) | |
593 | rdata->is_mt_collection = true; | |
594 | } | |
595 | } | |
596 | ||
597 | list_add_tail(&rdata->list, &td->reports); | |
598 | ||
599 | return rdata; | |
600 | } | |
601 | ||
602 | static struct mt_report_data *mt_find_report_data(struct mt_device *td, | |
603 | struct hid_report *report) | |
604 | { | |
605 | struct mt_report_data *tmp, *rdata = NULL; | |
606 | ||
607 | list_for_each_entry(tmp, &td->reports, list) { | |
608 | if (report == tmp->report) { | |
609 | rdata = tmp; | |
610 | break; | |
611 | } | |
612 | } | |
613 | ||
614 | if (!rdata) | |
615 | rdata = mt_allocate_report_data(td, report); | |
616 | ||
617 | return rdata; | |
618 | } | |
619 | ||
01eaac7e BT |
620 | static void mt_store_field(struct hid_device *hdev, |
621 | struct mt_application *application, | |
622 | __s32 *value, | |
623 | size_t offset) | |
ed9d5c96 | 624 | { |
01eaac7e BT |
625 | struct mt_usages *usage; |
626 | __s32 **target; | |
627 | ||
628 | if (list_empty(&application->mt_usages)) | |
629 | usage = mt_allocate_usage(hdev, application); | |
630 | else | |
631 | usage = list_last_entry(&application->mt_usages, | |
632 | struct mt_usages, | |
633 | list); | |
3ac36d15 | 634 | |
01eaac7e | 635 | if (!usage) |
3ac36d15 BT |
636 | return; |
637 | ||
01eaac7e BT |
638 | target = (__s32 **)((char *)usage + offset); |
639 | ||
640 | /* the value has already been filled, create a new slot */ | |
641 | if (*target != DEFAULT_TRUE && | |
642 | *target != DEFAULT_FALSE && | |
643 | *target != DEFAULT_ZERO) { | |
644 | usage = mt_allocate_usage(hdev, application); | |
645 | if (!usage) | |
646 | return; | |
647 | ||
648 | target = (__s32 **)((char *)usage + offset); | |
649 | } | |
650 | ||
651 | *target = value; | |
ed9d5c96 BT |
652 | } |
653 | ||
01eaac7e BT |
654 | #define MT_STORE_FIELD(__name) \ |
655 | mt_store_field(hdev, app, \ | |
656 | &field->value[usage->usage_index], \ | |
657 | offsetof(struct mt_usages, __name)) | |
658 | ||
a69c5f8b | 659 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
5519cab4 | 660 | struct hid_field *field, struct hid_usage *usage, |
f146d1c4 | 661 | unsigned long **bit, int *max, struct mt_application *app) |
5519cab4 BT |
662 | { |
663 | struct mt_device *td = hid_get_drvdata(hdev); | |
eec29e3d | 664 | struct mt_class *cls = &td->mtclass; |
c2ef8f21 | 665 | int code; |
349fd670 | 666 | struct hid_usage *prev_usage = NULL; |
4875ac11 | 667 | |
76f5902a HR |
668 | /* |
669 | * Model touchscreens providing buttons as touchpads. | |
c2ef8f21 | 670 | */ |
ba6b055e BT |
671 | if (field->application == HID_DG_TOUCHSCREEN && |
672 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { | |
f146d1c4 | 673 | app->mt_flags |= INPUT_MT_POINTER; |
9abebedb AD |
674 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; |
675 | } | |
c2ef8f21 | 676 | |
015fdaa9 BT |
677 | /* count the buttons on touchpads */ |
678 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) | |
f146d1c4 | 679 | app->buttons_count++; |
015fdaa9 | 680 | |
349fd670 BT |
681 | if (usage->usage_index) |
682 | prev_usage = &field->usage[usage->usage_index - 1]; | |
683 | ||
5519cab4 BT |
684 | switch (usage->hid & HID_USAGE_PAGE) { |
685 | ||
686 | case HID_UP_GENDESK: | |
687 | switch (usage->hid) { | |
688 | case HID_GD_X: | |
01eaac7e | 689 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
f146d1c4 | 690 | code = ABS_MT_TOOL_X; |
01eaac7e BT |
691 | MT_STORE_FIELD(cx); |
692 | } else { | |
f146d1c4 | 693 | code = ABS_MT_POSITION_X; |
01eaac7e BT |
694 | MT_STORE_FIELD(x); |
695 | } | |
349fd670 | 696 | |
f146d1c4 | 697 | set_abs(hi->input, code, field, cls->sn_move); |
01eaac7e | 698 | |
ba6b055e BT |
699 | /* |
700 | * A system multi-axis that exports X and Y has a high | |
701 | * chance of being used directly on a surface | |
702 | */ | |
703 | if (field->application == HID_GD_SYSTEM_MULTIAXIS) { | |
704 | __set_bit(INPUT_PROP_DIRECT, | |
705 | hi->input->propbit); | |
706 | input_set_abs_params(hi->input, | |
707 | ABS_MT_TOOL_TYPE, | |
708 | MT_TOOL_DIAL, | |
709 | MT_TOOL_DIAL, 0, 0); | |
710 | } | |
711 | ||
5519cab4 BT |
712 | return 1; |
713 | case HID_GD_Y: | |
01eaac7e | 714 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
f146d1c4 | 715 | code = ABS_MT_TOOL_Y; |
01eaac7e BT |
716 | MT_STORE_FIELD(cy); |
717 | } else { | |
f146d1c4 | 718 | code = ABS_MT_POSITION_Y; |
01eaac7e BT |
719 | MT_STORE_FIELD(y); |
720 | } | |
349fd670 | 721 | |
f146d1c4 | 722 | set_abs(hi->input, code, field, cls->sn_move); |
01eaac7e | 723 | |
5519cab4 BT |
724 | return 1; |
725 | } | |
726 | return 0; | |
727 | ||
728 | case HID_UP_DIGITIZER: | |
729 | switch (usage->hid) { | |
730 | case HID_DG_INRANGE: | |
3ceb3826 | 731 | if (app->quirks & MT_QUIRK_HOVERING) { |
9b3bb9b8 BT |
732 | input_set_abs_params(hi->input, |
733 | ABS_MT_DISTANCE, 0, 1, 0, 0); | |
734 | } | |
01eaac7e | 735 | MT_STORE_FIELD(inrange_state); |
5519cab4 BT |
736 | return 1; |
737 | case HID_DG_CONFIDENCE: | |
504c932c MO |
738 | if ((cls->name == MT_CLS_WIN_8 || |
739 | cls->name == MT_CLS_WIN_8_DUAL) && | |
f9024374 DT |
740 | (field->application == HID_DG_TOUCHPAD || |
741 | field->application == HID_DG_TOUCHSCREEN)) | |
3ceb3826 | 742 | app->quirks |= MT_QUIRK_CONFIDENCE; |
9152c7d7 DT |
743 | |
744 | if (app->quirks & MT_QUIRK_CONFIDENCE) | |
745 | input_set_abs_params(hi->input, | |
746 | ABS_MT_TOOL_TYPE, | |
747 | MT_TOOL_FINGER, | |
748 | MT_TOOL_PALM, 0, 0); | |
749 | ||
01eaac7e | 750 | MT_STORE_FIELD(confidence_state); |
5519cab4 BT |
751 | return 1; |
752 | case HID_DG_TIPSWITCH: | |
ba6b055e BT |
753 | if (field->application != HID_GD_SYSTEM_MULTIAXIS) |
754 | input_set_capability(hi->input, | |
755 | EV_KEY, BTN_TOUCH); | |
01eaac7e | 756 | MT_STORE_FIELD(tip_state); |
5519cab4 BT |
757 | return 1; |
758 | case HID_DG_CONTACTID: | |
01eaac7e | 759 | MT_STORE_FIELD(contactid); |
f146d1c4 | 760 | app->touches_by_report++; |
5519cab4 BT |
761 | return 1; |
762 | case HID_DG_WIDTH: | |
3ceb3826 | 763 | if (!(app->quirks & MT_QUIRK_NO_AREA)) |
77723e3b HR |
764 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, |
765 | cls->sn_width); | |
01eaac7e | 766 | MT_STORE_FIELD(w); |
5519cab4 BT |
767 | return 1; |
768 | case HID_DG_HEIGHT: | |
3ceb3826 | 769 | if (!(app->quirks & MT_QUIRK_NO_AREA)) { |
77723e3b HR |
770 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, |
771 | cls->sn_height); | |
00720277 WNH |
772 | |
773 | /* | |
774 | * Only set ABS_MT_ORIENTATION if it is not | |
775 | * already set by the HID_DG_AZIMUTH usage. | |
776 | */ | |
777 | if (!test_bit(ABS_MT_ORIENTATION, | |
778 | hi->input->absbit)) | |
779 | input_set_abs_params(hi->input, | |
780 | ABS_MT_ORIENTATION, 0, 1, 0, 0); | |
77723e3b | 781 | } |
01eaac7e | 782 | MT_STORE_FIELD(h); |
5519cab4 BT |
783 | return 1; |
784 | case HID_DG_TIPPRESSURE: | |
5519cab4 BT |
785 | set_abs(hi->input, ABS_MT_PRESSURE, field, |
786 | cls->sn_pressure); | |
01eaac7e | 787 | MT_STORE_FIELD(p); |
5519cab4 | 788 | return 1; |
29cc309d | 789 | case HID_DG_SCANTIME: |
29cc309d | 790 | input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); |
01eaac7e BT |
791 | app->scantime = &field->value[usage->usage_index]; |
792 | app->scantime_logical_max = field->logical_maximum; | |
29cc309d | 793 | return 1; |
5519cab4 | 794 | case HID_DG_CONTACTCOUNT: |
01eaac7e BT |
795 | app->have_contact_count = true; |
796 | app->raw_cc = &field->value[usage->usage_index]; | |
5519cab4 | 797 | return 1; |
00720277 | 798 | case HID_DG_AZIMUTH: |
00720277 WNH |
799 | /* |
800 | * Azimuth has the range of [0, MAX) representing a full | |
801 | * revolution. Set ABS_MT_ORIENTATION to a quarter of | |
802 | * MAX according the definition of ABS_MT_ORIENTATION | |
803 | */ | |
804 | input_set_abs_params(hi->input, ABS_MT_ORIENTATION, | |
805 | -field->logical_maximum / 4, | |
806 | field->logical_maximum / 4, | |
807 | cls->sn_move ? | |
808 | field->logical_maximum / cls->sn_move : 0, 0); | |
01eaac7e | 809 | MT_STORE_FIELD(a); |
00720277 | 810 | return 1; |
5519cab4 | 811 | case HID_DG_CONTACTMAX: |
01eaac7e | 812 | /* contact max are global to the report */ |
5519cab4 | 813 | return -1; |
c2ef8f21 BT |
814 | case HID_DG_TOUCH: |
815 | /* Legacy devices use TIPSWITCH and not TOUCH. | |
816 | * Let's just ignore this field. */ | |
817 | return -1; | |
65b258e9 | 818 | } |
5519cab4 BT |
819 | /* let hid-input decide for the others */ |
820 | return 0; | |
821 | ||
c2ef8f21 BT |
822 | case HID_UP_BUTTON: |
823 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); | |
594312b8 BT |
824 | /* |
825 | * MS PTP spec says that external buttons left and right have | |
826 | * usages 2 and 3. | |
827 | */ | |
3ceb3826 | 828 | if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
594312b8 BT |
829 | field->application == HID_DG_TOUCHPAD && |
830 | (usage->hid & HID_USAGE) > 1) | |
831 | code--; | |
ba6b055e BT |
832 | |
833 | if (field->application == HID_GD_SYSTEM_MULTIAXIS) | |
834 | code = BTN_0 + ((usage->hid - 1) & HID_USAGE); | |
835 | ||
c2ef8f21 BT |
836 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); |
837 | input_set_capability(hi->input, EV_KEY, code); | |
838 | return 1; | |
839 | ||
5519cab4 BT |
840 | case 0xff000000: |
841 | /* we do not want to map these: no input-oriented meaning */ | |
842 | return -1; | |
843 | } | |
844 | ||
845 | return 0; | |
846 | } | |
847 | ||
f146d1c4 | 848 | static int mt_compute_slot(struct mt_device *td, struct mt_application *app, |
01eaac7e | 849 | struct mt_usages *slot, |
f146d1c4 | 850 | struct input_dev *input) |
5519cab4 | 851 | { |
3ceb3826 | 852 | __s32 quirks = app->quirks; |
5519cab4 | 853 | |
2d93666e | 854 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
01eaac7e | 855 | return *slot->contactid; |
5519cab4 | 856 | |
2d93666e | 857 | if (quirks & MT_QUIRK_CYPRESS) |
01eaac7e | 858 | return cypress_compute_slot(app, slot); |
a3b5e577 | 859 | |
2d93666e | 860 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
f146d1c4 | 861 | return app->num_received; |
5572da08 | 862 | |
4a6ee685 | 863 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
01eaac7e | 864 | return *slot->contactid - 1; |
4a6ee685 | 865 | |
01eaac7e | 866 | return input_mt_get_slot_by_key(input, *slot->contactid); |
3e1b5015 HR |
867 | } |
868 | ||
28a042a3 DT |
869 | static void mt_release_pending_palms(struct mt_device *td, |
870 | struct mt_application *app, | |
871 | struct input_dev *input) | |
872 | { | |
873 | int slotnum; | |
874 | bool need_sync = false; | |
875 | ||
876 | for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { | |
877 | clear_bit(slotnum, app->pending_palm_slots); | |
878 | ||
879 | input_mt_slot(input, slotnum); | |
880 | input_mt_report_slot_state(input, MT_TOOL_PALM, false); | |
881 | ||
882 | need_sync = true; | |
883 | } | |
884 | ||
885 | if (need_sync) { | |
886 | input_mt_sync_frame(input); | |
887 | input_sync(input); | |
888 | } | |
889 | } | |
890 | ||
3e1b5015 HR |
891 | /* |
892 | * this function is called when a whole packet has been received and processed, | |
893 | * so that it can decide what to send to the input layer. | |
894 | */ | |
f146d1c4 BT |
895 | static void mt_sync_frame(struct mt_device *td, struct mt_application *app, |
896 | struct input_dev *input) | |
3e1b5015 | 897 | { |
3ceb3826 | 898 | if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) |
f146d1c4 | 899 | input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); |
127e71bd | 900 | |
76f5902a | 901 | input_mt_sync_frame(input); |
f146d1c4 | 902 | input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); |
5519cab4 | 903 | input_sync(input); |
28a042a3 DT |
904 | |
905 | mt_release_pending_palms(td, app, input); | |
906 | ||
f146d1c4 BT |
907 | app->num_received = 0; |
908 | app->left_button_state = 0; | |
909 | ||
96098274 BT |
910 | if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) |
911 | set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); | |
912 | else | |
913 | clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); | |
914 | clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); | |
5519cab4 BT |
915 | } |
916 | ||
01eaac7e | 917 | static int mt_compute_timestamp(struct mt_application *app, __s32 value) |
29cc309d | 918 | { |
f146d1c4 BT |
919 | long delta = value - app->prev_scantime; |
920 | unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); | |
29cc309d | 921 | |
f146d1c4 | 922 | app->jiffies = jiffies; |
29cc309d NB |
923 | |
924 | if (delta < 0) | |
01eaac7e | 925 | delta += app->scantime_logical_max; |
29cc309d NB |
926 | |
927 | /* HID_DG_SCANTIME is expressed in 100us, we want it in us. */ | |
928 | delta *= 100; | |
929 | ||
930 | if (jdelta > MAX_TIMESTAMP_INTERVAL) | |
931 | /* No data received for a while, resync the timestamp. */ | |
932 | return 0; | |
933 | else | |
f146d1c4 | 934 | return app->timestamp + delta; |
29cc309d NB |
935 | } |
936 | ||
a69c5f8b | 937 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
5519cab4 | 938 | struct hid_usage *usage, __s32 value) |
55978fa9 BT |
939 | { |
940 | /* we will handle the hidinput part later, now remains hiddev */ | |
941 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) | |
942 | hid->hiddev_hid_event(hid, field, usage, value); | |
943 | ||
944 | return 1; | |
945 | } | |
946 | ||
01eaac7e BT |
947 | static int mt_process_slot(struct mt_device *td, struct input_dev *input, |
948 | struct mt_application *app, | |
949 | struct mt_usages *slot) | |
5519cab4 | 950 | { |
01eaac7e | 951 | struct input_mt *mt = input->mt; |
3ceb3826 | 952 | __s32 quirks = app->quirks; |
01eaac7e BT |
953 | bool valid = true; |
954 | bool confidence_state = true; | |
955 | bool inrange_state = false; | |
956 | int active; | |
957 | int slotnum; | |
ba6b055e | 958 | int tool = MT_TOOL_FINGER; |
5519cab4 | 959 | |
01eaac7e BT |
960 | if (!slot) |
961 | return -EINVAL; | |
962 | ||
963 | if ((quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && | |
964 | app->num_received >= app->num_expected) | |
965 | return -EAGAIN; | |
966 | ||
967 | if (!(quirks & MT_QUIRK_ALWAYS_VALID)) { | |
968 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) | |
969 | valid = *slot->inrange_state; | |
970 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | |
971 | valid = *slot->tip_state; | |
972 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) | |
973 | valid = *slot->confidence_state; | |
974 | ||
975 | if (!valid) | |
976 | return 0; | |
977 | } | |
978 | ||
979 | slotnum = mt_compute_slot(td, app, slot, input); | |
980 | if (slotnum < 0 || slotnum >= td->maxcontacts) | |
981 | return 0; | |
982 | ||
983 | if ((quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { | |
984 | struct input_mt_slot *i_slot = &mt->slots[slotnum]; | |
985 | ||
986 | if (input_mt_is_active(i_slot) && | |
987 | input_mt_is_used(mt, i_slot)) | |
988 | return -EAGAIN; | |
989 | } | |
990 | ||
991 | if (quirks & MT_QUIRK_CONFIDENCE) | |
992 | confidence_state = *slot->confidence_state; | |
993 | ||
994 | if (quirks & MT_QUIRK_HOVERING) | |
995 | inrange_state = *slot->inrange_state; | |
996 | ||
9152c7d7 | 997 | active = *slot->tip_state || inrange_state; |
01eaac7e | 998 | |
ba6b055e BT |
999 | if (app->application == HID_GD_SYSTEM_MULTIAXIS) |
1000 | tool = MT_TOOL_DIAL; | |
28a042a3 | 1001 | else if (unlikely(!confidence_state)) { |
9152c7d7 | 1002 | tool = MT_TOOL_PALM; |
28a042a3 DT |
1003 | if (!active && |
1004 | input_mt_is_active(&mt->slots[slotnum])) { | |
1005 | /* | |
1006 | * The non-confidence was reported for | |
1007 | * previously valid contact that is also no | |
1008 | * longer valid. We can't simply report | |
1009 | * lift-off as userspace will not be aware | |
1010 | * of non-confidence, so we need to split | |
1011 | * it into 2 events: active MT_TOOL_PALM | |
1012 | * and a separate liftoff. | |
1013 | */ | |
1014 | active = true; | |
1015 | set_bit(slotnum, app->pending_palm_slots); | |
1016 | } | |
1017 | } | |
ba6b055e | 1018 | |
01eaac7e | 1019 | input_mt_slot(input, slotnum); |
ba6b055e | 1020 | input_mt_report_slot_state(input, tool, active); |
01eaac7e BT |
1021 | if (active) { |
1022 | /* this finger is in proximity of the sensor */ | |
1023 | int wide = (*slot->w > *slot->h); | |
1024 | int major = max(*slot->w, *slot->h); | |
1025 | int minor = min(*slot->w, *slot->h); | |
1026 | int orientation = wide; | |
1027 | int max_azimuth; | |
1028 | int azimuth; | |
1029 | ||
1030 | if (slot->a != DEFAULT_ZERO) { | |
00720277 WNH |
1031 | /* |
1032 | * Azimuth is counter-clockwise and ranges from [0, MAX) | |
1033 | * (a full revolution). Convert it to clockwise ranging | |
1034 | * [-MAX/2, MAX/2]. | |
1035 | * | |
1036 | * Note that ABS_MT_ORIENTATION require us to report | |
1037 | * the limit of [-MAX/4, MAX/4], but the value can go | |
1038 | * out of range to [-MAX/2, MAX/2] to report an upside | |
1039 | * down ellipsis. | |
1040 | */ | |
01eaac7e BT |
1041 | azimuth = *slot->a; |
1042 | max_azimuth = input_abs_get_max(input, | |
1043 | ABS_MT_ORIENTATION); | |
1044 | if (azimuth > max_azimuth * 2) | |
1045 | azimuth -= max_azimuth * 4; | |
1046 | orientation = -azimuth; | |
1047 | } | |
5519cab4 | 1048 | |
01eaac7e | 1049 | if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { |
9152c7d7 DT |
1050 | /* |
1051 | * divided by two to match visual scale of touch | |
1052 | * for devices with this quirk | |
1053 | */ | |
01eaac7e BT |
1054 | major = major >> 1; |
1055 | minor = minor >> 1; | |
1056 | } | |
55746d28 | 1057 | |
01eaac7e BT |
1058 | input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); |
1059 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); | |
1060 | input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); | |
1061 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); | |
1062 | input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); | |
1063 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, orientation); | |
1064 | input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); | |
1065 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); | |
1066 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); | |
1067 | ||
1068 | set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); | |
1069 | } | |
127e71bd | 1070 | |
01eaac7e BT |
1071 | return 0; |
1072 | } | |
1073 | ||
1074 | static void mt_process_mt_event(struct hid_device *hid, | |
1075 | struct mt_application *app, | |
1076 | struct hid_field *field, | |
1077 | struct hid_usage *usage, | |
1078 | __s32 value, | |
1079 | bool first_packet) | |
1080 | { | |
1081 | __s32 quirks = app->quirks; | |
1082 | struct input_dev *input = field->hidinput->input; | |
1083 | ||
1084 | if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) | |
1085 | return; | |
1086 | ||
1087 | if (quirks & MT_QUIRK_WIN8_PTP_BUTTONS) { | |
1088 | ||
1089 | /* | |
1090 | * For Win8 PTP touchpads we should only look at | |
1091 | * non finger/touch events in the first_packet of a | |
1092 | * (possible) multi-packet frame. | |
1093 | */ | |
1094 | if (!first_packet) | |
55978fa9 | 1095 | return; |
5519cab4 | 1096 | |
01eaac7e BT |
1097 | /* |
1098 | * For Win8 PTP touchpads we map both the clickpad click | |
1099 | * and any "external" left buttons to BTN_LEFT if a | |
1100 | * device claims to have both we need to report 1 for | |
1101 | * BTN_LEFT if either is pressed, so we or all values | |
1102 | * together and report the result in mt_sync_frame(). | |
1103 | */ | |
1104 | if (usage->type == EV_KEY && usage->code == BTN_LEFT) { | |
1105 | app->left_button_state |= value; | |
1106 | return; | |
54f4c0c3 | 1107 | } |
2d93666e | 1108 | } |
01eaac7e BT |
1109 | |
1110 | input_event(input, usage->type, usage->code, value); | |
55978fa9 | 1111 | } |
5519cab4 | 1112 | |
8dfe14b3 BT |
1113 | static void mt_touch_report(struct hid_device *hid, |
1114 | struct mt_report_data *rdata) | |
55978fa9 BT |
1115 | { |
1116 | struct mt_device *td = hid_get_drvdata(hid); | |
8dfe14b3 BT |
1117 | struct hid_report *report = rdata->report; |
1118 | struct mt_application *app = rdata->application; | |
55978fa9 | 1119 | struct hid_field *field; |
01eaac7e BT |
1120 | struct input_dev *input; |
1121 | struct mt_usages *slot; | |
55746d28 | 1122 | bool first_packet; |
55978fa9 | 1123 | unsigned count; |
f146d1c4 BT |
1124 | int r, n; |
1125 | int scantime = 0; | |
1126 | int contact_count = -1; | |
5519cab4 | 1127 | |
4f4001bc BT |
1128 | /* sticky fingers release in progress, abort */ |
1129 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) | |
1130 | return; | |
1131 | ||
01eaac7e BT |
1132 | scantime = *app->scantime; |
1133 | app->timestamp = mt_compute_timestamp(app, scantime); | |
1134 | if (app->raw_cc != DEFAULT_ZERO) | |
1135 | contact_count = *app->raw_cc; | |
1136 | ||
c2517f62 BT |
1137 | /* |
1138 | * Includes multi-packet support where subsequent | |
1139 | * packets are sent with zero contactcount. | |
1140 | */ | |
01eaac7e | 1141 | if (contact_count >= 0) { |
af8dc4d0 HG |
1142 | /* |
1143 | * For Win8 PTPs the first packet (td->num_received == 0) may | |
1144 | * have a contactcount of 0 if there only is a button event. | |
1145 | * We double check that this is not a continuation packet | |
1146 | * of a possible multi-packet frame be checking that the | |
1147 | * timestamp has changed. | |
1148 | */ | |
3ceb3826 | 1149 | if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
f146d1c4 BT |
1150 | app->num_received == 0 && |
1151 | app->prev_scantime != scantime) | |
1152 | app->num_expected = contact_count; | |
af8dc4d0 | 1153 | /* A non 0 contact count always indicates a first packet */ |
f146d1c4 BT |
1154 | else if (contact_count) |
1155 | app->num_expected = contact_count; | |
7e3cc447 | 1156 | } |
f146d1c4 | 1157 | app->prev_scantime = scantime; |
c2517f62 | 1158 | |
f146d1c4 | 1159 | first_packet = app->num_received == 0; |
01eaac7e BT |
1160 | |
1161 | input = report->field[0]->hidinput->input; | |
1162 | ||
1163 | list_for_each_entry(slot, &app->mt_usages, list) { | |
1164 | if (!mt_process_slot(td, input, app, slot)) | |
1165 | app->num_received++; | |
1166 | } | |
1167 | ||
55978fa9 BT |
1168 | for (r = 0; r < report->maxfield; r++) { |
1169 | field = report->field[r]; | |
1170 | count = field->report_count; | |
1171 | ||
1172 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) | |
1173 | continue; | |
1174 | ||
1175 | for (n = 0; n < count; n++) | |
01eaac7e BT |
1176 | mt_process_mt_event(hid, app, field, |
1177 | &field->usage[n], field->value[n], | |
1178 | first_packet); | |
55978fa9 | 1179 | } |
5b62efd8 | 1180 | |
f146d1c4 | 1181 | if (app->num_received >= app->num_expected) |
01eaac7e | 1182 | mt_sync_frame(td, app, input); |
4f4001bc BT |
1183 | |
1184 | /* | |
1185 | * Windows 8 specs says 2 things: | |
1186 | * - once a contact has been reported, it has to be reported in each | |
1187 | * subsequent report | |
1188 | * - the report rate when fingers are present has to be at least | |
1189 | * the refresh rate of the screen, 60 or 120 Hz | |
1190 | * | |
1191 | * I interprete this that the specification forces a report rate of | |
1192 | * at least 60 Hz for a touchscreen to be certified. | |
1193 | * Which means that if we do not get a report whithin 16 ms, either | |
1194 | * something wrong happens, either the touchscreen forgets to send | |
1195 | * a release. Taking a reasonable margin allows to remove issues | |
1196 | * with USB communication or the load of the machine. | |
1197 | * | |
1198 | * Given that Win 8 devices are forced to send a release, this will | |
1199 | * only affect laggish machines and the ones that have a firmware | |
1200 | * defect. | |
1201 | */ | |
3ceb3826 | 1202 | if (app->quirks & MT_QUIRK_STICKY_FINGERS) { |
96098274 BT |
1203 | if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) |
1204 | mod_timer(&td->release_timer, | |
1205 | jiffies + msecs_to_jiffies(100)); | |
1206 | else | |
1207 | del_timer(&td->release_timer); | |
1208 | } | |
4f4001bc BT |
1209 | |
1210 | clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); | |
5519cab4 BT |
1211 | } |
1212 | ||
b2c68a2f | 1213 | static int mt_touch_input_configured(struct hid_device *hdev, |
f146d1c4 BT |
1214 | struct hid_input *hi, |
1215 | struct mt_application *app) | |
a69c5f8b BT |
1216 | { |
1217 | struct mt_device *td = hid_get_drvdata(hdev); | |
1218 | struct mt_class *cls = &td->mtclass; | |
1219 | struct input_dev *input = hi->input; | |
b2c68a2f | 1220 | int ret; |
a69c5f8b BT |
1221 | |
1222 | if (!td->maxcontacts) | |
1223 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | |
1224 | ||
f146d1c4 | 1225 | mt_post_parse(td, app); |
a69c5f8b | 1226 | if (td->serial_maybe) |
f146d1c4 | 1227 | mt_post_parse_default_settings(td, app); |
a69c5f8b BT |
1228 | |
1229 | if (cls->is_indirect) | |
f146d1c4 | 1230 | app->mt_flags |= INPUT_MT_POINTER; |
a69c5f8b | 1231 | |
3ceb3826 | 1232 | if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
f146d1c4 | 1233 | app->mt_flags |= INPUT_MT_DROP_UNUSED; |
a69c5f8b | 1234 | |
015fdaa9 | 1235 | /* check for clickpads */ |
f146d1c4 BT |
1236 | if ((app->mt_flags & INPUT_MT_POINTER) && |
1237 | (app->buttons_count == 1)) | |
2c6e0277 SF |
1238 | td->is_buttonpad = true; |
1239 | ||
1240 | if (td->is_buttonpad) | |
015fdaa9 BT |
1241 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); |
1242 | ||
28a042a3 DT |
1243 | app->pending_palm_slots = devm_kcalloc(&hi->input->dev, |
1244 | BITS_TO_LONGS(td->maxcontacts), | |
1245 | sizeof(long), | |
1246 | GFP_KERNEL); | |
1247 | if (!app->pending_palm_slots) | |
1248 | return -ENOMEM; | |
1249 | ||
f146d1c4 | 1250 | ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); |
b2c68a2f DT |
1251 | if (ret) |
1252 | return ret; | |
a69c5f8b | 1253 | |
f146d1c4 | 1254 | app->mt_flags = 0; |
b2c68a2f | 1255 | return 0; |
a69c5f8b BT |
1256 | } |
1257 | ||
957b8dff JPRV |
1258 | #define mt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ |
1259 | max, EV_KEY, (c)) | |
a69c5f8b BT |
1260 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
1261 | struct hid_field *field, struct hid_usage *usage, | |
1262 | unsigned long **bit, int *max) | |
1263 | { | |
6aef704e | 1264 | struct mt_device *td = hid_get_drvdata(hdev); |
f146d1c4 | 1265 | struct mt_application *application; |
8dfe14b3 BT |
1266 | struct mt_report_data *rdata; |
1267 | ||
1268 | rdata = mt_find_report_data(td, field->report); | |
1269 | if (!rdata) { | |
1270 | hid_err(hdev, "failed to allocate data for report\n"); | |
1271 | return 0; | |
1272 | } | |
6aef704e | 1273 | |
8dfe14b3 | 1274 | application = rdata->application; |
3ceb3826 | 1275 | |
6aef704e BT |
1276 | /* |
1277 | * If mtclass.export_all_inputs is not set, only map fields from | |
1278 | * TouchScreen or TouchPad collections. We need to ignore fields | |
1279 | * that belong to other collections such as Mouse that might have | |
1280 | * the same GenericDesktop usages. | |
1281 | */ | |
1282 | if (!td->mtclass.export_all_inputs && | |
1283 | field->application != HID_DG_TOUCHSCREEN && | |
fa11aa72 | 1284 | field->application != HID_DG_PEN && |
8fe89ef0 BT |
1285 | field->application != HID_DG_TOUCHPAD && |
1286 | field->application != HID_GD_KEYBOARD && | |
e57f4e67 | 1287 | field->application != HID_GD_SYSTEM_CONTROL && |
1fbf74ef | 1288 | field->application != HID_CP_CONSUMER_CONTROL && |
957b8dff | 1289 | field->application != HID_GD_WIRELESS_RADIO_CTLS && |
ba6b055e | 1290 | field->application != HID_GD_SYSTEM_MULTIAXIS && |
957b8dff | 1291 | !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && |
3ceb3826 | 1292 | application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) |
6f492f28 | 1293 | return -1; |
a69c5f8b | 1294 | |
957b8dff JPRV |
1295 | /* |
1296 | * Some Asus keyboard+touchpad devices have the hotkeys defined in the | |
1297 | * touchpad report descriptor. We need to treat these as an array to | |
1298 | * map usages to input keys. | |
1299 | */ | |
39bbf402 | 1300 | if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && |
3ceb3826 | 1301 | application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && |
957b8dff JPRV |
1302 | (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { |
1303 | set_bit(EV_REP, hi->input->evbit); | |
1304 | if (field->flags & HID_MAIN_ITEM_VARIABLE) | |
1305 | field->flags &= ~HID_MAIN_ITEM_VARIABLE; | |
1306 | switch (usage->hid & HID_USAGE) { | |
1307 | case 0x10: mt_map_key_clear(KEY_BRIGHTNESSDOWN); break; | |
1308 | case 0x20: mt_map_key_clear(KEY_BRIGHTNESSUP); break; | |
1309 | case 0x35: mt_map_key_clear(KEY_DISPLAY_OFF); break; | |
1310 | case 0x6b: mt_map_key_clear(KEY_F21); break; | |
1311 | case 0x6c: mt_map_key_clear(KEY_SLEEP); break; | |
1312 | default: | |
1313 | return -1; | |
1314 | } | |
1315 | return 1; | |
1316 | } | |
1317 | ||
ba6b055e | 1318 | if (rdata->is_mt_collection) |
f146d1c4 BT |
1319 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max, |
1320 | application); | |
6aef704e | 1321 | |
7ffa13be BT |
1322 | /* |
1323 | * some egalax touchscreens have "application == DG_TOUCHSCREEN" | |
1324 | * for the stylus. Overwrite the hid_input application | |
1325 | */ | |
1326 | if (field->physical == HID_DG_STYLUS) | |
1327 | hi->application = HID_DG_STYLUS; | |
1328 | ||
6aef704e BT |
1329 | /* let hid-core decide for the others */ |
1330 | return 0; | |
a69c5f8b BT |
1331 | } |
1332 | ||
1333 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |
1334 | struct hid_field *field, struct hid_usage *usage, | |
1335 | unsigned long **bit, int *max) | |
1336 | { | |
ba6b055e BT |
1337 | struct mt_device *td = hid_get_drvdata(hdev); |
1338 | struct mt_report_data *rdata; | |
fa11aa72 | 1339 | |
ba6b055e BT |
1340 | rdata = mt_find_report_data(td, field->report); |
1341 | if (rdata && rdata->is_mt_collection) { | |
4cf56a89 DT |
1342 | /* We own these mappings, tell hid-input to ignore them */ |
1343 | return -1; | |
1344 | } | |
6aef704e BT |
1345 | |
1346 | /* let hid-core decide for the others */ | |
1347 | return 0; | |
a69c5f8b BT |
1348 | } |
1349 | ||
1350 | static int mt_event(struct hid_device *hid, struct hid_field *field, | |
1351 | struct hid_usage *usage, __s32 value) | |
1352 | { | |
1353 | struct mt_device *td = hid_get_drvdata(hid); | |
8dfe14b3 | 1354 | struct mt_report_data *rdata; |
a69c5f8b | 1355 | |
8dfe14b3 BT |
1356 | rdata = mt_find_report_data(td, field->report); |
1357 | if (rdata && rdata->is_mt_collection) | |
a69c5f8b BT |
1358 | return mt_touch_event(hid, field, usage, value); |
1359 | ||
e55f6200 | 1360 | return 0; |
a69c5f8b BT |
1361 | } |
1362 | ||
1363 | static void mt_report(struct hid_device *hid, struct hid_report *report) | |
1364 | { | |
1365 | struct mt_device *td = hid_get_drvdata(hid); | |
e55f6200 | 1366 | struct hid_field *field = report->field[0]; |
8dfe14b3 | 1367 | struct mt_report_data *rdata; |
a69c5f8b BT |
1368 | |
1369 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | |
1370 | return; | |
1371 | ||
8dfe14b3 BT |
1372 | rdata = mt_find_report_data(td, report); |
1373 | if (rdata && rdata->is_mt_collection) | |
1374 | return mt_touch_report(hid, rdata); | |
fa11aa72 | 1375 | |
e55f6200 BT |
1376 | if (field && field->hidinput && field->hidinput->input) |
1377 | input_sync(field->hidinput->input); | |
5519cab4 BT |
1378 | } |
1379 | ||
7f81c8db BT |
1380 | static bool mt_need_to_apply_feature(struct hid_device *hdev, |
1381 | struct hid_field *field, | |
02946f4b BT |
1382 | struct hid_usage *usage, |
1383 | enum latency_mode latency, | |
1384 | bool surface_switch, | |
ec6adef5 BT |
1385 | bool button_switch, |
1386 | bool *inputmode_found) | |
5519cab4 BT |
1387 | { |
1388 | struct mt_device *td = hid_get_drvdata(hdev); | |
da10bc25 | 1389 | struct mt_class *cls = &td->mtclass; |
7f81c8db BT |
1390 | struct hid_report *report = field->report; |
1391 | unsigned int index = usage->usage_index; | |
da10bc25 | 1392 | char *buf; |
3064a03b | 1393 | u32 report_len; |
7f81c8db | 1394 | int max; |
5519cab4 | 1395 | |
7f81c8db BT |
1396 | switch (usage->hid) { |
1397 | case HID_DG_INPUTMODE: | |
ec6adef5 BT |
1398 | /* |
1399 | * Some elan panels wrongly declare 2 input mode features, | |
1400 | * and silently ignore when we set the value in the second | |
1401 | * field. Skip the second feature and hope for the best. | |
1402 | */ | |
1403 | if (*inputmode_found) | |
1404 | return false; | |
1405 | ||
da10bc25 | 1406 | if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { |
7f81c8db BT |
1407 | report_len = hid_report_len(report); |
1408 | buf = hid_alloc_report_buf(report, GFP_KERNEL); | |
da10bc25 | 1409 | if (!buf) { |
7f81c8db BT |
1410 | hid_err(hdev, |
1411 | "failed to allocate buffer for report\n"); | |
1412 | return false; | |
da10bc25 | 1413 | } |
7f81c8db | 1414 | hid_hw_raw_request(hdev, report->id, buf, report_len, |
da10bc25 MM |
1415 | HID_FEATURE_REPORT, |
1416 | HID_REQ_GET_REPORT); | |
1417 | kfree(buf); | |
1418 | } | |
5519cab4 | 1419 | |
7f81c8db | 1420 | field->value[index] = td->inputmode_value; |
ec6adef5 | 1421 | *inputmode_found = true; |
7f81c8db | 1422 | return true; |
31ae9bdd | 1423 | |
7f81c8db | 1424 | case HID_DG_CONTACTMAX: |
3ceb3826 | 1425 | if (cls->maxcontacts) { |
7f81c8db | 1426 | max = min_t(int, field->logical_maximum, |
3ceb3826 | 1427 | cls->maxcontacts); |
7f81c8db BT |
1428 | if (field->value[index] != max) { |
1429 | field->value[index] = max; | |
1430 | return true; | |
1431 | } | |
1432 | } | |
1433 | break; | |
02946f4b BT |
1434 | |
1435 | case HID_DG_LATENCYMODE: | |
1436 | field->value[index] = latency; | |
99c703ac | 1437 | return true; |
02946f4b BT |
1438 | |
1439 | case HID_DG_SURFACESWITCH: | |
1440 | field->value[index] = surface_switch; | |
99c703ac | 1441 | return true; |
02946f4b BT |
1442 | |
1443 | case HID_DG_BUTTONSWITCH: | |
1444 | field->value[index] = button_switch; | |
99c703ac | 1445 | return true; |
7f81c8db | 1446 | } |
31ae9bdd | 1447 | |
7f81c8db BT |
1448 | return false; /* no need to update the report */ |
1449 | } | |
31ae9bdd | 1450 | |
02946f4b BT |
1451 | static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, |
1452 | bool surface_switch, bool button_switch) | |
7f81c8db BT |
1453 | { |
1454 | struct hid_report_enum *rep_enum; | |
1455 | struct hid_report *rep; | |
1456 | struct hid_usage *usage; | |
1457 | int i, j; | |
1458 | bool update_report; | |
ec6adef5 | 1459 | bool inputmode_found = false; |
7f81c8db BT |
1460 | |
1461 | rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; | |
1462 | list_for_each_entry(rep, &rep_enum->report_list, list) { | |
1463 | update_report = false; | |
1464 | ||
1465 | for (i = 0; i < rep->maxfield; i++) { | |
1466 | /* Ignore if report count is out of bounds. */ | |
1467 | if (rep->field[i]->report_count < 1) | |
1468 | continue; | |
1469 | ||
1470 | for (j = 0; j < rep->field[i]->maxusage; j++) { | |
1471 | usage = &rep->field[i]->usage[j]; | |
1472 | ||
1473 | if (mt_need_to_apply_feature(hdev, | |
1474 | rep->field[i], | |
02946f4b BT |
1475 | usage, |
1476 | latency, | |
1477 | surface_switch, | |
ec6adef5 BT |
1478 | button_switch, |
1479 | &inputmode_found)) | |
7f81c8db BT |
1480 | update_report = true; |
1481 | } | |
31ae9bdd | 1482 | } |
7f81c8db BT |
1483 | |
1484 | if (update_report) | |
1485 | hid_hw_request(hdev, rep, HID_REQ_SET_REPORT); | |
31ae9bdd BT |
1486 | } |
1487 | } | |
1488 | ||
f146d1c4 BT |
1489 | static void mt_post_parse_default_settings(struct mt_device *td, |
1490 | struct mt_application *app) | |
4fa3a583 | 1491 | { |
3ceb3826 | 1492 | __s32 quirks = app->quirks; |
4fa3a583 HR |
1493 | |
1494 | /* unknown serial device needs special quirks */ | |
01eaac7e | 1495 | if (list_is_singular(&app->mt_usages)) { |
4fa3a583 HR |
1496 | quirks |= MT_QUIRK_ALWAYS_VALID; |
1497 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | |
1498 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | |
1499 | quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; | |
e0bb8f9a | 1500 | quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
4fa3a583 HR |
1501 | } |
1502 | ||
3ceb3826 | 1503 | app->quirks = quirks; |
4fa3a583 HR |
1504 | } |
1505 | ||
f146d1c4 | 1506 | static void mt_post_parse(struct mt_device *td, struct mt_application *app) |
3ac36d15 | 1507 | { |
01eaac7e | 1508 | if (!app->have_contact_count) |
3ceb3826 | 1509 | app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
3ac36d15 BT |
1510 | } |
1511 | ||
b2c68a2f | 1512 | static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
76f5902a HR |
1513 | { |
1514 | struct mt_device *td = hid_get_drvdata(hdev); | |
c08d46aa BT |
1515 | char *name; |
1516 | const char *suffix = NULL; | |
8dfe14b3 | 1517 | struct mt_report_data *rdata; |
f146d1c4 | 1518 | struct mt_application *mt_application = NULL; |
40ec2603 | 1519 | struct hid_report *report; |
b2c68a2f | 1520 | int ret; |
76f5902a | 1521 | |
40ec2603 | 1522 | list_for_each_entry(report, &hi->reports, hidinput_list) { |
8dfe14b3 BT |
1523 | rdata = mt_find_report_data(td, report); |
1524 | if (!rdata) { | |
1525 | hid_err(hdev, "failed to allocate data for report\n"); | |
1526 | return -ENOMEM; | |
1527 | } | |
1528 | ||
1529 | mt_application = rdata->application; | |
f146d1c4 | 1530 | |
8dfe14b3 | 1531 | if (rdata->is_mt_collection) { |
f146d1c4 BT |
1532 | ret = mt_touch_input_configured(hdev, hi, |
1533 | mt_application); | |
40ec2603 BT |
1534 | if (ret) |
1535 | return ret; | |
1536 | } | |
b2c68a2f | 1537 | } |
76f5902a | 1538 | |
7ffa13be BT |
1539 | switch (hi->application) { |
1540 | case HID_GD_KEYBOARD: | |
1541 | case HID_GD_KEYPAD: | |
1542 | case HID_GD_MOUSE: | |
1543 | case HID_DG_TOUCHPAD: | |
1544 | case HID_GD_SYSTEM_CONTROL: | |
1545 | case HID_CP_CONSUMER_CONTROL: | |
1546 | case HID_GD_WIRELESS_RADIO_CTLS: | |
1547 | case HID_GD_SYSTEM_MULTIAXIS: | |
1548 | /* already handled by hid core */ | |
1549 | break; | |
1550 | case HID_DG_TOUCHSCREEN: | |
1551 | /* we do not set suffix = "Touchscreen" */ | |
1552 | hi->input->name = hdev->name; | |
1553 | break; | |
1554 | case HID_DG_STYLUS: | |
1555 | /* force BTN_STYLUS to allow tablet matching in udev */ | |
1556 | __set_bit(BTN_STYLUS, hi->input->keybit); | |
1557 | break; | |
1558 | case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: | |
1559 | suffix = "Custom Media Keys"; | |
1560 | break; | |
1561 | default: | |
1562 | suffix = "UNKNOWN"; | |
1563 | break; | |
c08d46aa BT |
1564 | } |
1565 | ||
1566 | if (suffix) { | |
1567 | name = devm_kzalloc(&hi->input->dev, | |
1568 | strlen(hdev->name) + strlen(suffix) + 2, | |
1569 | GFP_KERNEL); | |
1570 | if (name) { | |
1571 | sprintf(name, "%s %s", hdev->name, suffix); | |
1572 | hi->input->name = name; | |
1573 | } | |
1574 | } | |
b2c68a2f DT |
1575 | |
1576 | return 0; | |
76f5902a HR |
1577 | } |
1578 | ||
f3287a99 BT |
1579 | static void mt_fix_const_field(struct hid_field *field, unsigned int usage) |
1580 | { | |
1581 | if (field->usage[0].hid != usage || | |
1582 | !(field->flags & HID_MAIN_ITEM_CONSTANT)) | |
1583 | return; | |
1584 | ||
1585 | field->flags &= ~HID_MAIN_ITEM_CONSTANT; | |
1586 | field->flags |= HID_MAIN_ITEM_VARIABLE; | |
1587 | } | |
1588 | ||
1589 | static void mt_fix_const_fields(struct hid_device *hdev, unsigned int usage) | |
1590 | { | |
1591 | struct hid_report *report; | |
1592 | int i; | |
1593 | ||
1594 | list_for_each_entry(report, | |
1595 | &hdev->report_enum[HID_INPUT_REPORT].report_list, | |
1596 | list) { | |
1597 | ||
1598 | if (!report->maxfield) | |
1599 | continue; | |
1600 | ||
1601 | for (i = 0; i < report->maxfield; i++) | |
1602 | if (report->field[i]->maxusage >= 1) | |
1603 | mt_fix_const_field(report->field[i], usage); | |
1604 | } | |
1605 | } | |
1606 | ||
4f4001bc BT |
1607 | static void mt_release_contacts(struct hid_device *hid) |
1608 | { | |
1609 | struct hid_input *hidinput; | |
f146d1c4 | 1610 | struct mt_application *application; |
4f4001bc BT |
1611 | struct mt_device *td = hid_get_drvdata(hid); |
1612 | ||
1613 | list_for_each_entry(hidinput, &hid->inputs, list) { | |
1614 | struct input_dev *input_dev = hidinput->input; | |
1615 | struct input_mt *mt = input_dev->mt; | |
1616 | int i; | |
1617 | ||
1618 | if (mt) { | |
1619 | for (i = 0; i < mt->num_slots; i++) { | |
1620 | input_mt_slot(input_dev, i); | |
1621 | input_mt_report_slot_state(input_dev, | |
1622 | MT_TOOL_FINGER, | |
1623 | false); | |
1624 | } | |
1625 | input_mt_sync_frame(input_dev); | |
1626 | input_sync(input_dev); | |
1627 | } | |
1628 | } | |
1629 | ||
f146d1c4 BT |
1630 | list_for_each_entry(application, &td->applications, list) { |
1631 | application->num_received = 0; | |
1632 | } | |
4f4001bc BT |
1633 | } |
1634 | ||
0ee32774 | 1635 | static void mt_expired_timeout(struct timer_list *t) |
4f4001bc | 1636 | { |
0ee32774 KC |
1637 | struct mt_device *td = from_timer(td, t, release_timer); |
1638 | struct hid_device *hdev = td->hdev; | |
4f4001bc BT |
1639 | |
1640 | /* | |
1641 | * An input report came in just before we release the sticky fingers, | |
1642 | * it will take care of the sticky fingers. | |
1643 | */ | |
1644 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) | |
1645 | return; | |
96098274 BT |
1646 | if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) |
1647 | mt_release_contacts(hdev); | |
4f4001bc BT |
1648 | clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); |
1649 | } | |
1650 | ||
5519cab4 BT |
1651 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
1652 | { | |
2d93666e | 1653 | int ret, i; |
5519cab4 | 1654 | struct mt_device *td; |
cf6d15d7 | 1655 | const struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
2d93666e | 1656 | |
94b5485c HR |
1657 | for (i = 0; mt_classes[i].name ; i++) { |
1658 | if (id->driver_data == mt_classes[i].name) { | |
1659 | mtclass = &(mt_classes[i]); | |
1660 | break; | |
2d93666e BT |
1661 | } |
1662 | } | |
5519cab4 | 1663 | |
c08d46aa | 1664 | td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); |
5519cab4 BT |
1665 | if (!td) { |
1666 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | |
1667 | return -ENOMEM; | |
1668 | } | |
0ee32774 | 1669 | td->hdev = hdev; |
eec29e3d | 1670 | td->mtclass = *mtclass; |
9abebedb | 1671 | td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; |
5519cab4 BT |
1672 | hid_set_drvdata(hdev, td); |
1673 | ||
f146d1c4 | 1674 | INIT_LIST_HEAD(&td->applications); |
8dfe14b3 | 1675 | INIT_LIST_HEAD(&td->reports); |
f146d1c4 | 1676 | |
76f5902a HR |
1677 | if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) |
1678 | td->serial_maybe = true; | |
1679 | ||
b897f6db BT |
1680 | /* This allows the driver to correctly support devices |
1681 | * that emit events over several HID messages. | |
1682 | */ | |
1683 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; | |
1684 | ||
1685 | /* | |
1686 | * This allows the driver to handle different input sensors | |
40ec2603 | 1687 | * that emits events through different applications on the same HID |
b897f6db BT |
1688 | * device. |
1689 | */ | |
40ec2603 | 1690 | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; |
b897f6db | 1691 | |
0d6c3011 BT |
1692 | if (id->group != HID_GROUP_MULTITOUCH_WIN_8) |
1693 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | |
1694 | ||
0ee32774 | 1695 | timer_setup(&td->release_timer, mt_expired_timeout, 0); |
4f4001bc | 1696 | |
5519cab4 BT |
1697 | ret = hid_parse(hdev); |
1698 | if (ret != 0) | |
c08d46aa | 1699 | return ret; |
5519cab4 | 1700 | |
f3287a99 BT |
1701 | if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) |
1702 | mt_fix_const_fields(hdev, HID_DG_CONTACTID); | |
1703 | ||
5519cab4 | 1704 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
2d93666e | 1705 | if (ret) |
c08d46aa | 1706 | return ret; |
5519cab4 | 1707 | |
eec29e3d | 1708 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
0c4b3c63 NK |
1709 | if (ret) |
1710 | dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", | |
1711 | hdev->name); | |
eec29e3d | 1712 | |
02946f4b | 1713 | mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); |
5519cab4 BT |
1714 | |
1715 | return 0; | |
5519cab4 BT |
1716 | } |
1717 | ||
1718 | #ifdef CONFIG_PM | |
1719 | static int mt_reset_resume(struct hid_device *hdev) | |
1720 | { | |
d3e69b9a | 1721 | mt_release_contacts(hdev); |
02946f4b | 1722 | mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); |
5519cab4 BT |
1723 | return 0; |
1724 | } | |
dfeefd10 SL |
1725 | |
1726 | static int mt_resume(struct hid_device *hdev) | |
1727 | { | |
dfeefd10 SL |
1728 | /* Some Elan legacy devices require SET_IDLE to be set on resume. |
1729 | * It should be safe to send it to other devices too. | |
1730 | * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ | |
1731 | ||
4ba25d3f | 1732 | hid_hw_idle(hdev, 0, 0, HID_REQ_SET_IDLE); |
dfeefd10 SL |
1733 | |
1734 | return 0; | |
1735 | } | |
5519cab4 BT |
1736 | #endif |
1737 | ||
1738 | static void mt_remove(struct hid_device *hdev) | |
1739 | { | |
b897f6db BT |
1740 | struct mt_device *td = hid_get_drvdata(hdev); |
1741 | ||
4f4001bc BT |
1742 | del_timer_sync(&td->release_timer); |
1743 | ||
eec29e3d | 1744 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
5939212d | 1745 | hid_hw_stop(hdev); |
5519cab4 BT |
1746 | } |
1747 | ||
0fa9c616 BT |
1748 | /* |
1749 | * This list contains only: | |
1750 | * - VID/PID of products not working with the default multitouch handling | |
1751 | * - 2 generic rules. | |
1752 | * So there is no point in adding here any device with MT_CLS_DEFAULT. | |
1753 | */ | |
5519cab4 BT |
1754 | static const struct hid_device_id mt_devices[] = { |
1755 | ||
f786bba4 BT |
1756 | /* 3M panels */ |
1757 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1758 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 BT |
1759 | USB_DEVICE_ID_3M1968) }, |
1760 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1761 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 | 1762 | USB_DEVICE_ID_3M2256) }, |
c4fad877 | 1763 | { .driver_data = MT_CLS_3M, |
2c2110e9 | 1764 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
c4fad877 | 1765 | USB_DEVICE_ID_3M3266) }, |
f786bba4 | 1766 | |
504c932c MO |
1767 | /* Alps devices */ |
1768 | { .driver_data = MT_CLS_WIN_8_DUAL, | |
1769 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
1770 | USB_VENDOR_ID_ALPS_JP, | |
1771 | HID_DEVICE_ID_ALPS_U1_DUAL_PTP) }, | |
1772 | { .driver_data = MT_CLS_WIN_8_DUAL, | |
1773 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
1774 | USB_VENDOR_ID_ALPS_JP, | |
1775 | HID_DEVICE_ID_ALPS_U1_DUAL_3BTN_PTP) }, | |
1776 | ||
56d859e1 PT |
1777 | /* Lenovo X1 TAB Gen 2 */ |
1778 | { .driver_data = MT_CLS_WIN_8_DUAL, | |
1779 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, | |
1780 | USB_VENDOR_ID_LENOVO, | |
1781 | USB_DEVICE_ID_LENOVO_X1_TAB) }, | |
1782 | ||
8d5037dc MW |
1783 | /* Lenovo X1 TAB Gen 3 */ |
1784 | { .driver_data = MT_CLS_WIN_8_DUAL, | |
1785 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, | |
1786 | USB_VENDOR_ID_LENOVO, | |
1787 | USB_DEVICE_ID_LENOVO_X1_TAB3) }, | |
1788 | ||
6aef704e BT |
1789 | /* Anton devices */ |
1790 | { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, | |
1791 | MT_USB_DEVICE(USB_VENDOR_ID_ANTON, | |
1792 | USB_DEVICE_ID_ANTON_TOUCH_PAD) }, | |
e6aac342 | 1793 | |
957b8dff JPRV |
1794 | /* Asus T304UA */ |
1795 | { .driver_data = MT_CLS_ASUS, | |
1796 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, | |
1797 | USB_VENDOR_ID_ASUSTEK, | |
1798 | USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD) }, | |
1799 | ||
b1057124 | 1800 | /* Atmel panels */ |
841cb157 | 1801 | { .driver_data = MT_CLS_SERIAL, |
2c2110e9 | 1802 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
841cb157 | 1803 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
b1057124 | 1804 | |
9ed32695 | 1805 | /* Baanto multitouch devices */ |
dc3e1d80 | 1806 | { .driver_data = MT_CLS_NSMU, |
16b79bb8 | 1807 | MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, |
9ed32695 | 1808 | USB_DEVICE_ID_BAANTO_MT_190W2) }, |
0fa9c616 | 1809 | |
a841b62c BT |
1810 | /* Cando panels */ |
1811 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1812 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c | 1813 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
a841b62c | 1814 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2c2110e9 | 1815 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
1816 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
1817 | ||
942fd422 | 1818 | /* Chunghwa Telecom touch panels */ |
dc3e1d80 | 1819 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1820 | MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
942fd422 AZ |
1821 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
1822 | ||
12d43aac KHF |
1823 | /* Cirque devices */ |
1824 | { .driver_data = MT_CLS_WIN_8_DUAL, | |
1825 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
1826 | I2C_VENDOR_ID_CIRQUE, | |
1827 | I2C_PRODUCT_ID_CIRQUE_121F) }, | |
1828 | ||
070f63b4 YB |
1829 | /* CJTouch panels */ |
1830 | { .driver_data = MT_CLS_NSMU, | |
1831 | MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, | |
1832 | USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020) }, | |
1833 | { .driver_data = MT_CLS_NSMU, | |
1834 | MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, | |
1835 | USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0040) }, | |
1836 | ||
79603dc9 | 1837 | /* CVTouch panels */ |
dc3e1d80 | 1838 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1839 | MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
79603dc9 BT |
1840 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
1841 | ||
22408283 | 1842 | /* eGalax devices (resistive) */ |
e36f690b | 1843 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1844 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b BT |
1845 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
1846 | { .driver_data = MT_CLS_EGALAX, | |
2c2110e9 | 1847 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1848 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
22408283 BT |
1849 | |
1850 | /* eGalax devices (capacitive) */ | |
fd1d1525 | 1851 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1852 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1853 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
aa672da1 | 1854 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1855 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1856 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
fd1d1525 | 1857 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1858 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1859 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
2ce09df4 | 1860 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1861 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
2ce09df4 | 1862 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
aa672da1 | 1863 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1864 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1865 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
fd1d1525 | 1866 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1867 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1868 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
aa672da1 AS |
1869 | { .driver_data = MT_CLS_EGALAX, |
1870 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1871 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, | |
e36f690b | 1872 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1873 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1874 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
fd1d1525 | 1875 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1876 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1877 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
aa672da1 AS |
1878 | { .driver_data = MT_CLS_EGALAX, |
1879 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1880 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, | |
1881 | { .driver_data = MT_CLS_EGALAX, | |
1882 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1883 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, | |
66f06127 | 1884 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1885 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
66f06127 | 1886 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
bb9ff210 | 1887 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1888 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
bb9ff210 | 1889 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
fd1d1525 | 1890 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1891 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1892 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
1b723e8d | 1893 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
ae01c9e5 TR |
1894 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
1895 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, | |
1b723e8d | 1896 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1897 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1898 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
22408283 | 1899 | |
7c7606a2 TS |
1900 | /* Elitegroup panel */ |
1901 | { .driver_data = MT_CLS_SERIAL, | |
1902 | MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP, | |
1903 | USB_DEVICE_ID_ELITEGROUP_05D8) }, | |
1904 | ||
77723e3b HR |
1905 | /* Flatfrog Panels */ |
1906 | { .driver_data = MT_CLS_FLATFROG, | |
1907 | MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, | |
1908 | USB_DEVICE_ID_MULTITOUCH_3200) }, | |
1909 | ||
3db187e7 BT |
1910 | /* FocalTech Panels */ |
1911 | { .driver_data = MT_CLS_SERIAL, | |
1912 | MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL, | |
1913 | USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH) }, | |
1914 | ||
5572da08 | 1915 | /* GeneralTouch panel */ |
f5ff4e1e | 1916 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
2c2110e9 | 1917 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
5572da08 | 1918 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
f5ff4e1e XY |
1919 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
1920 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1921 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, | |
7b226292 L |
1922 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
1923 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1924 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) }, | |
1925 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1926 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1927 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) }, | |
1928 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1929 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1930 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) }, | |
1931 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1932 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1933 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) }, | |
1934 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1935 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1936 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) }, | |
5572da08 | 1937 | |
4d5df5d1 | 1938 | /* Gametel game controller */ |
dc3e1d80 | 1939 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1940 | MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, |
4d5df5d1 AN |
1941 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
1942 | ||
ee0fbd14 | 1943 | /* GoodTouch panels */ |
dc3e1d80 | 1944 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1945 | MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
ee0fbd14 BT |
1946 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
1947 | ||
54580365 BT |
1948 | /* Hanvon panels */ |
1949 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | |
2c2110e9 | 1950 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
54580365 BT |
1951 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
1952 | ||
4e61f0d7 | 1953 | /* Ilitek dual touch panel */ |
dc3e1d80 | 1954 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1955 | MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
4e61f0d7 AZ |
1956 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
1957 | ||
f3287a99 BT |
1958 | /* LG Melfas panel */ |
1959 | { .driver_data = MT_CLS_LG, | |
1960 | HID_USB_DEVICE(USB_VENDOR_ID_LG, | |
1961 | USB_DEVICE_ID_LG_MELFAS_MT) }, | |
1962 | ||
4a6ee685 BT |
1963 | /* MosArt panels */ |
1964 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1965 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1966 | USB_DEVICE_ID_ASUS_T91MT)}, |
1967 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1968 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1969 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
1970 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1971 | MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
4a6ee685 BT |
1972 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
1973 | ||
4db703ea | 1974 | /* Novatek Panel */ |
dc3e1d80 | 1975 | { .driver_data = MT_CLS_NSMU, |
4380d819 | 1976 | MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, |
4db703ea AH |
1977 | USB_DEVICE_ID_NOVATEK_PCT) }, |
1978 | ||
a80e803a BT |
1979 | /* Ntrig Panel */ |
1980 | { .driver_data = MT_CLS_NSMU, | |
1981 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
1982 | USB_VENDOR_ID_NTRIG, 0x1b05) }, | |
1983 | ||
fb55b402 HG |
1984 | /* Panasonic panels */ |
1985 | { .driver_data = MT_CLS_PANASONIC, | |
1986 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, | |
1987 | USB_DEVICE_ID_PANABOARD_UBT780) }, | |
1988 | { .driver_data = MT_CLS_PANASONIC, | |
1989 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, | |
1990 | USB_DEVICE_ID_PANABOARD_UBT880) }, | |
1991 | ||
b7ea95ff AT |
1992 | /* PixArt optical touch screen */ |
1993 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1994 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1995 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
1996 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1997 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1998 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
1999 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 2000 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
2001 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
2002 | ||
5519cab4 | 2003 | /* PixCir-based panels */ |
1e9cf35b | 2004 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
2c2110e9 | 2005 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
5519cab4 BT |
2006 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
2007 | ||
5e7ea11f | 2008 | /* Quanta-based panels */ |
5e7ea11f | 2009 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
2c2110e9 | 2010 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f | 2011 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
a6802e00 | 2012 | |
843e475f BT |
2013 | /* Razer touchpads */ |
2014 | { .driver_data = MT_CLS_RAZER_BLADE_STEALTH, | |
2015 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
2016 | USB_VENDOR_ID_SYNAPTICS, 0x8323) }, | |
2017 | ||
043b403a | 2018 | /* Stantum panels */ |
bf5af9b5 | 2019 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 2020 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
043b403a | 2021 | USB_DEVICE_ID_MTP_STM)}, |
043b403a | 2022 | |
847672cd BT |
2023 | /* TopSeed panels */ |
2024 | { .driver_data = MT_CLS_TOPSEED, | |
2c2110e9 | 2025 | MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
847672cd BT |
2026 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
2027 | ||
5e74e56d | 2028 | /* Touch International panels */ |
dc3e1d80 | 2029 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2030 | MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
5e74e56d BT |
2031 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
2032 | ||
617b64f9 | 2033 | /* Unitec panels */ |
dc3e1d80 | 2034 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2035 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 2036 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
dc3e1d80 | 2037 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2038 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 2039 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
bf9d121e | 2040 | |
da10bc25 MM |
2041 | /* VTL panels */ |
2042 | { .driver_data = MT_CLS_VTL, | |
2043 | MT_USB_DEVICE(USB_VENDOR_ID_VTL, | |
2044 | USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, | |
2045 | ||
bf9d121e KC |
2046 | /* Wistron panels */ |
2047 | { .driver_data = MT_CLS_NSMU, | |
2048 | MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, | |
2049 | USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, | |
2050 | ||
bc8a2a9b | 2051 | /* XAT */ |
dc3e1d80 | 2052 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2053 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
bc8a2a9b | 2054 | USB_DEVICE_ID_XAT_CSR) }, |
617b64f9 | 2055 | |
11576c61 | 2056 | /* Xiroku */ |
dc3e1d80 | 2057 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2058 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2059 | USB_DEVICE_ID_XIROKU_SPX) }, |
dc3e1d80 | 2060 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2061 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2062 | USB_DEVICE_ID_XIROKU_MPX) }, |
dc3e1d80 | 2063 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2064 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2065 | USB_DEVICE_ID_XIROKU_CSR) }, |
dc3e1d80 | 2066 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2067 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2068 | USB_DEVICE_ID_XIROKU_SPX1) }, |
dc3e1d80 | 2069 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2070 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2071 | USB_DEVICE_ID_XIROKU_MPX1) }, |
dc3e1d80 | 2072 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2073 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2074 | USB_DEVICE_ID_XIROKU_CSR1) }, |
dc3e1d80 | 2075 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2076 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2077 | USB_DEVICE_ID_XIROKU_SPX2) }, |
dc3e1d80 | 2078 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2079 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 2080 | USB_DEVICE_ID_XIROKU_MPX2) }, |
dc3e1d80 | 2081 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 2082 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
2083 | USB_DEVICE_ID_XIROKU_CSR2) }, |
2084 | ||
0e82232c WNH |
2085 | /* Google MT devices */ |
2086 | { .driver_data = MT_CLS_GOOGLE, | |
2087 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE, | |
2088 | USB_DEVICE_ID_GOOGLE_TOUCH_ROSE) }, | |
2089 | ||
4fa3a583 HR |
2090 | /* Generic MT device */ |
2091 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
f961bd35 BT |
2092 | |
2093 | /* Generic Win 8 certified MT device */ | |
2094 | { .driver_data = MT_CLS_WIN_8, | |
2095 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, | |
2096 | HID_ANY_ID, HID_ANY_ID) }, | |
5519cab4 BT |
2097 | { } |
2098 | }; | |
2099 | MODULE_DEVICE_TABLE(hid, mt_devices); | |
2100 | ||
2101 | static const struct hid_usage_id mt_grabbed_usages[] = { | |
2102 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, | |
2103 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} | |
2104 | }; | |
2105 | ||
2106 | static struct hid_driver mt_driver = { | |
2107 | .name = "hid-multitouch", | |
2108 | .id_table = mt_devices, | |
2109 | .probe = mt_probe, | |
2110 | .remove = mt_remove, | |
2111 | .input_mapping = mt_input_mapping, | |
2112 | .input_mapped = mt_input_mapped, | |
76f5902a | 2113 | .input_configured = mt_input_configured, |
5519cab4 BT |
2114 | .feature_mapping = mt_feature_mapping, |
2115 | .usage_table = mt_grabbed_usages, | |
2116 | .event = mt_event, | |
55978fa9 | 2117 | .report = mt_report, |
5519cab4 BT |
2118 | #ifdef CONFIG_PM |
2119 | .reset_resume = mt_reset_resume, | |
dfeefd10 | 2120 | .resume = mt_resume, |
5519cab4 BT |
2121 | #endif |
2122 | }; | |
f425458e | 2123 | module_hid_driver(mt_driver); |