hid-multitouch.c 30.0 KB
Newer Older
1 2 3
/*
 *  HID driver for multitouch panels
 *
4 5 6
 *  Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr>
 *  Copyright (c) 2010-2012 Benjamin Tissoires <benjamin.tissoires@gmail.com>
 *  Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France
7
 *
8 9 10 11 12 13
 *  This code is partly based on hid-egalax.c:
 *
 *  Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
 *  Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
 *  Copyright (c) 2010 Canonical, Ltd.
 *
14 15 16 17 18 19
 *  This code is partly based on hid-3m-pct.c:
 *
 *  Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
 *  Copyright (c) 2010      Henrik Rydberg <rydberg@euromail.se>
 *  Copyright (c) 2010      Canonical, Ltd.
 *
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 */

/*
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 */

#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/input/mt.h>
#include "usbhid/usbhid.h"


MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
39
MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
40 41 42 43 44 45 46 47
MODULE_DESCRIPTION("HID multitouch panels");
MODULE_LICENSE("GPL");

#include "hid-ids.h"

/* quirks to control the device */
#define MT_QUIRK_NOT_SEEN_MEANS_UP	(1 << 0)
#define MT_QUIRK_SLOT_IS_CONTACTID	(1 << 1)
48
#define MT_QUIRK_CYPRESS		(1 << 2)
49
#define MT_QUIRK_SLOT_IS_CONTACTNUMBER	(1 << 3)
50 51 52 53
#define MT_QUIRK_ALWAYS_VALID		(1 << 4)
#define MT_QUIRK_VALID_IS_INRANGE	(1 << 5)
#define MT_QUIRK_VALID_IS_CONFIDENCE	(1 << 6)
#define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE	(1 << 8)
54 55 56 57 58 59 60

struct mt_slot {
	__s32 x, y, p, w, h;
	__s32 contactid;	/* the device ContactID assigned to this slot */
	bool touch_state;	/* is the touch valid? */
};

61 62 63 64 65 66 67 68
struct mt_class {
	__s32 name;	/* MT_CLS */
	__s32 quirks;
	__s32 sn_move;	/* Signal/noise ratio for move events */
	__s32 sn_width;	/* Signal/noise ratio for width events */
	__s32 sn_height;	/* Signal/noise ratio for height events */
	__s32 sn_pressure;	/* Signal/noise ratio for pressure events */
	__u8 maxcontacts;
69
	bool is_indirect;	/* true for touchpads */
70 71
};

72 73 74 75 76
struct mt_fields {
	unsigned usages[HID_MAX_FIELDS];
	unsigned int length;
};

77 78
struct mt_device {
	struct mt_slot curdata;	/* placeholder of incoming data */
79
	struct mt_class mtclass;	/* our mt device class */
80 81
	struct mt_fields *fields;	/* temporary placeholder for storing the
					   multitouch fields */
82 83 84
	unsigned last_field_index;	/* last field index of the report */
	unsigned last_slot_field;	/* the last field of a slot */
	__s8 inputmode;		/* InputMode HID feature, -1 if non-existent */
85
	__s8 inputmode_index;	/* InputMode HID feature index in the report */
86 87
	__s8 maxcontact_report_id;	/* Maximum Contact Number HID feature,
				   -1 if non-existent */
88 89
	__u8 num_received;	/* how many contacts we received */
	__u8 num_expected;	/* expected last contact index */
90
	__u8 maxcontacts;
91 92 93
	__u8 touches_by_report;	/* how many touches are present in one report:
				* 1 means we should use a serial protocol
				* > 1 means hybrid (multitouch) protocol */
94
	bool serial_maybe;	/* need to check for serial protocol */
95
	bool curvalid;		/* is the current contact valid? */
96
	unsigned mt_flags;	/* flags to pass to input-mt */
97 98 99
};

/* classes of device behavior */
100 101
#define MT_CLS_DEFAULT				0x0001

102 103
#define MT_CLS_SERIAL				0x0002
#define MT_CLS_CONFIDENCE			0x0003
104 105 106 107 108
#define MT_CLS_CONFIDENCE_CONTACT_ID		0x0004
#define MT_CLS_CONFIDENCE_MINUS_ONE		0x0005
#define MT_CLS_DUAL_INRANGE_CONTACTID		0x0006
#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER	0x0007
#define MT_CLS_DUAL_NSMU_CONTACTID		0x0008
109
#define MT_CLS_INRANGE_CONTACTNUMBER		0x0009
110 111 112 113 114

