2 * HID driver for multitouch panels
4 * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr>
5 * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com>
6 * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France
7 * Copyright (c) 2012-2013 Red Hat, Inc
9 * This code is partly based on hid-egalax.c:
11 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
12 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
13 * Copyright (c) 2010 Canonical, Ltd.
15 * This code is partly based on hid-3m-pct.c:
17 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
18 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
19 * Copyright (c) 2010 Canonical, Ltd.
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the Free
26 * Software Foundation; either version 2 of the License, or (at your option)
31 * This driver is regularly tested thanks to the tool hid-test[1].
32 * This tool relies on hid-replay[2] and a database of hid devices[3].
33 * Please run these regression tests before patching this module so that
34 * your patch won't break existing known devices.
36 * [1] https://github.com/bentiss/hid-test
37 * [2] https://github.com/bentiss/hid-replay
38 * [3] https://github.com/bentiss/hid-devices
41 #include <linux/device.h>
42 #include <linux/hid.h>
43 #include <linux/module.h>
44 #include <linux/slab.h>
45 #include <linux/input/mt.h>
46 #include <linux/string.h>
49 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
50 MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
51 MODULE_DESCRIPTION("HID multitouch panels");
52 MODULE_LICENSE("GPL");
56 /* quirks to control the device */
57 #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0)
58 #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1)
59 #define MT_QUIRK_CYPRESS (1 << 2)
60 #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3)
61 #define MT_QUIRK_ALWAYS_VALID (1 << 4)
62 #define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
63 #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
64 #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
65 #define MT_QUIRK_NO_AREA (1 << 9)
66 #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10)
67 #define MT_QUIRK_HOVERING (1 << 11)
68 #define MT_QUIRK_CONTACT_CNT_ACCURATE (1 << 12)
69 #define MT_QUIRK_FORCE_GET_FEATURE (1 << 13)
71 #define MT_INPUTMODE_TOUCHSCREEN 0x02
72 #define MT_INPUTMODE_TOUCHPAD 0x03
75 __s32 x
, y
, cx
, cy
, p
, w
, h
;
76 __s32 contactid
; /* the device ContactID assigned to this slot */
77 bool touch_state
; /* is the touch valid? */
78 bool inrange_state
; /* is the finger in proximity of the sensor? */
82 __s32 name
; /* MT_CLS */
84 __s32 sn_move
; /* Signal/noise ratio for move events */
85 __s32 sn_width
; /* Signal/noise ratio for width events */
86 __s32 sn_height
; /* Signal/noise ratio for height events */
87 __s32 sn_pressure
; /* Signal/noise ratio for pressure events */
89 bool is_indirect
; /* true for touchpads */
90 bool export_all_inputs
; /* do not ignore mouse, keyboards, etc... */
94 unsigned usages
[HID_MAX_FIELDS
];
99 struct mt_slot curdata
; /* placeholder of incoming data */
100 struct mt_class mtclass
; /* our mt device class */
101 struct mt_fields
*fields
; /* temporary placeholder for storing the
103 int cc_index
; /* contact count field index in the report */
104 int cc_value_index
; /* contact count value index in the field */
105 unsigned last_slot_field
; /* the last field of a slot */
106 unsigned mt_report_id
; /* the report ID of the multitouch device */
107 __s16 inputmode
; /* InputMode HID feature, -1 if non-existent */
108 __s16 inputmode_index
; /* InputMode HID feature index in the report */
109 __s16 maxcontact_report_id
; /* Maximum Contact Number HID feature,
110 -1 if non-existent */
111 __u8 inputmode_value
; /* InputMode HID feature value */
112 __u8 num_received
; /* how many contacts we received */
113 __u8 num_expected
; /* expected last contact index */
115 __u8 touches_by_report
; /* how many touches are present in one report:
116 * 1 means we should use a serial protocol
117 * > 1 means hybrid (multitouch) protocol */
118 bool serial_maybe
; /* need to check for serial protocol */
119 bool curvalid
; /* is the current contact valid? */
120 unsigned mt_flags
; /* flags to pass to input-mt */
123 static void mt_post_parse_default_settings(struct mt_device
*td
);
124 static void mt_post_parse(struct mt_device
*td
);
126 /* classes of device behavior */
127 #define MT_CLS_DEFAULT 0x0001
129 #define MT_CLS_SERIAL 0x0002
130 #define MT_CLS_CONFIDENCE 0x0003
131 #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004
132 #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005
133 #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006
134 #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007
135 /* reserved 0x0008 */
136 #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009
137 #define MT_CLS_NSMU 0x000a
138 /* reserved 0x0010 */
139 /* reserved 0x0011 */
140 #define MT_CLS_WIN_8 0x0012
141 #define MT_CLS_EXPORT_ALL_INPUTS 0x0013
143 /* vendor specific classes */
144 #define MT_CLS_3M 0x0101
145 /* reserved 0x0102 */
146 #define MT_CLS_EGALAX 0x0103
147 #define MT_CLS_EGALAX_SERIAL 0x0104
148 #define MT_CLS_TOPSEED 0x0105
149 #define MT_CLS_PANASONIC 0x0106
150 #define MT_CLS_FLATFROG 0x0107
151 #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108
152 #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109
153 #define MT_CLS_VTL 0x0110
155 #define MT_DEFAULT_MAXCONTACT 10
156 #define MT_MAX_MAXCONTACT 250
158 #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p)
159 #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p)
162 * these device-dependent functions determine what slot corresponds
163 * to a valid contact that was just read.
166 static int cypress_compute_slot(struct mt_device
*td
)
168 if (td
->curdata
.contactid
!= 0 || td
->num_received
== 0)
169 return td
->curdata
.contactid
;
174 static struct mt_class mt_classes
[] = {
175 { .name
= MT_CLS_DEFAULT
,
176 .quirks
= MT_QUIRK_ALWAYS_VALID
|
177 MT_QUIRK_CONTACT_CNT_ACCURATE
},
178 { .name
= MT_CLS_NSMU
,
179 .quirks
= MT_QUIRK_NOT_SEEN_MEANS_UP
},
180 { .name
= MT_CLS_SERIAL
,
181 .quirks
= MT_QUIRK_ALWAYS_VALID
},
182 { .name
= MT_CLS_CONFIDENCE
,
183 .quirks
= MT_QUIRK_VALID_IS_CONFIDENCE
},
184 { .name
= MT_CLS_CONFIDENCE_CONTACT_ID
,
185 .quirks
= MT_QUIRK_VALID_IS_CONFIDENCE
|
186 MT_QUIRK_SLOT_IS_CONTACTID
},
187 { .name
= MT_CLS_CONFIDENCE_MINUS_ONE
,
188 .quirks
= MT_QUIRK_VALID_IS_CONFIDENCE
|
189 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE
},
190 { .name
= MT_CLS_DUAL_INRANGE_CONTACTID
,
191 .quirks
= MT_QUIRK_VALID_IS_INRANGE
|
192 MT_QUIRK_SLOT_IS_CONTACTID
,
194 { .name
= MT_CLS_DUAL_INRANGE_CONTACTNUMBER
,
195 .quirks
= MT_QUIRK_VALID_IS_INRANGE
|
196 MT_QUIRK_SLOT_IS_CONTACTNUMBER
,
198 { .name
= MT_CLS_INRANGE_CONTACTNUMBER
,
199 .quirks
= MT_QUIRK_VALID_IS_INRANGE
|
200 MT_QUIRK_SLOT_IS_CONTACTNUMBER
},
201 { .name
= MT_CLS_WIN_8
,
202 .quirks
= MT_QUIRK_ALWAYS_VALID
|
203 MT_QUIRK_IGNORE_DUPLICATES
|
205 MT_QUIRK_CONTACT_CNT_ACCURATE
},
206 { .name
= MT_CLS_EXPORT_ALL_INPUTS
,
207 .quirks
= MT_QUIRK_ALWAYS_VALID
|
208 MT_QUIRK_CONTACT_CNT_ACCURATE
,
209 .export_all_inputs
= true },
212 * vendor specific classes
215 .quirks
= MT_QUIRK_VALID_IS_CONFIDENCE
|
216 MT_QUIRK_SLOT_IS_CONTACTID
,
222 { .name
= MT_CLS_EGALAX
,
223 .quirks
= MT_QUIRK_SLOT_IS_CONTACTID
|
224 MT_QUIRK_VALID_IS_INRANGE
,
228 { .name
= MT_CLS_EGALAX_SERIAL
,
229 .quirks
= MT_QUIRK_SLOT_IS_CONTACTID
|
230 MT_QUIRK_ALWAYS_VALID
,
234 { .name
= MT_CLS_TOPSEED
,
235 .quirks
= MT_QUIRK_ALWAYS_VALID
,
239 { .name
= MT_CLS_PANASONIC
,
240 .quirks
= MT_QUIRK_NOT_SEEN_MEANS_UP
,
242 { .name
= MT_CLS_GENERALTOUCH_TWOFINGERS
,
243 .quirks
= MT_QUIRK_NOT_SEEN_MEANS_UP
|
244 MT_QUIRK_VALID_IS_INRANGE
|
245 MT_QUIRK_SLOT_IS_CONTACTID
,
248 { .name
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
249 .quirks
= MT_QUIRK_NOT_SEEN_MEANS_UP
|
250 MT_QUIRK_SLOT_IS_CONTACTID
253 { .name
= MT_CLS_FLATFROG
,
254 .quirks
= MT_QUIRK_NOT_SEEN_MEANS_UP
|
259 { .name
= MT_CLS_VTL
,
260 .quirks
= MT_QUIRK_ALWAYS_VALID
|
261 MT_QUIRK_CONTACT_CNT_ACCURATE
|
262 MT_QUIRK_FORCE_GET_FEATURE
,
267 static ssize_t
mt_show_quirks(struct device
*dev
,
268 struct device_attribute
*attr
,
271 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
272 struct mt_device
*td
= hid_get_drvdata(hdev
);
274 return sprintf(buf
, "%u\n", td
->mtclass
.quirks
);
277 static ssize_t
mt_set_quirks(struct device
*dev
,
278 struct device_attribute
*attr
,
279 const char *buf
, size_t count
)
281 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
282 struct mt_device
*td
= hid_get_drvdata(hdev
);
286 if (kstrtoul(buf
, 0, &val
))
289 td
->mtclass
.quirks
= val
;
291 if (td
->cc_index
< 0)
292 td
->mtclass
.quirks
&= ~MT_QUIRK_CONTACT_CNT_ACCURATE
;
297 static DEVICE_ATTR(quirks
, S_IWUSR
| S_IRUGO
, mt_show_quirks
, mt_set_quirks
);
299 static struct attribute
*sysfs_attrs
[] = {
300 &dev_attr_quirks
.attr
,
304 static struct attribute_group mt_attribute_group
= {
308 static void mt_feature_mapping(struct hid_device
*hdev
,
309 struct hid_field
*field
, struct hid_usage
*usage
)
311 struct mt_device
*td
= hid_get_drvdata(hdev
);
313 switch (usage
->hid
) {
314 case HID_DG_INPUTMODE
:
315 /* Ignore if value index is out of bounds. */
316 if (usage
->usage_index
>= field
->report_count
) {
317 dev_err(&hdev
->dev
, "HID_DG_INPUTMODE out of range\n");
321 td
->inputmode
= field
->report
->id
;
322 td
->inputmode_index
= usage
->usage_index
;
325 case HID_DG_CONTACTMAX
:
326 td
->maxcontact_report_id
= field
->report
->id
;
327 td
->maxcontacts
= field
->value
[0];
328 if (!td
->maxcontacts
&&
329 field
->logical_maximum
<= MT_MAX_MAXCONTACT
)
330 td
->maxcontacts
= field
->logical_maximum
;
331 if (td
->mtclass
.maxcontacts
)
332 /* check if the maxcontacts is given by the class */
333 td
->maxcontacts
= td
->mtclass
.maxcontacts
;
339 static void set_abs(struct input_dev
*input
, unsigned int code
,
340 struct hid_field
*field
, int snratio
)
342 int fmin
= field
->logical_minimum
;
343 int fmax
= field
->logical_maximum
;
344 int fuzz
= snratio
? (fmax
- fmin
) / snratio
: 0;
345 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
346 input_abs_set_res(input
, code
, hidinput_calc_abs_res(field
, code
));
349 static void mt_store_field(struct hid_usage
*usage
, struct mt_device
*td
,
350 struct hid_input
*hi
)
352 struct mt_fields
*f
= td
->fields
;
354 if (f
->length
>= HID_MAX_FIELDS
)
357 f
->usages
[f
->length
++] = usage
->hid
;
360 static int mt_touch_input_mapping(struct hid_device
*hdev
, struct hid_input
*hi
,
361 struct hid_field
*field
, struct hid_usage
*usage
,
362 unsigned long **bit
, int *max
)
364 struct mt_device
*td
= hid_get_drvdata(hdev
);
365 struct mt_class
*cls
= &td
->mtclass
;
367 struct hid_usage
*prev_usage
= NULL
;
369 if (field
->application
== HID_DG_TOUCHSCREEN
)
370 td
->mt_flags
|= INPUT_MT_DIRECT
;
373 * Model touchscreens providing buttons as touchpads.
375 if (field
->application
== HID_DG_TOUCHPAD
||
376 (usage
->hid
& HID_USAGE_PAGE
) == HID_UP_BUTTON
) {
377 td
->mt_flags
|= INPUT_MT_POINTER
;
378 td
->inputmode_value
= MT_INPUTMODE_TOUCHPAD
;
381 if (usage
->usage_index
)
382 prev_usage
= &field
->usage
[usage
->usage_index
- 1];
384 switch (usage
->hid
& HID_USAGE_PAGE
) {
387 switch (usage
->hid
) {
389 if (prev_usage
&& (prev_usage
->hid
== usage
->hid
)) {
390 hid_map_usage(hi
, usage
, bit
, max
,
391 EV_ABS
, ABS_MT_TOOL_X
);
392 set_abs(hi
->input
, ABS_MT_TOOL_X
, field
,
395 hid_map_usage(hi
, usage
, bit
, max
,
396 EV_ABS
, ABS_MT_POSITION_X
);
397 set_abs(hi
->input
, ABS_MT_POSITION_X
, field
,
401 mt_store_field(usage
, td
, hi
);
404 if (prev_usage
&& (prev_usage
->hid
== usage
->hid
)) {
405 hid_map_usage(hi
, usage
, bit
, max
,
406 EV_ABS
, ABS_MT_TOOL_Y
);
407 set_abs(hi
->input
, ABS_MT_TOOL_Y
, field
,
410 hid_map_usage(hi
, usage
, bit
, max
,
411 EV_ABS
, ABS_MT_POSITION_Y
);
412 set_abs(hi
->input
, ABS_MT_POSITION_Y
, field
,
416 mt_store_field(usage
, td
, hi
);
421 case HID_UP_DIGITIZER
:
422 switch (usage
->hid
) {
424 if (cls
->quirks
& MT_QUIRK_HOVERING
) {
425 hid_map_usage(hi
, usage
, bit
, max
,
426 EV_ABS
, ABS_MT_DISTANCE
);
427 input_set_abs_params(hi
->input
,
428 ABS_MT_DISTANCE
, 0, 1, 0, 0);
430 mt_store_field(usage
, td
, hi
);
432 case HID_DG_CONFIDENCE
:
433 mt_store_field(usage
, td
, hi
);
435 case HID_DG_TIPSWITCH
:
436 hid_map_usage(hi
, usage
, bit
, max
, EV_KEY
, BTN_TOUCH
);
437 input_set_capability(hi
->input
, EV_KEY
, BTN_TOUCH
);
438 mt_store_field(usage
, td
, hi
);
440 case HID_DG_CONTACTID
:
441 mt_store_field(usage
, td
, hi
);
442 td
->touches_by_report
++;
443 td
->mt_report_id
= field
->report
->id
;
446 hid_map_usage(hi
, usage
, bit
, max
,
447 EV_ABS
, ABS_MT_TOUCH_MAJOR
);
448 if (!(cls
->quirks
& MT_QUIRK_NO_AREA
))
449 set_abs(hi
->input
, ABS_MT_TOUCH_MAJOR
, field
,
451 mt_store_field(usage
, td
, hi
);
454 hid_map_usage(hi
, usage
, bit
, max
,
455 EV_ABS
, ABS_MT_TOUCH_MINOR
);
456 if (!(cls
->quirks
& MT_QUIRK_NO_AREA
)) {
457 set_abs(hi
->input
, ABS_MT_TOUCH_MINOR
, field
,
459 input_set_abs_params(hi
->input
,
460 ABS_MT_ORIENTATION
, 0, 1, 0, 0);
462 mt_store_field(usage
, td
, hi
);
464 case HID_DG_TIPPRESSURE
:
465 hid_map_usage(hi
, usage
, bit
, max
,
466 EV_ABS
, ABS_MT_PRESSURE
);
467 set_abs(hi
->input
, ABS_MT_PRESSURE
, field
,
469 mt_store_field(usage
, td
, hi
);
471 case HID_DG_CONTACTCOUNT
:
472 /* Ignore if indexes are out of bounds. */
473 if (field
->index
>= field
->report
->maxfield
||
474 usage
->usage_index
>= field
->report_count
)
476 td
->cc_index
= field
->index
;
477 td
->cc_value_index
= usage
->usage_index
;
479 case HID_DG_CONTACTMAX
:
480 /* we don't set td->last_slot_field as contactcount and
481 * contact max are global to the report */
484 /* Legacy devices use TIPSWITCH and not TOUCH.
485 * Let's just ignore this field. */
488 /* let hid-input decide for the others */
492 code
= BTN_MOUSE
+ ((usage
->hid
- 1) & HID_USAGE
);
493 hid_map_usage(hi
, usage
, bit
, max
, EV_KEY
, code
);
494 input_set_capability(hi
->input
, EV_KEY
, code
);
498 /* we do not want to map these: no input-oriented meaning */
505 static int mt_touch_input_mapped(struct hid_device
*hdev
, struct hid_input
*hi
,
506 struct hid_field
*field
, struct hid_usage
*usage
,
507 unsigned long **bit
, int *max
)
509 if (usage
->type
== EV_KEY
|| usage
->type
== EV_ABS
)
510 set_bit(usage
->type
, hi
->input
->evbit
);
515 static int mt_compute_slot(struct mt_device
*td
, struct input_dev
*input
)
517 __s32 quirks
= td
->mtclass
.quirks
;
519 if (quirks
& MT_QUIRK_SLOT_IS_CONTACTID
)
520 return td
->curdata
.contactid
;
522 if (quirks
& MT_QUIRK_CYPRESS
)
523 return cypress_compute_slot(td
);
525 if (quirks
& MT_QUIRK_SLOT_IS_CONTACTNUMBER
)
526 return td
->num_received
;
528 if (quirks
& MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE
)
529 return td
->curdata
.contactid
- 1;
531 return input_mt_get_slot_by_key(input
, td
->curdata
.contactid
);
535 * this function is called when a whole contact has been processed,
536 * so that it can assign it to a slot and store the data there
538 static void mt_complete_slot(struct mt_device
*td
, struct input_dev
*input
)
540 if ((td
->mtclass
.quirks
& MT_QUIRK_CONTACT_CNT_ACCURATE
) &&
541 td
->num_received
>= td
->num_expected
)
544 if (td
->curvalid
|| (td
->mtclass
.quirks
& MT_QUIRK_ALWAYS_VALID
)) {
545 int slotnum
= mt_compute_slot(td
, input
);
546 struct mt_slot
*s
= &td
->curdata
;
547 struct input_mt
*mt
= input
->mt
;
549 if (slotnum
< 0 || slotnum
>= td
->maxcontacts
)
552 if ((td
->mtclass
.quirks
& MT_QUIRK_IGNORE_DUPLICATES
) && mt
) {
553 struct input_mt_slot
*slot
= &mt
->slots
[slotnum
];
554 if (input_mt_is_active(slot
) &&
555 input_mt_is_used(mt
, slot
))
559 input_mt_slot(input
, slotnum
);
560 input_mt_report_slot_state(input
, MT_TOOL_FINGER
,
561 s
->touch_state
|| s
->inrange_state
);
562 if (s
->touch_state
|| s
->inrange_state
) {
563 /* this finger is in proximity of the sensor */
564 int wide
= (s
->w
> s
->h
);
565 /* divided by two to match visual scale of touch */
566 int major
= max(s
->w
, s
->h
) >> 1;
567 int minor
= min(s
->w
, s
->h
) >> 1;
569 input_event(input
, EV_ABS
, ABS_MT_POSITION_X
, s
->x
);
570 input_event(input
, EV_ABS
, ABS_MT_POSITION_Y
, s
->y
);
571 input_event(input
, EV_ABS
, ABS_MT_TOOL_X
, s
->cx
);
572 input_event(input
, EV_ABS
, ABS_MT_TOOL_Y
, s
->cy
);
573 input_event(input
, EV_ABS
, ABS_MT_DISTANCE
,
575 input_event(input
, EV_ABS
, ABS_MT_ORIENTATION
, wide
);
576 input_event(input
, EV_ABS
, ABS_MT_PRESSURE
, s
->p
);
577 input_event(input
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, major
);
578 input_event(input
, EV_ABS
, ABS_MT_TOUCH_MINOR
, minor
);
586 * this function is called when a whole packet has been received and processed,
587 * so that it can decide what to send to the input layer.
589 static void mt_sync_frame(struct mt_device
*td
, struct input_dev
*input
)
591 input_mt_sync_frame(input
);
593 td
->num_received
= 0;
596 static int mt_touch_event(struct hid_device
*hid
, struct hid_field
*field
,
597 struct hid_usage
*usage
, __s32 value
)
599 /* we will handle the hidinput part later, now remains hiddev */
600 if (hid
->claimed
& HID_CLAIMED_HIDDEV
&& hid
->hiddev_hid_event
)
601 hid
->hiddev_hid_event(hid
, field
, usage
, value
);
606 static void mt_process_mt_event(struct hid_device
*hid
, struct hid_field
*field
,
607 struct hid_usage
*usage
, __s32 value
)
609 struct mt_device
*td
= hid_get_drvdata(hid
);
610 __s32 quirks
= td
->mtclass
.quirks
;
611 struct input_dev
*input
= field
->hidinput
->input
;
613 if (hid
->claimed
& HID_CLAIMED_INPUT
) {
614 switch (usage
->hid
) {
616 if (quirks
& MT_QUIRK_VALID_IS_INRANGE
)
617 td
->curvalid
= value
;
618 if (quirks
& MT_QUIRK_HOVERING
)
619 td
->curdata
.inrange_state
= value
;
621 case HID_DG_TIPSWITCH
:
622 if (quirks
& MT_QUIRK_NOT_SEEN_MEANS_UP
)
623 td
->curvalid
= value
;
624 td
->curdata
.touch_state
= value
;
626 case HID_DG_CONFIDENCE
:
627 if (quirks
& MT_QUIRK_VALID_IS_CONFIDENCE
)
628 td
->curvalid
= value
;
630 case HID_DG_CONTACTID
:
631 td
->curdata
.contactid
= value
;
633 case HID_DG_TIPPRESSURE
:
634 td
->curdata
.p
= value
;
637 if (usage
->code
== ABS_MT_TOOL_X
)
638 td
->curdata
.cx
= value
;
640 td
->curdata
.x
= value
;
643 if (usage
->code
== ABS_MT_TOOL_Y
)
644 td
->curdata
.cy
= value
;
646 td
->curdata
.y
= value
;
649 td
->curdata
.w
= value
;
652 td
->curdata
.h
= value
;
654 case HID_DG_CONTACTCOUNT
:
662 input_event(input
, usage
->type
, usage
->code
,
667 if (usage
->usage_index
+ 1 == field
->report_count
) {
668 /* we only take into account the last report. */
669 if (usage
->hid
== td
->last_slot_field
)
670 mt_complete_slot(td
, field
->hidinput
->input
);
676 static void mt_touch_report(struct hid_device
*hid
, struct hid_report
*report
)
678 struct mt_device
*td
= hid_get_drvdata(hid
);
679 struct hid_field
*field
;
684 * Includes multi-packet support where subsequent
685 * packets are sent with zero contactcount.
687 if (td
->cc_index
>= 0) {
688 struct hid_field
*field
= report
->field
[td
->cc_index
];
689 int value
= field
->value
[td
->cc_value_index
];
691 td
->num_expected
= value
;
694 for (r
= 0; r
< report
->maxfield
; r
++) {
695 field
= report
->field
[r
];
696 count
= field
->report_count
;
698 if (!(HID_MAIN_ITEM_VARIABLE
& field
->flags
))
701 for (n
= 0; n
< count
; n
++)
702 mt_process_mt_event(hid
, field
, &field
->usage
[n
],
706 if (td
->num_received
>= td
->num_expected
)
707 mt_sync_frame(td
, report
->field
[0]->hidinput
->input
);
710 static void mt_touch_input_configured(struct hid_device
*hdev
,
711 struct hid_input
*hi
)
713 struct mt_device
*td
= hid_get_drvdata(hdev
);
714 struct mt_class
*cls
= &td
->mtclass
;
715 struct input_dev
*input
= hi
->input
;
717 if (!td
->maxcontacts
)
718 td
->maxcontacts
= MT_DEFAULT_MAXCONTACT
;
721 if (td
->serial_maybe
)
722 mt_post_parse_default_settings(td
);
724 if (cls
->is_indirect
)
725 td
->mt_flags
|= INPUT_MT_POINTER
;
727 if (cls
->quirks
& MT_QUIRK_NOT_SEEN_MEANS_UP
)
728 td
->mt_flags
|= INPUT_MT_DROP_UNUSED
;
730 input_mt_init_slots(input
, td
->maxcontacts
, td
->mt_flags
);
735 static int mt_input_mapping(struct hid_device
*hdev
, struct hid_input
*hi
,
736 struct hid_field
*field
, struct hid_usage
*usage
,
737 unsigned long **bit
, int *max
)
739 struct mt_device
*td
= hid_get_drvdata(hdev
);
742 * If mtclass.export_all_inputs is not set, only map fields from
743 * TouchScreen or TouchPad collections. We need to ignore fields
744 * that belong to other collections such as Mouse that might have
745 * the same GenericDesktop usages.
747 if (!td
->mtclass
.export_all_inputs
&&
748 field
->application
!= HID_DG_TOUCHSCREEN
&&
749 field
->application
!= HID_DG_PEN
&&
750 field
->application
!= HID_DG_TOUCHPAD
)
754 * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
757 if (field
->physical
== HID_DG_STYLUS
)
760 if (field
->application
== HID_DG_TOUCHSCREEN
||
761 field
->application
== HID_DG_TOUCHPAD
)
762 return mt_touch_input_mapping(hdev
, hi
, field
, usage
, bit
, max
);
764 /* let hid-core decide for the others */
768 static int mt_input_mapped(struct hid_device
*hdev
, struct hid_input
*hi
,
769 struct hid_field
*field
, struct hid_usage
*usage
,
770 unsigned long **bit
, int *max
)
773 * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
776 if (field
->physical
== HID_DG_STYLUS
)
779 if (field
->application
== HID_DG_TOUCHSCREEN
||
780 field
->application
== HID_DG_TOUCHPAD
)
781 return mt_touch_input_mapped(hdev
, hi
, field
, usage
, bit
, max
);
783 /* let hid-core decide for the others */
787 static int mt_event(struct hid_device
*hid
, struct hid_field
*field
,
788 struct hid_usage
*usage
, __s32 value
)
790 struct mt_device
*td
= hid_get_drvdata(hid
);
792 if (field
->report
->id
== td
->mt_report_id
)
793 return mt_touch_event(hid
, field
, usage
, value
);
798 static void mt_report(struct hid_device
*hid
, struct hid_report
*report
)
800 struct mt_device
*td
= hid_get_drvdata(hid
);
801 struct hid_field
*field
= report
->field
[0];
803 if (!(hid
->claimed
& HID_CLAIMED_INPUT
))
806 if (report
->id
== td
->mt_report_id
)
807 return mt_touch_report(hid
, report
);
809 if (field
&& field
->hidinput
&& field
->hidinput
->input
)
810 input_sync(field
->hidinput
->input
);
813 static void mt_set_input_mode(struct hid_device
*hdev
)
815 struct mt_device
*td
= hid_get_drvdata(hdev
);
816 struct hid_report
*r
;
817 struct hid_report_enum
*re
;
818 struct mt_class
*cls
= &td
->mtclass
;
822 if (td
->inputmode
< 0)
825 re
= &(hdev
->report_enum
[HID_FEATURE_REPORT
]);
826 r
= re
->report_id_hash
[td
->inputmode
];
828 if (cls
->quirks
& MT_QUIRK_FORCE_GET_FEATURE
) {
829 report_len
= hid_report_len(r
);
830 buf
= hid_alloc_report_buf(r
, GFP_KERNEL
);
832 hid_err(hdev
, "failed to allocate buffer for report\n");
835 hid_hw_raw_request(hdev
, r
->id
, buf
, report_len
,
840 r
->field
[0]->value
[td
->inputmode_index
] = td
->inputmode_value
;
841 hid_hw_request(hdev
, r
, HID_REQ_SET_REPORT
);
845 static void mt_set_maxcontacts(struct hid_device
*hdev
)
847 struct mt_device
*td
= hid_get_drvdata(hdev
);
848 struct hid_report
*r
;
849 struct hid_report_enum
*re
;
852 if (td
->maxcontact_report_id
< 0)
855 if (!td
->mtclass
.maxcontacts
)
858 re
= &hdev
->report_enum
[HID_FEATURE_REPORT
];
859 r
= re
->report_id_hash
[td
->maxcontact_report_id
];
861 max
= td
->mtclass
.maxcontacts
;
862 fieldmax
= r
->field
[0]->logical_maximum
;
863 max
= min(fieldmax
, max
);
864 if (r
->field
[0]->value
[0] != max
) {
865 r
->field
[0]->value
[0] = max
;
866 hid_hw_request(hdev
, r
, HID_REQ_SET_REPORT
);
871 static void mt_post_parse_default_settings(struct mt_device
*td
)
873 __s32 quirks
= td
->mtclass
.quirks
;
875 /* unknown serial device needs special quirks */
876 if (td
->touches_by_report
== 1) {
877 quirks
|= MT_QUIRK_ALWAYS_VALID
;
878 quirks
&= ~MT_QUIRK_NOT_SEEN_MEANS_UP
;
879 quirks
&= ~MT_QUIRK_VALID_IS_INRANGE
;
880 quirks
&= ~MT_QUIRK_VALID_IS_CONFIDENCE
;
881 quirks
&= ~MT_QUIRK_CONTACT_CNT_ACCURATE
;
884 td
->mtclass
.quirks
= quirks
;
887 static void mt_post_parse(struct mt_device
*td
)
889 struct mt_fields
*f
= td
->fields
;
890 struct mt_class
*cls
= &td
->mtclass
;
892 if (td
->touches_by_report
> 0) {
893 int field_count_per_touch
= f
->length
/ td
->touches_by_report
;
894 td
->last_slot_field
= f
->usages
[field_count_per_touch
- 1];
897 if (td
->cc_index
< 0)
898 cls
->quirks
&= ~MT_QUIRK_CONTACT_CNT_ACCURATE
;
901 static void mt_input_configured(struct hid_device
*hdev
, struct hid_input
*hi
)
903 struct mt_device
*td
= hid_get_drvdata(hdev
);
905 const char *suffix
= NULL
;
906 struct hid_field
*field
= hi
->report
->field
[0];
908 if (hi
->report
->id
== td
->mt_report_id
)
909 mt_touch_input_configured(hdev
, hi
);
912 * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
913 * for the stylus. Check this first, and then rely on the application
916 if (hi
->report
->field
[0]->physical
== HID_DG_STYLUS
) {
918 /* force BTN_STYLUS to allow tablet matching in udev */
919 __set_bit(BTN_STYLUS
, hi
->input
->keybit
);
921 switch (field
->application
) {
922 case HID_GD_KEYBOARD
:
933 /* force BTN_STYLUS to allow tablet matching in udev */
934 __set_bit(BTN_STYLUS
, hi
->input
->keybit
);
936 case HID_DG_TOUCHSCREEN
:
937 /* we do not set suffix = "Touchscreen" */
939 case HID_GD_SYSTEM_CONTROL
:
940 suffix
= "System Control";
942 case HID_CP_CONSUMER_CONTROL
:
943 suffix
= "Consumer Control";
952 name
= devm_kzalloc(&hi
->input
->dev
,
953 strlen(hdev
->name
) + strlen(suffix
) + 2,
956 sprintf(name
, "%s %s", hdev
->name
, suffix
);
957 hi
->input
->name
= name
;
962 static int mt_probe(struct hid_device
*hdev
, const struct hid_device_id
*id
)
965 struct mt_device
*td
;
966 struct mt_class
*mtclass
= mt_classes
; /* MT_CLS_DEFAULT */
968 for (i
= 0; mt_classes
[i
].name
; i
++) {
969 if (id
->driver_data
== mt_classes
[i
].name
) {
970 mtclass
= &(mt_classes
[i
]);
975 /* This allows the driver to correctly support devices
976 * that emit events over several HID messages.
978 hdev
->quirks
|= HID_QUIRK_NO_INPUT_SYNC
;
981 * This allows the driver to handle different input sensors
982 * that emits events through different reports on the same HID
985 hdev
->quirks
|= HID_QUIRK_MULTI_INPUT
;
986 hdev
->quirks
|= HID_QUIRK_NO_EMPTY_INPUT
;
989 * Handle special quirks for Windows 8 certified devices.
991 if (id
->group
== HID_GROUP_MULTITOUCH_WIN_8
)
993 * Some multitouch screens do not like to be polled for input
994 * reports. Fortunately, the Win8 spec says that all touches
995 * should be sent during each report, making the initialization
996 * of input reports unnecessary.
998 hdev
->quirks
|= HID_QUIRK_NO_INIT_INPUT_REPORTS
;
1000 td
= devm_kzalloc(&hdev
->dev
, sizeof(struct mt_device
), GFP_KERNEL
);
1002 dev_err(&hdev
->dev
, "cannot allocate multitouch data\n");
1005 td
->mtclass
= *mtclass
;
1007 td
->maxcontact_report_id
= -1;
1008 td
->inputmode_value
= MT_INPUTMODE_TOUCHSCREEN
;
1010 td
->mt_report_id
= -1;
1011 hid_set_drvdata(hdev
, td
);
1013 td
->fields
= devm_kzalloc(&hdev
->dev
, sizeof(struct mt_fields
),
1016 dev_err(&hdev
->dev
, "cannot allocate multitouch fields data\n");
1020 if (id
->vendor
== HID_ANY_ID
&& id
->product
== HID_ANY_ID
)
1021 td
->serial_maybe
= true;
1023 ret
= hid_parse(hdev
);
1027 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
);
1031 ret
= sysfs_create_group(&hdev
->dev
.kobj
, &mt_attribute_group
);
1033 mt_set_maxcontacts(hdev
);
1034 mt_set_input_mode(hdev
);
1036 /* release .fields memory as it is not used anymore */
1037 devm_kfree(&hdev
->dev
, td
->fields
);
1044 static int mt_reset_resume(struct hid_device
*hdev
)
1046 mt_set_maxcontacts(hdev
);
1047 mt_set_input_mode(hdev
);
1051 static int mt_resume(struct hid_device
*hdev
)
1053 /* Some Elan legacy devices require SET_IDLE to be set on resume.
1054 * It should be safe to send it to other devices too.
1055 * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */
1057 hid_hw_idle(hdev
, 0, 0, HID_REQ_SET_IDLE
);
1063 static void mt_remove(struct hid_device
*hdev
)
1065 sysfs_remove_group(&hdev
->dev
.kobj
, &mt_attribute_group
);
1070 * This list contains only:
1071 * - VID/PID of products not working with the default multitouch handling
1072 * - 2 generic rules.
1073 * So there is no point in adding here any device with MT_CLS_DEFAULT.
1075 static const struct hid_device_id mt_devices
[] = {
1078 { .driver_data
= MT_CLS_3M
,
1079 MT_USB_DEVICE(USB_VENDOR_ID_3M
,
1080 USB_DEVICE_ID_3M1968
) },
1081 { .driver_data
= MT_CLS_3M
,
1082 MT_USB_DEVICE(USB_VENDOR_ID_3M
,
1083 USB_DEVICE_ID_3M2256
) },
1084 { .driver_data
= MT_CLS_3M
,
1085 MT_USB_DEVICE(USB_VENDOR_ID_3M
,
1086 USB_DEVICE_ID_3M3266
) },
1089 { .driver_data
= MT_CLS_EXPORT_ALL_INPUTS
,
1090 MT_USB_DEVICE(USB_VENDOR_ID_ANTON
,
1091 USB_DEVICE_ID_ANTON_TOUCH_PAD
) },
1094 { .driver_data
= MT_CLS_SERIAL
,
1095 MT_USB_DEVICE(USB_VENDOR_ID_ATMEL
,
1096 USB_DEVICE_ID_ATMEL_MXT_DIGITIZER
) },
1098 /* Baanto multitouch devices */
1099 { .driver_data
= MT_CLS_NSMU
,
1100 MT_USB_DEVICE(USB_VENDOR_ID_BAANTO
,
1101 USB_DEVICE_ID_BAANTO_MT_190W2
) },
1104 { .driver_data
= MT_CLS_DUAL_INRANGE_CONTACTNUMBER
,
1105 MT_USB_DEVICE(USB_VENDOR_ID_CANDO
,
1106 USB_DEVICE_ID_CANDO_MULTI_TOUCH
) },
1107 { .driver_data
= MT_CLS_DUAL_INRANGE_CONTACTNUMBER
,
1108 MT_USB_DEVICE(USB_VENDOR_ID_CANDO
,
1109 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6
) },
1111 /* Chunghwa Telecom touch panels */
1112 { .driver_data
= MT_CLS_NSMU
,
1113 MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT
,
1114 USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH
) },
1116 /* CVTouch panels */
1117 { .driver_data
= MT_CLS_NSMU
,
1118 MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH
,
1119 USB_DEVICE_ID_CVTOUCH_SCREEN
) },
1121 /* eGalax devices (resistive) */
1122 { .driver_data
= MT_CLS_EGALAX
,
1123 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1124 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D
) },
1125 { .driver_data
= MT_CLS_EGALAX
,
1126 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1127 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E
) },
1129 /* eGalax devices (capacitive) */
1130 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1131 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1132 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207
) },
1133 { .driver_data
= MT_CLS_EGALAX
,
1134 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1135 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C
) },
1136 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1137 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1138 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224
) },
1139 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1140 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1141 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A
) },
1142 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1143 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1144 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E
) },
1145 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1146 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1147 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262
) },
1148 { .driver_data
= MT_CLS_EGALAX
,
1149 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1150 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B
) },
1151 { .driver_data
= MT_CLS_EGALAX
,
1152 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1153 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1
) },
1154 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1155 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1156 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA
) },
1157 { .driver_data
= MT_CLS_EGALAX
,
1158 HID_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1159 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4
) },
1160 { .driver_data
= MT_CLS_EGALAX
,
1161 HID_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1162 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0
) },
1163 { .driver_data
= MT_CLS_EGALAX
,
1164 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1165 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA
) },
1166 { .driver_data
= MT_CLS_EGALAX
,
1167 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1168 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302
) },
1169 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1170 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1171 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349
) },
1172 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1173 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1174 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7
) },
1175 { .driver_data
= MT_CLS_EGALAX_SERIAL
,
1176 MT_USB_DEVICE(USB_VENDOR_ID_DWAV
,
1177 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001
) },
1179 /* Elitegroup panel */
1180 { .driver_data
= MT_CLS_SERIAL
,
1181 MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP
,
1182 USB_DEVICE_ID_ELITEGROUP_05D8
) },
1184 /* Flatfrog Panels */
1185 { .driver_data
= MT_CLS_FLATFROG
,
1186 MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG
,
1187 USB_DEVICE_ID_MULTITOUCH_3200
) },
1189 /* FocalTech Panels */
1190 { .driver_data
= MT_CLS_SERIAL
,
1191 MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL
,
1192 USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH
) },
1194 /* GeneralTouch panel */
1195 { .driver_data
= MT_CLS_GENERALTOUCH_TWOFINGERS
,
1196 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1197 USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS
) },
1198 { .driver_data
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
1199 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1200 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS
) },
1201 { .driver_data
= MT_CLS_GENERALTOUCH_TWOFINGERS
,
1202 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1203 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101
) },
1204 { .driver_data
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
1205 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1206 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102
) },
1207 { .driver_data
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
1208 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1209 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106
) },
1210 { .driver_data
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
1211 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1212 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A
) },
1213 { .driver_data
= MT_CLS_GENERALTOUCH_PWT_TENFINGERS
,
1214 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
,
1215 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100
) },
1217 /* Gametel game controller */
1218 { .driver_data
= MT_CLS_NSMU
,
1219 MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL
,
1220 USB_DEVICE_ID_GAMETEL_MT_MODE
) },
1222 /* GoodTouch panels */
1223 { .driver_data
= MT_CLS_NSMU
,
1224 MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH
,
1225 USB_DEVICE_ID_GOODTOUCH_000f
) },
1228 { .driver_data
= MT_CLS_DUAL_INRANGE_CONTACTID
,
1229 MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT
,
1230 USB_DEVICE_ID_HANVON_ALT_MULTITOUCH
) },
1232 /* Ilitek dual touch panel */
1233 { .driver_data
= MT_CLS_NSMU
,
1234 MT_USB_DEVICE(USB_VENDOR_ID_ILITEK
,
1235 USB_DEVICE_ID_ILITEK_MULTITOUCH
) },
1238 { .driver_data
= MT_CLS_CONFIDENCE_MINUS_ONE
,
1239 MT_USB_DEVICE(USB_VENDOR_ID_ASUS
,
1240 USB_DEVICE_ID_ASUS_T91MT
)},
1241 { .driver_data
= MT_CLS_CONFIDENCE_MINUS_ONE
,
1242 MT_USB_DEVICE(USB_VENDOR_ID_ASUS
,
1243 USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO
) },
1244 { .driver_data
= MT_CLS_CONFIDENCE_MINUS_ONE
,
1245 MT_USB_DEVICE(USB_VENDOR_ID_TURBOX
,
1246 USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART
) },
1248 /* Panasonic panels */
1249 { .driver_data
= MT_CLS_PANASONIC
,
1250 MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC
,
1251 USB_DEVICE_ID_PANABOARD_UBT780
) },
1252 { .driver_data
= MT_CLS_PANASONIC
,
1253 MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC
,
1254 USB_DEVICE_ID_PANABOARD_UBT880
) },
1257 { .driver_data
= MT_CLS_NSMU
,
1258 MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK
,
1259 USB_DEVICE_ID_NOVATEK_PCT
) },
1261 /* PixArt optical touch screen */
1262 { .driver_data
= MT_CLS_INRANGE_CONTACTNUMBER
,
1263 MT_USB_DEVICE(USB_VENDOR_ID_PIXART
,
1264 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN
) },
1265 { .driver_data
= MT_CLS_INRANGE_CONTACTNUMBER
,
1266 MT_USB_DEVICE(USB_VENDOR_ID_PIXART
,
1267 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1
) },
1268 { .driver_data
= MT_CLS_INRANGE_CONTACTNUMBER
,
1269 MT_USB_DEVICE(USB_VENDOR_ID_PIXART
,
1270 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2
) },
1272 /* PixCir-based panels */
1273 { .driver_data
= MT_CLS_DUAL_INRANGE_CONTACTID
,
1274 MT_USB_DEVICE(USB_VENDOR_ID_CANDO
,
1275 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH
) },
1277 /* Quanta-based panels */
1278 { .driver_data
= MT_CLS_CONFIDENCE_CONTACT_ID
,
1279 MT_USB_DEVICE(USB_VENDOR_ID_QUANTA
,
1280 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001
) },
1282 /* Stantum panels */
1283 { .driver_data
= MT_CLS_CONFIDENCE
,
1284 MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM
,
1285 USB_DEVICE_ID_MTP_STM
)},
1287 /* TopSeed panels */
1288 { .driver_data
= MT_CLS_TOPSEED
,
1289 MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2
,
1290 USB_DEVICE_ID_TOPSEED2_PERIPAD_701
) },
1292 /* Touch International panels */
1293 { .driver_data
= MT_CLS_NSMU
,
1294 MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL
,
1295 USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH
) },
1298 { .driver_data
= MT_CLS_NSMU
,
1299 MT_USB_DEVICE(USB_VENDOR_ID_UNITEC
,
1300 USB_DEVICE_ID_UNITEC_USB_TOUCH_0709
) },
1301 { .driver_data
= MT_CLS_NSMU
,
1302 MT_USB_DEVICE(USB_VENDOR_ID_UNITEC
,
1303 USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19
) },
1306 { .driver_data
= MT_CLS_VTL
,
1307 MT_USB_DEVICE(USB_VENDOR_ID_VTL
,
1308 USB_DEVICE_ID_VTL_MULTITOUCH_FF3F
) },
1310 /* Wistron panels */
1311 { .driver_data
= MT_CLS_NSMU
,
1312 MT_USB_DEVICE(USB_VENDOR_ID_WISTRON
,
1313 USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH
) },
1316 { .driver_data
= MT_CLS_NSMU
,
1317 MT_USB_DEVICE(USB_VENDOR_ID_XAT
,
1318 USB_DEVICE_ID_XAT_CSR
) },
1321 { .driver_data
= MT_CLS_NSMU
,
1322 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1323 USB_DEVICE_ID_XIROKU_SPX
) },
1324 { .driver_data
= MT_CLS_NSMU
,
1325 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1326 USB_DEVICE_ID_XIROKU_MPX
) },
1327 { .driver_data
= MT_CLS_NSMU
,
1328 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1329 USB_DEVICE_ID_XIROKU_CSR
) },
1330 { .driver_data
= MT_CLS_NSMU
,
1331 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1332 USB_DEVICE_ID_XIROKU_SPX1
) },
1333 { .driver_data
= MT_CLS_NSMU
,
1334 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1335 USB_DEVICE_ID_XIROKU_MPX1
) },
1336 { .driver_data
= MT_CLS_NSMU
,
1337 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1338 USB_DEVICE_ID_XIROKU_CSR1
) },
1339 { .driver_data
= MT_CLS_NSMU
,
1340 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1341 USB_DEVICE_ID_XIROKU_SPX2
) },
1342 { .driver_data
= MT_CLS_NSMU
,
1343 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1344 USB_DEVICE_ID_XIROKU_MPX2
) },
1345 { .driver_data
= MT_CLS_NSMU
,
1346 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU
,
1347 USB_DEVICE_ID_XIROKU_CSR2
) },
1349 /* Generic MT device */
1350 { HID_DEVICE(HID_BUS_ANY
, HID_GROUP_MULTITOUCH
, HID_ANY_ID
, HID_ANY_ID
) },
1352 /* Generic Win 8 certified MT device */
1353 { .driver_data
= MT_CLS_WIN_8
,
1354 HID_DEVICE(HID_BUS_ANY
, HID_GROUP_MULTITOUCH_WIN_8
,
1355 HID_ANY_ID
, HID_ANY_ID
) },
1358 MODULE_DEVICE_TABLE(hid
, mt_devices
);
1360 static const struct hid_usage_id mt_grabbed_usages
[] = {
1361 { HID_ANY_ID
, HID_ANY_ID
, HID_ANY_ID
},
1362 { HID_ANY_ID
- 1, HID_ANY_ID
- 1, HID_ANY_ID
- 1}
1365 static struct hid_driver mt_driver
= {
1366 .name
= "hid-multitouch",
1367 .id_table
= mt_devices
,
1369 .remove
= mt_remove
,
1370 .input_mapping
= mt_input_mapping
,
1371 .input_mapped
= mt_input_mapped
,
1372 .input_configured
= mt_input_configured
,
1373 .feature_mapping
= mt_feature_mapping
,
1374 .usage_table
= mt_grabbed_usages
,
1376 .report
= mt_report
,
1378 .reset_resume
= mt_reset_resume
,
1379 .resume
= mt_resume
,
1382 module_hid_driver(mt_driver
);