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