/* vendor specific classes */
#define MT_CLS_3M				0x0101
#define MT_CLS_CYPRESS				0x0102
#define MT_CLS_EGALAX				0x0103
115
#define MT_CLS_EGALAX_SERIAL			0x0104
116
#define MT_CLS_TOPSEED				0x0105
117
#define MT_CLS_PANASONIC			0x0106
118

119 120
#define MT_DEFAULT_MAXCONTACT	10

121 122 123
#define MT_USB_DEVICE(v, p)	HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p)
#define MT_BT_DEVICE(v, p)	HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p)

124 125 126 127 128
/*
 * these device-dependent functions determine what slot corresponds
 * to a valid contact that was just read.
 */

129 130 131 132 133 134 135 136
static int cypress_compute_slot(struct mt_device *td)
{
	if (td->curdata.contactid != 0 || td->num_received == 0)
		return td->curdata.contactid;
	else
		return -1;
}

137
static struct mt_class mt_classes[] = {
138
	{ .name = MT_CLS_DEFAULT,
139
		.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP },
140 141
	{ .name = MT_CLS_SERIAL,
		.quirks = MT_QUIRK_ALWAYS_VALID},
142 143
	{ .name = MT_CLS_CONFIDENCE,
		.quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
144 145 146
	{ .name = MT_CLS_CONFIDENCE_CONTACT_ID,
		.quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
			MT_QUIRK_SLOT_IS_CONTACTID },
147 148 149
	{ .name = MT_CLS_CONFIDENCE_MINUS_ONE,
		.quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
			MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
150
	{ .name = MT_CLS_DUAL_INRANGE_CONTACTID,
151 152 153
		.quirks = MT_QUIRK_VALID_IS_INRANGE |
			MT_QUIRK_SLOT_IS_CONTACTID,
		.maxcontacts = 2 },
154
	{ .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
155 156 157
		.quirks = MT_QUIRK_VALID_IS_INRANGE |
			MT_QUIRK_SLOT_IS_CONTACTNUMBER,
		.maxcontacts = 2 },
158 159 160 161
	{ .name = MT_CLS_DUAL_NSMU_CONTACTID,
		.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
			MT_QUIRK_SLOT_IS_CONTACTID,
		.maxcontacts = 2 },
162 163 164
	{ .name = MT_CLS_INRANGE_CONTACTNUMBER,
		.quirks = MT_QUIRK_VALID_IS_INRANGE |
			MT_QUIRK_SLOT_IS_CONTACTNUMBER },
165 166 167 168 169 170 171 172 173 174

	/*
	 * vendor specific classes
	 */
	{ .name = MT_CLS_3M,
		.quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
			MT_QUIRK_SLOT_IS_CONTACTID,
		.sn_move = 2048,
		.sn_width = 128,
		.sn_height = 128 },
175 176 177 178
	{ .name = MT_CLS_CYPRESS,
		.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
			MT_QUIRK_CYPRESS,
		.maxcontacts = 10 },
179 180
	{ .name = MT_CLS_EGALAX,
		.quirks =  MT_QUIRK_SLOT_IS_CONTACTID |
181
			MT_QUIRK_VALID_IS_INRANGE,
182 183 184
		.sn_move = 4096,
		.sn_pressure = 32,
	},
185 186 187
	{ .name = MT_CLS_EGALAX_SERIAL,
		.quirks =  MT_QUIRK_SLOT_IS_CONTACTID |
			MT_QUIRK_ALWAYS_VALID,
188 189 190
		.sn_move = 4096,
		.sn_pressure = 32,
	},
191 192 193 194 195
	{ .name = MT_CLS_TOPSEED,
		.quirks = MT_QUIRK_ALWAYS_VALID,
		.is_indirect = true,
		.maxcontacts = 2,
	},
196 197 198
	{ .name = MT_CLS_PANASONIC,
		.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP,
		.maxcontacts = 4 },
199

200
	{ }
201 202
};

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
static ssize_t mt_show_quirks(struct device *dev,
			   struct device_attribute *attr,
			   char *buf)
{
	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
	struct mt_device *td = hid_get_drvdata(hdev);

	return sprintf(buf, "%u\n", td->mtclass.quirks);
}

static ssize_t mt_set_quirks(struct device *dev,
			  struct device_attribute *attr,
			  const char *buf, size_t count)
{
	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
	struct mt_device *td = hid_get_drvdata(hdev);

	unsigned long val;

	if (kstrtoul(buf, 0, &val))
		return -EINVAL;

	td->mtclass.quirks = val;

	return count;
}

static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks);

static struct attribute *sysfs_attrs[] = {
	&dev_attr_quirks.attr,
	NULL
};

static struct attribute_group mt_attribute_group = {
	.attrs = sysfs_attrs
};

241
static void mt_feature_mapping(struct hid_device *hdev,
242 243
		struct hid_field *field, struct hid_usage *usage)
{
244
	struct mt_device *td = hid_get_drvdata(hdev);
245
	int i;
246 247 248

