blob: c3154af28132f33e4b5a3c5695feb54f2f00805b [file] [log] [blame]
Benjamin Tissoires5519cab2011-01-07 23:45:50 +01001/*
2 * HID driver for multitouch panels
3 *
4 * Copyright (c) 2010-2011 Stephane Chatty <chatty@enac.fr>
5 * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com>
6 * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France
7 *
Richard Nauber4875ac12011-03-09 06:20:57 +01008 * This code is partly based on hid-egalax.c:
9 *
10 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
11 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
12 * Copyright (c) 2010 Canonical, Ltd.
13 *
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +010014 * This code is partly based on hid-3m-pct.c:
15 *
16 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
17 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
18 * Copyright (c) 2010 Canonical, Ltd.
19 *
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010020 */
21
22/*
23 * This program is free software; you can redistribute it and/or modify it
24 * under the terms of the GNU General Public License as published by the Free
25 * Software Foundation; either version 2 of the License, or (at your option)
26 * any later version.
27 */
28
29#include <linux/device.h>
30#include <linux/hid.h>
31#include <linux/module.h>
32#include <linux/slab.h>
33#include <linux/usb.h>
34#include <linux/input/mt.h>
35#include "usbhid/usbhid.h"
36
37
38MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
Benjamin Tissoiresef2fafb2011-01-31 11:28:21 +010039MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010040MODULE_DESCRIPTION("HID multitouch panels");
41MODULE_LICENSE("GPL");
42
43#include "hid-ids.h"
44
45/* quirks to control the device */
46#define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0)
47#define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1)
Benjamin Tissoires2d936662011-01-11 16:45:54 +010048#define MT_QUIRK_CYPRESS (1 << 2)
Benjamin Tissoires5572da02011-01-07 23:47:27 +010049#define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3)
Stephane Chattya062cc52011-09-17 22:27:30 +020050#define MT_QUIRK_ALWAYS_VALID (1 << 4)
51#define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
52#define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
Stephane Chattya062cc52011-09-17 22:27:30 +020053#define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010054
55struct mt_slot {
56 __s32 x, y, p, w, h;
57 __s32 contactid; /* the device ContactID assigned to this slot */
58 bool touch_state; /* is the touch valid? */
59 bool seen_in_this_frame;/* has this slot been updated */
60};
61
Benjamin Tissoireseec29e32011-11-23 10:54:28 +010062struct mt_class {
63 __s32 name; /* MT_CLS */
64 __s32 quirks;
65 __s32 sn_move; /* Signal/noise ratio for move events */
66 __s32 sn_width; /* Signal/noise ratio for width events */
67 __s32 sn_height; /* Signal/noise ratio for height events */
68 __s32 sn_pressure; /* Signal/noise ratio for pressure events */
69 __u8 maxcontacts;
70};
71
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010072struct mt_device {
73 struct mt_slot curdata; /* placeholder of incoming data */
Benjamin Tissoireseec29e32011-11-23 10:54:28 +010074 struct mt_class mtclass; /* our mt device class */
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010075 unsigned last_field_index; /* last field index of the report */
76 unsigned last_slot_field; /* the last field of a slot */
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +020077 int last_mt_collection; /* last known mt-related collection */
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010078 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */
79 __u8 num_received; /* how many contacts we received */
80 __u8 num_expected; /* expected last contact index */
Benjamin Tissoires9498f952011-03-18 14:27:52 +010081 __u8 maxcontacts;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010082 bool curvalid; /* is the current contact valid? */
Benjamin Tissoires9498f952011-03-18 14:27:52 +010083 struct mt_slot *slots;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010084};
85
Benjamin Tissoires5519cab2011-01-07 23:45:50 +010086/* classes of device behavior */
Benjamin Tissoires22408282011-05-20 15:59:34 +020087#define MT_CLS_DEFAULT 0x0001
88
Stephane Chattya062cc52011-09-17 22:27:30 +020089#define MT_CLS_SERIAL 0x0002
90#define MT_CLS_CONFIDENCE 0x0003
Benjamin Tissoires5e7ea112011-11-29 13:13:10 +010091#define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004
92#define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005
93#define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006
94#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007
95#define MT_CLS_DUAL_NSMU_CONTACTID 0x0008
Aaron Tianb7ea95f2011-12-15 11:09:06 +080096#define MT_CLS_INRANGE_CONTACTNUMBER 0x0009
Benjamin Tissoires22408282011-05-20 15:59:34 +020097
98/* vendor specific classes */
99#define MT_CLS_3M 0x0101
100#define MT_CLS_CYPRESS 0x0102
101#define MT_CLS_EGALAX 0x0103
Benjamin Tissoires1b723e82011-11-23 10:54:34 +0100102#define MT_CLS_EGALAX_SERIAL 0x0104
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100103
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100104#define MT_DEFAULT_MAXCONTACT 10
105
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100106/*
107 * these device-dependent functions determine what slot corresponds
108 * to a valid contact that was just read.
109 */
110
Benjamin Tissoiresa3b5e572011-01-07 23:46:30 +0100111static int cypress_compute_slot(struct mt_device *td)
112{
113 if (td->curdata.contactid != 0 || td->num_received == 0)
114 return td->curdata.contactid;
115 else
116 return -1;
117}
118
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100119static int find_slot_from_contactid(struct mt_device *td)
120{
121 int i;
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100122 for (i = 0; i < td->maxcontacts; ++i) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100123 if (td->slots[i].contactid == td->curdata.contactid &&
124 td->slots[i].touch_state)
125 return i;
126 }
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100127 for (i = 0; i < td->maxcontacts; ++i) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100128 if (!td->slots[i].seen_in_this_frame &&
129 !td->slots[i].touch_state)
130 return i;
131 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100132 /* should not occurs. If this happens that means
133 * that the device sent more touches that it says
134 * in the report descriptor. It is ignored then. */
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100135 return -1;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100136}
137
138struct mt_class mt_classes[] = {
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100139 { .name = MT_CLS_DEFAULT,
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100140 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP },
Stephane Chattya062cc52011-09-17 22:27:30 +0200141 { .name = MT_CLS_SERIAL,
142 .quirks = MT_QUIRK_ALWAYS_VALID},
Benjamin Tissoires22408282011-05-20 15:59:34 +0200143 { .name = MT_CLS_CONFIDENCE,
144 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
Benjamin Tissoires5e7ea112011-11-29 13:13:10 +0100145 { .name = MT_CLS_CONFIDENCE_CONTACT_ID,
146 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
147 MT_QUIRK_SLOT_IS_CONTACTID },
Benjamin Tissoires22408282011-05-20 15:59:34 +0200148 { .name = MT_CLS_CONFIDENCE_MINUS_ONE,
149 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
150 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
Benjamin Tissoires1e9cf352011-01-31 11:28:20 +0100151 { .name = MT_CLS_DUAL_INRANGE_CONTACTID,
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100152 .quirks = MT_QUIRK_VALID_IS_INRANGE |
153 MT_QUIRK_SLOT_IS_CONTACTID,
154 .maxcontacts = 2 },
Benjamin Tissoires1e9cf352011-01-31 11:28:20 +0100155 { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100156 .quirks = MT_QUIRK_VALID_IS_INRANGE |
157 MT_QUIRK_SLOT_IS_CONTACTNUMBER,
158 .maxcontacts = 2 },
Benjamin Tissoires22408282011-05-20 15:59:34 +0200159 { .name = MT_CLS_DUAL_NSMU_CONTACTID,
160 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
161 MT_QUIRK_SLOT_IS_CONTACTID,
162 .maxcontacts = 2 },
Aaron Tianb7ea95f2011-12-15 11:09:06 +0800163 { .name = MT_CLS_INRANGE_CONTACTNUMBER,
164 .quirks = MT_QUIRK_VALID_IS_INRANGE |
165 MT_QUIRK_SLOT_IS_CONTACTNUMBER },
Benjamin Tissoires22408282011-05-20 15:59:34 +0200166
167 /*
168 * vendor specific classes
169 */
170 { .name = MT_CLS_3M,
171 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
172 MT_QUIRK_SLOT_IS_CONTACTID,
173 .sn_move = 2048,
174 .sn_width = 128,
175 .sn_height = 128 },
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100176 { .name = MT_CLS_CYPRESS,
177 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
178 MT_QUIRK_CYPRESS,
179 .maxcontacts = 10 },
Richard Nauber4875ac12011-03-09 06:20:57 +0100180 { .name = MT_CLS_EGALAX,
181 .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
Benjamin Tissoires2261bb92011-11-23 10:54:29 +0100182 MT_QUIRK_VALID_IS_INRANGE,
Richard Nauber4875ac12011-03-09 06:20:57 +0100183 .sn_move = 4096,
184 .sn_pressure = 32,
185 },
Benjamin Tissoires1b723e82011-11-23 10:54:34 +0100186 { .name = MT_CLS_EGALAX_SERIAL,
187 .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
188 MT_QUIRK_ALWAYS_VALID,
189 .sn_move = 4096,
190 .sn_pressure = 32,
191 },
Benjamin Tissoires043b4032011-03-18 14:27:53 +0100192
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100193 { }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100194};
195
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100196static ssize_t mt_show_quirks(struct device *dev,
197 struct device_attribute *attr,
198 char *buf)
199{
200 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
201 struct mt_device *td = hid_get_drvdata(hdev);
202
203 return sprintf(buf, "%u\n", td->mtclass.quirks);
204}
205
206static ssize_t mt_set_quirks(struct device *dev,
207 struct device_attribute *attr,
208 const char *buf, size_t count)
209{
210 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
211 struct mt_device *td = hid_get_drvdata(hdev);
212
213 unsigned long val;
214
215 if (kstrtoul(buf, 0, &val))
216 return -EINVAL;
217
218 td->mtclass.quirks = val;
219
220 return count;
221}
222
223static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks);
224
225static struct attribute *sysfs_attrs[] = {
226 &dev_attr_quirks.attr,
227 NULL
228};
229
230static struct attribute_group mt_attribute_group = {
231 .attrs = sysfs_attrs
232};
233
Henrik Rydbergf635bd12011-02-24 19:30:59 +0100234static void mt_feature_mapping(struct hid_device *hdev,
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100235 struct hid_field *field, struct hid_usage *usage)
236{
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100237 struct mt_device *td = hid_get_drvdata(hdev);
238
239 switch (usage->hid) {
240 case HID_DG_INPUTMODE:
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100241 td->inputmode = field->report->id;
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100242 break;
243 case HID_DG_CONTACTMAX:
244 td->maxcontacts = field->value[0];
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100245 if (td->mtclass.maxcontacts)
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100246 /* check if the maxcontacts is given by the class */
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100247 td->maxcontacts = td->mtclass.maxcontacts;
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100248
249 break;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100250 }
251}
252
253static void set_abs(struct input_dev *input, unsigned int code,
254 struct hid_field *field, int snratio)
255{
256 int fmin = field->logical_minimum;
257 int fmax = field->logical_maximum;
258 int fuzz = snratio ? (fmax - fmin) / snratio : 0;
259 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
260}
261
262static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
263 struct hid_field *field, struct hid_usage *usage,
264 unsigned long **bit, int *max)
265{
266 struct mt_device *td = hid_get_drvdata(hdev);
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100267 struct mt_class *cls = &td->mtclass;
Richard Nauber4875ac12011-03-09 06:20:57 +0100268
Jeff Brown658d4aed592011-08-15 16:44:28 -0700269 /* Only map fields from TouchScreen or TouchPad collections.
270 * We need to ignore fields that belong to other collections
271 * such as Mouse that might have the same GenericDesktop usages. */
272 if (field->application == HID_DG_TOUCHSCREEN)
273 set_bit(INPUT_PROP_DIRECT, hi->input->propbit);
274 else if (field->application == HID_DG_TOUCHPAD)
275 set_bit(INPUT_PROP_POINTER, hi->input->propbit);
276 else
277 return 0;
278
Benjamin Tissoires2261bb92011-11-23 10:54:29 +0100279 /* eGalax devices provide a Digitizer.Stylus input which overrides
280 * the correct Digitizers.Finger X/Y ranges.
281 * Let's just ignore this input. */
282 if (field->physical == HID_DG_STYLUS)
283 return -1;
284
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100285 switch (usage->hid & HID_USAGE_PAGE) {
286
287 case HID_UP_GENDESK:
288 switch (usage->hid) {
289 case HID_GD_X:
290 hid_map_usage(hi, usage, bit, max,
291 EV_ABS, ABS_MT_POSITION_X);
292 set_abs(hi->input, ABS_MT_POSITION_X, field,
293 cls->sn_move);
294 /* touchscreen emulation */
295 set_abs(hi->input, ABS_X, field, cls->sn_move);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200296 if (td->last_mt_collection == usage->collection_index) {
297 td->last_slot_field = usage->hid;
298 td->last_field_index = field->index;
299 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100300 return 1;
301 case HID_GD_Y:
302 hid_map_usage(hi, usage, bit, max,
303 EV_ABS, ABS_MT_POSITION_Y);
304 set_abs(hi->input, ABS_MT_POSITION_Y, field,
305 cls->sn_move);
306 /* touchscreen emulation */
307 set_abs(hi->input, ABS_Y, field, cls->sn_move);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200308 if (td->last_mt_collection == usage->collection_index) {
309 td->last_slot_field = usage->hid;
310 td->last_field_index = field->index;
311 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100312 return 1;
313 }
314 return 0;
315
316 case HID_UP_DIGITIZER:
317 switch (usage->hid) {
318 case HID_DG_INRANGE:
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200319 if (td->last_mt_collection == usage->collection_index) {
320 td->last_slot_field = usage->hid;
321 td->last_field_index = field->index;
322 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100323 return 1;
324 case HID_DG_CONFIDENCE:
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200325 if (td->last_mt_collection == usage->collection_index) {
326 td->last_slot_field = usage->hid;
327 td->last_field_index = field->index;
328 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100329 return 1;
330 case HID_DG_TIPSWITCH:
331 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
332 input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200333 if (td->last_mt_collection == usage->collection_index) {
334 td->last_slot_field = usage->hid;
335 td->last_field_index = field->index;
336 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100337 return 1;
338 case HID_DG_CONTACTID:
Benjamin Tissoires50bc03a2011-06-21 15:01:53 +0200339 if (!td->maxcontacts)
340 td->maxcontacts = MT_DEFAULT_MAXCONTACT;
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100341 input_mt_init_slots(hi->input, td->maxcontacts);
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100342 td->last_slot_field = usage->hid;
Benjamin Tissoires2955cae2011-04-21 14:15:59 +0200343 td->last_field_index = field->index;
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200344 td->last_mt_collection = usage->collection_index;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100345 return 1;
346 case HID_DG_WIDTH:
347 hid_map_usage(hi, usage, bit, max,
348 EV_ABS, ABS_MT_TOUCH_MAJOR);
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100349 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
350 cls->sn_width);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200351 if (td->last_mt_collection == usage->collection_index) {
352 td->last_slot_field = usage->hid;
353 td->last_field_index = field->index;
354 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100355 return 1;
356 case HID_DG_HEIGHT:
357 hid_map_usage(hi, usage, bit, max,
358 EV_ABS, ABS_MT_TOUCH_MINOR);
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100359 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
360 cls->sn_height);
Benjamin Tissoires1e648a12011-03-18 14:27:55 +0100361 input_set_abs_params(hi->input,
362 ABS_MT_ORIENTATION, 0, 1, 0, 0);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200363 if (td->last_mt_collection == usage->collection_index) {
364 td->last_slot_field = usage->hid;
365 td->last_field_index = field->index;
366 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100367 return 1;
368 case HID_DG_TIPPRESSURE:
369 hid_map_usage(hi, usage, bit, max,
370 EV_ABS, ABS_MT_PRESSURE);
371 set_abs(hi->input, ABS_MT_PRESSURE, field,
372 cls->sn_pressure);
373 /* touchscreen emulation */
374 set_abs(hi->input, ABS_PRESSURE, field,
375 cls->sn_pressure);
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200376 if (td->last_mt_collection == usage->collection_index) {
377 td->last_slot_field = usage->hid;
378 td->last_field_index = field->index;
379 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100380 return 1;
381 case HID_DG_CONTACTCOUNT:
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200382 if (td->last_mt_collection == usage->collection_index)
383 td->last_field_index = field->index;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100384 return 1;
385 case HID_DG_CONTACTMAX:
386 /* we don't set td->last_slot_field as contactcount and
387 * contact max are global to the report */
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200388 if (td->last_mt_collection == usage->collection_index)
389 td->last_field_index = field->index;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100390 return -1;
391 }
392 /* let hid-input decide for the others */
393 return 0;
394
395 case 0xff000000:
396 /* we do not want to map these: no input-oriented meaning */
397 return -1;
398 }
399
400 return 0;
401}
402
403static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
404 struct hid_field *field, struct hid_usage *usage,
405 unsigned long **bit, int *max)
406{
407 if (usage->type == EV_KEY || usage->type == EV_ABS)
408 set_bit(usage->type, hi->input->evbit);
409
410 return -1;
411}
412
413static int mt_compute_slot(struct mt_device *td)
414{
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100415 __s32 quirks = td->mtclass.quirks;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100416
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100417 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID)
418 return td->curdata.contactid;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100419
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100420 if (quirks & MT_QUIRK_CYPRESS)
Benjamin Tissoiresa3b5e572011-01-07 23:46:30 +0100421 return cypress_compute_slot(td);
422
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100423 if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER)
424 return td->num_received;
Benjamin Tissoires5572da02011-01-07 23:47:27 +0100425
Benjamin Tissoires4a6ee682011-04-22 11:51:48 +0200426 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE)
427 return td->curdata.contactid - 1;
428
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100429 return find_slot_from_contactid(td);
430}
431
432/*
433 * this function is called when a whole contact has been processed,
434 * so that it can assign it to a slot and store the data there
435 */
436static void mt_complete_slot(struct mt_device *td)
437{
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100438 td->curdata.seen_in_this_frame = true;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100439 if (td->curvalid) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100440 int slotnum = mt_compute_slot(td);
441
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100442 if (slotnum >= 0 && slotnum < td->maxcontacts)
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100443 td->slots[slotnum] = td->curdata;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100444 }
445 td->num_received++;
446}
447
448
449/*
450 * this function is called when a whole packet has been received and processed,
451 * so that it can decide what to send to the input layer.
452 */
453static void mt_emit_event(struct mt_device *td, struct input_dev *input)
454{
455 int i;
456
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100457 for (i = 0; i < td->maxcontacts; ++i) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100458 struct mt_slot *s = &(td->slots[i]);
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100459 if ((td->mtclass.quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) &&
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100460 !s->seen_in_this_frame) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100461 s->touch_state = false;
462 }
463
464 input_mt_slot(input, i);
465 input_mt_report_slot_state(input, MT_TOOL_FINGER,
466 s->touch_state);
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100467 if (s->touch_state) {
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100468 /* this finger is on the screen */
469 int wide = (s->w > s->h);
470 /* divided by two to match visual scale of touch */
471 int major = max(s->w, s->h) >> 1;
472 int minor = min(s->w, s->h) >> 1;
473
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100474 input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
475 input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100476 input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100477 input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100478 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
479 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100480 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100481 s->seen_in_this_frame = false;
482
483 }
484
485 input_mt_report_pointer_emulation(input, true);
486 input_sync(input);
487 td->num_received = 0;
488}
489
490
491
492static int mt_event(struct hid_device *hid, struct hid_field *field,
493 struct hid_usage *usage, __s32 value)
494{
495 struct mt_device *td = hid_get_drvdata(hid);
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100496 __s32 quirks = td->mtclass.quirks;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100497
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100498 if (hid->claimed & HID_CLAIMED_INPUT && td->slots) {
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100499 switch (usage->hid) {
500 case HID_DG_INRANGE:
Stephane Chattya062cc52011-09-17 22:27:30 +0200501 if (quirks & MT_QUIRK_ALWAYS_VALID)
502 td->curvalid = true;
503 else if (quirks & MT_QUIRK_VALID_IS_INRANGE)
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100504 td->curvalid = value;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100505 break;
506 case HID_DG_TIPSWITCH:
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100507 if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
508 td->curvalid = value;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100509 td->curdata.touch_state = value;
510 break;
511 case HID_DG_CONFIDENCE:
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100512 if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
513 td->curvalid = value;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100514 break;
515 case HID_DG_CONTACTID:
516 td->curdata.contactid = value;
517 break;
518 case HID_DG_TIPPRESSURE:
519 td->curdata.p = value;
520 break;
521 case HID_GD_X:
522 td->curdata.x = value;
523 break;
524 case HID_GD_Y:
525 td->curdata.y = value;
526 break;
527 case HID_DG_WIDTH:
528 td->curdata.w = value;
529 break;
530 case HID_DG_HEIGHT:
531 td->curdata.h = value;
532 break;
533 case HID_DG_CONTACTCOUNT:
534 /*
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100535 * Includes multi-packet support where subsequent
536 * packets are sent with zero contactcount.
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100537 */
538 if (value)
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100539 td->num_expected = value;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100540 break;
541
542 default:
543 /* fallback to the generic hidinput handling */
544 return 0;
545 }
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100546
Henrik Rydbergf153fc32011-03-09 06:35:25 +0100547 if (usage->hid == td->last_slot_field) {
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100548 mt_complete_slot(td);
Henrik Rydbergf153fc32011-03-09 06:35:25 +0100549 }
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100550
551 if (field->index == td->last_field_index
552 && td->num_received >= td->num_expected)
553 mt_emit_event(td, field->hidinput->input);
554
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100555 }
556
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100557 /* we have handled the hidinput part, now remains hiddev */
558 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
559 hid->hiddev_hid_event(hid, field, usage, value);
560
561 return 1;
562}
563
564static void mt_set_input_mode(struct hid_device *hdev)
565{
566 struct mt_device *td = hid_get_drvdata(hdev);
567 struct hid_report *r;
568 struct hid_report_enum *re;
569
570 if (td->inputmode < 0)
571 return;
572
573 re = &(hdev->report_enum[HID_FEATURE_REPORT]);
574 r = re->report_id_hash[td->inputmode];
575 if (r) {
576 r->field[0]->value[0] = 0x02;
577 usbhid_submit_report(hdev, r, USB_DIR_OUT);
578 }
579}
580
581static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
582{
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100583 int ret, i;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100584 struct mt_device *td;
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100585 struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */
586
587 for (i = 0; mt_classes[i].name ; i++) {
588 if (id->driver_data == mt_classes[i].name) {
589 mtclass = &(mt_classes[i]);
590 break;
591 }
592 }
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100593
Henrik Rydbergd682bd72011-11-01 15:26:31 +0100594 /* This allows the driver to correctly support devices
595 * that emit events over several HID messages.
596 */
597 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100598
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100599 td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100600 if (!td) {
601 dev_err(&hdev->dev, "cannot allocate multitouch data\n");
602 return -ENOMEM;
603 }
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100604 td->mtclass = *mtclass;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100605 td->inputmode = -1;
Benjamin Tissoiresb84bd272011-06-12 08:22:08 +0200606 td->last_mt_collection = -1;
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100607 hid_set_drvdata(hdev, td);
608
609 ret = hid_parse(hdev);
610 if (ret != 0)
611 goto fail;
612
613 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
Benjamin Tissoires2d936662011-01-11 16:45:54 +0100614 if (ret)
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100615 goto fail;
616
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100617 td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
618 GFP_KERNEL);
619 if (!td->slots) {
620 dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
621 hid_hw_stop(hdev);
622 ret = -ENOMEM;
623 goto fail;
624 }
625
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100626 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
627
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100628 mt_set_input_mode(hdev);
629
630 return 0;
631
632fail:
633 kfree(td);
634 return ret;
635}
636
637#ifdef CONFIG_PM
638static int mt_reset_resume(struct hid_device *hdev)
639{
640 mt_set_input_mode(hdev);
641 return 0;
642}
643#endif
644
645static void mt_remove(struct hid_device *hdev)
646{
647 struct mt_device *td = hid_get_drvdata(hdev);
Benjamin Tissoireseec29e32011-11-23 10:54:28 +0100648 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100649 hid_hw_stop(hdev);
Benjamin Tissoires9498f952011-03-18 14:27:52 +0100650 kfree(td->slots);
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100651 kfree(td);
652 hid_set_drvdata(hdev, NULL);
653}
654
655static const struct hid_device_id mt_devices[] = {
656
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100657 /* 3M panels */
658 { .driver_data = MT_CLS_3M,
659 HID_USB_DEVICE(USB_VENDOR_ID_3M,
660 USB_DEVICE_ID_3M1968) },
661 { .driver_data = MT_CLS_3M,
662 HID_USB_DEVICE(USB_VENDOR_ID_3M,
663 USB_DEVICE_ID_3M2256) },
Benjamin Tissoiresc4fad872011-12-23 15:41:00 +0100664 { .driver_data = MT_CLS_3M,
665 HID_USB_DEVICE(USB_VENDOR_ID_3M,
666 USB_DEVICE_ID_3M3266) },
Benjamin Tissoiresf786bba2011-03-22 17:34:01 +0100667
Benjamin Tissoirese6aac342011-05-19 14:18:13 +0200668 /* ActionStar panels */
669 { .driver_data = MT_CLS_DEFAULT,
670 HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR,
671 USB_DEVICE_ID_ACTIONSTAR_1011) },
672
Benjamin Tissoiresb1057122011-12-23 15:40:59 +0100673 /* Atmel panels */
674 { .driver_data = MT_CLS_SERIAL,
675 HID_USB_DEVICE(USB_VENDOR_ID_ATMEL,
676 USB_DEVICE_ID_ATMEL_MULTITOUCH) },
677
Benjamin Tissoiresa841b622011-03-18 14:27:54 +0100678 /* Cando panels */
679 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
680 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
681 USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
682 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
683 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
684 USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
685 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
686 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
687 USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
688 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
689 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
690 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
691
Austin Zhang942fd422011-05-28 02:03:47 +0800692 /* Chunghwa Telecom touch panels */
693 { .driver_data = MT_CLS_DEFAULT,
694 HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT,
695 USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
696
Benjamin Tissoires79603dc2011-05-19 14:18:14 +0200697 /* CVTouch panels */
698 { .driver_data = MT_CLS_DEFAULT,
699 HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
700 USB_DEVICE_ID_CVTOUCH_SCREEN) },
701
Benjamin Tissoiresa3b5e572011-01-07 23:46:30 +0100702 /* Cypress panel */
703 { .driver_data = MT_CLS_CYPRESS,
704 HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
705 USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
706
Benjamin Tissoires22408282011-05-20 15:59:34 +0200707 /* eGalax devices (resistive) */
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100708 { .driver_data = MT_CLS_EGALAX,
Benjamin Tissoires22408282011-05-20 15:59:34 +0200709 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100710 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
711 { .driver_data = MT_CLS_EGALAX,
Benjamin Tissoires22408282011-05-20 15:59:34 +0200712 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100713 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
Benjamin Tissoires22408282011-05-20 15:59:34 +0200714
715 /* eGalax devices (capacitive) */
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100716 { .driver_data = MT_CLS_EGALAX,
Benjamin Tissoires22408282011-05-20 15:59:34 +0200717 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100718 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
719 { .driver_data = MT_CLS_EGALAX,
Benjamin Tissoires22408282011-05-20 15:59:34 +0200720 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100721 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
722 { .driver_data = MT_CLS_EGALAX,
Benjamin Tissoires22408282011-05-20 15:59:34 +0200723 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100724 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
725 { .driver_data = MT_CLS_EGALAX,
Chris Bagwell1fd8f042011-11-23 10:54:27 +0100726 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoires66f06122011-11-23 10:54:33 +0100727 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) },
728 { .driver_data = MT_CLS_EGALAX,
729 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Marek Vasutbb9ff212011-11-23 10:54:32 +0100730 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
Benjamin Tissoires1b723e82011-11-23 10:54:34 +0100731 { .driver_data = MT_CLS_EGALAX_SERIAL,
Marek Vasutbb9ff212011-11-23 10:54:32 +0100732 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
Benjamin Tissoirese36f6902011-11-23 10:54:31 +0100733 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
Benjamin Tissoires22408282011-05-20 15:59:34 +0200734
Benjamin Tissoiresc04abee2011-05-19 11:37:29 +0200735 /* Elo TouchSystems IntelliTouch Plus panel */
736 { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
737 HID_USB_DEVICE(USB_VENDOR_ID_ELO,
738 USB_DEVICE_ID_ELO_TS2515) },
739
Benjamin Tissoires5572da02011-01-07 23:47:27 +0100740 /* GeneralTouch panel */
Benjamin Tissoires1e9cf352011-01-31 11:28:20 +0100741 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
Benjamin Tissoires5572da02011-01-07 23:47:27 +0100742 HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
743 USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
744
Benjamin Tissoiresee0fbd12011-05-19 14:18:15 +0200745 /* GoodTouch panels */
746 { .driver_data = MT_CLS_DEFAULT,
747 HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH,
748 USB_DEVICE_ID_GOODTOUCH_000f) },
749
Benjamin Tissoires54580362011-11-29 13:13:12 +0100750 /* Hanvon panels */
751 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
752 HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT,
753 USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },
754
Stephane Chattya062cc52011-09-17 22:27:30 +0200755 /* Ideacom panel */
756 { .driver_data = MT_CLS_SERIAL,
757 HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
758 USB_DEVICE_ID_IDEACOM_IDC6650) },
759
Austin Zhang4e61f0d2011-05-09 23:54:14 +0800760 /* Ilitek dual touch panel */
761 { .driver_data = MT_CLS_DEFAULT,
762 HID_USB_DEVICE(USB_VENDOR_ID_ILITEK,
763 USB_DEVICE_ID_ILITEK_MULTITOUCH) },
764
Benjamin Tissoires4dfcced2011-01-31 11:28:22 +0100765 /* IRTOUCH panels */
766 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
767 HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
768 USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
769
Jeff Brownc50bb1a2011-08-15 21:12:09 -0700770 /* LG Display panels */
771 { .driver_data = MT_CLS_DEFAULT,
772 HID_USB_DEVICE(USB_VENDOR_ID_LG,
773 USB_DEVICE_ID_LG_MULTITOUCH) },
774
Benjamin Tissoiresdf167c42011-05-18 15:27:24 +0200775 /* Lumio panels */
776 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
777 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
778 USB_DEVICE_ID_CRYSTALTOUCH) },
Benjamin Tissoiresc3ead6d2011-06-21 15:01:55 +0200779 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
780 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
781 USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
Benjamin Tissoiresdf167c42011-05-18 15:27:24 +0200782
Benjamin Tissoires4a6ee682011-04-22 11:51:48 +0200783 /* MosArt panels */
784 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
785 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
786 USB_DEVICE_ID_ASUS_T91MT)},
787 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
788 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
789 USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
790 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
791 HID_USB_DEVICE(USB_VENDOR_ID_TURBOX,
792 USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
793
John Sung6ab3a9a2011-04-21 16:21:52 +0200794 /* PenMount panels */
795 { .driver_data = MT_CLS_CONFIDENCE,
796 HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT,
797 USB_DEVICE_ID_PENMOUNT_PCI) },
798
Aaron Tianb7ea95f2011-12-15 11:09:06 +0800799 /* PixArt optical touch screen */
800 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
801 HID_USB_DEVICE(USB_VENDOR_ID_PIXART,
802 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) },
803 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
804 HID_USB_DEVICE(USB_VENDOR_ID_PIXART,
805 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) },
806 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
807 HID_USB_DEVICE(USB_VENDOR_ID_PIXART,
808 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) },
809
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100810 /* PixCir-based panels */
Benjamin Tissoires1e9cf352011-01-31 11:28:20 +0100811 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100812 HID_USB_DEVICE(USB_VENDOR_ID_HANVON,
813 USB_DEVICE_ID_HANVON_MULTITOUCH) },
Benjamin Tissoires1e9cf352011-01-31 11:28:20 +0100814 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100815 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
816 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
817
Benjamin Tissoires5e7ea112011-11-29 13:13:10 +0100818 /* Quanta-based panels */
819 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
820 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
821 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
822 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
823 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
824 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) },
825 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
826 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
827 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) },
828
Benjamin Tissoires043b4032011-03-18 14:27:53 +0100829 /* Stantum panels */
Benjamin Tissoiresbf5af9b2011-05-19 14:18:18 +0200830 { .driver_data = MT_CLS_CONFIDENCE,
Benjamin Tissoires043b4032011-03-18 14:27:53 +0100831 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
832 USB_DEVICE_ID_MTP)},
Benjamin Tissoiresbf5af9b2011-05-19 14:18:18 +0200833 { .driver_data = MT_CLS_CONFIDENCE,
Benjamin Tissoires85a60082011-06-21 15:01:54 +0200834 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
Benjamin Tissoires043b4032011-03-18 14:27:53 +0100835 USB_DEVICE_ID_MTP_STM)},
Benjamin Tissoiresbf5af9b2011-05-19 14:18:18 +0200836 { .driver_data = MT_CLS_CONFIDENCE,
Benjamin Tissoires85a60082011-06-21 15:01:54 +0200837 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX,
Benjamin Tissoires043b4032011-03-18 14:27:53 +0100838 USB_DEVICE_ID_MTP_SITRONIX)},
839
Benjamin Tissoires5e74e562011-05-19 14:18:16 +0200840 /* Touch International panels */
841 { .driver_data = MT_CLS_DEFAULT,
842 HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL,
843 USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
844
Benjamin Tissoires617b64f2011-05-19 14:18:17 +0200845 /* Unitec panels */
846 { .driver_data = MT_CLS_DEFAULT,
847 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
848 USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
849 { .driver_data = MT_CLS_DEFAULT,
850 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
851 USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
ice chienbc8a2a92011-07-15 16:58:06 +0800852 /* XAT */
853 { .driver_data = MT_CLS_DEFAULT,
854 HID_USB_DEVICE(USB_VENDOR_ID_XAT,
855 USB_DEVICE_ID_XAT_CSR) },
Benjamin Tissoires617b64f2011-05-19 14:18:17 +0200856
Benjamin Tissoires5519cab2011-01-07 23:45:50 +0100857 { }
858};
859MODULE_DEVICE_TABLE(hid, mt_devices);
860
861static const struct hid_usage_id mt_grabbed_usages[] = {
862 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
863 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
864};
865
866static struct hid_driver mt_driver = {
867 .name = "hid-multitouch",
868 .id_table = mt_devices,
869 .probe = mt_probe,
870 .remove = mt_remove,
871 .input_mapping = mt_input_mapping,
872 .input_mapped = mt_input_mapped,
873 .feature_mapping = mt_feature_mapping,
874 .usage_table = mt_grabbed_usages,
875 .event = mt_event,
876#ifdef CONFIG_PM
877 .reset_resume = mt_reset_resume,
878#endif
879};
880
881static int __init mt_init(void)
882{
883 return hid_register_driver(&mt_driver);
884}
885
886static void __exit mt_exit(void)
887{
888 hid_unregister_driver(&mt_driver);
889}
890
891module_init(mt_init);
892module_exit(mt_exit);