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