	switch (usage->hid) {
	case HID_DG_INPUTMODE:
249
		td->inputmode = field->report->id;
250 251 252 253 254 255 256 257 258
		td->inputmode_index = 0; /* has to be updated below */

		for (i=0; i < field->maxusage; i++) {
			if (field->usage[i].hid == usage->hid) {
				td->inputmode_index = i;
				break;
			}
		}

259 260
		break;
	case HID_DG_CONTACTMAX:
261
		td->maxcontact_report_id = field->report->id;
262
		td->maxcontacts = field->value[0];
263
		if (td->mtclass.maxcontacts)
264
			/* check if the maxcontacts is given by the class */
265
			td->maxcontacts = td->mtclass.maxcontacts;
266 267

		break;
268 269 270 271 272 273 274 275 276 277 278 279
	}
}

static void set_abs(struct input_dev *input, unsigned int code,
		struct hid_field *field, int snratio)
{
	int fmin = field->logical_minimum;
	int fmax = field->logical_maximum;
	int fuzz = snratio ? (fmax - fmin) / snratio : 0;
	input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
}

280
static void mt_store_field(struct hid_usage *usage, struct mt_device *td,
281 282
		struct hid_input *hi)
{
283 284 285 286 287 288
	struct mt_fields *f = td->fields;

	if (f->length >= HID_MAX_FIELDS)
		return;

	f->usages[f->length++] = usage->hid;
289 290
}

291 292 293 294 295
static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
		struct hid_field *field, struct hid_usage *usage,
		unsigned long **bit, int *max)
{
	struct mt_device *td = hid_get_drvdata(hdev);
296
	struct mt_class *cls = &td->mtclass;
297
	int code;
298

299
	/* Only map fields from TouchScreen or TouchPad collections.
300 301
	* We need to ignore fields that belong to other collections
	* such as Mouse that might have the same GenericDesktop usages. */
302
	if (field->application == HID_DG_TOUCHSCREEN)
303
		td->mt_flags |= INPUT_MT_DIRECT;
304
	else if (field->application != HID_DG_TOUCHPAD)
305 306
		return 0;

307 308
	/*
	 * Model touchscreens providing buttons as touchpads.
309 310
	 */
	if (field->application == HID_DG_TOUCHPAD ||
311 312
	    (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)
		td->mt_flags |= INPUT_MT_POINTER;
313

314 315 316 317 318 319
	/* eGalax devices provide a Digitizer.Stylus input which overrides
	 * the correct Digitizers.Finger X/Y ranges.
	 * Let's just ignore this input. */
	if (field->physical == HID_DG_STYLUS)
		return -1;

320 321 322 323 324 325 326 327 328
	switch (usage->hid & HID_USAGE_PAGE) {

	case HID_UP_GENDESK:
		switch (usage->hid) {
		case HID_GD_X:
			hid_map_usage(hi, usage, bit, max,
					EV_ABS, ABS_MT_POSITION_X);
			set_abs(hi->input, ABS_MT_POSITION_X, field,
				cls->sn_move);
329
			mt_store_field(usage, td, hi);
330
			td->last_field_index = field->index;
331 332 333 334 335 336
			return 1;
		case HID_GD_Y:
			hid_map_usage(hi, usage, bit, max,
					EV_ABS, ABS_MT_POSITION_Y);
			set_abs(hi->input, ABS_MT_POSITION_Y, field,
				cls->sn_move);
337
			mt_store_field(usage, td, hi);
338
			td->last_field_index = field->index;
339 340 341 342 343 344 345
			return 1;
		}
		return 0;

	case HID_UP_DIGITIZER:
		switch (usage->hid) {
		case HID_DG_INRANGE:
346
			mt_store_field(usage, td, hi);
347
			td->last_field_index = field->index;
348 349
			return 1;
		case HID_DG_CONFIDENCE:
350
			mt_store_field(usage, td, hi);
351
			td->last_field_index = field->index;
352 353 354 355
			return 1;
		case HID_DG_TIPSWITCH:
			hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
			input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
356
			mt_store_field(usage, td, hi);
357
			td->last_field_index = field->index;
358 359
			return 1;
		case HID_DG_CONTACTID:
360
			mt_store_field(usage, td, hi);
361
			td->last_field_index = field->index;
362
			td->touches_by_report++;
363 364 365 366
			return 1;
		case HID_DG_WIDTH:
			hid_map_usage(hi, usage, bit, max,
					EV_ABS, ABS_MT_TOUCH_MAJOR);
367 368
			set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
				cls->sn_width);
369
			mt_store_field(usage, td, hi);
370
			td->last_field_index = field->index;
371 372 373 374
			return 1;
		case HID_DG_HEIGHT:
			hid_map_usage(hi, usage, bit, max,
					EV_ABS, ABS_MT_TOUCH_MINOR);
375 376
			set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
				cls->sn_height);
377 378
			input_set_abs_params(hi->input,
					ABS_MT_ORIENTATION, 0, 1, 0, 0);
379
			mt_store_field(usage, td, hi);
380
			td->last_field_index = field->index;
381 382 383 384 385 386
			return 1;
		case HID_DG_TIPPRESSURE:
			hid_map_usage(hi, usage, bit, max,
					EV_ABS, ABS_MT_PRESSURE);
			set_abs(hi->input, ABS_MT_PRESSURE, field,
				cls->sn_pressure);
387
			mt_store_field(usage, td, hi);
388
			td->last_field_index = field->index;
389 390
			return 1;
		case HID_DG_CONTACTCOUNT:
391
			td->last_field_index = field->index;
392 393 394 395
			return 1;
		case HID_DG_CONTACTMAX:
			/* we don't set td->last_slot_field as contactcount and
			 * contact max are global to the report */
396
			td->last_field_index = field->index;
397 398
			return -1;
		}
399 400 401 402
		case HID_DG_TOUCH:
			/* Legacy devices use TIPSWITCH and not TOUCH.
			 * Let's just ignore this field. */
			return -1;
403 404 405
		/* let hid-input decide for the others */
		return 0;

406 407 408 409 410 411
	case HID_UP_BUTTON:
		code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE);
		hid_map_usage(hi, usage, bit, max, EV_KEY, code);
		input_set_capability(hi->input, EV_KEY, code);
		return 1;

