]>
Commit | Line | Data |
---|---|---|
5519cab4 BT |
1 | /* |
2 | * HID driver for multitouch panels | |
3 | * | |
c2ef8f21 BT |
4 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> |
5 | * Copyright (c) 2010-2012 Benjamin Tissoires <benjamin.tissoires@gmail.com> | |
6 | * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France | |
5519cab4 | 7 | * |
4875ac11 RN |
8 | * This code is partly based on hid-egalax.c: |
9 | * | |
10 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> | |
11 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | |
12 | * Copyright (c) 2010 Canonical, Ltd. | |
13 | * | |
f786bba4 BT |
14 | * This code is partly based on hid-3m-pct.c: |
15 | * | |
16 | * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr> | |
17 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | |
18 | * Copyright (c) 2010 Canonical, Ltd. | |
19 | * | |
5519cab4 BT |
20 | */ |
21 | ||
22 | /* | |
23 | * This program is free software; you can redistribute it and/or modify it | |
24 | * under the terms of the GNU General Public License as published by the Free | |
25 | * Software Foundation; either version 2 of the License, or (at your option) | |
26 | * any later version. | |
27 | */ | |
28 | ||
29 | #include <linux/device.h> | |
30 | #include <linux/hid.h> | |
31 | #include <linux/module.h> | |
32 | #include <linux/slab.h> | |
33 | #include <linux/usb.h> | |
34 | #include <linux/input/mt.h> | |
35 | #include "usbhid/usbhid.h" | |
36 | ||
37 | ||
38 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | |
ef2fafb3 | 39 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); |
5519cab4 BT |
40 | MODULE_DESCRIPTION("HID multitouch panels"); |
41 | MODULE_LICENSE("GPL"); | |
42 | ||
43 | #include "hid-ids.h" | |
44 | ||
45 | /* quirks to control the device */ | |
46 | #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0) | |
47 | #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1) | |
2d93666e | 48 | #define MT_QUIRK_CYPRESS (1 << 2) |
5572da08 | 49 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) |
a062cc5a SC |
50 | #define MT_QUIRK_ALWAYS_VALID (1 << 4) |
51 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) | |
52 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) | |
a062cc5a | 53 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) |
77723e3b | 54 | #define MT_QUIRK_NO_AREA (1 << 9) |
28728399 | 55 | #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) |
5519cab4 BT |
56 | |
57 | struct mt_slot { | |
349fd670 | 58 | __s32 x, y, cx, cy, p, w, h; |
5519cab4 BT |
59 | __s32 contactid; /* the device ContactID assigned to this slot */ |
60 | bool touch_state; /* is the touch valid? */ | |
5519cab4 BT |
61 | }; |
62 | ||
eec29e3d BT |
63 | struct mt_class { |
64 | __s32 name; /* MT_CLS */ | |
65 | __s32 quirks; | |
66 | __s32 sn_move; /* Signal/noise ratio for move events */ | |
67 | __s32 sn_width; /* Signal/noise ratio for width events */ | |
68 | __s32 sn_height; /* Signal/noise ratio for height events */ | |
69 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ | |
70 | __u8 maxcontacts; | |
c2ef8f21 | 71 | bool is_indirect; /* true for touchpads */ |
eec29e3d BT |
72 | }; |
73 | ||
3ac36d15 BT |
74 | struct mt_fields { |
75 | unsigned usages[HID_MAX_FIELDS]; | |
76 | unsigned int length; | |
77 | }; | |
78 | ||
5519cab4 BT |
79 | struct mt_device { |
80 | struct mt_slot curdata; /* placeholder of incoming data */ | |
eec29e3d | 81 | struct mt_class mtclass; /* our mt device class */ |
3ac36d15 BT |
82 | struct mt_fields *fields; /* temporary placeholder for storing the |
83 | multitouch fields */ | |
5519cab4 BT |
84 | unsigned last_field_index; /* last field index of the report */ |
85 | unsigned last_slot_field; /* the last field of a slot */ | |
86 | __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ | |
4aceed37 | 87 | __s8 inputmode_index; /* InputMode HID feature index in the report */ |
31ae9bdd BT |
88 | __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, |
89 | -1 if non-existent */ | |
5519cab4 BT |
90 | __u8 num_received; /* how many contacts we received */ |
91 | __u8 num_expected; /* expected last contact index */ | |
9498f954 | 92 | __u8 maxcontacts; |
9e87f22a BT |
93 | __u8 touches_by_report; /* how many touches are present in one report: |
94 | * 1 means we should use a serial protocol | |
95 | * > 1 means hybrid (multitouch) protocol */ | |
76f5902a | 96 | bool serial_maybe; /* need to check for serial protocol */ |
5519cab4 | 97 | bool curvalid; /* is the current contact valid? */ |
76f5902a | 98 | unsigned mt_flags; /* flags to pass to input-mt */ |
5519cab4 BT |
99 | }; |
100 | ||
5519cab4 | 101 | /* classes of device behavior */ |
22408283 BT |
102 | #define MT_CLS_DEFAULT 0x0001 |
103 | ||
a062cc5a SC |
104 | #define MT_CLS_SERIAL 0x0002 |
105 | #define MT_CLS_CONFIDENCE 0x0003 | |
5e7ea11f BT |
106 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
107 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 | |
108 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 | |
109 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 | |
110 | #define MT_CLS_DUAL_NSMU_CONTACTID 0x0008 | |
b7ea95ff | 111 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
22408283 BT |
112 | |
113 | /* vendor specific classes */ | |
114 | #define MT_CLS_3M 0x0101 | |
115 | #define MT_CLS_CYPRESS 0x0102 | |
116 | #define MT_CLS_EGALAX 0x0103 | |
1b723e8d | 117 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
847672cd | 118 | #define MT_CLS_TOPSEED 0x0105 |
2258e863 | 119 | #define MT_CLS_PANASONIC 0x0106 |
77723e3b | 120 | #define MT_CLS_FLATFROG 0x0107 |
cdcd3ac4 JK |
121 | #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 |
122 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 | |
5519cab4 | 123 | |
9498f954 | 124 | #define MT_DEFAULT_MAXCONTACT 10 |
afbcb04c | 125 | #define MT_MAX_MAXCONTACT 250 |
9498f954 | 126 | |
2c2110e9 HR |
127 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
128 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) | |
129 | ||
5519cab4 BT |
130 | /* |
131 | * these device-dependent functions determine what slot corresponds | |
132 | * to a valid contact that was just read. | |
133 | */ | |
134 | ||
a3b5e577 BT |
135 | static int cypress_compute_slot(struct mt_device *td) |
136 | { | |
137 | if (td->curdata.contactid != 0 || td->num_received == 0) | |
138 | return td->curdata.contactid; | |
139 | else | |
140 | return -1; | |
141 | } | |
142 | ||
b3c21d2c | 143 | static struct mt_class mt_classes[] = { |
2d93666e | 144 | { .name = MT_CLS_DEFAULT, |
9498f954 | 145 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
a062cc5a SC |
146 | { .name = MT_CLS_SERIAL, |
147 | .quirks = MT_QUIRK_ALWAYS_VALID}, | |
22408283 BT |
148 | { .name = MT_CLS_CONFIDENCE, |
149 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, | |
5e7ea11f BT |
150 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
151 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
152 | MT_QUIRK_SLOT_IS_CONTACTID }, | |
22408283 BT |
153 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
154 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
155 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, | |
1e9cf35b | 156 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
2d93666e BT |
157 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
158 | MT_QUIRK_SLOT_IS_CONTACTID, | |
159 | .maxcontacts = 2 }, | |
1e9cf35b | 160 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2d93666e BT |
161 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
162 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | |
163 | .maxcontacts = 2 }, | |
22408283 BT |
164 | { .name = MT_CLS_DUAL_NSMU_CONTACTID, |
165 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
166 | MT_QUIRK_SLOT_IS_CONTACTID, | |
167 | .maxcontacts = 2 }, | |
b7ea95ff AT |
168 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
169 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | |
170 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, | |
22408283 BT |
171 | |
172 | /* | |
173 | * vendor specific classes | |
174 | */ | |
175 | { .name = MT_CLS_3M, | |
176 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
177 | MT_QUIRK_SLOT_IS_CONTACTID, | |
178 | .sn_move = 2048, | |
179 | .sn_width = 128, | |
c5d40be5 HR |
180 | .sn_height = 128, |
181 | .maxcontacts = 60, | |
182 | }, | |
2d93666e BT |
183 | { .name = MT_CLS_CYPRESS, |
184 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
185 | MT_QUIRK_CYPRESS, | |
186 | .maxcontacts = 10 }, | |
4875ac11 RN |
187 | { .name = MT_CLS_EGALAX, |
188 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
2261bb9f | 189 | MT_QUIRK_VALID_IS_INRANGE, |
4875ac11 RN |
190 | .sn_move = 4096, |
191 | .sn_pressure = 32, | |
192 | }, | |
1b723e8d BT |
193 | { .name = MT_CLS_EGALAX_SERIAL, |
194 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
195 | MT_QUIRK_ALWAYS_VALID, | |
4875ac11 RN |
196 | .sn_move = 4096, |
197 | .sn_pressure = 32, | |
198 | }, | |
847672cd BT |
199 | { .name = MT_CLS_TOPSEED, |
200 | .quirks = MT_QUIRK_ALWAYS_VALID, | |
201 | .is_indirect = true, | |
202 | .maxcontacts = 2, | |
203 | }, | |
2258e863 DK |
204 | { .name = MT_CLS_PANASONIC, |
205 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, | |
206 | .maxcontacts = 4 }, | |
f5ff4e1e XY |
207 | { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, |
208 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
209 | MT_QUIRK_VALID_IS_INRANGE | | |
210 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | |
211 | .maxcontacts = 2 | |
212 | }, | |
213 | { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
214 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
58ad34bf | 215 | MT_QUIRK_SLOT_IS_CONTACTNUMBER |
f5ff4e1e | 216 | }, |
043b403a | 217 | |
77723e3b HR |
218 | { .name = MT_CLS_FLATFROG, |
219 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
220 | MT_QUIRK_NO_AREA, | |
221 | .sn_move = 2048, | |
222 | .maxcontacts = 40, | |
223 | }, | |
2d93666e | 224 | { } |
5519cab4 BT |
225 | }; |
226 | ||
eec29e3d BT |
227 | static ssize_t mt_show_quirks(struct device *dev, |
228 | struct device_attribute *attr, | |
229 | char *buf) | |
230 | { | |
231 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
232 | struct mt_device *td = hid_get_drvdata(hdev); | |
233 | ||
234 | return sprintf(buf, "%u\n", td->mtclass.quirks); | |
235 | } | |
236 | ||
237 | static ssize_t mt_set_quirks(struct device *dev, | |
238 | struct device_attribute *attr, | |
239 | const char *buf, size_t count) | |
240 | { | |
241 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
242 | struct mt_device *td = hid_get_drvdata(hdev); | |
243 | ||
244 | unsigned long val; | |
245 | ||
246 | if (kstrtoul(buf, 0, &val)) | |
247 | return -EINVAL; | |
248 | ||
249 | td->mtclass.quirks = val; | |
250 | ||
251 | return count; | |
252 | } | |
253 | ||
254 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); | |
255 | ||
256 | static struct attribute *sysfs_attrs[] = { | |
257 | &dev_attr_quirks.attr, | |
258 | NULL | |
259 | }; | |
260 | ||
261 | static struct attribute_group mt_attribute_group = { | |
262 | .attrs = sysfs_attrs | |
263 | }; | |
264 | ||
f635bd11 | 265 | static void mt_feature_mapping(struct hid_device *hdev, |
5519cab4 BT |
266 | struct hid_field *field, struct hid_usage *usage) |
267 | { | |
9498f954 | 268 | struct mt_device *td = hid_get_drvdata(hdev); |
4aceed37 | 269 | int i; |
9498f954 BT |
270 | |
271 | switch (usage->hid) { | |
272 | case HID_DG_INPUTMODE: | |
5519cab4 | 273 | td->inputmode = field->report->id; |
4aceed37 BT |
274 | td->inputmode_index = 0; /* has to be updated below */ |
275 | ||
276 | for (i=0; i < field->maxusage; i++) { | |
277 | if (field->usage[i].hid == usage->hid) { | |
278 | td->inputmode_index = i; | |
279 | break; | |
280 | } | |
281 | } | |
282 | ||
9498f954 BT |
283 | break; |
284 | case HID_DG_CONTACTMAX: | |
31ae9bdd | 285 | td->maxcontact_report_id = field->report->id; |
9498f954 | 286 | td->maxcontacts = field->value[0]; |
afbcb04c BT |
287 | if (!td->maxcontacts && |
288 | field->logical_maximum <= MT_MAX_MAXCONTACT) | |
289 | td->maxcontacts = field->logical_maximum; | |
eec29e3d | 290 | if (td->mtclass.maxcontacts) |
9498f954 | 291 | /* check if the maxcontacts is given by the class */ |
eec29e3d | 292 | td->maxcontacts = td->mtclass.maxcontacts; |
9498f954 BT |
293 | |
294 | break; | |
5519cab4 BT |
295 | } |
296 | } | |
297 | ||
298 | static void set_abs(struct input_dev *input, unsigned int code, | |
299 | struct hid_field *field, int snratio) | |
300 | { | |
301 | int fmin = field->logical_minimum; | |
302 | int fmax = field->logical_maximum; | |
303 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | |
304 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | |
37cf6e6f | 305 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
5519cab4 BT |
306 | } |
307 | ||
3ac36d15 | 308 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, |
ed9d5c96 BT |
309 | struct hid_input *hi) |
310 | { | |
3ac36d15 BT |
311 | struct mt_fields *f = td->fields; |
312 | ||
313 | if (f->length >= HID_MAX_FIELDS) | |
314 | return; | |
315 | ||
316 | f->usages[f->length++] = usage->hid; | |
ed9d5c96 BT |
317 | } |
318 | ||
5519cab4 BT |
319 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
320 | struct hid_field *field, struct hid_usage *usage, | |
321 | unsigned long **bit, int *max) | |
322 | { | |
323 | struct mt_device *td = hid_get_drvdata(hdev); | |
eec29e3d | 324 | struct mt_class *cls = &td->mtclass; |
c2ef8f21 | 325 | int code; |
349fd670 | 326 | struct hid_usage *prev_usage = NULL; |
4875ac11 | 327 | |
658d4aed | 328 | /* Only map fields from TouchScreen or TouchPad collections. |
2258e863 DK |
329 | * We need to ignore fields that belong to other collections |
330 | * such as Mouse that might have the same GenericDesktop usages. */ | |
658d4aed | 331 | if (field->application == HID_DG_TOUCHSCREEN) |
76f5902a | 332 | td->mt_flags |= INPUT_MT_DIRECT; |
c2ef8f21 | 333 | else if (field->application != HID_DG_TOUCHPAD) |
658d4aed JB |
334 | return 0; |
335 | ||
76f5902a HR |
336 | /* |
337 | * Model touchscreens providing buttons as touchpads. | |
c2ef8f21 BT |
338 | */ |
339 | if (field->application == HID_DG_TOUCHPAD || | |
76f5902a HR |
340 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
341 | td->mt_flags |= INPUT_MT_POINTER; | |
c2ef8f21 | 342 | |
2261bb9f BT |
343 | /* eGalax devices provide a Digitizer.Stylus input which overrides |
344 | * the correct Digitizers.Finger X/Y ranges. | |
345 | * Let's just ignore this input. */ | |
346 | if (field->physical == HID_DG_STYLUS) | |
347 | return -1; | |
348 | ||
349fd670 BT |
349 | if (usage->usage_index) |
350 | prev_usage = &field->usage[usage->usage_index - 1]; | |
351 | ||
5519cab4 BT |
352 | switch (usage->hid & HID_USAGE_PAGE) { |
353 | ||
354 | case HID_UP_GENDESK: | |
355 | switch (usage->hid) { | |
356 | case HID_GD_X: | |
349fd670 BT |
357 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
358 | hid_map_usage(hi, usage, bit, max, | |
359 | EV_ABS, ABS_MT_TOOL_X); | |
360 | set_abs(hi->input, ABS_MT_TOOL_X, field, | |
361 | cls->sn_move); | |
362 | } else { | |
363 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 364 | EV_ABS, ABS_MT_POSITION_X); |
349fd670 BT |
365 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
366 | cls->sn_move); | |
367 | } | |
368 | ||
3ac36d15 | 369 | mt_store_field(usage, td, hi); |
ed9d5c96 | 370 | td->last_field_index = field->index; |
5519cab4 BT |
371 | return 1; |
372 | case HID_GD_Y: | |
349fd670 BT |
373 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
374 | hid_map_usage(hi, usage, bit, max, | |
375 | EV_ABS, ABS_MT_TOOL_Y); | |
376 | set_abs(hi->input, ABS_MT_TOOL_Y, field, | |
377 | cls->sn_move); | |
378 | } else { | |
379 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 380 | EV_ABS, ABS_MT_POSITION_Y); |
349fd670 BT |
381 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
382 | cls->sn_move); | |
383 | } | |
384 | ||
3ac36d15 | 385 | mt_store_field(usage, td, hi); |
ed9d5c96 | 386 | td->last_field_index = field->index; |
5519cab4 BT |
387 | return 1; |
388 | } | |
389 | return 0; | |
390 | ||
391 | case HID_UP_DIGITIZER: | |
392 | switch (usage->hid) { | |
393 | case HID_DG_INRANGE: | |
3ac36d15 | 394 | mt_store_field(usage, td, hi); |
ed9d5c96 | 395 | td->last_field_index = field->index; |
5519cab4 BT |
396 | return 1; |
397 | case HID_DG_CONFIDENCE: | |
3ac36d15 | 398 | mt_store_field(usage, td, hi); |
ed9d5c96 | 399 | td->last_field_index = field->index; |
5519cab4 BT |
400 | return 1; |
401 | case HID_DG_TIPSWITCH: | |
402 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | |
403 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); | |
3ac36d15 | 404 | mt_store_field(usage, td, hi); |
ed9d5c96 | 405 | td->last_field_index = field->index; |
5519cab4 BT |
406 | return 1; |
407 | case HID_DG_CONTACTID: | |
3ac36d15 | 408 | mt_store_field(usage, td, hi); |
2955caed | 409 | td->last_field_index = field->index; |
9e87f22a | 410 | td->touches_by_report++; |
5519cab4 BT |
411 | return 1; |
412 | case HID_DG_WIDTH: | |
413 | hid_map_usage(hi, usage, bit, max, | |
414 | EV_ABS, ABS_MT_TOUCH_MAJOR); | |
77723e3b HR |
415 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) |
416 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, | |
417 | cls->sn_width); | |
3ac36d15 | 418 | mt_store_field(usage, td, hi); |
ed9d5c96 | 419 | td->last_field_index = field->index; |
5519cab4 BT |
420 | return 1; |
421 | case HID_DG_HEIGHT: | |
422 | hid_map_usage(hi, usage, bit, max, | |
423 | EV_ABS, ABS_MT_TOUCH_MINOR); | |
77723e3b HR |
424 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) { |
425 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, | |
426 | cls->sn_height); | |
427 | input_set_abs_params(hi->input, | |
1e648a13 | 428 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
77723e3b | 429 | } |
3ac36d15 | 430 | mt_store_field(usage, td, hi); |
ed9d5c96 | 431 | td->last_field_index = field->index; |
5519cab4 BT |
432 | return 1; |
433 | case HID_DG_TIPPRESSURE: | |
434 | hid_map_usage(hi, usage, bit, max, | |
435 | EV_ABS, ABS_MT_PRESSURE); | |
436 | set_abs(hi->input, ABS_MT_PRESSURE, field, | |
437 | cls->sn_pressure); | |
3ac36d15 | 438 | mt_store_field(usage, td, hi); |
ed9d5c96 | 439 | td->last_field_index = field->index; |
5519cab4 BT |
440 | return 1; |
441 | case HID_DG_CONTACTCOUNT: | |
ed9d5c96 | 442 | td->last_field_index = field->index; |
5519cab4 BT |
443 | return 1; |
444 | case HID_DG_CONTACTMAX: | |
445 | /* we don't set td->last_slot_field as contactcount and | |
446 | * contact max are global to the report */ | |
ed9d5c96 | 447 | td->last_field_index = field->index; |
5519cab4 | 448 | return -1; |
c2ef8f21 BT |
449 | case HID_DG_TOUCH: |
450 | /* Legacy devices use TIPSWITCH and not TOUCH. | |
451 | * Let's just ignore this field. */ | |
452 | return -1; | |
65b258e9 | 453 | } |
5519cab4 BT |
454 | /* let hid-input decide for the others */ |
455 | return 0; | |
456 | ||
c2ef8f21 BT |
457 | case HID_UP_BUTTON: |
458 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); | |
459 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); | |
460 | input_set_capability(hi->input, EV_KEY, code); | |
461 | return 1; | |
462 | ||
5519cab4 BT |
463 | case 0xff000000: |
464 | /* we do not want to map these: no input-oriented meaning */ | |
465 | return -1; | |
466 | } | |
467 | ||
468 | return 0; | |
469 | } | |
470 | ||
471 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |
472 | struct hid_field *field, struct hid_usage *usage, | |
473 | unsigned long **bit, int *max) | |
474 | { | |
475 | if (usage->type == EV_KEY || usage->type == EV_ABS) | |
476 | set_bit(usage->type, hi->input->evbit); | |
477 | ||
478 | return -1; | |
479 | } | |
480 | ||
3e1b5015 | 481 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 482 | { |
eec29e3d | 483 | __s32 quirks = td->mtclass.quirks; |
5519cab4 | 484 | |
2d93666e BT |
485 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
486 | return td->curdata.contactid; | |
5519cab4 | 487 | |
2d93666e | 488 | if (quirks & MT_QUIRK_CYPRESS) |
a3b5e577 BT |
489 | return cypress_compute_slot(td); |
490 | ||
2d93666e BT |
491 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
492 | return td->num_received; | |
5572da08 | 493 | |
4a6ee685 BT |
494 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
495 | return td->curdata.contactid - 1; | |
496 | ||
3e1b5015 | 497 | return input_mt_get_slot_by_key(input, td->curdata.contactid); |
5519cab4 BT |
498 | } |
499 | ||
500 | /* | |
501 | * this function is called when a whole contact has been processed, | |
502 | * so that it can assign it to a slot and store the data there | |
503 | */ | |
3e1b5015 | 504 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 505 | { |
20b60e6d | 506 | if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { |
3e1b5015 HR |
507 | int slotnum = mt_compute_slot(td, input); |
508 | struct mt_slot *s = &td->curdata; | |
28728399 | 509 | struct input_mt *mt = input->mt; |
5519cab4 | 510 | |
3e1b5015 HR |
511 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
512 | return; | |
5519cab4 | 513 | |
28728399 BT |
514 | if ((td->mtclass.quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { |
515 | struct input_mt_slot *slot = &mt->slots[slotnum]; | |
516 | if (input_mt_is_active(slot) && | |
517 | input_mt_is_used(mt, slot)) | |
518 | return; | |
519 | } | |
520 | ||
3e1b5015 | 521 | input_mt_slot(input, slotnum); |
5519cab4 BT |
522 | input_mt_report_slot_state(input, MT_TOOL_FINGER, |
523 | s->touch_state); | |
2d93666e | 524 | if (s->touch_state) { |
f786bba4 BT |
525 | /* this finger is on the screen */ |
526 | int wide = (s->w > s->h); | |
527 | /* divided by two to match visual scale of touch */ | |
528 | int major = max(s->w, s->h) >> 1; | |
529 | int minor = min(s->w, s->h) >> 1; | |
530 | ||
2d93666e BT |
531 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); |
532 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); | |
349fd670 BT |
533 | input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx); |
534 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); | |
f786bba4 | 535 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); |
2d93666e | 536 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); |
f786bba4 BT |
537 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
538 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); | |
2d93666e | 539 | } |
5519cab4 BT |
540 | } |
541 | ||
3e1b5015 HR |
542 | td->num_received++; |
543 | } | |
544 | ||
545 | /* | |
546 | * this function is called when a whole packet has been received and processed, | |
547 | * so that it can decide what to send to the input layer. | |
548 | */ | |
549 | static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | |
550 | { | |
76f5902a | 551 | input_mt_sync_frame(input); |
5519cab4 BT |
552 | input_sync(input); |
553 | td->num_received = 0; | |
554 | } | |
555 | ||
5519cab4 BT |
556 | static int mt_event(struct hid_device *hid, struct hid_field *field, |
557 | struct hid_usage *usage, __s32 value) | |
558 | { | |
559 | struct mt_device *td = hid_get_drvdata(hid); | |
eec29e3d | 560 | __s32 quirks = td->mtclass.quirks; |
5519cab4 | 561 | |
3e1b5015 | 562 | if (hid->claimed & HID_CLAIMED_INPUT) { |
5519cab4 BT |
563 | switch (usage->hid) { |
564 | case HID_DG_INRANGE: | |
20b60e6d | 565 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
2d93666e | 566 | td->curvalid = value; |
5519cab4 BT |
567 | break; |
568 | case HID_DG_TIPSWITCH: | |
2d93666e BT |
569 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
570 | td->curvalid = value; | |
5519cab4 BT |
571 | td->curdata.touch_state = value; |
572 | break; | |
573 | case HID_DG_CONFIDENCE: | |
2d93666e BT |
574 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
575 | td->curvalid = value; | |
5519cab4 BT |
576 | break; |
577 | case HID_DG_CONTACTID: | |
578 | td->curdata.contactid = value; | |
579 | break; | |
580 | case HID_DG_TIPPRESSURE: | |
581 | td->curdata.p = value; | |
582 | break; | |
583 | case HID_GD_X: | |
349fd670 BT |
584 | if (usage->code == ABS_MT_TOOL_X) |
585 | td->curdata.cx = value; | |
586 | else | |
587 | td->curdata.x = value; | |
5519cab4 BT |
588 | break; |
589 | case HID_GD_Y: | |
349fd670 BT |
590 | if (usage->code == ABS_MT_TOOL_Y) |
591 | td->curdata.cy = value; | |
592 | else | |
593 | td->curdata.y = value; | |
5519cab4 BT |
594 | break; |
595 | case HID_DG_WIDTH: | |
596 | td->curdata.w = value; | |
597 | break; | |
598 | case HID_DG_HEIGHT: | |
599 | td->curdata.h = value; | |
600 | break; | |
601 | case HID_DG_CONTACTCOUNT: | |
602 | /* | |
2d93666e BT |
603 | * Includes multi-packet support where subsequent |
604 | * packets are sent with zero contactcount. | |
5519cab4 BT |
605 | */ |
606 | if (value) | |
2d93666e | 607 | td->num_expected = value; |
5519cab4 | 608 | break; |
c2ef8f21 BT |
609 | case HID_DG_TOUCH: |
610 | /* do nothing */ | |
611 | break; | |
5519cab4 BT |
612 | |
613 | default: | |
614 | /* fallback to the generic hidinput handling */ | |
615 | return 0; | |
616 | } | |
5519cab4 | 617 | |
54f4c0c3 BT |
618 | if (usage->usage_index + 1 == field->report_count) { |
619 | /* we only take into account the last report. */ | |
620 | if (usage->hid == td->last_slot_field) | |
621 | mt_complete_slot(td, field->hidinput->input); | |
622 | ||
623 | if (field->index == td->last_field_index | |
624 | && td->num_received >= td->num_expected) | |
625 | mt_sync_frame(td, field->hidinput->input); | |
626 | } | |
5519cab4 | 627 | |
2d93666e | 628 | } |
5519cab4 BT |
629 | |
630 | /* we have handled the hidinput part, now remains hiddev */ | |
631 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) | |
632 | hid->hiddev_hid_event(hid, field, usage, value); | |
633 | ||
634 | return 1; | |
635 | } | |
636 | ||
637 | static void mt_set_input_mode(struct hid_device *hdev) | |
638 | { | |
639 | struct mt_device *td = hid_get_drvdata(hdev); | |
640 | struct hid_report *r; | |
641 | struct hid_report_enum *re; | |
642 | ||
643 | if (td->inputmode < 0) | |
644 | return; | |
645 | ||
646 | re = &(hdev->report_enum[HID_FEATURE_REPORT]); | |
647 | r = re->report_id_hash[td->inputmode]; | |
648 | if (r) { | |
4aceed37 | 649 | r->field[0]->value[td->inputmode_index] = 0x02; |
5519cab4 BT |
650 | usbhid_submit_report(hdev, r, USB_DIR_OUT); |
651 | } | |
652 | } | |
653 | ||
31ae9bdd BT |
654 | static void mt_set_maxcontacts(struct hid_device *hdev) |
655 | { | |
656 | struct mt_device *td = hid_get_drvdata(hdev); | |
657 | struct hid_report *r; | |
658 | struct hid_report_enum *re; | |
659 | int fieldmax, max; | |
660 | ||
661 | if (td->maxcontact_report_id < 0) | |
662 | return; | |
663 | ||
664 | if (!td->mtclass.maxcontacts) | |
665 | return; | |
666 | ||
667 | re = &hdev->report_enum[HID_FEATURE_REPORT]; | |
668 | r = re->report_id_hash[td->maxcontact_report_id]; | |
669 | if (r) { | |
670 | max = td->mtclass.maxcontacts; | |
671 | fieldmax = r->field[0]->logical_maximum; | |
672 | max = min(fieldmax, max); | |
673 | if (r->field[0]->value[0] != max) { | |
674 | r->field[0]->value[0] = max; | |
675 | usbhid_submit_report(hdev, r, USB_DIR_OUT); | |
676 | } | |
677 | } | |
678 | } | |
679 | ||
4fa3a583 HR |
680 | static void mt_post_parse_default_settings(struct mt_device *td) |
681 | { | |
682 | __s32 quirks = td->mtclass.quirks; | |
683 | ||
684 | /* unknown serial device needs special quirks */ | |
685 | if (td->touches_by_report == 1) { | |
686 | quirks |= MT_QUIRK_ALWAYS_VALID; | |
687 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | |
688 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | |
689 | quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; | |
690 | } | |
691 | ||
692 | td->mtclass.quirks = quirks; | |
693 | } | |
694 | ||
3ac36d15 BT |
695 | static void mt_post_parse(struct mt_device *td) |
696 | { | |
697 | struct mt_fields *f = td->fields; | |
698 | ||
699 | if (td->touches_by_report > 0) { | |
700 | int field_count_per_touch = f->length / td->touches_by_report; | |
701 | td->last_slot_field = f->usages[field_count_per_touch - 1]; | |
702 | } | |
703 | } | |
704 | ||
76f5902a HR |
705 | static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
706 | ||
707 | { | |
708 | struct mt_device *td = hid_get_drvdata(hdev); | |
709 | struct mt_class *cls = &td->mtclass; | |
710 | struct input_dev *input = hi->input; | |
711 | ||
712 | /* Only initialize slots for MT input devices */ | |
713 | if (!test_bit(ABS_MT_POSITION_X, input->absbit)) | |
714 | return; | |
715 | ||
716 | if (!td->maxcontacts) | |
717 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | |
718 | ||
719 | mt_post_parse(td); | |
720 | if (td->serial_maybe) | |
721 | mt_post_parse_default_settings(td); | |
722 | ||
723 | if (cls->is_indirect) | |
724 | td->mt_flags |= INPUT_MT_POINTER; | |
725 | ||
3e1b5015 HR |
726 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
727 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | |
728 | ||
76f5902a HR |
729 | input_mt_init_slots(input, td->maxcontacts, td->mt_flags); |
730 | ||
731 | td->mt_flags = 0; | |
732 | } | |
733 | ||
5519cab4 BT |
734 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
735 | { | |
2d93666e | 736 | int ret, i; |
5519cab4 | 737 | struct mt_device *td; |
2d93666e BT |
738 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
739 | ||
94b5485c HR |
740 | for (i = 0; mt_classes[i].name ; i++) { |
741 | if (id->driver_data == mt_classes[i].name) { | |
742 | mtclass = &(mt_classes[i]); | |
743 | break; | |
2d93666e BT |
744 | } |
745 | } | |
5519cab4 | 746 | |
d682bd7f HR |
747 | /* This allows the driver to correctly support devices |
748 | * that emit events over several HID messages. | |
749 | */ | |
750 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; | |
5519cab4 | 751 | |
9498f954 | 752 | td = kzalloc(sizeof(struct mt_device), GFP_KERNEL); |
5519cab4 BT |
753 | if (!td) { |
754 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | |
755 | return -ENOMEM; | |
756 | } | |
eec29e3d | 757 | td->mtclass = *mtclass; |
5519cab4 | 758 | td->inputmode = -1; |
31ae9bdd | 759 | td->maxcontact_report_id = -1; |
5519cab4 BT |
760 | hid_set_drvdata(hdev, td); |
761 | ||
3ac36d15 BT |
762 | td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL); |
763 | if (!td->fields) { | |
764 | dev_err(&hdev->dev, "cannot allocate multitouch fields data\n"); | |
765 | ret = -ENOMEM; | |
766 | goto fail; | |
767 | } | |
768 | ||
76f5902a HR |
769 | if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) |
770 | td->serial_maybe = true; | |
771 | ||
5519cab4 BT |
772 | ret = hid_parse(hdev); |
773 | if (ret != 0) | |
774 | goto fail; | |
775 | ||
776 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
2d93666e | 777 | if (ret) |
5519cab4 BT |
778 | goto fail; |
779 | ||
eec29e3d BT |
780 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
781 | ||
31ae9bdd | 782 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
783 | mt_set_input_mode(hdev); |
784 | ||
3ac36d15 BT |
785 | kfree(td->fields); |
786 | td->fields = NULL; | |
787 | ||
5519cab4 BT |
788 | return 0; |
789 | ||
790 | fail: | |
3ac36d15 | 791 | kfree(td->fields); |
5519cab4 BT |
792 | kfree(td); |
793 | return ret; | |
794 | } | |
795 | ||
796 | #ifdef CONFIG_PM | |
797 | static int mt_reset_resume(struct hid_device *hdev) | |
798 | { | |
31ae9bdd | 799 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
800 | mt_set_input_mode(hdev); |
801 | return 0; | |
802 | } | |
dfeefd10 SL |
803 | |
804 | static int mt_resume(struct hid_device *hdev) | |
805 | { | |
806 | struct usb_interface *intf; | |
807 | struct usb_host_interface *interface; | |
808 | struct usb_device *dev; | |
809 | ||
810 | if (hdev->bus != BUS_USB) | |
811 | return 0; | |
812 | ||
813 | intf = to_usb_interface(hdev->dev.parent); | |
814 | interface = intf->cur_altsetting; | |
815 | dev = hid_to_usb_dev(hdev); | |
816 | ||
817 | /* Some Elan legacy devices require SET_IDLE to be set on resume. | |
818 | * It should be safe to send it to other devices too. | |
819 | * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ | |
820 | ||
821 | usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | |
822 | HID_REQ_SET_IDLE, | |
823 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | |
824 | 0, interface->desc.bInterfaceNumber, | |
825 | NULL, 0, USB_CTRL_SET_TIMEOUT); | |
826 | ||
827 | return 0; | |
828 | } | |
5519cab4 BT |
829 | #endif |
830 | ||
831 | static void mt_remove(struct hid_device *hdev) | |
832 | { | |
833 | struct mt_device *td = hid_get_drvdata(hdev); | |
eec29e3d | 834 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
5519cab4 BT |
835 | hid_hw_stop(hdev); |
836 | kfree(td); | |
837 | hid_set_drvdata(hdev, NULL); | |
838 | } | |
839 | ||
840 | static const struct hid_device_id mt_devices[] = { | |
841 | ||
f786bba4 BT |
842 | /* 3M panels */ |
843 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 844 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 BT |
845 | USB_DEVICE_ID_3M1968) }, |
846 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 847 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 | 848 | USB_DEVICE_ID_3M2256) }, |
c4fad877 | 849 | { .driver_data = MT_CLS_3M, |
2c2110e9 | 850 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
c4fad877 | 851 | USB_DEVICE_ID_3M3266) }, |
f786bba4 | 852 | |
e6aac342 BT |
853 | /* ActionStar panels */ |
854 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 855 | MT_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, |
e6aac342 BT |
856 | USB_DEVICE_ID_ACTIONSTAR_1011) }, |
857 | ||
b1057124 BT |
858 | /* Atmel panels */ |
859 | { .driver_data = MT_CLS_SERIAL, | |
2c2110e9 | 860 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
b1057124 | 861 | USB_DEVICE_ID_ATMEL_MULTITOUCH) }, |
841cb157 | 862 | { .driver_data = MT_CLS_SERIAL, |
2c2110e9 | 863 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
841cb157 | 864 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
b1057124 | 865 | |
9ed32695 JK |
866 | /* Baanto multitouch devices */ |
867 | { .driver_data = MT_CLS_DEFAULT, | |
16b79bb8 | 868 | MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, |
9ed32695 | 869 | USB_DEVICE_ID_BAANTO_MT_190W2) }, |
a841b62c BT |
870 | /* Cando panels */ |
871 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 872 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
873 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
874 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 875 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
876 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, |
877 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 878 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
879 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
880 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 881 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
882 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
883 | ||
942fd422 AZ |
884 | /* Chunghwa Telecom touch panels */ |
885 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 886 | MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
942fd422 AZ |
887 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
888 | ||
79603dc9 BT |
889 | /* CVTouch panels */ |
890 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 891 | MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
79603dc9 BT |
892 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
893 | ||
a3b5e577 BT |
894 | /* Cypress panel */ |
895 | { .driver_data = MT_CLS_CYPRESS, | |
896 | HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, | |
897 | USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, | |
898 | ||
22408283 | 899 | /* eGalax devices (resistive) */ |
e36f690b | 900 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 901 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b BT |
902 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
903 | { .driver_data = MT_CLS_EGALAX, | |
2c2110e9 | 904 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 905 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
22408283 BT |
906 | |
907 | /* eGalax devices (capacitive) */ | |
e36f690b | 908 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 909 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 910 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
fd1d1525 | 911 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 912 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 BT |
913 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
914 | { .driver_data = MT_CLS_EGALAX_SERIAL, | |
2c2110e9 | 915 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 BT |
916 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
917 | { .driver_data = MT_CLS_EGALAX_SERIAL, | |
2c2110e9 | 918 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 919 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
2ce09df4 | 920 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 921 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
2ce09df4 | 922 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
e36f690b | 923 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 924 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 925 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, |
fd1d1525 | 926 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 927 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 928 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
e36f690b | 929 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 930 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 931 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
fd1d1525 | 932 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 933 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 934 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
66f06127 | 935 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 936 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
66f06127 | 937 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
bb9ff210 | 938 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 939 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
bb9ff210 | 940 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
fd1d1525 | 941 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 942 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 943 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
1b723e8d | 944 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
ae01c9e5 TR |
945 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
946 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, | |
1b723e8d | 947 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 948 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 949 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
3d77104a JK |
950 | { .driver_data = MT_CLS_EGALAX, |
951 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
952 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, | |
953 | { .driver_data = MT_CLS_EGALAX, | |
954 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
955 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, | |
956 | { .driver_data = MT_CLS_EGALAX, | |
957 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
958 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, | |
22408283 | 959 | |
c04abeef BT |
960 | /* Elo TouchSystems IntelliTouch Plus panel */ |
961 | { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID, | |
2c2110e9 | 962 | MT_USB_DEVICE(USB_VENDOR_ID_ELO, |
c04abeef BT |
963 | USB_DEVICE_ID_ELO_TS2515) }, |
964 | ||
77723e3b HR |
965 | /* Flatfrog Panels */ |
966 | { .driver_data = MT_CLS_FLATFROG, | |
967 | MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, | |
968 | USB_DEVICE_ID_MULTITOUCH_3200) }, | |
969 | ||
5572da08 | 970 | /* GeneralTouch panel */ |
f5ff4e1e | 971 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
2c2110e9 | 972 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
5572da08 | 973 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
f5ff4e1e XY |
974 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
975 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
976 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, | |
5572da08 | 977 | |
4d5df5d1 AN |
978 | /* Gametel game controller */ |
979 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 980 | MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, |
4d5df5d1 AN |
981 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
982 | ||
ee0fbd14 BT |
983 | /* GoodTouch panels */ |
984 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 985 | MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
ee0fbd14 BT |
986 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
987 | ||
54580365 BT |
988 | /* Hanvon panels */ |
989 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | |
2c2110e9 | 990 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
54580365 BT |
991 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
992 | ||
a062cc5a SC |
993 | /* Ideacom panel */ |
994 | { .driver_data = MT_CLS_SERIAL, | |
2c2110e9 | 995 | MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM, |
a062cc5a | 996 | USB_DEVICE_ID_IDEACOM_IDC6650) }, |
71078b0d | 997 | { .driver_data = MT_CLS_SERIAL, |
2c2110e9 | 998 | MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM, |
71078b0d | 999 | USB_DEVICE_ID_IDEACOM_IDC6651) }, |
a062cc5a | 1000 | |
4e61f0d7 AZ |
1001 | /* Ilitek dual touch panel */ |
1002 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1003 | MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
4e61f0d7 AZ |
1004 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
1005 | ||
4dfcced8 BT |
1006 | /* IRTOUCH panels */ |
1007 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | |
2c2110e9 | 1008 | MT_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, |
4dfcced8 BT |
1009 | USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, |
1010 | ||
c50bb1a4 JB |
1011 | /* LG Display panels */ |
1012 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1013 | MT_USB_DEVICE(USB_VENDOR_ID_LG, |
c50bb1a4 JB |
1014 | USB_DEVICE_ID_LG_MULTITOUCH) }, |
1015 | ||
df167c4a BT |
1016 | /* Lumio panels */ |
1017 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1018 | MT_USB_DEVICE(USB_VENDOR_ID_LUMIO, |
df167c4a | 1019 | USB_DEVICE_ID_CRYSTALTOUCH) }, |
c3ead6de | 1020 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
2c2110e9 | 1021 | MT_USB_DEVICE(USB_VENDOR_ID_LUMIO, |
c3ead6de | 1022 | USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, |
df167c4a | 1023 | |
4a6ee685 BT |
1024 | /* MosArt panels */ |
1025 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1026 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1027 | USB_DEVICE_ID_ASUS_T91MT)}, |
1028 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1029 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1030 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
1031 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1032 | MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
4a6ee685 BT |
1033 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
1034 | ||
2258e863 DK |
1035 | /* Panasonic panels */ |
1036 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1037 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1038 | USB_DEVICE_ID_PANABOARD_UBT780) }, |
1039 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1040 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1041 | USB_DEVICE_ID_PANABOARD_UBT880) }, |
1042 | ||
4db703ea AH |
1043 | /* Novatek Panel */ |
1044 | { .driver_data = MT_CLS_DEFAULT, | |
4380d819 | 1045 | MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, |
4db703ea AH |
1046 | USB_DEVICE_ID_NOVATEK_PCT) }, |
1047 | ||
6ab3a9a6 JS |
1048 | /* PenMount panels */ |
1049 | { .driver_data = MT_CLS_CONFIDENCE, | |
2c2110e9 | 1050 | MT_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, |
6ab3a9a6 JS |
1051 | USB_DEVICE_ID_PENMOUNT_PCI) }, |
1052 | ||
b7ea95ff AT |
1053 | /* PixArt optical touch screen */ |
1054 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1055 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1056 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
1057 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1058 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1059 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
1060 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1061 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1062 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
1063 | ||
5519cab4 | 1064 | /* PixCir-based panels */ |
1e9cf35b | 1065 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
2c2110e9 | 1066 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON, |
5519cab4 | 1067 | USB_DEVICE_ID_HANVON_MULTITOUCH) }, |
1e9cf35b | 1068 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
2c2110e9 | 1069 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
5519cab4 BT |
1070 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
1071 | ||
5e7ea11f BT |
1072 | /* Quanta-based panels */ |
1073 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, | |
2c2110e9 | 1074 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f BT |
1075 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
1076 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, | |
2c2110e9 | 1077 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f BT |
1078 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
1079 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, | |
2c2110e9 | 1080 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f BT |
1081 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) }, |
1082 | ||
043b403a | 1083 | /* Stantum panels */ |
bf5af9b5 | 1084 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 1085 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM, |
043b403a | 1086 | USB_DEVICE_ID_MTP)}, |
bf5af9b5 | 1087 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 1088 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
043b403a | 1089 | USB_DEVICE_ID_MTP_STM)}, |
bf5af9b5 | 1090 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 1091 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, |
043b403a BT |
1092 | USB_DEVICE_ID_MTP_SITRONIX)}, |
1093 | ||
847672cd BT |
1094 | /* TopSeed panels */ |
1095 | { .driver_data = MT_CLS_TOPSEED, | |
2c2110e9 | 1096 | MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
847672cd BT |
1097 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
1098 | ||
5e74e56d BT |
1099 | /* Touch International panels */ |
1100 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1101 | MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
5e74e56d BT |
1102 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
1103 | ||
617b64f9 BT |
1104 | /* Unitec panels */ |
1105 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1106 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 BT |
1107 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
1108 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1109 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 1110 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
bc8a2a9b | 1111 | /* XAT */ |
1112 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1113 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
bc8a2a9b | 1114 | USB_DEVICE_ID_XAT_CSR) }, |
617b64f9 | 1115 | |
11576c61 MH |
1116 | /* Xiroku */ |
1117 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1118 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1119 | USB_DEVICE_ID_XIROKU_SPX) }, |
1120 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1121 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1122 | USB_DEVICE_ID_XIROKU_MPX) }, |
1123 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1124 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1125 | USB_DEVICE_ID_XIROKU_CSR) }, |
1126 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1127 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1128 | USB_DEVICE_ID_XIROKU_SPX1) }, |
1129 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1130 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1131 | USB_DEVICE_ID_XIROKU_MPX1) }, |
1132 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1133 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1134 | USB_DEVICE_ID_XIROKU_CSR1) }, |
1135 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1136 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1137 | USB_DEVICE_ID_XIROKU_SPX2) }, |
1138 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1139 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1140 | USB_DEVICE_ID_XIROKU_MPX2) }, |
1141 | { .driver_data = MT_CLS_DEFAULT, | |
2c2110e9 | 1142 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1143 | USB_DEVICE_ID_XIROKU_CSR2) }, |
1144 | ||
82d06982 BT |
1145 | /* Zytronic panels */ |
1146 | { .driver_data = MT_CLS_SERIAL, | |
1147 | MT_USB_DEVICE(USB_VENDOR_ID_ZYTRONIC, | |
1148 | USB_DEVICE_ID_ZYTRONIC_ZXY100) }, | |
1149 | ||
4fa3a583 HR |
1150 | /* Generic MT device */ |
1151 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
5519cab4 BT |
1152 | { } |
1153 | }; | |
1154 | MODULE_DEVICE_TABLE(hid, mt_devices); | |
1155 | ||
1156 | static const struct hid_usage_id mt_grabbed_usages[] = { | |
1157 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, | |
1158 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} | |
1159 | }; | |
1160 | ||
1161 | static struct hid_driver mt_driver = { | |
1162 | .name = "hid-multitouch", | |
1163 | .id_table = mt_devices, | |
1164 | .probe = mt_probe, | |
1165 | .remove = mt_remove, | |
1166 | .input_mapping = mt_input_mapping, | |
1167 | .input_mapped = mt_input_mapped, | |
76f5902a | 1168 | .input_configured = mt_input_configured, |
5519cab4 BT |
1169 | .feature_mapping = mt_feature_mapping, |
1170 | .usage_table = mt_grabbed_usages, | |
1171 | .event = mt_event, | |
1172 | #ifdef CONFIG_PM | |
1173 | .reset_resume = mt_reset_resume, | |
dfeefd10 | 1174 | .resume = mt_resume, |
5519cab4 BT |
1175 | #endif |
1176 | }; | |
1177 | ||
1178 | static int __init mt_init(void) | |
1179 | { | |
1180 | return hid_register_driver(&mt_driver); | |
1181 | } | |
1182 | ||
1183 | static void __exit mt_exit(void) | |
1184 | { | |
1185 | hid_unregister_driver(&mt_driver); | |
1186 | } | |
1187 | ||
1188 | module_init(mt_init); | |
1189 | module_exit(mt_exit); |