]>
Commit | Line | Data |
---|---|---|
5519cab4 BT |
1 | /* |
2 | * HID driver for multitouch panels | |
3 | * | |
c2ef8f21 | 4 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> |
b0a78681 | 5 | * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
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 <chatty@enac.fr> | |
12 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | |
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 <chatty@enac.fr> | |
18 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | |
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 BT |
30 | /* |
31 | * This driver is regularly tested thanks to the tool hid-test[1]. | |
32 | * This tool relies on hid-replay[2] and a database of hid devices[3]. | |
33 | * Please run these regression tests before patching this module so that | |
34 | * your patch won't break existing known devices. | |
35 | * | |
36 | * [1] https://github.com/bentiss/hid-test | |
37 | * [2] https://github.com/bentiss/hid-replay | |
38 | * [3] https://github.com/bentiss/hid-devices | |
39 | */ | |
40 | ||
5519cab4 BT |
41 | #include <linux/device.h> |
42 | #include <linux/hid.h> | |
43 | #include <linux/module.h> | |
44 | #include <linux/slab.h> | |
45 | #include <linux/usb.h> | |
46 | #include <linux/input/mt.h> | |
49a5a827 | 47 | #include <linux/string.h> |
5519cab4 BT |
48 | |
49 | ||
50 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | |
ef2fafb3 | 51 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); |
5519cab4 BT |
52 | MODULE_DESCRIPTION("HID multitouch panels"); |
53 | MODULE_LICENSE("GPL"); | |
54 | ||
55 | #include "hid-ids.h" | |
56 | ||
57 | /* quirks to control the device */ | |
58 | #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0) | |
59 | #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1) | |
2d93666e | 60 | #define MT_QUIRK_CYPRESS (1 << 2) |
5572da08 | 61 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) |
a062cc5a SC |
62 | #define MT_QUIRK_ALWAYS_VALID (1 << 4) |
63 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) | |
64 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) | |
a062cc5a | 65 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) |
77723e3b | 66 | #define MT_QUIRK_NO_AREA (1 << 9) |
28728399 | 67 | #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) |
9b3bb9b8 | 68 | #define MT_QUIRK_HOVERING (1 << 11) |
c2517f62 | 69 | #define MT_QUIRK_CONTACT_CNT_ACCURATE (1 << 12) |
5519cab4 BT |
70 | |
71 | struct mt_slot { | |
349fd670 | 72 | __s32 x, y, cx, cy, p, w, h; |
5519cab4 BT |
73 | __s32 contactid; /* the device ContactID assigned to this slot */ |
74 | bool touch_state; /* is the touch valid? */ | |
9b3bb9b8 | 75 | bool inrange_state; /* is the finger in proximity of the sensor? */ |
5519cab4 BT |
76 | }; |
77 | ||
eec29e3d BT |
78 | struct mt_class { |
79 | __s32 name; /* MT_CLS */ | |
80 | __s32 quirks; | |
81 | __s32 sn_move; /* Signal/noise ratio for move events */ | |
82 | __s32 sn_width; /* Signal/noise ratio for width events */ | |
83 | __s32 sn_height; /* Signal/noise ratio for height events */ | |
84 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ | |
85 | __u8 maxcontacts; | |
c2ef8f21 | 86 | bool is_indirect; /* true for touchpads */ |
6aef704e | 87 | bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ |
eec29e3d BT |
88 | }; |
89 | ||
3ac36d15 BT |
90 | struct mt_fields { |
91 | unsigned usages[HID_MAX_FIELDS]; | |
92 | unsigned int length; | |
93 | }; | |
94 | ||
5519cab4 BT |
95 | struct mt_device { |
96 | struct mt_slot curdata; /* placeholder of incoming data */ | |
eec29e3d | 97 | struct mt_class mtclass; /* our mt device class */ |
3ac36d15 BT |
98 | struct mt_fields *fields; /* temporary placeholder for storing the |
99 | multitouch fields */ | |
7e3cc447 BT |
100 | int cc_index; /* contact count field index in the report */ |
101 | int cc_value_index; /* contact count value index in the field */ | |
5519cab4 | 102 | unsigned last_slot_field; /* the last field of a slot */ |
55978fa9 | 103 | unsigned mt_report_id; /* the report ID of the multitouch device */ |
8821f5dc BT |
104 | __s16 inputmode; /* InputMode HID feature, -1 if non-existent */ |
105 | __s16 inputmode_index; /* InputMode HID feature index in the report */ | |
106 | __s16 maxcontact_report_id; /* Maximum Contact Number HID feature, | |
31ae9bdd | 107 | -1 if non-existent */ |
5519cab4 BT |
108 | __u8 num_received; /* how many contacts we received */ |
109 | __u8 num_expected; /* expected last contact index */ | |
9498f954 | 110 | __u8 maxcontacts; |
9e87f22a BT |
111 | __u8 touches_by_report; /* how many touches are present in one report: |
112 | * 1 means we should use a serial protocol | |
113 | * > 1 means hybrid (multitouch) protocol */ | |
76f5902a | 114 | bool serial_maybe; /* need to check for serial protocol */ |
5519cab4 | 115 | bool curvalid; /* is the current contact valid? */ |
76f5902a | 116 | unsigned mt_flags; /* flags to pass to input-mt */ |
5519cab4 BT |
117 | }; |
118 | ||
a69c5f8b BT |
119 | static void mt_post_parse_default_settings(struct mt_device *td); |
120 | static void mt_post_parse(struct mt_device *td); | |
121 | ||
5519cab4 | 122 | /* classes of device behavior */ |
22408283 BT |
123 | #define MT_CLS_DEFAULT 0x0001 |
124 | ||
a062cc5a SC |
125 | #define MT_CLS_SERIAL 0x0002 |
126 | #define MT_CLS_CONFIDENCE 0x0003 | |
5e7ea11f BT |
127 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
128 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 | |
129 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 | |
130 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 | |
0fa9c616 | 131 | /* reserved 0x0008 */ |
b7ea95ff | 132 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
dc3e1d80 | 133 | #define MT_CLS_NSMU 0x000a |
0fa9c616 BT |
134 | /* reserved 0x0010 */ |
135 | /* reserved 0x0011 */ | |
f961bd35 | 136 | #define MT_CLS_WIN_8 0x0012 |
6aef704e | 137 | #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 |
22408283 BT |
138 | |
139 | /* vendor specific classes */ | |
140 | #define MT_CLS_3M 0x0101 | |
0fa9c616 | 141 | /* reserved 0x0102 */ |
22408283 | 142 | #define MT_CLS_EGALAX 0x0103 |
1b723e8d | 143 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
847672cd | 144 | #define MT_CLS_TOPSEED 0x0105 |
2258e863 | 145 | #define MT_CLS_PANASONIC 0x0106 |
77723e3b | 146 | #define MT_CLS_FLATFROG 0x0107 |
cdcd3ac4 JK |
147 | #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 |
148 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 | |
5519cab4 | 149 | |
9498f954 | 150 | #define MT_DEFAULT_MAXCONTACT 10 |
afbcb04c | 151 | #define MT_MAX_MAXCONTACT 250 |
9498f954 | 152 | |
2c2110e9 HR |
153 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
154 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) | |
155 | ||
5519cab4 BT |
156 | /* |
157 | * these device-dependent functions determine what slot corresponds | |
158 | * to a valid contact that was just read. | |
159 | */ | |
160 | ||
a3b5e577 BT |
161 | static int cypress_compute_slot(struct mt_device *td) |
162 | { | |
163 | if (td->curdata.contactid != 0 || td->num_received == 0) | |
164 | return td->curdata.contactid; | |
165 | else | |
166 | return -1; | |
167 | } | |
168 | ||
b3c21d2c | 169 | static struct mt_class mt_classes[] = { |
2d93666e | 170 | { .name = MT_CLS_DEFAULT, |
dc3e1d80 BT |
171 | .quirks = MT_QUIRK_ALWAYS_VALID | |
172 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
173 | { .name = MT_CLS_NSMU, | |
9498f954 | 174 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
a062cc5a SC |
175 | { .name = MT_CLS_SERIAL, |
176 | .quirks = MT_QUIRK_ALWAYS_VALID}, | |
22408283 BT |
177 | { .name = MT_CLS_CONFIDENCE, |
178 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, | |
5e7ea11f BT |
179 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
180 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
181 | MT_QUIRK_SLOT_IS_CONTACTID }, | |
22408283 BT |
182 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
183 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
184 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, | |
1e9cf35b | 185 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
2d93666e BT |
186 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
187 | MT_QUIRK_SLOT_IS_CONTACTID, | |
188 | .maxcontacts = 2 }, | |
1e9cf35b | 189 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2d93666e BT |
190 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
191 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | |
192 | .maxcontacts = 2 }, | |
b7ea95ff AT |
193 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
194 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | |
195 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, | |
f961bd35 BT |
196 | { .name = MT_CLS_WIN_8, |
197 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
198 | MT_QUIRK_IGNORE_DUPLICATES | | |
199 | MT_QUIRK_HOVERING | | |
200 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
6aef704e BT |
201 | { .name = MT_CLS_EXPORT_ALL_INPUTS, |
202 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
203 | MT_QUIRK_CONTACT_CNT_ACCURATE, | |
204 | .export_all_inputs = true }, | |
22408283 BT |
205 | |
206 | /* | |
207 | * vendor specific classes | |
208 | */ | |
209 | { .name = MT_CLS_3M, | |
210 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
211 | MT_QUIRK_SLOT_IS_CONTACTID, | |
212 | .sn_move = 2048, | |
213 | .sn_width = 128, | |
c5d40be5 HR |
214 | .sn_height = 128, |
215 | .maxcontacts = 60, | |
216 | }, | |
4875ac11 RN |
217 | { .name = MT_CLS_EGALAX, |
218 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
2261bb9f | 219 | MT_QUIRK_VALID_IS_INRANGE, |
4875ac11 RN |
220 | .sn_move = 4096, |
221 | .sn_pressure = 32, | |
222 | }, | |
1b723e8d BT |
223 | { .name = MT_CLS_EGALAX_SERIAL, |
224 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
225 | MT_QUIRK_ALWAYS_VALID, | |
4875ac11 RN |
226 | .sn_move = 4096, |
227 | .sn_pressure = 32, | |
228 | }, | |
847672cd BT |
229 | { .name = MT_CLS_TOPSEED, |
230 | .quirks = MT_QUIRK_ALWAYS_VALID, | |
231 | .is_indirect = true, | |
232 | .maxcontacts = 2, | |
233 | }, | |
2258e863 DK |
234 | { .name = MT_CLS_PANASONIC, |
235 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, | |
236 | .maxcontacts = 4 }, | |
f5ff4e1e XY |
237 | { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, |
238 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
239 | MT_QUIRK_VALID_IS_INRANGE | | |
7b226292 | 240 | MT_QUIRK_SLOT_IS_CONTACTID, |
f5ff4e1e XY |
241 | .maxcontacts = 2 |
242 | }, | |
243 | { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
244 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
7b226292 | 245 | MT_QUIRK_SLOT_IS_CONTACTID |
f5ff4e1e | 246 | }, |
043b403a | 247 | |
77723e3b HR |
248 | { .name = MT_CLS_FLATFROG, |
249 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
250 | MT_QUIRK_NO_AREA, | |
251 | .sn_move = 2048, | |
252 | .maxcontacts = 40, | |
253 | }, | |
2d93666e | 254 | { } |
5519cab4 BT |
255 | }; |
256 | ||
eec29e3d BT |
257 | static ssize_t mt_show_quirks(struct device *dev, |
258 | struct device_attribute *attr, | |
259 | char *buf) | |
260 | { | |
261 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
262 | struct mt_device *td = hid_get_drvdata(hdev); | |
263 | ||
264 | return sprintf(buf, "%u\n", td->mtclass.quirks); | |
265 | } | |
266 | ||
267 | static ssize_t mt_set_quirks(struct device *dev, | |
268 | struct device_attribute *attr, | |
269 | const char *buf, size_t count) | |
270 | { | |
271 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
272 | struct mt_device *td = hid_get_drvdata(hdev); | |
273 | ||
274 | unsigned long val; | |
275 | ||
276 | if (kstrtoul(buf, 0, &val)) | |
277 | return -EINVAL; | |
278 | ||
279 | td->mtclass.quirks = val; | |
280 | ||
7e3cc447 | 281 | if (td->cc_index < 0) |
c2517f62 BT |
282 | td->mtclass.quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
283 | ||
eec29e3d BT |
284 | return count; |
285 | } | |
286 | ||
287 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); | |
288 | ||
289 | static struct attribute *sysfs_attrs[] = { | |
290 | &dev_attr_quirks.attr, | |
291 | NULL | |
292 | }; | |
293 | ||
294 | static struct attribute_group mt_attribute_group = { | |
295 | .attrs = sysfs_attrs | |
296 | }; | |
297 | ||
f635bd11 | 298 | static void mt_feature_mapping(struct hid_device *hdev, |
5519cab4 BT |
299 | struct hid_field *field, struct hid_usage *usage) |
300 | { | |
9498f954 BT |
301 | struct mt_device *td = hid_get_drvdata(hdev); |
302 | ||
303 | switch (usage->hid) { | |
304 | case HID_DG_INPUTMODE: | |
8821f5dc BT |
305 | /* Ignore if value index is out of bounds. */ |
306 | if (usage->usage_index >= field->report_count) { | |
307 | dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n"); | |
308 | break; | |
4aceed37 BT |
309 | } |
310 | ||
8821f5dc BT |
311 | td->inputmode = field->report->id; |
312 | td->inputmode_index = usage->usage_index; | |
313 | ||
9498f954 BT |
314 | break; |
315 | case HID_DG_CONTACTMAX: | |
31ae9bdd | 316 | td->maxcontact_report_id = field->report->id; |
9498f954 | 317 | td->maxcontacts = field->value[0]; |
afbcb04c BT |
318 | if (!td->maxcontacts && |
319 | field->logical_maximum <= MT_MAX_MAXCONTACT) | |
320 | td->maxcontacts = field->logical_maximum; | |
eec29e3d | 321 | if (td->mtclass.maxcontacts) |
9498f954 | 322 | /* check if the maxcontacts is given by the class */ |
eec29e3d | 323 | td->maxcontacts = td->mtclass.maxcontacts; |
9498f954 BT |
324 | |
325 | break; | |
5519cab4 BT |
326 | } |
327 | } | |
328 | ||
329 | static void set_abs(struct input_dev *input, unsigned int code, | |
330 | struct hid_field *field, int snratio) | |
331 | { | |
332 | int fmin = field->logical_minimum; | |
333 | int fmax = field->logical_maximum; | |
334 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | |
335 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | |
37cf6e6f | 336 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
5519cab4 BT |
337 | } |
338 | ||
3ac36d15 | 339 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, |
ed9d5c96 BT |
340 | struct hid_input *hi) |
341 | { | |
3ac36d15 BT |
342 | struct mt_fields *f = td->fields; |
343 | ||
344 | if (f->length >= HID_MAX_FIELDS) | |
345 | return; | |
346 | ||
347 | f->usages[f->length++] = usage->hid; | |
ed9d5c96 BT |
348 | } |
349 | ||
a69c5f8b | 350 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
5519cab4 BT |
351 | struct hid_field *field, struct hid_usage *usage, |
352 | unsigned long **bit, int *max) | |
353 | { | |
354 | struct mt_device *td = hid_get_drvdata(hdev); | |
eec29e3d | 355 | struct mt_class *cls = &td->mtclass; |
c2ef8f21 | 356 | int code; |
349fd670 | 357 | struct hid_usage *prev_usage = NULL; |
4875ac11 | 358 | |
658d4aed | 359 | if (field->application == HID_DG_TOUCHSCREEN) |
76f5902a | 360 | td->mt_flags |= INPUT_MT_DIRECT; |
658d4aed | 361 | |
76f5902a HR |
362 | /* |
363 | * Model touchscreens providing buttons as touchpads. | |
c2ef8f21 BT |
364 | */ |
365 | if (field->application == HID_DG_TOUCHPAD || | |
76f5902a HR |
366 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
367 | td->mt_flags |= INPUT_MT_POINTER; | |
c2ef8f21 | 368 | |
349fd670 BT |
369 | if (usage->usage_index) |
370 | prev_usage = &field->usage[usage->usage_index - 1]; | |
371 | ||
5519cab4 BT |
372 | switch (usage->hid & HID_USAGE_PAGE) { |
373 | ||
374 | case HID_UP_GENDESK: | |
375 | switch (usage->hid) { | |
376 | case HID_GD_X: | |
349fd670 BT |
377 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
378 | hid_map_usage(hi, usage, bit, max, | |
379 | EV_ABS, ABS_MT_TOOL_X); | |
380 | set_abs(hi->input, ABS_MT_TOOL_X, field, | |
381 | cls->sn_move); | |
382 | } else { | |
383 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 384 | EV_ABS, ABS_MT_POSITION_X); |
349fd670 BT |
385 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
386 | cls->sn_move); | |
387 | } | |
388 | ||
3ac36d15 | 389 | mt_store_field(usage, td, hi); |
5519cab4 BT |
390 | return 1; |
391 | case HID_GD_Y: | |
349fd670 BT |
392 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
393 | hid_map_usage(hi, usage, bit, max, | |
394 | EV_ABS, ABS_MT_TOOL_Y); | |
395 | set_abs(hi->input, ABS_MT_TOOL_Y, field, | |
396 | cls->sn_move); | |
397 | } else { | |
398 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 399 | EV_ABS, ABS_MT_POSITION_Y); |
349fd670 BT |
400 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
401 | cls->sn_move); | |
402 | } | |
403 | ||
3ac36d15 | 404 | mt_store_field(usage, td, hi); |
5519cab4 BT |
405 | return 1; |
406 | } | |
407 | return 0; | |
408 | ||
409 | case HID_UP_DIGITIZER: | |
410 | switch (usage->hid) { | |
411 | case HID_DG_INRANGE: | |
9b3bb9b8 BT |
412 | if (cls->quirks & MT_QUIRK_HOVERING) { |
413 | hid_map_usage(hi, usage, bit, max, | |
414 | EV_ABS, ABS_MT_DISTANCE); | |
415 | input_set_abs_params(hi->input, | |
416 | ABS_MT_DISTANCE, 0, 1, 0, 0); | |
417 | } | |
3ac36d15 | 418 | mt_store_field(usage, td, hi); |
5519cab4 BT |
419 | return 1; |
420 | case HID_DG_CONFIDENCE: | |
3ac36d15 | 421 | mt_store_field(usage, td, hi); |
5519cab4 BT |
422 | return 1; |
423 | case HID_DG_TIPSWITCH: | |
424 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | |
425 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); | |
3ac36d15 | 426 | mt_store_field(usage, td, hi); |
5519cab4 BT |
427 | return 1; |
428 | case HID_DG_CONTACTID: | |
3ac36d15 | 429 | mt_store_field(usage, td, hi); |
9e87f22a | 430 | td->touches_by_report++; |
55978fa9 | 431 | td->mt_report_id = field->report->id; |
5519cab4 BT |
432 | return 1; |
433 | case HID_DG_WIDTH: | |
434 | hid_map_usage(hi, usage, bit, max, | |
435 | EV_ABS, ABS_MT_TOUCH_MAJOR); | |
77723e3b HR |
436 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) |
437 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, | |
438 | cls->sn_width); | |
3ac36d15 | 439 | mt_store_field(usage, td, hi); |
5519cab4 BT |
440 | return 1; |
441 | case HID_DG_HEIGHT: | |
442 | hid_map_usage(hi, usage, bit, max, | |
443 | EV_ABS, ABS_MT_TOUCH_MINOR); | |
77723e3b HR |
444 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) { |
445 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, | |
446 | cls->sn_height); | |
447 | input_set_abs_params(hi->input, | |
1e648a13 | 448 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
77723e3b | 449 | } |
3ac36d15 | 450 | mt_store_field(usage, td, hi); |
5519cab4 BT |
451 | return 1; |
452 | case HID_DG_TIPPRESSURE: | |
453 | hid_map_usage(hi, usage, bit, max, | |
454 | EV_ABS, ABS_MT_PRESSURE); | |
455 | set_abs(hi->input, ABS_MT_PRESSURE, field, | |
456 | cls->sn_pressure); | |
3ac36d15 | 457 | mt_store_field(usage, td, hi); |
5519cab4 BT |
458 | return 1; |
459 | case HID_DG_CONTACTCOUNT: | |
8821f5dc BT |
460 | /* Ignore if indexes are out of bounds. */ |
461 | if (field->index >= field->report->maxfield || | |
462 | usage->usage_index >= field->report_count) | |
463 | return 1; | |
7e3cc447 BT |
464 | td->cc_index = field->index; |
465 | td->cc_value_index = usage->usage_index; | |
5519cab4 BT |
466 | return 1; |
467 | case HID_DG_CONTACTMAX: | |
468 | /* we don't set td->last_slot_field as contactcount and | |
469 | * contact max are global to the report */ | |
470 | return -1; | |
c2ef8f21 BT |
471 | case HID_DG_TOUCH: |
472 | /* Legacy devices use TIPSWITCH and not TOUCH. | |
473 | * Let's just ignore this field. */ | |
474 | return -1; | |
65b258e9 | 475 | } |
5519cab4 BT |
476 | /* let hid-input decide for the others */ |
477 | return 0; | |
478 | ||
c2ef8f21 BT |
479 | case HID_UP_BUTTON: |
480 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); | |
481 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); | |
482 | input_set_capability(hi->input, EV_KEY, code); | |
483 | return 1; | |
484 | ||
5519cab4 BT |
485 | case 0xff000000: |
486 | /* we do not want to map these: no input-oriented meaning */ | |
487 | return -1; | |
488 | } | |
489 | ||
490 | return 0; | |
491 | } | |
492 | ||
a69c5f8b | 493 | static int mt_touch_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
5519cab4 BT |
494 | struct hid_field *field, struct hid_usage *usage, |
495 | unsigned long **bit, int *max) | |
496 | { | |
497 | if (usage->type == EV_KEY || usage->type == EV_ABS) | |
498 | set_bit(usage->type, hi->input->evbit); | |
499 | ||
500 | return -1; | |
501 | } | |
502 | ||
3e1b5015 | 503 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 504 | { |
eec29e3d | 505 | __s32 quirks = td->mtclass.quirks; |
5519cab4 | 506 | |
2d93666e BT |
507 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
508 | return td->curdata.contactid; | |
5519cab4 | 509 | |
2d93666e | 510 | if (quirks & MT_QUIRK_CYPRESS) |
a3b5e577 BT |
511 | return cypress_compute_slot(td); |
512 | ||
2d93666e BT |
513 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
514 | return td->num_received; | |
5572da08 | 515 | |
4a6ee685 BT |
516 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
517 | return td->curdata.contactid - 1; | |
518 | ||
3e1b5015 | 519 | return input_mt_get_slot_by_key(input, td->curdata.contactid); |
5519cab4 BT |
520 | } |
521 | ||
522 | /* | |
523 | * this function is called when a whole contact has been processed, | |
524 | * so that it can assign it to a slot and store the data there | |
525 | */ | |
3e1b5015 | 526 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 527 | { |
c2517f62 BT |
528 | if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && |
529 | td->num_received >= td->num_expected) | |
530 | return; | |
531 | ||
20b60e6d | 532 | if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { |
3e1b5015 HR |
533 | int slotnum = mt_compute_slot(td, input); |
534 | struct mt_slot *s = &td->curdata; | |
28728399 | 535 | struct input_mt *mt = input->mt; |
5519cab4 | 536 | |
3e1b5015 HR |
537 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
538 | return; | |
5519cab4 | 539 | |
28728399 BT |
540 | if ((td->mtclass.quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { |
541 | struct input_mt_slot *slot = &mt->slots[slotnum]; | |
542 | if (input_mt_is_active(slot) && | |
543 | input_mt_is_used(mt, slot)) | |
544 | return; | |
545 | } | |
546 | ||
3e1b5015 | 547 | input_mt_slot(input, slotnum); |
5519cab4 | 548 | input_mt_report_slot_state(input, MT_TOOL_FINGER, |
9b3bb9b8 BT |
549 | s->touch_state || s->inrange_state); |
550 | if (s->touch_state || s->inrange_state) { | |
551 | /* this finger is in proximity of the sensor */ | |
f786bba4 BT |
552 | int wide = (s->w > s->h); |
553 | /* divided by two to match visual scale of touch */ | |
554 | int major = max(s->w, s->h) >> 1; | |
555 | int minor = min(s->w, s->h) >> 1; | |
556 | ||
2d93666e BT |
557 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); |
558 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); | |
349fd670 BT |
559 | input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx); |
560 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); | |
9b3bb9b8 BT |
561 | input_event(input, EV_ABS, ABS_MT_DISTANCE, |
562 | !s->touch_state); | |
f786bba4 | 563 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); |
2d93666e | 564 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); |
f786bba4 BT |
565 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
566 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); | |
2d93666e | 567 | } |
5519cab4 BT |
568 | } |
569 | ||
3e1b5015 HR |
570 | td->num_received++; |
571 | } | |
572 | ||
573 | /* | |
574 | * this function is called when a whole packet has been received and processed, | |
575 | * so that it can decide what to send to the input layer. | |
576 | */ | |
577 | static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | |
578 | { | |
76f5902a | 579 | input_mt_sync_frame(input); |
5519cab4 BT |
580 | input_sync(input); |
581 | td->num_received = 0; | |
582 | } | |
583 | ||
a69c5f8b | 584 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
5519cab4 | 585 | struct hid_usage *usage, __s32 value) |
55978fa9 BT |
586 | { |
587 | /* we will handle the hidinput part later, now remains hiddev */ | |
588 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) | |
589 | hid->hiddev_hid_event(hid, field, usage, value); | |
590 | ||
591 | return 1; | |
592 | } | |
593 | ||
594 | static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |
595 | struct hid_usage *usage, __s32 value) | |
5519cab4 BT |
596 | { |
597 | struct mt_device *td = hid_get_drvdata(hid); | |
eec29e3d | 598 | __s32 quirks = td->mtclass.quirks; |
4c437555 | 599 | struct input_dev *input = field->hidinput->input; |
5519cab4 | 600 | |
3e1b5015 | 601 | if (hid->claimed & HID_CLAIMED_INPUT) { |
5519cab4 BT |
602 | switch (usage->hid) { |
603 | case HID_DG_INRANGE: | |
20b60e6d | 604 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
2d93666e | 605 | td->curvalid = value; |
9b3bb9b8 BT |
606 | if (quirks & MT_QUIRK_HOVERING) |
607 | td->curdata.inrange_state = value; | |
5519cab4 BT |
608 | break; |
609 | case HID_DG_TIPSWITCH: | |
2d93666e BT |
610 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
611 | td->curvalid = value; | |
5519cab4 BT |
612 | td->curdata.touch_state = value; |
613 | break; | |
614 | case HID_DG_CONFIDENCE: | |
2d93666e BT |
615 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
616 | td->curvalid = value; | |
5519cab4 BT |
617 | break; |
618 | case HID_DG_CONTACTID: | |
619 | td->curdata.contactid = value; | |
620 | break; | |
621 | case HID_DG_TIPPRESSURE: | |
622 | td->curdata.p = value; | |
623 | break; | |
624 | case HID_GD_X: | |
349fd670 BT |
625 | if (usage->code == ABS_MT_TOOL_X) |
626 | td->curdata.cx = value; | |
627 | else | |
628 | td->curdata.x = value; | |
5519cab4 BT |
629 | break; |
630 | case HID_GD_Y: | |
349fd670 BT |
631 | if (usage->code == ABS_MT_TOOL_Y) |
632 | td->curdata.cy = value; | |
633 | else | |
634 | td->curdata.y = value; | |
5519cab4 BT |
635 | break; |
636 | case HID_DG_WIDTH: | |
637 | td->curdata.w = value; | |
638 | break; | |
639 | case HID_DG_HEIGHT: | |
640 | td->curdata.h = value; | |
641 | break; | |
642 | case HID_DG_CONTACTCOUNT: | |
5519cab4 | 643 | break; |
c2ef8f21 BT |
644 | case HID_DG_TOUCH: |
645 | /* do nothing */ | |
646 | break; | |
5519cab4 BT |
647 | |
648 | default: | |
4c437555 BT |
649 | if (usage->type) |
650 | input_event(input, usage->type, usage->code, | |
651 | value); | |
55978fa9 | 652 | return; |
5519cab4 | 653 | } |
5519cab4 | 654 | |
54f4c0c3 BT |
655 | if (usage->usage_index + 1 == field->report_count) { |
656 | /* we only take into account the last report. */ | |
657 | if (usage->hid == td->last_slot_field) | |
658 | mt_complete_slot(td, field->hidinput->input); | |
54f4c0c3 | 659 | } |
5519cab4 | 660 | |
2d93666e | 661 | } |
55978fa9 | 662 | } |
5519cab4 | 663 | |
a69c5f8b | 664 | static void mt_touch_report(struct hid_device *hid, struct hid_report *report) |
55978fa9 BT |
665 | { |
666 | struct mt_device *td = hid_get_drvdata(hid); | |
667 | struct hid_field *field; | |
668 | unsigned count; | |
669 | int r, n; | |
5519cab4 | 670 | |
c2517f62 BT |
671 | /* |
672 | * Includes multi-packet support where subsequent | |
673 | * packets are sent with zero contactcount. | |
674 | */ | |
7e3cc447 BT |
675 | if (td->cc_index >= 0) { |
676 | struct hid_field *field = report->field[td->cc_index]; | |
677 | int value = field->value[td->cc_value_index]; | |
678 | if (value) | |
679 | td->num_expected = value; | |
680 | } | |
c2517f62 | 681 | |
55978fa9 BT |
682 | for (r = 0; r < report->maxfield; r++) { |
683 | field = report->field[r]; | |
684 | count = field->report_count; | |
685 | ||
686 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) | |
687 | continue; | |
688 | ||
689 | for (n = 0; n < count; n++) | |
690 | mt_process_mt_event(hid, field, &field->usage[n], | |
691 | field->value[n]); | |
692 | } | |
5b62efd8 BT |
693 | |
694 | if (td->num_received >= td->num_expected) | |
695 | mt_sync_frame(td, report->field[0]->hidinput->input); | |
5519cab4 BT |
696 | } |
697 | ||
a69c5f8b BT |
698 | static void mt_touch_input_configured(struct hid_device *hdev, |
699 | struct hid_input *hi) | |
700 | { | |
701 | struct mt_device *td = hid_get_drvdata(hdev); | |
702 | struct mt_class *cls = &td->mtclass; | |
703 | struct input_dev *input = hi->input; | |
704 | ||
705 | if (!td->maxcontacts) | |
706 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | |
707 | ||
708 | mt_post_parse(td); | |
709 | if (td->serial_maybe) | |
710 | mt_post_parse_default_settings(td); | |
711 | ||
712 | if (cls->is_indirect) | |
713 | td->mt_flags |= INPUT_MT_POINTER; | |
714 | ||
715 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | |
716 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | |
717 | ||
718 | input_mt_init_slots(input, td->maxcontacts, td->mt_flags); | |
719 | ||
720 | td->mt_flags = 0; | |
721 | } | |
722 | ||
723 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |
724 | struct hid_field *field, struct hid_usage *usage, | |
725 | unsigned long **bit, int *max) | |
726 | { | |
6aef704e BT |
727 | struct mt_device *td = hid_get_drvdata(hdev); |
728 | ||
729 | /* | |
730 | * If mtclass.export_all_inputs is not set, only map fields from | |
731 | * TouchScreen or TouchPad collections. We need to ignore fields | |
732 | * that belong to other collections such as Mouse that might have | |
733 | * the same GenericDesktop usages. | |
734 | */ | |
735 | if (!td->mtclass.export_all_inputs && | |
736 | field->application != HID_DG_TOUCHSCREEN && | |
fa11aa72 | 737 | field->application != HID_DG_PEN && |
a69c5f8b | 738 | field->application != HID_DG_TOUCHPAD) |
6f492f28 | 739 | return -1; |
a69c5f8b | 740 | |
6aef704e BT |
741 | /* |
742 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
743 | * for the stylus. | |
744 | */ | |
a69c5f8b | 745 | if (field->physical == HID_DG_STYLUS) |
e55f6200 | 746 | return 0; |
a69c5f8b | 747 | |
6aef704e BT |
748 | if (field->application == HID_DG_TOUCHSCREEN || |
749 | field->application == HID_DG_TOUCHPAD) | |
750 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max); | |
751 | ||
752 | /* let hid-core decide for the others */ | |
753 | return 0; | |
a69c5f8b BT |
754 | } |
755 | ||
756 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |
757 | struct hid_field *field, struct hid_usage *usage, | |
758 | unsigned long **bit, int *max) | |
759 | { | |
6aef704e BT |
760 | /* |
761 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
762 | * for the stylus. | |
763 | */ | |
fa11aa72 | 764 | if (field->physical == HID_DG_STYLUS) |
e55f6200 | 765 | return 0; |
fa11aa72 | 766 | |
6aef704e BT |
767 | if (field->application == HID_DG_TOUCHSCREEN || |
768 | field->application == HID_DG_TOUCHPAD) | |
769 | return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); | |
770 | ||
771 | /* let hid-core decide for the others */ | |
772 | return 0; | |
a69c5f8b BT |
773 | } |
774 | ||
775 | static int mt_event(struct hid_device *hid, struct hid_field *field, | |
776 | struct hid_usage *usage, __s32 value) | |
777 | { | |
778 | struct mt_device *td = hid_get_drvdata(hid); | |
779 | ||
780 | if (field->report->id == td->mt_report_id) | |
781 | return mt_touch_event(hid, field, usage, value); | |
782 | ||
e55f6200 | 783 | return 0; |
a69c5f8b BT |
784 | } |
785 | ||
786 | static void mt_report(struct hid_device *hid, struct hid_report *report) | |
787 | { | |
788 | struct mt_device *td = hid_get_drvdata(hid); | |
e55f6200 | 789 | struct hid_field *field = report->field[0]; |
a69c5f8b BT |
790 | |
791 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | |
792 | return; | |
793 | ||
794 | if (report->id == td->mt_report_id) | |
e55f6200 | 795 | return mt_touch_report(hid, report); |
fa11aa72 | 796 | |
e55f6200 BT |
797 | if (field && field->hidinput && field->hidinput->input) |
798 | input_sync(field->hidinput->input); | |
5519cab4 BT |
799 | } |
800 | ||
801 | static void mt_set_input_mode(struct hid_device *hdev) | |
802 | { | |
803 | struct mt_device *td = hid_get_drvdata(hdev); | |
804 | struct hid_report *r; | |
805 | struct hid_report_enum *re; | |
806 | ||
807 | if (td->inputmode < 0) | |
808 | return; | |
809 | ||
810 | re = &(hdev->report_enum[HID_FEATURE_REPORT]); | |
811 | r = re->report_id_hash[td->inputmode]; | |
812 | if (r) { | |
4aceed37 | 813 | r->field[0]->value[td->inputmode_index] = 0x02; |
d8814272 | 814 | hid_hw_request(hdev, r, HID_REQ_SET_REPORT); |
5519cab4 BT |
815 | } |
816 | } | |
817 | ||
31ae9bdd BT |
818 | static void mt_set_maxcontacts(struct hid_device *hdev) |
819 | { | |
820 | struct mt_device *td = hid_get_drvdata(hdev); | |
821 | struct hid_report *r; | |
822 | struct hid_report_enum *re; | |
823 | int fieldmax, max; | |
824 | ||
825 | if (td->maxcontact_report_id < 0) | |
826 | return; | |
827 | ||
828 | if (!td->mtclass.maxcontacts) | |
829 | return; | |
830 | ||
831 | re = &hdev->report_enum[HID_FEATURE_REPORT]; | |
832 | r = re->report_id_hash[td->maxcontact_report_id]; | |
833 | if (r) { | |
834 | max = td->mtclass.maxcontacts; | |
835 | fieldmax = r->field[0]->logical_maximum; | |
836 | max = min(fieldmax, max); | |
837 | if (r->field[0]->value[0] != max) { | |
838 | r->field[0]->value[0] = max; | |
d8814272 | 839 | hid_hw_request(hdev, r, HID_REQ_SET_REPORT); |
31ae9bdd BT |
840 | } |
841 | } | |
842 | } | |
843 | ||
4fa3a583 HR |
844 | static void mt_post_parse_default_settings(struct mt_device *td) |
845 | { | |
846 | __s32 quirks = td->mtclass.quirks; | |
847 | ||
848 | /* unknown serial device needs special quirks */ | |
849 | if (td->touches_by_report == 1) { | |
850 | quirks |= MT_QUIRK_ALWAYS_VALID; | |
851 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | |
852 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | |
853 | quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; | |
e0bb8f9a | 854 | quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
4fa3a583 HR |
855 | } |
856 | ||
857 | td->mtclass.quirks = quirks; | |
858 | } | |
859 | ||
3ac36d15 BT |
860 | static void mt_post_parse(struct mt_device *td) |
861 | { | |
862 | struct mt_fields *f = td->fields; | |
c2517f62 | 863 | struct mt_class *cls = &td->mtclass; |
3ac36d15 BT |
864 | |
865 | if (td->touches_by_report > 0) { | |
866 | int field_count_per_touch = f->length / td->touches_by_report; | |
867 | td->last_slot_field = f->usages[field_count_per_touch - 1]; | |
868 | } | |
c2517f62 | 869 | |
7e3cc447 | 870 | if (td->cc_index < 0) |
c2517f62 | 871 | cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
3ac36d15 BT |
872 | } |
873 | ||
76f5902a | 874 | static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
76f5902a HR |
875 | { |
876 | struct mt_device *td = hid_get_drvdata(hdev); | |
c08d46aa BT |
877 | char *name; |
878 | const char *suffix = NULL; | |
6aef704e | 879 | struct hid_field *field = hi->report->field[0]; |
76f5902a | 880 | |
5b6498a1 BT |
881 | if (hi->report->id == td->mt_report_id) |
882 | mt_touch_input_configured(hdev, hi); | |
76f5902a | 883 | |
6aef704e BT |
884 | /* |
885 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
886 | * for the stylus. Check this first, and then rely on the application | |
887 | * field. | |
888 | */ | |
c08d46aa BT |
889 | if (hi->report->field[0]->physical == HID_DG_STYLUS) { |
890 | suffix = "Pen"; | |
e55f6200 BT |
891 | /* force BTN_STYLUS to allow tablet matching in udev */ |
892 | __set_bit(BTN_STYLUS, hi->input->keybit); | |
6aef704e BT |
893 | } else { |
894 | switch (field->application) { | |
895 | case HID_GD_KEYBOARD: | |
896 | suffix = "Keyboard"; | |
897 | break; | |
898 | case HID_GD_KEYPAD: | |
899 | suffix = "Keypad"; | |
900 | break; | |
901 | case HID_GD_MOUSE: | |
902 | suffix = "Mouse"; | |
903 | break; | |
904 | case HID_DG_STYLUS: | |
905 | suffix = "Pen"; | |
906 | /* force BTN_STYLUS to allow tablet matching in udev */ | |
907 | __set_bit(BTN_STYLUS, hi->input->keybit); | |
908 | break; | |
909 | case HID_DG_TOUCHSCREEN: | |
910 | /* we do not set suffix = "Touchscreen" */ | |
911 | break; | |
912 | case HID_GD_SYSTEM_CONTROL: | |
913 | suffix = "System Control"; | |
914 | break; | |
915 | case HID_CP_CONSUMER_CONTROL: | |
916 | suffix = "Consumer Control"; | |
917 | break; | |
918 | default: | |
919 | suffix = "UNKNOWN"; | |
920 | break; | |
921 | } | |
c08d46aa BT |
922 | } |
923 | ||
924 | if (suffix) { | |
925 | name = devm_kzalloc(&hi->input->dev, | |
926 | strlen(hdev->name) + strlen(suffix) + 2, | |
927 | GFP_KERNEL); | |
928 | if (name) { | |
929 | sprintf(name, "%s %s", hdev->name, suffix); | |
930 | hi->input->name = name; | |
931 | } | |
932 | } | |
76f5902a HR |
933 | } |
934 | ||
5519cab4 BT |
935 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
936 | { | |
2d93666e | 937 | int ret, i; |
5519cab4 | 938 | struct mt_device *td; |
2d93666e BT |
939 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
940 | ||
94b5485c HR |
941 | for (i = 0; mt_classes[i].name ; i++) { |
942 | if (id->driver_data == mt_classes[i].name) { | |
943 | mtclass = &(mt_classes[i]); | |
944 | break; | |
2d93666e BT |
945 | } |
946 | } | |
5519cab4 | 947 | |
d682bd7f HR |
948 | /* This allows the driver to correctly support devices |
949 | * that emit events over several HID messages. | |
950 | */ | |
951 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; | |
5519cab4 | 952 | |
fa11aa72 BT |
953 | /* |
954 | * This allows the driver to handle different input sensors | |
955 | * that emits events through different reports on the same HID | |
956 | * device. | |
957 | */ | |
958 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | |
959 | hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; | |
960 | ||
595e9276 BT |
961 | /* |
962 | * Handle special quirks for Windows 8 certified devices. | |
963 | */ | |
964 | if (id->group == HID_GROUP_MULTITOUCH_WIN_8) | |
965 | /* | |
966 | * Some multitouch screens do not like to be polled for input | |
967 | * reports. Fortunately, the Win8 spec says that all touches | |
968 | * should be sent during each report, making the initialization | |
969 | * of input reports unnecessary. | |
970 | */ | |
971 | hdev->quirks |= HID_QUIRK_NO_INIT_INPUT_REPORTS; | |
972 | ||
c08d46aa | 973 | td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); |
5519cab4 BT |
974 | if (!td) { |
975 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | |
976 | return -ENOMEM; | |
977 | } | |
eec29e3d | 978 | td->mtclass = *mtclass; |
5519cab4 | 979 | td->inputmode = -1; |
31ae9bdd | 980 | td->maxcontact_report_id = -1; |
7e3cc447 | 981 | td->cc_index = -1; |
fa11aa72 | 982 | td->mt_report_id = -1; |
5519cab4 BT |
983 | hid_set_drvdata(hdev, td); |
984 | ||
c08d46aa BT |
985 | td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), |
986 | GFP_KERNEL); | |
3ac36d15 BT |
987 | if (!td->fields) { |
988 | dev_err(&hdev->dev, "cannot allocate multitouch fields data\n"); | |
c08d46aa | 989 | return -ENOMEM; |
3ac36d15 BT |
990 | } |
991 | ||
76f5902a HR |
992 | if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) |
993 | td->serial_maybe = true; | |
994 | ||
5519cab4 BT |
995 | ret = hid_parse(hdev); |
996 | if (ret != 0) | |
c08d46aa | 997 | return ret; |
5519cab4 BT |
998 | |
999 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
2d93666e | 1000 | if (ret) |
c08d46aa | 1001 | return ret; |
5519cab4 | 1002 | |
eec29e3d BT |
1003 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
1004 | ||
31ae9bdd | 1005 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
1006 | mt_set_input_mode(hdev); |
1007 | ||
c08d46aa BT |
1008 | /* release .fields memory as it is not used anymore */ |
1009 | devm_kfree(&hdev->dev, td->fields); | |
3ac36d15 BT |
1010 | td->fields = NULL; |
1011 | ||
5519cab4 | 1012 | return 0; |
5519cab4 BT |
1013 | } |
1014 | ||
1015 | #ifdef CONFIG_PM | |
1016 | static int mt_reset_resume(struct hid_device *hdev) | |
1017 | { | |
31ae9bdd | 1018 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
1019 | mt_set_input_mode(hdev); |
1020 | return 0; | |
1021 | } | |
dfeefd10 SL |
1022 | |
1023 | static int mt_resume(struct hid_device *hdev) | |
1024 | { | |
dfeefd10 SL |
1025 | /* Some Elan legacy devices require SET_IDLE to be set on resume. |
1026 | * It should be safe to send it to other devices too. | |
1027 | * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ | |
1028 | ||
4ba25d3f | 1029 | hid_hw_idle(hdev, 0, 0, HID_REQ_SET_IDLE); |
dfeefd10 SL |
1030 | |
1031 | return 0; | |
1032 | } | |
5519cab4 BT |
1033 | #endif |
1034 | ||
1035 | static void mt_remove(struct hid_device *hdev) | |
1036 | { | |
eec29e3d | 1037 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
5939212d | 1038 | hid_hw_stop(hdev); |
5519cab4 BT |
1039 | } |
1040 | ||
0fa9c616 BT |
1041 | /* |
1042 | * This list contains only: | |
1043 | * - VID/PID of products not working with the default multitouch handling | |
1044 | * - 2 generic rules. | |
1045 | * So there is no point in adding here any device with MT_CLS_DEFAULT. | |
1046 | */ | |
5519cab4 BT |
1047 | static const struct hid_device_id mt_devices[] = { |
1048 | ||
f786bba4 BT |
1049 | /* 3M panels */ |
1050 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1051 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 BT |
1052 | USB_DEVICE_ID_3M1968) }, |
1053 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1054 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 | 1055 | USB_DEVICE_ID_3M2256) }, |
c4fad877 | 1056 | { .driver_data = MT_CLS_3M, |
2c2110e9 | 1057 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
c4fad877 | 1058 | USB_DEVICE_ID_3M3266) }, |
f786bba4 | 1059 | |
6aef704e BT |
1060 | /* Anton devices */ |
1061 | { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, | |
1062 | MT_USB_DEVICE(USB_VENDOR_ID_ANTON, | |
1063 | USB_DEVICE_ID_ANTON_TOUCH_PAD) }, | |
1064 | ||
b1057124 | 1065 | /* Atmel panels */ |
841cb157 | 1066 | { .driver_data = MT_CLS_SERIAL, |
2c2110e9 | 1067 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
841cb157 | 1068 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
b1057124 | 1069 | |
9ed32695 | 1070 | /* Baanto multitouch devices */ |
dc3e1d80 | 1071 | { .driver_data = MT_CLS_NSMU, |
16b79bb8 | 1072 | MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, |
9ed32695 | 1073 | USB_DEVICE_ID_BAANTO_MT_190W2) }, |
0fa9c616 | 1074 | |
a841b62c BT |
1075 | /* Cando panels */ |
1076 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1077 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c | 1078 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
a841b62c | 1079 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2c2110e9 | 1080 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
1081 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
1082 | ||
942fd422 | 1083 | /* Chunghwa Telecom touch panels */ |
dc3e1d80 | 1084 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1085 | MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
942fd422 AZ |
1086 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
1087 | ||
79603dc9 | 1088 | /* CVTouch panels */ |
dc3e1d80 | 1089 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1090 | MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
79603dc9 BT |
1091 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
1092 | ||
22408283 | 1093 | /* eGalax devices (resistive) */ |
e36f690b | 1094 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1095 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b BT |
1096 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
1097 | { .driver_data = MT_CLS_EGALAX, | |
2c2110e9 | 1098 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1099 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
22408283 BT |
1100 | |
1101 | /* eGalax devices (capacitive) */ | |
fd1d1525 | 1102 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1103 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1104 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
aa672da1 | 1105 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1106 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1107 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
fd1d1525 | 1108 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1109 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1110 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
2ce09df4 | 1111 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1112 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
2ce09df4 | 1113 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
aa672da1 | 1114 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1115 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1116 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
fd1d1525 | 1117 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1118 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1119 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
aa672da1 AS |
1120 | { .driver_data = MT_CLS_EGALAX, |
1121 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1122 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, | |
e36f690b | 1123 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1124 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1125 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
fd1d1525 | 1126 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1127 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1128 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
aa672da1 AS |
1129 | { .driver_data = MT_CLS_EGALAX, |
1130 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1131 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, | |
1132 | { .driver_data = MT_CLS_EGALAX, | |
1133 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1134 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, | |
66f06127 | 1135 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1136 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
66f06127 | 1137 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
bb9ff210 | 1138 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1139 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
bb9ff210 | 1140 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
fd1d1525 | 1141 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1142 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1143 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
1b723e8d | 1144 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
ae01c9e5 TR |
1145 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
1146 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, | |
1b723e8d | 1147 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1148 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1149 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
22408283 | 1150 | |
77723e3b HR |
1151 | /* Flatfrog Panels */ |
1152 | { .driver_data = MT_CLS_FLATFROG, | |
1153 | MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, | |
1154 | USB_DEVICE_ID_MULTITOUCH_3200) }, | |
1155 | ||
5572da08 | 1156 | /* GeneralTouch panel */ |
f5ff4e1e | 1157 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
2c2110e9 | 1158 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
5572da08 | 1159 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
f5ff4e1e XY |
1160 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
1161 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1162 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, | |
7b226292 L |
1163 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
1164 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1165 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) }, | |
1166 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1167 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1168 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) }, | |
1169 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1170 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1171 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) }, | |
1172 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1173 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1174 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) }, | |
1175 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1176 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1177 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) }, | |
5572da08 | 1178 | |
4d5df5d1 | 1179 | /* Gametel game controller */ |
dc3e1d80 | 1180 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1181 | MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, |
4d5df5d1 AN |
1182 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
1183 | ||
ee0fbd14 | 1184 | /* GoodTouch panels */ |
dc3e1d80 | 1185 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1186 | MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
ee0fbd14 BT |
1187 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
1188 | ||
54580365 BT |
1189 | /* Hanvon panels */ |
1190 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | |
2c2110e9 | 1191 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
54580365 BT |
1192 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
1193 | ||
4e61f0d7 | 1194 | /* Ilitek dual touch panel */ |
dc3e1d80 | 1195 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1196 | MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
4e61f0d7 AZ |
1197 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
1198 | ||
4a6ee685 BT |
1199 | /* MosArt panels */ |
1200 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1201 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1202 | USB_DEVICE_ID_ASUS_T91MT)}, |
1203 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1204 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1205 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
1206 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1207 | MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
4a6ee685 BT |
1208 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
1209 | ||
2258e863 DK |
1210 | /* Panasonic panels */ |
1211 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1212 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1213 | USB_DEVICE_ID_PANABOARD_UBT780) }, |
1214 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1215 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1216 | USB_DEVICE_ID_PANABOARD_UBT880) }, |
1217 | ||
4db703ea | 1218 | /* Novatek Panel */ |
dc3e1d80 | 1219 | { .driver_data = MT_CLS_NSMU, |
4380d819 | 1220 | MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, |
4db703ea AH |
1221 | USB_DEVICE_ID_NOVATEK_PCT) }, |
1222 | ||
b7ea95ff AT |
1223 | /* PixArt optical touch screen */ |
1224 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1225 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1226 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
1227 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1228 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1229 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
1230 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1231 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1232 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
1233 | ||
5519cab4 | 1234 | /* PixCir-based panels */ |
1e9cf35b | 1235 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
2c2110e9 | 1236 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
5519cab4 BT |
1237 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
1238 | ||
5e7ea11f | 1239 | /* Quanta-based panels */ |
5e7ea11f | 1240 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
2c2110e9 | 1241 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f | 1242 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
a6802e00 | 1243 | |
043b403a | 1244 | /* Stantum panels */ |
bf5af9b5 | 1245 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 1246 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
043b403a | 1247 | USB_DEVICE_ID_MTP_STM)}, |
043b403a | 1248 | |
847672cd BT |
1249 | /* TopSeed panels */ |
1250 | { .driver_data = MT_CLS_TOPSEED, | |
2c2110e9 | 1251 | MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
847672cd BT |
1252 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
1253 | ||
5e74e56d | 1254 | /* Touch International panels */ |
dc3e1d80 | 1255 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1256 | MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
5e74e56d BT |
1257 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
1258 | ||
617b64f9 | 1259 | /* Unitec panels */ |
dc3e1d80 | 1260 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1261 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 1262 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
dc3e1d80 | 1263 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1264 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 1265 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
bf9d121e KC |
1266 | |
1267 | /* Wistron panels */ | |
1268 | { .driver_data = MT_CLS_NSMU, | |
1269 | MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, | |
1270 | USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, | |
1271 | ||
bc8a2a9b | 1272 | /* XAT */ |
dc3e1d80 | 1273 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1274 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
bc8a2a9b | 1275 | USB_DEVICE_ID_XAT_CSR) }, |
617b64f9 | 1276 | |
11576c61 | 1277 | /* Xiroku */ |
dc3e1d80 | 1278 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1279 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1280 | USB_DEVICE_ID_XIROKU_SPX) }, |
dc3e1d80 | 1281 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1282 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1283 | USB_DEVICE_ID_XIROKU_MPX) }, |
dc3e1d80 | 1284 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1285 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1286 | USB_DEVICE_ID_XIROKU_CSR) }, |
dc3e1d80 | 1287 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1288 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1289 | USB_DEVICE_ID_XIROKU_SPX1) }, |
dc3e1d80 | 1290 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1291 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1292 | USB_DEVICE_ID_XIROKU_MPX1) }, |
dc3e1d80 | 1293 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1294 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1295 | USB_DEVICE_ID_XIROKU_CSR1) }, |
dc3e1d80 | 1296 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1297 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1298 | USB_DEVICE_ID_XIROKU_SPX2) }, |
dc3e1d80 | 1299 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1300 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1301 | USB_DEVICE_ID_XIROKU_MPX2) }, |
dc3e1d80 | 1302 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1303 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1304 | USB_DEVICE_ID_XIROKU_CSR2) }, |
1305 | ||
4fa3a583 HR |
1306 | /* Generic MT device */ |
1307 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
f961bd35 BT |
1308 | |
1309 | /* Generic Win 8 certified MT device */ | |
1310 | { .driver_data = MT_CLS_WIN_8, | |
1311 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, | |
1312 | HID_ANY_ID, HID_ANY_ID) }, | |
5519cab4 BT |
1313 | { } |
1314 | }; | |
1315 | MODULE_DEVICE_TABLE(hid, mt_devices); | |
1316 | ||
1317 | static const struct hid_usage_id mt_grabbed_usages[] = { | |
1318 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, | |
1319 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} | |
1320 | }; | |
1321 | ||
1322 | static struct hid_driver mt_driver = { | |
1323 | .name = "hid-multitouch", | |
1324 | .id_table = mt_devices, | |
1325 | .probe = mt_probe, | |
1326 | .remove = mt_remove, | |
1327 | .input_mapping = mt_input_mapping, | |
1328 | .input_mapped = mt_input_mapped, | |
76f5902a | 1329 | .input_configured = mt_input_configured, |
5519cab4 BT |
1330 | .feature_mapping = mt_feature_mapping, |
1331 | .usage_table = mt_grabbed_usages, | |
1332 | .event = mt_event, | |
55978fa9 | 1333 | .report = mt_report, |
5519cab4 BT |
1334 | #ifdef CONFIG_PM |
1335 | .reset_resume = mt_reset_resume, | |
dfeefd10 | 1336 | .resume = mt_resume, |
5519cab4 BT |
1337 | #endif |
1338 | }; | |
f425458e | 1339 | module_hid_driver(mt_driver); |