412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
	case 0xff000000:
		/* we do not want to map these: no input-oriented meaning */
		return -1;
	}

	return 0;
}

static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
		struct hid_field *field, struct hid_usage *usage,
		unsigned long **bit, int *max)
{
	if (usage->type == EV_KEY || usage->type == EV_ABS)
		set_bit(usage->type, hi->input->evbit);

	return -1;
}

430
static int mt_compute_slot(struct mt_device *td, struct input_dev *input)
431
{
432
	__s32 quirks = td->mtclass.quirks;
433

434 435
	if (quirks & MT_QUIRK_SLOT_IS_CONTACTID)
		return td->curdata.contactid;
436

437
	if (quirks & MT_QUIRK_CYPRESS)
438 439
		return cypress_compute_slot(td);

440 441
	if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER)
		return td->num_received;
442

443 444 445
	if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE)
		return td->curdata.contactid - 1;

446
	return input_mt_get_slot_by_key(input, td->curdata.contactid);
447 448 449 450 451 452
}

/*
 * this function is called when a whole contact has been processed,
 * so that it can assign it to a slot and store the data there
 */
453
static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
454 455
{
	if (td->curvalid) {
456 457
		int slotnum = mt_compute_slot(td, input);
		struct mt_slot *s = &td->curdata;
458

459 460
		if (slotnum < 0 || slotnum >= td->maxcontacts)
			return;
461

462
		input_mt_slot(input, slotnum);
463 464
		input_mt_report_slot_state(input, MT_TOOL_FINGER,
			s->touch_state);
465
		if (s->touch_state) {
466 467 468 469 470 471
			/* this finger is on the screen */
			int wide = (s->w > s->h);
			/* divided by two to match visual scale of touch */
			int major = max(s->w, s->h) >> 1;
			int minor = min(s->w, s->h) >> 1;

472 473
			input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
			input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
474
			input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
475
			input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
476 477
			input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
			input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
478
		}
479 480
	}

481 482 483 484 485 486 487 488 489
	td->num_received++;
}

/*
 * this function is called when a whole packet has been received and processed,
 * so that it can decide what to send to the input layer.
 */
static void mt_sync_frame(struct mt_device *td, struct input_dev *input)
{
490
	input_mt_sync_frame(input);
491 492 493 494 495 496 497 498
	input_sync(input);
	td->num_received = 0;
}

