]>
Commit | Line | Data |
---|---|---|
5519cab4 BT |
1 | /* |
2 | * HID driver for multitouch panels | |
3 | * | |
c2ef8f21 | 4 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> |
b0a78681 | 5 | * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
c2ef8f21 | 6 | * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France |
b0a78681 | 7 | * Copyright (c) 2012-2013 Red Hat, Inc |
5519cab4 | 8 | * |
4875ac11 RN |
9 | * This code is partly based on hid-egalax.c: |
10 | * | |
11 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> | |
12 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | |
13 | * Copyright (c) 2010 Canonical, Ltd. | |
14 | * | |
f786bba4 BT |
15 | * This code is partly based on hid-3m-pct.c: |
16 | * | |
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. | |
20 | * | |
5519cab4 BT |
21 | */ |
22 | ||
23 | /* | |
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) | |
27 | * any later version. | |
28 | */ | |
29 | ||
b0a78681 BT |
30 | /* |
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. | |
35 | * | |
36 | * [1] https://github.com/bentiss/hid-test | |
37 | * [2] https://github.com/bentiss/hid-replay | |
38 | * [3] https://github.com/bentiss/hid-devices | |
39 | */ | |
40 | ||
5519cab4 BT |
41 | #include <linux/device.h> |
42 | #include <linux/hid.h> | |
43 | #include <linux/module.h> | |
44 | #include <linux/slab.h> | |
45 | #include <linux/usb.h> | |
46 | #include <linux/input/mt.h> | |
49a5a827 | 47 | #include <linux/string.h> |
5519cab4 BT |
48 | |
49 | ||
50 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | |
ef2fafb3 | 51 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); |
5519cab4 BT |
52 | MODULE_DESCRIPTION("HID multitouch panels"); |
53 | MODULE_LICENSE("GPL"); | |
54 | ||
55 | #include "hid-ids.h" | |
56 | ||
57 | /* quirks to control the device */ | |
58 | #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0) | |
59 | #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1) | |
2d93666e | 60 | #define MT_QUIRK_CYPRESS (1 << 2) |
5572da08 | 61 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) |
a062cc5a SC |
62 | #define MT_QUIRK_ALWAYS_VALID (1 << 4) |
63 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) | |
64 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) | |
a062cc5a | 65 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) |
77723e3b | 66 | #define MT_QUIRK_NO_AREA (1 << 9) |
28728399 | 67 | #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) |
9b3bb9b8 | 68 | #define MT_QUIRK_HOVERING (1 << 11) |
c2517f62 | 69 | #define MT_QUIRK_CONTACT_CNT_ACCURATE (1 << 12) |
da10bc25 | 70 | #define MT_QUIRK_FORCE_GET_FEATURE (1 << 13) |
5519cab4 | 71 | |
9abebedb AD |
72 | #define MT_INPUTMODE_TOUCHSCREEN 0x02 |
73 | #define MT_INPUTMODE_TOUCHPAD 0x03 | |
74 | ||
2c6e0277 SF |
75 | #define MT_BUTTONTYPE_CLICKPAD 0 |
76 | ||
5519cab4 | 77 | struct mt_slot { |
349fd670 | 78 | __s32 x, y, cx, cy, p, w, h; |
5519cab4 BT |
79 | __s32 contactid; /* the device ContactID assigned to this slot */ |
80 | bool touch_state; /* is the touch valid? */ | |
9b3bb9b8 | 81 | bool inrange_state; /* is the finger in proximity of the sensor? */ |
5519cab4 BT |
82 | }; |
83 | ||
eec29e3d BT |
84 | struct mt_class { |
85 | __s32 name; /* MT_CLS */ | |
86 | __s32 quirks; | |
87 | __s32 sn_move; /* Signal/noise ratio for move events */ | |
88 | __s32 sn_width; /* Signal/noise ratio for width events */ | |
89 | __s32 sn_height; /* Signal/noise ratio for height events */ | |
90 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ | |
91 | __u8 maxcontacts; | |
c2ef8f21 | 92 | bool is_indirect; /* true for touchpads */ |
6aef704e | 93 | bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ |
eec29e3d BT |
94 | }; |
95 | ||
3ac36d15 BT |
96 | struct mt_fields { |
97 | unsigned usages[HID_MAX_FIELDS]; | |
98 | unsigned int length; | |
99 | }; | |
100 | ||
5519cab4 BT |
101 | struct mt_device { |
102 | struct mt_slot curdata; /* placeholder of incoming data */ | |
eec29e3d | 103 | struct mt_class mtclass; /* our mt device class */ |
3ac36d15 BT |
104 | struct mt_fields *fields; /* temporary placeholder for storing the |
105 | multitouch fields */ | |
7e3cc447 BT |
106 | int cc_index; /* contact count field index in the report */ |
107 | int cc_value_index; /* contact count value index in the field */ | |
5519cab4 | 108 | unsigned last_slot_field; /* the last field of a slot */ |
55978fa9 | 109 | unsigned mt_report_id; /* the report ID of the multitouch device */ |
8821f5dc BT |
110 | __s16 inputmode; /* InputMode HID feature, -1 if non-existent */ |
111 | __s16 inputmode_index; /* InputMode HID feature index in the report */ | |
112 | __s16 maxcontact_report_id; /* Maximum Contact Number HID feature, | |
31ae9bdd | 113 | -1 if non-existent */ |
9abebedb | 114 | __u8 inputmode_value; /* InputMode HID feature value */ |
5519cab4 BT |
115 | __u8 num_received; /* how many contacts we received */ |
116 | __u8 num_expected; /* expected last contact index */ | |
9498f954 | 117 | __u8 maxcontacts; |
9e87f22a BT |
118 | __u8 touches_by_report; /* how many touches are present in one report: |
119 | * 1 means we should use a serial protocol | |
120 | * > 1 means hybrid (multitouch) protocol */ | |
015fdaa9 | 121 | __u8 buttons_count; /* number of physical buttons per touchpad */ |
2c6e0277 | 122 | bool is_buttonpad; /* is this device a button pad? */ |
76f5902a | 123 | bool serial_maybe; /* need to check for serial protocol */ |
5519cab4 | 124 | bool curvalid; /* is the current contact valid? */ |
76f5902a | 125 | unsigned mt_flags; /* flags to pass to input-mt */ |
5519cab4 BT |
126 | }; |
127 | ||
a69c5f8b BT |
128 | static void mt_post_parse_default_settings(struct mt_device *td); |
129 | static void mt_post_parse(struct mt_device *td); | |
130 | ||
5519cab4 | 131 | /* classes of device behavior */ |
22408283 BT |
132 | #define MT_CLS_DEFAULT 0x0001 |
133 | ||
a062cc5a SC |
134 | #define MT_CLS_SERIAL 0x0002 |
135 | #define MT_CLS_CONFIDENCE 0x0003 | |
5e7ea11f BT |
136 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
137 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 | |
138 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 | |
139 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 | |
0fa9c616 | 140 | /* reserved 0x0008 */ |
b7ea95ff | 141 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
dc3e1d80 | 142 | #define MT_CLS_NSMU 0x000a |
0fa9c616 BT |
143 | /* reserved 0x0010 */ |
144 | /* reserved 0x0011 */ | |
f961bd35 | 145 | #define MT_CLS_WIN_8 0x0012 |
6aef704e | 146 | #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 |
22408283 BT |
147 | |
148 | /* vendor specific classes */ | |
149 | #define MT_CLS_3M 0x0101 | |
0fa9c616 | 150 | /* reserved 0x0102 */ |
22408283 | 151 | #define MT_CLS_EGALAX 0x0103 |
1b723e8d | 152 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
847672cd | 153 | #define MT_CLS_TOPSEED 0x0105 |
2258e863 | 154 | #define MT_CLS_PANASONIC 0x0106 |
77723e3b | 155 | #define MT_CLS_FLATFROG 0x0107 |
cdcd3ac4 JK |
156 | #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 |
157 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 | |
da10bc25 | 158 | #define MT_CLS_VTL 0x0110 |
5519cab4 | 159 | |
9498f954 | 160 | #define MT_DEFAULT_MAXCONTACT 10 |
afbcb04c | 161 | #define MT_MAX_MAXCONTACT 250 |
9498f954 | 162 | |
2c2110e9 HR |
163 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
164 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) | |
165 | ||
5519cab4 BT |
166 | /* |
167 | * these device-dependent functions determine what slot corresponds | |
168 | * to a valid contact that was just read. | |
169 | */ | |
170 | ||
a3b5e577 BT |
171 | static int cypress_compute_slot(struct mt_device *td) |
172 | { | |
173 | if (td->curdata.contactid != 0 || td->num_received == 0) | |
174 | return td->curdata.contactid; | |
175 | else | |
176 | return -1; | |
177 | } | |
178 | ||
b3c21d2c | 179 | static struct mt_class mt_classes[] = { |
2d93666e | 180 | { .name = MT_CLS_DEFAULT, |
dc3e1d80 BT |
181 | .quirks = MT_QUIRK_ALWAYS_VALID | |
182 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
183 | { .name = MT_CLS_NSMU, | |
9498f954 | 184 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
a062cc5a SC |
185 | { .name = MT_CLS_SERIAL, |
186 | .quirks = MT_QUIRK_ALWAYS_VALID}, | |
22408283 BT |
187 | { .name = MT_CLS_CONFIDENCE, |
188 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, | |
5e7ea11f BT |
189 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
190 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
191 | MT_QUIRK_SLOT_IS_CONTACTID }, | |
22408283 BT |
192 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
193 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
194 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, | |
1e9cf35b | 195 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
2d93666e BT |
196 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
197 | MT_QUIRK_SLOT_IS_CONTACTID, | |
198 | .maxcontacts = 2 }, | |
1e9cf35b | 199 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2d93666e BT |
200 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
201 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | |
202 | .maxcontacts = 2 }, | |
b7ea95ff AT |
203 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
204 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | |
205 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, | |
f961bd35 BT |
206 | { .name = MT_CLS_WIN_8, |
207 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
208 | MT_QUIRK_IGNORE_DUPLICATES | | |
209 | MT_QUIRK_HOVERING | | |
210 | MT_QUIRK_CONTACT_CNT_ACCURATE }, | |
6aef704e BT |
211 | { .name = MT_CLS_EXPORT_ALL_INPUTS, |
212 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
213 | MT_QUIRK_CONTACT_CNT_ACCURATE, | |
214 | .export_all_inputs = true }, | |
22408283 BT |
215 | |
216 | /* | |
217 | * vendor specific classes | |
218 | */ | |
219 | { .name = MT_CLS_3M, | |
220 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | | |
221 | MT_QUIRK_SLOT_IS_CONTACTID, | |
222 | .sn_move = 2048, | |
223 | .sn_width = 128, | |
c5d40be5 HR |
224 | .sn_height = 128, |
225 | .maxcontacts = 60, | |
226 | }, | |
4875ac11 RN |
227 | { .name = MT_CLS_EGALAX, |
228 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
2261bb9f | 229 | MT_QUIRK_VALID_IS_INRANGE, |
4875ac11 RN |
230 | .sn_move = 4096, |
231 | .sn_pressure = 32, | |
232 | }, | |
1b723e8d BT |
233 | { .name = MT_CLS_EGALAX_SERIAL, |
234 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | |
235 | MT_QUIRK_ALWAYS_VALID, | |
4875ac11 RN |
236 | .sn_move = 4096, |
237 | .sn_pressure = 32, | |
238 | }, | |
847672cd BT |
239 | { .name = MT_CLS_TOPSEED, |
240 | .quirks = MT_QUIRK_ALWAYS_VALID, | |
241 | .is_indirect = true, | |
242 | .maxcontacts = 2, | |
243 | }, | |
2258e863 DK |
244 | { .name = MT_CLS_PANASONIC, |
245 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, | |
246 | .maxcontacts = 4 }, | |
f5ff4e1e XY |
247 | { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, |
248 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
249 | MT_QUIRK_VALID_IS_INRANGE | | |
7b226292 | 250 | MT_QUIRK_SLOT_IS_CONTACTID, |
f5ff4e1e XY |
251 | .maxcontacts = 2 |
252 | }, | |
253 | { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
254 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
7b226292 | 255 | MT_QUIRK_SLOT_IS_CONTACTID |
f5ff4e1e | 256 | }, |
043b403a | 257 | |
77723e3b HR |
258 | { .name = MT_CLS_FLATFROG, |
259 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | | |
260 | MT_QUIRK_NO_AREA, | |
261 | .sn_move = 2048, | |
262 | .maxcontacts = 40, | |
263 | }, | |
da10bc25 MM |
264 | { .name = MT_CLS_VTL, |
265 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
266 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
267 | MT_QUIRK_FORCE_GET_FEATURE, | |
268 | }, | |
2d93666e | 269 | { } |
5519cab4 BT |
270 | }; |
271 | ||
eec29e3d BT |
272 | static ssize_t mt_show_quirks(struct device *dev, |
273 | struct device_attribute *attr, | |
274 | char *buf) | |
275 | { | |
276 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
277 | struct mt_device *td = hid_get_drvdata(hdev); | |
278 | ||
279 | return sprintf(buf, "%u\n", td->mtclass.quirks); | |
280 | } | |
281 | ||
282 | static ssize_t mt_set_quirks(struct device *dev, | |
283 | struct device_attribute *attr, | |
284 | const char *buf, size_t count) | |
285 | { | |
286 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | |
287 | struct mt_device *td = hid_get_drvdata(hdev); | |
288 | ||
289 | unsigned long val; | |
290 | ||
291 | if (kstrtoul(buf, 0, &val)) | |
292 | return -EINVAL; | |
293 | ||
294 | td->mtclass.quirks = val; | |
295 | ||
7e3cc447 | 296 | if (td->cc_index < 0) |
c2517f62 BT |
297 | td->mtclass.quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
298 | ||
eec29e3d BT |
299 | return count; |
300 | } | |
301 | ||
302 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); | |
303 | ||
304 | static struct attribute *sysfs_attrs[] = { | |
305 | &dev_attr_quirks.attr, | |
306 | NULL | |
307 | }; | |
308 | ||
309 | static struct attribute_group mt_attribute_group = { | |
310 | .attrs = sysfs_attrs | |
311 | }; | |
312 | ||
f635bd11 | 313 | static void mt_feature_mapping(struct hid_device *hdev, |
5519cab4 BT |
314 | struct hid_field *field, struct hid_usage *usage) |
315 | { | |
9498f954 BT |
316 | struct mt_device *td = hid_get_drvdata(hdev); |
317 | ||
318 | switch (usage->hid) { | |
319 | case HID_DG_INPUTMODE: | |
8821f5dc BT |
320 | /* Ignore if value index is out of bounds. */ |
321 | if (usage->usage_index >= field->report_count) { | |
322 | dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n"); | |
323 | break; | |
4aceed37 BT |
324 | } |
325 | ||
8821f5dc BT |
326 | td->inputmode = field->report->id; |
327 | td->inputmode_index = usage->usage_index; | |
328 | ||
9498f954 BT |
329 | break; |
330 | case HID_DG_CONTACTMAX: | |
31ae9bdd | 331 | td->maxcontact_report_id = field->report->id; |
9498f954 | 332 | td->maxcontacts = field->value[0]; |
afbcb04c BT |
333 | if (!td->maxcontacts && |
334 | field->logical_maximum <= MT_MAX_MAXCONTACT) | |
335 | td->maxcontacts = field->logical_maximum; | |
eec29e3d | 336 | if (td->mtclass.maxcontacts) |
9498f954 | 337 | /* check if the maxcontacts is given by the class */ |
eec29e3d | 338 | td->maxcontacts = td->mtclass.maxcontacts; |
9498f954 | 339 | |
2c6e0277 SF |
340 | break; |
341 | case HID_DG_BUTTONTYPE: | |
342 | if (usage->usage_index >= field->report_count) { | |
343 | dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); | |
344 | break; | |
345 | } | |
346 | ||
347 | if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) | |
348 | td->is_buttonpad = true; | |
349 | ||
9498f954 | 350 | break; |
5519cab4 BT |
351 | } |
352 | } | |
353 | ||
354 | static void set_abs(struct input_dev *input, unsigned int code, | |
355 | struct hid_field *field, int snratio) | |
356 | { | |
357 | int fmin = field->logical_minimum; | |
358 | int fmax = field->logical_maximum; | |
359 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | |
360 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | |
37cf6e6f | 361 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
5519cab4 BT |
362 | } |
363 | ||
3ac36d15 | 364 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, |
ed9d5c96 BT |
365 | struct hid_input *hi) |
366 | { | |
3ac36d15 BT |
367 | struct mt_fields *f = td->fields; |
368 | ||
369 | if (f->length >= HID_MAX_FIELDS) | |
370 | return; | |
371 | ||
372 | f->usages[f->length++] = usage->hid; | |
ed9d5c96 BT |
373 | } |
374 | ||
a69c5f8b | 375 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
5519cab4 BT |
376 | struct hid_field *field, struct hid_usage *usage, |
377 | unsigned long **bit, int *max) | |
378 | { | |
379 | struct mt_device *td = hid_get_drvdata(hdev); | |
eec29e3d | 380 | struct mt_class *cls = &td->mtclass; |
c2ef8f21 | 381 | int code; |
349fd670 | 382 | struct hid_usage *prev_usage = NULL; |
4875ac11 | 383 | |
658d4aed | 384 | if (field->application == HID_DG_TOUCHSCREEN) |
76f5902a | 385 | td->mt_flags |= INPUT_MT_DIRECT; |
658d4aed | 386 | |
76f5902a HR |
387 | /* |
388 | * Model touchscreens providing buttons as touchpads. | |
c2ef8f21 BT |
389 | */ |
390 | if (field->application == HID_DG_TOUCHPAD || | |
9abebedb | 391 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { |
76f5902a | 392 | td->mt_flags |= INPUT_MT_POINTER; |
9abebedb AD |
393 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; |
394 | } | |
c2ef8f21 | 395 | |
015fdaa9 BT |
396 | /* count the buttons on touchpads */ |
397 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) | |
398 | td->buttons_count++; | |
399 | ||
349fd670 BT |
400 | if (usage->usage_index) |
401 | prev_usage = &field->usage[usage->usage_index - 1]; | |
402 | ||
5519cab4 BT |
403 | switch (usage->hid & HID_USAGE_PAGE) { |
404 | ||
405 | case HID_UP_GENDESK: | |
406 | switch (usage->hid) { | |
407 | case HID_GD_X: | |
349fd670 BT |
408 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
409 | hid_map_usage(hi, usage, bit, max, | |
410 | EV_ABS, ABS_MT_TOOL_X); | |
411 | set_abs(hi->input, ABS_MT_TOOL_X, field, | |
412 | cls->sn_move); | |
413 | } else { | |
414 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 415 | EV_ABS, ABS_MT_POSITION_X); |
349fd670 BT |
416 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
417 | cls->sn_move); | |
418 | } | |
419 | ||
3ac36d15 | 420 | mt_store_field(usage, td, hi); |
5519cab4 BT |
421 | return 1; |
422 | case HID_GD_Y: | |
349fd670 BT |
423 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
424 | hid_map_usage(hi, usage, bit, max, | |
425 | EV_ABS, ABS_MT_TOOL_Y); | |
426 | set_abs(hi->input, ABS_MT_TOOL_Y, field, | |
427 | cls->sn_move); | |
428 | } else { | |
429 | hid_map_usage(hi, usage, bit, max, | |
5519cab4 | 430 | EV_ABS, ABS_MT_POSITION_Y); |
349fd670 BT |
431 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
432 | cls->sn_move); | |
433 | } | |
434 | ||
3ac36d15 | 435 | mt_store_field(usage, td, hi); |
5519cab4 BT |
436 | return 1; |
437 | } | |
438 | return 0; | |
439 | ||
440 | case HID_UP_DIGITIZER: | |
441 | switch (usage->hid) { | |
442 | case HID_DG_INRANGE: | |
9b3bb9b8 BT |
443 | if (cls->quirks & MT_QUIRK_HOVERING) { |
444 | hid_map_usage(hi, usage, bit, max, | |
445 | EV_ABS, ABS_MT_DISTANCE); | |
446 | input_set_abs_params(hi->input, | |
447 | ABS_MT_DISTANCE, 0, 1, 0, 0); | |
448 | } | |
3ac36d15 | 449 | mt_store_field(usage, td, hi); |
5519cab4 BT |
450 | return 1; |
451 | case HID_DG_CONFIDENCE: | |
3ac36d15 | 452 | mt_store_field(usage, td, hi); |
5519cab4 BT |
453 | return 1; |
454 | case HID_DG_TIPSWITCH: | |
455 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | |
456 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); | |
3ac36d15 | 457 | mt_store_field(usage, td, hi); |
5519cab4 BT |
458 | return 1; |
459 | case HID_DG_CONTACTID: | |
3ac36d15 | 460 | mt_store_field(usage, td, hi); |
9e87f22a | 461 | td->touches_by_report++; |
55978fa9 | 462 | td->mt_report_id = field->report->id; |
5519cab4 BT |
463 | return 1; |
464 | case HID_DG_WIDTH: | |
465 | hid_map_usage(hi, usage, bit, max, | |
466 | EV_ABS, ABS_MT_TOUCH_MAJOR); | |
77723e3b HR |
467 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) |
468 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, | |
469 | cls->sn_width); | |
3ac36d15 | 470 | mt_store_field(usage, td, hi); |
5519cab4 BT |
471 | return 1; |
472 | case HID_DG_HEIGHT: | |
473 | hid_map_usage(hi, usage, bit, max, | |
474 | EV_ABS, ABS_MT_TOUCH_MINOR); | |
77723e3b HR |
475 | if (!(cls->quirks & MT_QUIRK_NO_AREA)) { |
476 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, | |
477 | cls->sn_height); | |
478 | input_set_abs_params(hi->input, | |
1e648a13 | 479 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
77723e3b | 480 | } |
3ac36d15 | 481 | mt_store_field(usage, td, hi); |
5519cab4 BT |
482 | return 1; |
483 | case HID_DG_TIPPRESSURE: | |
484 | hid_map_usage(hi, usage, bit, max, | |
485 | EV_ABS, ABS_MT_PRESSURE); | |
486 | set_abs(hi->input, ABS_MT_PRESSURE, field, | |
487 | cls->sn_pressure); | |
3ac36d15 | 488 | mt_store_field(usage, td, hi); |
5519cab4 BT |
489 | return 1; |
490 | case HID_DG_CONTACTCOUNT: | |
8821f5dc BT |
491 | /* Ignore if indexes are out of bounds. */ |
492 | if (field->index >= field->report->maxfield || | |
493 | usage->usage_index >= field->report_count) | |
494 | return 1; | |
7e3cc447 BT |
495 | td->cc_index = field->index; |
496 | td->cc_value_index = usage->usage_index; | |
5519cab4 BT |
497 | return 1; |
498 | case HID_DG_CONTACTMAX: | |
499 | /* we don't set td->last_slot_field as contactcount and | |
500 | * contact max are global to the report */ | |
501 | return -1; | |
c2ef8f21 BT |
502 | case HID_DG_TOUCH: |
503 | /* Legacy devices use TIPSWITCH and not TOUCH. | |
504 | * Let's just ignore this field. */ | |
505 | return -1; | |
65b258e9 | 506 | } |
5519cab4 BT |
507 | /* let hid-input decide for the others */ |
508 | return 0; | |
509 | ||
c2ef8f21 BT |
510 | case HID_UP_BUTTON: |
511 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); | |
512 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); | |
513 | input_set_capability(hi->input, EV_KEY, code); | |
514 | return 1; | |
515 | ||
5519cab4 BT |
516 | case 0xff000000: |
517 | /* we do not want to map these: no input-oriented meaning */ | |
518 | return -1; | |
519 | } | |
520 | ||
521 | return 0; | |
522 | } | |
523 | ||
a69c5f8b | 524 | static int mt_touch_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
5519cab4 BT |
525 | struct hid_field *field, struct hid_usage *usage, |
526 | unsigned long **bit, int *max) | |
527 | { | |
528 | if (usage->type == EV_KEY || usage->type == EV_ABS) | |
529 | set_bit(usage->type, hi->input->evbit); | |
530 | ||
531 | return -1; | |
532 | } | |
533 | ||
3e1b5015 | 534 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 535 | { |
eec29e3d | 536 | __s32 quirks = td->mtclass.quirks; |
5519cab4 | 537 | |
2d93666e BT |
538 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
539 | return td->curdata.contactid; | |
5519cab4 | 540 | |
2d93666e | 541 | if (quirks & MT_QUIRK_CYPRESS) |
a3b5e577 BT |
542 | return cypress_compute_slot(td); |
543 | ||
2d93666e BT |
544 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
545 | return td->num_received; | |
5572da08 | 546 | |
4a6ee685 BT |
547 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
548 | return td->curdata.contactid - 1; | |
549 | ||
3e1b5015 | 550 | return input_mt_get_slot_by_key(input, td->curdata.contactid); |
5519cab4 BT |
551 | } |
552 | ||
553 | /* | |
554 | * this function is called when a whole contact has been processed, | |
555 | * so that it can assign it to a slot and store the data there | |
556 | */ | |
3e1b5015 | 557 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) |
5519cab4 | 558 | { |
c2517f62 BT |
559 | if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && |
560 | td->num_received >= td->num_expected) | |
561 | return; | |
562 | ||
20b60e6d | 563 | if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { |
3e1b5015 HR |
564 | int slotnum = mt_compute_slot(td, input); |
565 | struct mt_slot *s = &td->curdata; | |
28728399 | 566 | struct input_mt *mt = input->mt; |
5519cab4 | 567 | |
3e1b5015 HR |
568 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
569 | return; | |
5519cab4 | 570 | |
28728399 BT |
571 | if ((td->mtclass.quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { |
572 | struct input_mt_slot *slot = &mt->slots[slotnum]; | |
573 | if (input_mt_is_active(slot) && | |
574 | input_mt_is_used(mt, slot)) | |
575 | return; | |
576 | } | |
577 | ||
3e1b5015 | 578 | input_mt_slot(input, slotnum); |
5519cab4 | 579 | input_mt_report_slot_state(input, MT_TOOL_FINGER, |
9b3bb9b8 BT |
580 | s->touch_state || s->inrange_state); |
581 | if (s->touch_state || s->inrange_state) { | |
582 | /* this finger is in proximity of the sensor */ | |
f786bba4 BT |
583 | int wide = (s->w > s->h); |
584 | /* divided by two to match visual scale of touch */ | |
585 | int major = max(s->w, s->h) >> 1; | |
586 | int minor = min(s->w, s->h) >> 1; | |
587 | ||
2d93666e BT |
588 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); |
589 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); | |
349fd670 BT |
590 | input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx); |
591 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); | |
9b3bb9b8 BT |
592 | input_event(input, EV_ABS, ABS_MT_DISTANCE, |
593 | !s->touch_state); | |
f786bba4 | 594 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); |
2d93666e | 595 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); |
f786bba4 BT |
596 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
597 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); | |
2d93666e | 598 | } |
5519cab4 BT |
599 | } |
600 | ||
3e1b5015 HR |
601 | td->num_received++; |
602 | } | |
603 | ||
604 | /* | |
605 | * this function is called when a whole packet has been received and processed, | |
606 | * so that it can decide what to send to the input layer. | |
607 | */ | |
608 | static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | |
609 | { | |
76f5902a | 610 | input_mt_sync_frame(input); |
5519cab4 BT |
611 | input_sync(input); |
612 | td->num_received = 0; | |
613 | } | |
614 | ||
a69c5f8b | 615 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
5519cab4 | 616 | struct hid_usage *usage, __s32 value) |
55978fa9 BT |
617 | { |
618 | /* we will handle the hidinput part later, now remains hiddev */ | |
619 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) | |
620 | hid->hiddev_hid_event(hid, field, usage, value); | |
621 | ||
622 | return 1; | |
623 | } | |
624 | ||
625 | static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |
626 | struct hid_usage *usage, __s32 value) | |
5519cab4 BT |
627 | { |
628 | struct mt_device *td = hid_get_drvdata(hid); | |
eec29e3d | 629 | __s32 quirks = td->mtclass.quirks; |
4c437555 | 630 | struct input_dev *input = field->hidinput->input; |
5519cab4 | 631 | |
3e1b5015 | 632 | if (hid->claimed & HID_CLAIMED_INPUT) { |
5519cab4 BT |
633 | switch (usage->hid) { |
634 | case HID_DG_INRANGE: | |
20b60e6d | 635 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
2d93666e | 636 | td->curvalid = value; |
9b3bb9b8 BT |
637 | if (quirks & MT_QUIRK_HOVERING) |
638 | td->curdata.inrange_state = value; | |
5519cab4 BT |
639 | break; |
640 | case HID_DG_TIPSWITCH: | |
2d93666e BT |
641 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
642 | td->curvalid = value; | |
5519cab4 BT |
643 | td->curdata.touch_state = value; |
644 | break; | |
645 | case HID_DG_CONFIDENCE: | |
2d93666e BT |
646 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
647 | td->curvalid = value; | |
5519cab4 BT |
648 | break; |
649 | case HID_DG_CONTACTID: | |
650 | td->curdata.contactid = value; | |
651 | break; | |
652 | case HID_DG_TIPPRESSURE: | |
653 | td->curdata.p = value; | |
654 | break; | |
655 | case HID_GD_X: | |
349fd670 BT |
656 | if (usage->code == ABS_MT_TOOL_X) |
657 | td->curdata.cx = value; | |
658 | else | |
659 | td->curdata.x = value; | |
5519cab4 BT |
660 | break; |
661 | case HID_GD_Y: | |
349fd670 BT |
662 | if (usage->code == ABS_MT_TOOL_Y) |
663 | td->curdata.cy = value; | |
664 | else | |
665 | td->curdata.y = value; | |
5519cab4 BT |
666 | break; |
667 | case HID_DG_WIDTH: | |
668 | td->curdata.w = value; | |
669 | break; | |
670 | case HID_DG_HEIGHT: | |
671 | td->curdata.h = value; | |
672 | break; | |
673 | case HID_DG_CONTACTCOUNT: | |
5519cab4 | 674 | break; |
c2ef8f21 BT |
675 | case HID_DG_TOUCH: |
676 | /* do nothing */ | |
677 | break; | |
5519cab4 BT |
678 | |
679 | default: | |
4c437555 BT |
680 | if (usage->type) |
681 | input_event(input, usage->type, usage->code, | |
682 | value); | |
55978fa9 | 683 | return; |
5519cab4 | 684 | } |
5519cab4 | 685 | |
54f4c0c3 BT |
686 | if (usage->usage_index + 1 == field->report_count) { |
687 | /* we only take into account the last report. */ | |
688 | if (usage->hid == td->last_slot_field) | |
689 | mt_complete_slot(td, field->hidinput->input); | |
54f4c0c3 | 690 | } |
5519cab4 | 691 | |
2d93666e | 692 | } |
55978fa9 | 693 | } |
5519cab4 | 694 | |
a69c5f8b | 695 | static void mt_touch_report(struct hid_device *hid, struct hid_report *report) |
55978fa9 BT |
696 | { |
697 | struct mt_device *td = hid_get_drvdata(hid); | |
698 | struct hid_field *field; | |
699 | unsigned count; | |
700 | int r, n; | |
5519cab4 | 701 | |
c2517f62 BT |
702 | /* |
703 | * Includes multi-packet support where subsequent | |
704 | * packets are sent with zero contactcount. | |
705 | */ | |
7e3cc447 BT |
706 | if (td->cc_index >= 0) { |
707 | struct hid_field *field = report->field[td->cc_index]; | |
708 | int value = field->value[td->cc_value_index]; | |
709 | if (value) | |
710 | td->num_expected = value; | |
711 | } | |
c2517f62 | 712 | |
55978fa9 BT |
713 | for (r = 0; r < report->maxfield; r++) { |
714 | field = report->field[r]; | |
715 | count = field->report_count; | |
716 | ||
717 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) | |
718 | continue; | |
719 | ||
720 | for (n = 0; n < count; n++) | |
721 | mt_process_mt_event(hid, field, &field->usage[n], | |
722 | field->value[n]); | |
723 | } | |
5b62efd8 BT |
724 | |
725 | if (td->num_received >= td->num_expected) | |
726 | mt_sync_frame(td, report->field[0]->hidinput->input); | |
5519cab4 BT |
727 | } |
728 | ||
a69c5f8b BT |
729 | static void mt_touch_input_configured(struct hid_device *hdev, |
730 | struct hid_input *hi) | |
731 | { | |
732 | struct mt_device *td = hid_get_drvdata(hdev); | |
733 | struct mt_class *cls = &td->mtclass; | |
734 | struct input_dev *input = hi->input; | |
735 | ||
736 | if (!td->maxcontacts) | |
737 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | |
738 | ||
739 | mt_post_parse(td); | |
740 | if (td->serial_maybe) | |
741 | mt_post_parse_default_settings(td); | |
742 | ||
743 | if (cls->is_indirect) | |
744 | td->mt_flags |= INPUT_MT_POINTER; | |
745 | ||
746 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | |
747 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | |
748 | ||
015fdaa9 BT |
749 | /* check for clickpads */ |
750 | if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1)) | |
2c6e0277 SF |
751 | td->is_buttonpad = true; |
752 | ||
753 | if (td->is_buttonpad) | |
015fdaa9 BT |
754 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); |
755 | ||
a69c5f8b BT |
756 | input_mt_init_slots(input, td->maxcontacts, td->mt_flags); |
757 | ||
758 | td->mt_flags = 0; | |
759 | } | |
760 | ||
761 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |
762 | struct hid_field *field, struct hid_usage *usage, | |
763 | unsigned long **bit, int *max) | |
764 | { | |
6aef704e BT |
765 | struct mt_device *td = hid_get_drvdata(hdev); |
766 | ||
767 | /* | |
768 | * If mtclass.export_all_inputs is not set, only map fields from | |
769 | * TouchScreen or TouchPad collections. We need to ignore fields | |
770 | * that belong to other collections such as Mouse that might have | |
771 | * the same GenericDesktop usages. | |
772 | */ | |
773 | if (!td->mtclass.export_all_inputs && | |
774 | field->application != HID_DG_TOUCHSCREEN && | |
fa11aa72 | 775 | field->application != HID_DG_PEN && |
a69c5f8b | 776 | field->application != HID_DG_TOUCHPAD) |
6f492f28 | 777 | return -1; |
a69c5f8b | 778 | |
6aef704e BT |
779 | /* |
780 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
781 | * for the stylus. | |
782 | */ | |
a69c5f8b | 783 | if (field->physical == HID_DG_STYLUS) |
e55f6200 | 784 | return 0; |
a69c5f8b | 785 | |
6aef704e BT |
786 | if (field->application == HID_DG_TOUCHSCREEN || |
787 | field->application == HID_DG_TOUCHPAD) | |
788 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max); | |
789 | ||
790 | /* let hid-core decide for the others */ | |
791 | return 0; | |
a69c5f8b BT |
792 | } |
793 | ||
794 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |
795 | struct hid_field *field, struct hid_usage *usage, | |
796 | unsigned long **bit, int *max) | |
797 | { | |
6aef704e BT |
798 | /* |
799 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
800 | * for the stylus. | |
801 | */ | |
fa11aa72 | 802 | if (field->physical == HID_DG_STYLUS) |
e55f6200 | 803 | return 0; |
fa11aa72 | 804 | |
6aef704e BT |
805 | if (field->application == HID_DG_TOUCHSCREEN || |
806 | field->application == HID_DG_TOUCHPAD) | |
807 | return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); | |
808 | ||
809 | /* let hid-core decide for the others */ | |
810 | return 0; | |
a69c5f8b BT |
811 | } |
812 | ||
813 | static int mt_event(struct hid_device *hid, struct hid_field *field, | |
814 | struct hid_usage *usage, __s32 value) | |
815 | { | |
816 | struct mt_device *td = hid_get_drvdata(hid); | |
817 | ||
818 | if (field->report->id == td->mt_report_id) | |
819 | return mt_touch_event(hid, field, usage, value); | |
820 | ||
e55f6200 | 821 | return 0; |
a69c5f8b BT |
822 | } |
823 | ||
824 | static void mt_report(struct hid_device *hid, struct hid_report *report) | |
825 | { | |
826 | struct mt_device *td = hid_get_drvdata(hid); | |
e55f6200 | 827 | struct hid_field *field = report->field[0]; |
a69c5f8b BT |
828 | |
829 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | |
830 | return; | |
831 | ||
832 | if (report->id == td->mt_report_id) | |
e55f6200 | 833 | return mt_touch_report(hid, report); |
fa11aa72 | 834 | |
e55f6200 BT |
835 | if (field && field->hidinput && field->hidinput->input) |
836 | input_sync(field->hidinput->input); | |
5519cab4 BT |
837 | } |
838 | ||
839 | static void mt_set_input_mode(struct hid_device *hdev) | |
840 | { | |
841 | struct mt_device *td = hid_get_drvdata(hdev); | |
842 | struct hid_report *r; | |
843 | struct hid_report_enum *re; | |
da10bc25 MM |
844 | struct mt_class *cls = &td->mtclass; |
845 | char *buf; | |
846 | int report_len; | |
5519cab4 BT |
847 | |
848 | if (td->inputmode < 0) | |
849 | return; | |
850 | ||
851 | re = &(hdev->report_enum[HID_FEATURE_REPORT]); | |
852 | r = re->report_id_hash[td->inputmode]; | |
853 | if (r) { | |
da10bc25 | 854 | if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { |
dabb05c6 | 855 | report_len = hid_report_len(r); |
da10bc25 MM |
856 | buf = hid_alloc_report_buf(r, GFP_KERNEL); |
857 | if (!buf) { | |
858 | hid_err(hdev, "failed to allocate buffer for report\n"); | |
859 | return; | |
860 | } | |
861 | hid_hw_raw_request(hdev, r->id, buf, report_len, | |
862 | HID_FEATURE_REPORT, | |
863 | HID_REQ_GET_REPORT); | |
864 | kfree(buf); | |
865 | } | |
9abebedb | 866 | r->field[0]->value[td->inputmode_index] = td->inputmode_value; |
d8814272 | 867 | hid_hw_request(hdev, r, HID_REQ_SET_REPORT); |
5519cab4 BT |
868 | } |
869 | } | |
870 | ||
31ae9bdd BT |
871 | static void mt_set_maxcontacts(struct hid_device *hdev) |
872 | { | |
873 | struct mt_device *td = hid_get_drvdata(hdev); | |
874 | struct hid_report *r; | |
875 | struct hid_report_enum *re; | |
876 | int fieldmax, max; | |
877 | ||
878 | if (td->maxcontact_report_id < 0) | |
879 | return; | |
880 | ||
881 | if (!td->mtclass.maxcontacts) | |
882 | return; | |
883 | ||
884 | re = &hdev->report_enum[HID_FEATURE_REPORT]; | |
885 | r = re->report_id_hash[td->maxcontact_report_id]; | |
886 | if (r) { | |
887 | max = td->mtclass.maxcontacts; | |
888 | fieldmax = r->field[0]->logical_maximum; | |
889 | max = min(fieldmax, max); | |
890 | if (r->field[0]->value[0] != max) { | |
891 | r->field[0]->value[0] = max; | |
d8814272 | 892 | hid_hw_request(hdev, r, HID_REQ_SET_REPORT); |
31ae9bdd BT |
893 | } |
894 | } | |
895 | } | |
896 | ||
4fa3a583 HR |
897 | static void mt_post_parse_default_settings(struct mt_device *td) |
898 | { | |
899 | __s32 quirks = td->mtclass.quirks; | |
900 | ||
901 | /* unknown serial device needs special quirks */ | |
902 | if (td->touches_by_report == 1) { | |
903 | quirks |= MT_QUIRK_ALWAYS_VALID; | |
904 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | |
905 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | |
906 | quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; | |
e0bb8f9a | 907 | quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
4fa3a583 HR |
908 | } |
909 | ||
910 | td->mtclass.quirks = quirks; | |
911 | } | |
912 | ||
3ac36d15 BT |
913 | static void mt_post_parse(struct mt_device *td) |
914 | { | |
915 | struct mt_fields *f = td->fields; | |
c2517f62 | 916 | struct mt_class *cls = &td->mtclass; |
3ac36d15 BT |
917 | |
918 | if (td->touches_by_report > 0) { | |
919 | int field_count_per_touch = f->length / td->touches_by_report; | |
920 | td->last_slot_field = f->usages[field_count_per_touch - 1]; | |
921 | } | |
c2517f62 | 922 | |
7e3cc447 | 923 | if (td->cc_index < 0) |
c2517f62 | 924 | cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
3ac36d15 BT |
925 | } |
926 | ||
76f5902a | 927 | static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
76f5902a HR |
928 | { |
929 | struct mt_device *td = hid_get_drvdata(hdev); | |
c08d46aa BT |
930 | char *name; |
931 | const char *suffix = NULL; | |
6aef704e | 932 | struct hid_field *field = hi->report->field[0]; |
76f5902a | 933 | |
5b6498a1 BT |
934 | if (hi->report->id == td->mt_report_id) |
935 | mt_touch_input_configured(hdev, hi); | |
76f5902a | 936 | |
6aef704e BT |
937 | /* |
938 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | |
939 | * for the stylus. Check this first, and then rely on the application | |
940 | * field. | |
941 | */ | |
c08d46aa BT |
942 | if (hi->report->field[0]->physical == HID_DG_STYLUS) { |
943 | suffix = "Pen"; | |
e55f6200 BT |
944 | /* force BTN_STYLUS to allow tablet matching in udev */ |
945 | __set_bit(BTN_STYLUS, hi->input->keybit); | |
6aef704e BT |
946 | } else { |
947 | switch (field->application) { | |
948 | case HID_GD_KEYBOARD: | |
949 | suffix = "Keyboard"; | |
950 | break; | |
951 | case HID_GD_KEYPAD: | |
952 | suffix = "Keypad"; | |
953 | break; | |
954 | case HID_GD_MOUSE: | |
955 | suffix = "Mouse"; | |
956 | break; | |
957 | case HID_DG_STYLUS: | |
958 | suffix = "Pen"; | |
959 | /* force BTN_STYLUS to allow tablet matching in udev */ | |
960 | __set_bit(BTN_STYLUS, hi->input->keybit); | |
961 | break; | |
962 | case HID_DG_TOUCHSCREEN: | |
963 | /* we do not set suffix = "Touchscreen" */ | |
964 | break; | |
965 | case HID_GD_SYSTEM_CONTROL: | |
966 | suffix = "System Control"; | |
967 | break; | |
968 | case HID_CP_CONSUMER_CONTROL: | |
969 | suffix = "Consumer Control"; | |
970 | break; | |
971 | default: | |
972 | suffix = "UNKNOWN"; | |
973 | break; | |
974 | } | |
c08d46aa BT |
975 | } |
976 | ||
977 | if (suffix) { | |
978 | name = devm_kzalloc(&hi->input->dev, | |
979 | strlen(hdev->name) + strlen(suffix) + 2, | |
980 | GFP_KERNEL); | |
981 | if (name) { | |
982 | sprintf(name, "%s %s", hdev->name, suffix); | |
983 | hi->input->name = name; | |
984 | } | |
985 | } | |
76f5902a HR |
986 | } |
987 | ||
5519cab4 BT |
988 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
989 | { | |
2d93666e | 990 | int ret, i; |
5519cab4 | 991 | struct mt_device *td; |
2d93666e BT |
992 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
993 | ||
94b5485c HR |
994 | for (i = 0; mt_classes[i].name ; i++) { |
995 | if (id->driver_data == mt_classes[i].name) { | |
996 | mtclass = &(mt_classes[i]); | |
997 | break; | |
2d93666e BT |
998 | } |
999 | } | |
5519cab4 | 1000 | |
d682bd7f HR |
1001 | /* This allows the driver to correctly support devices |
1002 | * that emit events over several HID messages. | |
1003 | */ | |
1004 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; | |
5519cab4 | 1005 | |
fa11aa72 BT |
1006 | /* |
1007 | * This allows the driver to handle different input sensors | |
1008 | * that emits events through different reports on the same HID | |
1009 | * device. | |
1010 | */ | |
1011 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | |
1012 | hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; | |
1013 | ||
595e9276 BT |
1014 | /* |
1015 | * Handle special quirks for Windows 8 certified devices. | |
1016 | */ | |
1017 | if (id->group == HID_GROUP_MULTITOUCH_WIN_8) | |
1018 | /* | |
1019 | * Some multitouch screens do not like to be polled for input | |
1020 | * reports. Fortunately, the Win8 spec says that all touches | |
1021 | * should be sent during each report, making the initialization | |
1022 | * of input reports unnecessary. | |
1023 | */ | |
1024 | hdev->quirks |= HID_QUIRK_NO_INIT_INPUT_REPORTS; | |
1025 | ||
c08d46aa | 1026 | td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); |
5519cab4 BT |
1027 | if (!td) { |
1028 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | |
1029 | return -ENOMEM; | |
1030 | } | |
eec29e3d | 1031 | td->mtclass = *mtclass; |
5519cab4 | 1032 | td->inputmode = -1; |
31ae9bdd | 1033 | td->maxcontact_report_id = -1; |
9abebedb | 1034 | td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; |
7e3cc447 | 1035 | td->cc_index = -1; |
fa11aa72 | 1036 | td->mt_report_id = -1; |
5519cab4 BT |
1037 | hid_set_drvdata(hdev, td); |
1038 | ||
c08d46aa BT |
1039 | td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), |
1040 | GFP_KERNEL); | |
3ac36d15 BT |
1041 | if (!td->fields) { |
1042 | dev_err(&hdev->dev, "cannot allocate multitouch fields data\n"); | |
c08d46aa | 1043 | return -ENOMEM; |
3ac36d15 BT |
1044 | } |
1045 | ||
76f5902a HR |
1046 | if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) |
1047 | td->serial_maybe = true; | |
1048 | ||
5519cab4 BT |
1049 | ret = hid_parse(hdev); |
1050 | if (ret != 0) | |
c08d46aa | 1051 | return ret; |
5519cab4 BT |
1052 | |
1053 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
2d93666e | 1054 | if (ret) |
c08d46aa | 1055 | return ret; |
5519cab4 | 1056 | |
eec29e3d BT |
1057 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
1058 | ||
31ae9bdd | 1059 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
1060 | mt_set_input_mode(hdev); |
1061 | ||
c08d46aa BT |
1062 | /* release .fields memory as it is not used anymore */ |
1063 | devm_kfree(&hdev->dev, td->fields); | |
3ac36d15 BT |
1064 | td->fields = NULL; |
1065 | ||
5519cab4 | 1066 | return 0; |
5519cab4 BT |
1067 | } |
1068 | ||
1069 | #ifdef CONFIG_PM | |
1070 | static int mt_reset_resume(struct hid_device *hdev) | |
1071 | { | |
31ae9bdd | 1072 | mt_set_maxcontacts(hdev); |
5519cab4 BT |
1073 | mt_set_input_mode(hdev); |
1074 | return 0; | |
1075 | } | |
dfeefd10 SL |
1076 | |
1077 | static int mt_resume(struct hid_device *hdev) | |
1078 | { | |
dfeefd10 SL |
1079 | /* Some Elan legacy devices require SET_IDLE to be set on resume. |
1080 | * It should be safe to send it to other devices too. | |
1081 | * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ | |
1082 | ||
4ba25d3f | 1083 | hid_hw_idle(hdev, 0, 0, HID_REQ_SET_IDLE); |
dfeefd10 SL |
1084 | |
1085 | return 0; | |
1086 | } | |
5519cab4 BT |
1087 | #endif |
1088 | ||
1089 | static void mt_remove(struct hid_device *hdev) | |
1090 | { | |
eec29e3d | 1091 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
5939212d | 1092 | hid_hw_stop(hdev); |
5519cab4 BT |
1093 | } |
1094 | ||
0fa9c616 BT |
1095 | /* |
1096 | * This list contains only: | |
1097 | * - VID/PID of products not working with the default multitouch handling | |
1098 | * - 2 generic rules. | |
1099 | * So there is no point in adding here any device with MT_CLS_DEFAULT. | |
1100 | */ | |
5519cab4 BT |
1101 | static const struct hid_device_id mt_devices[] = { |
1102 | ||
f786bba4 BT |
1103 | /* 3M panels */ |
1104 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1105 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 BT |
1106 | USB_DEVICE_ID_3M1968) }, |
1107 | { .driver_data = MT_CLS_3M, | |
2c2110e9 | 1108 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
f786bba4 | 1109 | USB_DEVICE_ID_3M2256) }, |
c4fad877 | 1110 | { .driver_data = MT_CLS_3M, |
2c2110e9 | 1111 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
c4fad877 | 1112 | USB_DEVICE_ID_3M3266) }, |
f786bba4 | 1113 | |
6aef704e BT |
1114 | /* Anton devices */ |
1115 | { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, | |
1116 | MT_USB_DEVICE(USB_VENDOR_ID_ANTON, | |
1117 | USB_DEVICE_ID_ANTON_TOUCH_PAD) }, | |
e6aac342 | 1118 | |
b1057124 | 1119 | /* Atmel panels */ |
841cb157 | 1120 | { .driver_data = MT_CLS_SERIAL, |
2c2110e9 | 1121 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
841cb157 | 1122 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
b1057124 | 1123 | |
9ed32695 | 1124 | /* Baanto multitouch devices */ |
dc3e1d80 | 1125 | { .driver_data = MT_CLS_NSMU, |
16b79bb8 | 1126 | MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, |
9ed32695 | 1127 | USB_DEVICE_ID_BAANTO_MT_190W2) }, |
0fa9c616 | 1128 | |
a841b62c BT |
1129 | /* Cando panels */ |
1130 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1131 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c | 1132 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
a841b62c | 1133 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
2c2110e9 | 1134 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
a841b62c BT |
1135 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
1136 | ||
942fd422 | 1137 | /* Chunghwa Telecom touch panels */ |
dc3e1d80 | 1138 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1139 | MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
942fd422 AZ |
1140 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
1141 | ||
79603dc9 | 1142 | /* CVTouch panels */ |
dc3e1d80 | 1143 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1144 | MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
79603dc9 BT |
1145 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
1146 | ||
22408283 | 1147 | /* eGalax devices (resistive) */ |
e36f690b | 1148 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1149 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b BT |
1150 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
1151 | { .driver_data = MT_CLS_EGALAX, | |
2c2110e9 | 1152 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1153 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
22408283 BT |
1154 | |
1155 | /* eGalax devices (capacitive) */ | |
fd1d1525 | 1156 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1157 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1158 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
aa672da1 | 1159 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1160 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1161 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
fd1d1525 | 1162 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1163 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1164 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
2ce09df4 | 1165 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1166 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
2ce09df4 | 1167 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
aa672da1 | 1168 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1169 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
aa672da1 | 1170 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
fd1d1525 | 1171 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1172 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1173 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
aa672da1 AS |
1174 | { .driver_data = MT_CLS_EGALAX, |
1175 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1176 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, | |
e36f690b | 1177 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1178 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1179 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
fd1d1525 | 1180 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1181 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1182 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
aa672da1 AS |
1183 | { .driver_data = MT_CLS_EGALAX, |
1184 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1185 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, | |
1186 | { .driver_data = MT_CLS_EGALAX, | |
1187 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | |
1188 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, | |
66f06127 | 1189 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1190 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
66f06127 | 1191 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
bb9ff210 | 1192 | { .driver_data = MT_CLS_EGALAX, |
2c2110e9 | 1193 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
bb9ff210 | 1194 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
fd1d1525 | 1195 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1196 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
fd1d1525 | 1197 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
1b723e8d | 1198 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
ae01c9e5 TR |
1199 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
1200 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, | |
1b723e8d | 1201 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
2c2110e9 | 1202 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
e36f690b | 1203 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
22408283 | 1204 | |
7c7606a2 TS |
1205 | /* Elitegroup panel */ |
1206 | { .driver_data = MT_CLS_SERIAL, | |
1207 | MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP, | |
1208 | USB_DEVICE_ID_ELITEGROUP_05D8) }, | |
1209 | ||
77723e3b HR |
1210 | /* Flatfrog Panels */ |
1211 | { .driver_data = MT_CLS_FLATFROG, | |
1212 | MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, | |
1213 | USB_DEVICE_ID_MULTITOUCH_3200) }, | |
1214 | ||
3db187e7 BT |
1215 | /* FocalTech Panels */ |
1216 | { .driver_data = MT_CLS_SERIAL, | |
1217 | MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL, | |
1218 | USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH) }, | |
1219 | ||
5572da08 | 1220 | /* GeneralTouch panel */ |
f5ff4e1e | 1221 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
2c2110e9 | 1222 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
5572da08 | 1223 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
f5ff4e1e XY |
1224 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
1225 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1226 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, | |
7b226292 L |
1227 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
1228 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1229 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) }, | |
1230 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1231 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1232 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) }, | |
1233 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1234 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1235 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) }, | |
1236 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1237 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1238 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) }, | |
1239 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, | |
1240 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | |
1241 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) }, | |
5572da08 | 1242 | |
4d5df5d1 | 1243 | /* Gametel game controller */ |
dc3e1d80 | 1244 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1245 | MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, |
4d5df5d1 AN |
1246 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
1247 | ||
ee0fbd14 | 1248 | /* GoodTouch panels */ |
dc3e1d80 | 1249 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1250 | MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
ee0fbd14 BT |
1251 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
1252 | ||
54580365 BT |
1253 | /* Hanvon panels */ |
1254 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | |
2c2110e9 | 1255 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
54580365 BT |
1256 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
1257 | ||
4e61f0d7 | 1258 | /* Ilitek dual touch panel */ |
dc3e1d80 | 1259 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1260 | MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
4e61f0d7 AZ |
1261 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
1262 | ||
4a6ee685 BT |
1263 | /* MosArt panels */ |
1264 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1265 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1266 | USB_DEVICE_ID_ASUS_T91MT)}, |
1267 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1268 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
4a6ee685 BT |
1269 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
1270 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, | |
2c2110e9 | 1271 | MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
4a6ee685 BT |
1272 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
1273 | ||
2258e863 DK |
1274 | /* Panasonic panels */ |
1275 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1276 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1277 | USB_DEVICE_ID_PANABOARD_UBT780) }, |
1278 | { .driver_data = MT_CLS_PANASONIC, | |
2c2110e9 | 1279 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
2258e863 DK |
1280 | USB_DEVICE_ID_PANABOARD_UBT880) }, |
1281 | ||
4db703ea | 1282 | /* Novatek Panel */ |
dc3e1d80 | 1283 | { .driver_data = MT_CLS_NSMU, |
4380d819 | 1284 | MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, |
4db703ea AH |
1285 | USB_DEVICE_ID_NOVATEK_PCT) }, |
1286 | ||
b7ea95ff AT |
1287 | /* PixArt optical touch screen */ |
1288 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1289 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1290 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
1291 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1292 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1293 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
1294 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, | |
2c2110e9 | 1295 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
b7ea95ff AT |
1296 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
1297 | ||
5519cab4 | 1298 | /* PixCir-based panels */ |
1e9cf35b | 1299 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
2c2110e9 | 1300 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
5519cab4 BT |
1301 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
1302 | ||
5e7ea11f | 1303 | /* Quanta-based panels */ |
5e7ea11f | 1304 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
2c2110e9 | 1305 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
5e7ea11f | 1306 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
a6802e00 | 1307 | |
043b403a | 1308 | /* Stantum panels */ |
bf5af9b5 | 1309 | { .driver_data = MT_CLS_CONFIDENCE, |
2c2110e9 | 1310 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
043b403a | 1311 | USB_DEVICE_ID_MTP_STM)}, |
043b403a | 1312 | |
847672cd BT |
1313 | /* TopSeed panels */ |
1314 | { .driver_data = MT_CLS_TOPSEED, | |
2c2110e9 | 1315 | MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
847672cd BT |
1316 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
1317 | ||
5e74e56d | 1318 | /* Touch International panels */ |
dc3e1d80 | 1319 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1320 | MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
5e74e56d BT |
1321 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
1322 | ||
617b64f9 | 1323 | /* Unitec panels */ |
dc3e1d80 | 1324 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1325 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 1326 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
dc3e1d80 | 1327 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1328 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
617b64f9 | 1329 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
bf9d121e | 1330 | |
da10bc25 MM |
1331 | /* VTL panels */ |
1332 | { .driver_data = MT_CLS_VTL, | |
1333 | MT_USB_DEVICE(USB_VENDOR_ID_VTL, | |
1334 | USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, | |
1335 | ||
bf9d121e KC |
1336 | /* Wistron panels */ |
1337 | { .driver_data = MT_CLS_NSMU, | |
1338 | MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, | |
1339 | USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, | |
1340 | ||
bc8a2a9b | 1341 | /* XAT */ |
dc3e1d80 | 1342 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1343 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
bc8a2a9b | 1344 | USB_DEVICE_ID_XAT_CSR) }, |
617b64f9 | 1345 | |
11576c61 | 1346 | /* Xiroku */ |
dc3e1d80 | 1347 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1348 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1349 | USB_DEVICE_ID_XIROKU_SPX) }, |
dc3e1d80 | 1350 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1351 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1352 | USB_DEVICE_ID_XIROKU_MPX) }, |
dc3e1d80 | 1353 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1354 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1355 | USB_DEVICE_ID_XIROKU_CSR) }, |
dc3e1d80 | 1356 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1357 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1358 | USB_DEVICE_ID_XIROKU_SPX1) }, |
dc3e1d80 | 1359 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1360 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1361 | USB_DEVICE_ID_XIROKU_MPX1) }, |
dc3e1d80 | 1362 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1363 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1364 | USB_DEVICE_ID_XIROKU_CSR1) }, |
dc3e1d80 | 1365 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1366 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1367 | USB_DEVICE_ID_XIROKU_SPX2) }, |
dc3e1d80 | 1368 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1369 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 | 1370 | USB_DEVICE_ID_XIROKU_MPX2) }, |
dc3e1d80 | 1371 | { .driver_data = MT_CLS_NSMU, |
2c2110e9 | 1372 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
11576c61 MH |
1373 | USB_DEVICE_ID_XIROKU_CSR2) }, |
1374 | ||
4fa3a583 HR |
1375 | /* Generic MT device */ |
1376 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
f961bd35 BT |
1377 | |
1378 | /* Generic Win 8 certified MT device */ | |
1379 | { .driver_data = MT_CLS_WIN_8, | |
1380 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, | |
1381 | HID_ANY_ID, HID_ANY_ID) }, | |
5519cab4 BT |
1382 | { } |
1383 | }; | |
1384 | MODULE_DEVICE_TABLE(hid, mt_devices); | |
1385 | ||
1386 | static const struct hid_usage_id mt_grabbed_usages[] = { | |
1387 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, | |
1388 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} | |
1389 | }; | |
1390 | ||
1391 | static struct hid_driver mt_driver = { | |
1392 | .name = "hid-multitouch", | |
1393 | .id_table = mt_devices, | |
1394 | .probe = mt_probe, | |
1395 | .remove = mt_remove, | |
1396 | .input_mapping = mt_input_mapping, | |
1397 | .input_mapped = mt_input_mapped, | |
76f5902a | 1398 | .input_configured = mt_input_configured, |
5519cab4 BT |
1399 | .feature_mapping = mt_feature_mapping, |
1400 | .usage_table = mt_grabbed_usages, | |
1401 | .event = mt_event, | |
55978fa9 | 1402 | .report = mt_report, |
5519cab4 BT |
1403 | #ifdef CONFIG_PM |
1404 | .reset_resume = mt_reset_resume, | |
dfeefd10 | 1405 | .resume = mt_resume, |
5519cab4 BT |
1406 | #endif |
1407 | }; | |
f425458e | 1408 | module_hid_driver(mt_driver); |