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