static int mt_event(struct hid_device *hid, struct hid_field *field,
				struct hid_usage *usage, __s32 value)
{
	struct mt_device *td = hid_get_drvdata(hid);
499
	__s32 quirks = td->mtclass.quirks;
500

501
	if (hid->claimed & HID_CLAIMED_INPUT) {
502 503
		switch (usage->hid) {
		case HID_DG_INRANGE:
504 505 506
			if (quirks & MT_QUIRK_ALWAYS_VALID)
				td->curvalid = true;
			else if (quirks & MT_QUIRK_VALID_IS_INRANGE)
507
				td->curvalid = value;
508 509
			break;
		case HID_DG_TIPSWITCH:
510 511
			if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
				td->curvalid = value;
512 513 514
			td->curdata.touch_state = value;
			break;
		case HID_DG_CONFIDENCE:
515 516
			if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
				td->curvalid = value;
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
			break;
		case HID_DG_CONTACTID:
			td->curdata.contactid = value;
			break;
		case HID_DG_TIPPRESSURE:
			td->curdata.p = value;
			break;
		case HID_GD_X:
			td->curdata.x = value;
			break;
		case HID_GD_Y:
			td->curdata.y = value;
			break;
		case HID_DG_WIDTH:
			td->curdata.w = value;
			break;
		case HID_DG_HEIGHT:
			td->curdata.h = value;
			break;
		case HID_DG_CONTACTCOUNT:
			/*
538 539
			 * Includes multi-packet support where subsequent
			 * packets are sent with zero contactcount.
540 541
			 */
			if (value)
542
				td->num_expected = value;
543
			break;
544 545 546
		case HID_DG_TOUCH:
			/* do nothing */
			break;
547 548 549 550 551 552

		default:
			/* fallback to the generic hidinput handling */
			return 0;
		}

553
		if (usage->hid == td->last_slot_field)
554
			mt_complete_slot(td, field->hidinput->input);
555 556 557

		if (field->index == td->last_field_index
			&& td->num_received >= td->num_expected)
558
			mt_sync_frame(td, field->hidinput->input);
559

560
	}
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580

	/* we have handled the hidinput part, now remains hiddev */
	if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
		hid->hiddev_hid_event(hid, field, usage, value);

	return 1;
}

static void mt_set_input_mode(struct hid_device *hdev)
{
	struct mt_device *td = hid_get_drvdata(hdev);
	struct hid_report *r;
	struct hid_report_enum *re;

	if (td->inputmode < 0)
		return;

	re = &(hdev->report_enum[HID_FEATURE_REPORT]);
	r = re->report_id_hash[td->inputmode];
	if (r) {
581
		r->field[0]->value[td->inputmode_index] = 0x02;
582 583 584 585
		usbhid_submit_report(hdev, r, USB_DIR_OUT);
	}
}

586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
static void mt_set_maxcontacts(struct hid_device *hdev)
{
	struct mt_device *td = hid_get_drvdata(hdev);
	struct hid_report *r;
	struct hid_report_enum *re;
	int fieldmax, max;

	if (td->maxcontact_report_id < 0)
		return;

	if (!td->mtclass.maxcontacts)
		return;

	re = &hdev->report_enum[HID_FEATURE_REPORT];
	r = re->report_id_hash[td->maxcontact_report_id];
	if (r) {
		max = td->mtclass.maxcontacts;
		fieldmax = r->field[0]->logical_maximum;
		max = min(fieldmax, max);
		if (r->field[0]->value[0] != max) {
			r->field[0]->value[0] = max;
			usbhid_submit_report(hdev, r, USB_DIR_OUT);
		}
	}
}

612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
static void mt_post_parse_default_settings(struct mt_device *td)
{
	__s32 quirks = td->mtclass.quirks;

	/* unknown serial device needs special quirks */
	if (td->touches_by_report == 1) {
		quirks |= MT_QUIRK_ALWAYS_VALID;
		quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP;
		quirks &= ~MT_QUIRK_VALID_IS_INRANGE;
		quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE;
	}

	td->mtclass.quirks = quirks;
}

627 628 629 630 631 632 633 634 635 636
static void mt_post_parse(struct mt_device *td)
{
	struct mt_fields *f = td->fields;

	if (td->touches_by_report > 0) {
		int field_count_per_touch = f->length / td->touches_by_report;
		td->last_slot_field = f->usages[field_count_per_touch - 1];
	}
}

637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)

{
	struct mt_device *td = hid_get_drvdata(hdev);
	struct mt_class *cls = &td->mtclass;
	struct input_dev *input = hi->input;

	/* Only initialize slots for MT input devices */
	if (!test_bit(ABS_MT_POSITION_X, input->absbit))
		return;

	if (!td->maxcontacts)
		td->maxcontacts = MT_DEFAULT_MAXCONTACT;

	mt_post_parse(td);
	if (td->serial_maybe)
		mt_post_parse_default_settings(td);

	if (cls->is_indirect)
		td->mt_flags |= INPUT_MT_POINTER;

658 659 660
	if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
		td->mt_flags |= INPUT_MT_DROP_UNUSED;

661 662 663 664 665
	input_mt_init_slots(input, td->maxcontacts, td->mt_flags);

	td->mt_flags = 0;
}

