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