666 667
static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
668
	int ret, i;
669
	struct mt_device *td;
670 671
	struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */

672 673 674 675 676 677
	if (id) {
		for (i = 0; mt_classes[i].name ; i++) {
			if (id->driver_data == mt_classes[i].name) {
				mtclass = &(mt_classes[i]);
				break;
			}
678 679
		}
	}
680

681 682 683 684
	/* This allows the driver to correctly support devices
	 * that emit events over several HID messages.
	 */
	hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
685

686
	td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
687 688 689 690
	if (!td) {
		dev_err(&hdev->dev, "cannot allocate multitouch data\n");
		return -ENOMEM;
	}
691
	td->mtclass = *mtclass;
692
	td->inputmode = -1;
693
	td->maxcontact_report_id = -1;
694 695
	hid_set_drvdata(hdev, td);

696 697 698 699 700 701 702
	td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL);
	if (!td->fields) {
		dev_err(&hdev->dev, "cannot allocate multitouch fields data\n");
		ret = -ENOMEM;
		goto fail;
	}

703 704 705
	if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID)
		td->serial_maybe = true;

706 707 708 709 710
	ret = hid_parse(hdev);
	if (ret != 0)
		goto fail;

	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
711
	if (ret)
712 713
		goto fail;

714 715
	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);

716
	mt_set_maxcontacts(hdev);
717 718
	mt_set_input_mode(hdev);

719 720 721
	kfree(td->fields);
	td->fields = NULL;

722 723 724
	return 0;

fail:
725
	kfree(td->fields);
726 727 728 729 730 731 732
	kfree(td);
	return ret;
}

#ifdef CONFIG_PM
static int mt_reset_resume(struct hid_device *hdev)
{
733
	mt_set_maxcontacts(hdev);
734 735 736 737 738 739 740 741
	mt_set_input_mode(hdev);
	return 0;
}
#endif

static void mt_remove(struct hid_device *hdev)
{
	struct mt_device *td = hid_get_drvdata(hdev);
742
	sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
743 744 745 746 747 748 749
	hid_hw_stop(hdev);
	kfree(td);
	hid_set_drvdata(hdev, NULL);
}

static const struct hid_device_id mt_devices[] = {

750 751
	/* 3M panels */
	{ .driver_data = MT_CLS_3M,
752
		MT_USB_DEVICE(USB_VENDOR_ID_3M,
753 754
			USB_DEVICE_ID_3M1968) },
	{ .driver_data = MT_CLS_3M,
755
		MT_USB_DEVICE(USB_VENDOR_ID_3M,
756
			USB_DEVICE_ID_3M2256) },
757
	{ .driver_data = MT_CLS_3M,
758
		MT_USB_DEVICE(USB_VENDOR_ID_3M,
759
			USB_DEVICE_ID_3M3266) },
760

761 762
	/* ActionStar panels */
	{ .driver_data = MT_CLS_DEFAULT,
763
		MT_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR,
764 765
			USB_DEVICE_ID_ACTIONSTAR_1011) },

766 767
	/* Atmel panels */
	{ .driver_data = MT_CLS_SERIAL,
768
		MT_USB_DEVICE(USB_VENDOR_ID_ATMEL,
769
			USB_DEVICE_ID_ATMEL_MULTITOUCH) },
770
	{ .driver_data = MT_CLS_SERIAL,
771
		MT_USB_DEVICE(USB_VENDOR_ID_ATMEL,
772
			USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) },
773

774 775
	/* Baanto multitouch devices */
	{ .driver_data = MT_CLS_DEFAULT,
776
		MT_USB_DEVICE(USB_VENDOR_ID_BAANTO,
777
			USB_DEVICE_ID_BAANTO_MT_190W2) },
778 779
	/* Cando panels */
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
780
		MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
781 782
			USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
783
		MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
784 785
			USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
786
		MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
787 788
			USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
789
		MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
790 791
			USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },

792 793
	/* Chunghwa Telecom touch panels */
	{  .driver_data = MT_CLS_DEFAULT,
794
		MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT,
795 796
			USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },

797 798
	/* CVTouch panels */
	{ .driver_data = MT_CLS_DEFAULT,
799
		MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
800 801
			USB_DEVICE_ID_CVTOUCH_SCREEN) },

802 803 804 805 806
	/* Cypress panel */
	{ .driver_data = MT_CLS_CYPRESS,
		HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
			USB_DEVICE_ID_CYPRESS_TRUETOUCH) },

807
	/* eGalax devices (resistive) */
808
	{ .driver_data = MT_CLS_EGALAX,
809
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
810 811
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
	{ .driver_data = MT_CLS_EGALAX,
812
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
813
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
814 815

	/* eGalax devices (capacitive) */
816
	{ .driver_data = MT_CLS_EGALAX,
817
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
818
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
819
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
820
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
821 822
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) },
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
823
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
824 825
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) },
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
826
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
827
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) },
828
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
829
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
830
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) },
831
	{ .driver_data = MT_CLS_EGALAX,
832
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
833
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
834
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
835
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
836
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) },
837
	{ .driver_data = MT_CLS_EGALAX,
838
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
839
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
840
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
841
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
842
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) },
843
	{ .driver_data = MT_CLS_EGALAX,
844
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
845
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) },
846
	{ .driver_data = MT_CLS_EGALAX,
847
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
848
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
849
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
850
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
851
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) },
852
	{ .driver_data = MT_CLS_EGALAX_SERIAL,
853
		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
854
			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
855

856 857
	/* Elo TouchSystems IntelliTouch Plus panel */
	{ .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
858
		MT_USB_DEVICE(USB_VENDOR_ID_ELO,
859 860
			USB_DEVICE_ID_ELO_TS2515) },

861
	/* GeneralTouch panel */
862
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
863
		MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
864 865
			USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },

866 867
	/* Gametel game controller */
	{ .driver_data = MT_CLS_DEFAULT,
868
		MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL,
869 870
			USB_DEVICE_ID_GAMETEL_MT_MODE) },

871 872
	/* GoodTouch panels */
	{ .driver_data = MT_CLS_DEFAULT,
873
		MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH,
874 875
			USB_DEVICE_ID_GOODTOUCH_000f) },

876 877
	/* Hanvon panels */
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
878
		MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT,
879 880
			USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },

881 882
	/* Ideacom panel */
	{ .driver_data = MT_CLS_SERIAL,
883
		MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
884
			USB_DEVICE_ID_IDEACOM_IDC6650) },
885
	{ .driver_data = MT_CLS_SERIAL,
886
		MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
887
			USB_DEVICE_ID_IDEACOM_IDC6651) },
888

889 890
	/* Ilitek dual touch panel */
	{  .driver_data = MT_CLS_DEFAULT,
891
		MT_USB_DEVICE(USB_VENDOR_ID_ILITEK,
892 893
			USB_DEVICE_ID_ILITEK_MULTITOUCH) },

894 895
	/* IRTOUCH panels */
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
896
		MT_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
897 898
			USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },

899 900
	/* LG Display panels */
	{ .driver_data = MT_CLS_DEFAULT,
901
		MT_USB_DEVICE(USB_VENDOR_ID_LG,
902 903
			USB_DEVICE_ID_LG_MULTITOUCH) },

904 905
	/* Lumio panels */
	{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
906
		MT_USB_DEVICE(USB_VENDOR_ID_LUMIO,
907
			USB_DEVICE_ID_CRYSTALTOUCH) },
908
	{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
909
		MT_USB_DEVICE(USB_VENDOR_ID_LUMIO,
910
			USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
911

912 913
	/* MosArt panels */
	{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
914
		MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
915 916
			USB_DEVICE_ID_ASUS_T91MT)},
	{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
917
		MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
918 919
			USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
	{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
920
		MT_USB_DEVICE(USB_VENDOR_ID_TURBOX,
921 922
			USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },

923 924
	/* Panasonic panels */
	{ .driver_data = MT_CLS_PANASONIC,
925
		MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC,
926 927
			USB_DEVICE_ID_PANABOARD_UBT780) },
	{ .driver_data = MT_CLS_PANASONIC,
928
		MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC,
929 930
			USB_DEVICE_ID_PANABOARD_UBT880) },

931 932
	/* Novatek Panel */
	{ .driver_data = MT_CLS_DEFAULT,
933
		MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK,
934 935
			USB_DEVICE_ID_NOVATEK_PCT) },

936 937
	/* PenMount panels */
	{ .driver_data = MT_CLS_CONFIDENCE,
938
		MT_USB_DEVICE(USB_VENDOR_ID_PENMOUNT,
939 940
			USB_DEVICE_ID_PENMOUNT_PCI) },

941 942
	/* PixArt optical touch screen */
	{ .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
943
		MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
944 945
			USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) },
	{ .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
946
		MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
947 948
			USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) },
	{ .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
949
		MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
950 951
			USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) },

952
	/* PixCir-based panels */
953
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
954
		MT_USB_DEVICE(USB_VENDOR_ID_HANVON,
955
			USB_DEVICE_ID_HANVON_MULTITOUCH) },
956
	{ .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
957
		MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
958 959
			USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },

960 961
	/* Quanta-based panels */
	{ .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
962
		MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
963 964
			USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
	{ .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
965
		MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
966 967
			USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) },
	{ .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
968
		MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
969 970
			USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) },

971
	/* Stantum panels */
972
	{ .driver_data = MT_CLS_CONFIDENCE,
973
		MT_USB_DEVICE(USB_VENDOR_ID_STANTUM,
974
			USB_DEVICE_ID_MTP)},
975
	{ .driver_data = MT_CLS_CONFIDENCE,
976
		MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
977
			USB_DEVICE_ID_MTP_STM)},
978
	{ .driver_data = MT_CLS_CONFIDENCE,
979
		MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX,
980 981
			USB_DEVICE_ID_MTP_SITRONIX)},

982 983
	/* TopSeed panels */
	{ .driver_data = MT_CLS_TOPSEED,
984
		MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
985 986
			USB_DEVICE_ID_TOPSEED2_PERIPAD_701) },

987 988
	/* Touch International panels */
	{ .driver_data = MT_CLS_DEFAULT,
989
		MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL,
990 991
			USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },

992 993
	/* Unitec panels */
	{ .driver_data = MT_CLS_DEFAULT,
994
		MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
995 996
			USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
	{ .driver_data = MT_CLS_DEFAULT,
997
		MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
998
			USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
999 1000
	/* XAT */
	{ .driver_data = MT_CLS_DEFAULT,
1001
		MT_USB_DEVICE(USB_VENDOR_ID_XAT,
1002
			USB_DEVICE_ID_XAT_CSR) },
1003

1004 1005
	/* Xiroku */
	{ .driver_data = MT_CLS_DEFAULT,
1006
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1007 1008
			USB_DEVICE_ID_XIROKU_SPX) },
	{ .driver_data = MT_CLS_DEFAULT,
1009
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1010 1011
			USB_DEVICE_ID_XIROKU_MPX) },
	{ .driver_data = MT_CLS_DEFAULT,
1012
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1013 1014
			USB_DEVICE_ID_XIROKU_CSR) },
	{ .driver_data = MT_CLS_DEFAULT,
1015
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1016 1017
			USB_DEVICE_ID_XIROKU_SPX1) },
	{ .driver_data = MT_CLS_DEFAULT,
1018
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1019 1020
			USB_DEVICE_ID_XIROKU_MPX1) },
	{ .driver_data = MT_CLS_DEFAULT,
1021
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1022 1023
			USB_DEVICE_ID_XIROKU_CSR1) },
	{ .driver_data = MT_CLS_DEFAULT,
1024
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1025 1026
			USB_DEVICE_ID_XIROKU_SPX2) },
	{ .driver_data = MT_CLS_DEFAULT,
1027
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1028 1029
			USB_DEVICE_ID_XIROKU_MPX2) },
	{ .driver_data = MT_CLS_DEFAULT,
1030
		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1031 1032
			USB_DEVICE_ID_XIROKU_CSR2) },

1033 1034 1035 1036 1037
	/* Zytronic panels */
	{ .driver_data = MT_CLS_SERIAL,
		MT_USB_DEVICE(USB_VENDOR_ID_ZYTRONIC,
			USB_DEVICE_ID_ZYTRONIC_ZXY100) },

1038 1039
	/* Generic MT device */
	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) },
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
	{ }
};
MODULE_DEVICE_TABLE(hid, mt_devices);

static const struct hid_usage_id mt_grabbed_usages[] = {
	{ HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
	{ HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
};

static struct hid_driver mt_driver = {
	.name = "hid-multitouch",
	.id_table = mt_devices,
	.probe = mt_probe,
	.remove = mt_remove,
	.input_mapping = mt_input_mapping,
	.input_mapped = mt_input_mapped,
1056
	.input_configured = mt_input_configured,
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
	.feature_mapping = mt_feature_mapping,
	.usage_table = mt_grabbed_usages,
	.event = mt_event,
#ifdef CONFIG_PM
	.reset_resume = mt_reset_resume,
#endif
};

static int __init mt_init(void)
{
	return hid_register_driver(&mt_driver);
}

static void __exit mt_exit(void)
{
	hid_unregister_driver(&mt_driver);
}

module_init(mt_init);
module_exit(mt_exit);