1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * HID driver for multitouch panels 4 * 5 * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> 6 * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> 7 * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France 8 * Copyright (c) 2012-2013 Red Hat, Inc 9 * 10 * This code is partly based on hid-egalax.c: 11 * 12 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> 13 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> 14 * Copyright (c) 2010 Canonical, Ltd. 15 * 16 * This code is partly based on hid-3m-pct.c: 17 * 18 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr> 19 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> 20 * Copyright (c) 2010 Canonical, Ltd. 21 */ 22 23 /* 24 */ 25 26 /* 27 * This driver is regularly tested thanks to the test suite in hid-tools[1]. 28 * Please run these regression tests before patching this module so that 29 * your patch won't break existing known devices. 30 * 31 * [1] https://gitlab.freedesktop.org/libevdev/hid-tools 32 */ 33 34 #include <linux/bitmap.h> 35 #include <linux/bits.h> 36 #include <linux/device.h> 37 #include <linux/hid.h> 38 #include <linux/module.h> 39 #include <linux/slab.h> 40 #include <linux/input/mt.h> 41 #include <linux/jiffies.h> 42 #include <linux/string.h> 43 #include <linux/timer.h> 44 45 46 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); 47 MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); 48 MODULE_DESCRIPTION("HID multitouch panels"); 49 MODULE_LICENSE("GPL"); 50 51 #include "hid-ids.h" 52 53 #include "hid-haptic.h" 54 55 /* quirks to control the device */ 56 #define MT_QUIRK_NOT_SEEN_MEANS_UP BIT(0) 57 #define MT_QUIRK_SLOT_IS_CONTACTID BIT(1) 58 #define MT_QUIRK_CYPRESS BIT(2) 59 #define MT_QUIRK_SLOT_IS_CONTACTNUMBER BIT(3) 60 #define MT_QUIRK_ALWAYS_VALID BIT(4) 61 #define MT_QUIRK_VALID_IS_INRANGE BIT(5) 62 #define MT_QUIRK_VALID_IS_CONFIDENCE BIT(6) 63 #define MT_QUIRK_CONFIDENCE BIT(7) 64 #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE BIT(8) 65 #define MT_QUIRK_NO_AREA BIT(9) 66 #define MT_QUIRK_IGNORE_DUPLICATES BIT(10) 67 #define MT_QUIRK_HOVERING BIT(11) 68 #define MT_QUIRK_CONTACT_CNT_ACCURATE BIT(12) 69 #define MT_QUIRK_FORCE_GET_FEATURE BIT(13) 70 #define MT_QUIRK_FIX_CONST_CONTACT_ID BIT(14) 71 #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) 72 #define MT_QUIRK_STICKY_FINGERS BIT(16) 73 #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) 74 #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) 75 #define MT_QUIRK_SEPARATE_APP_REPORT BIT(19) 76 #define MT_QUIRK_FORCE_MULTI_INPUT BIT(20) 77 #define MT_QUIRK_DISABLE_WAKEUP BIT(21) 78 #define MT_QUIRK_ORIENTATION_INVERT BIT(22) 79 #define MT_QUIRK_APPLE_TOUCHBAR BIT(23) 80 #define MT_QUIRK_YOGABOOK9I BIT(24) 81 #define MT_QUIRK_KEEP_LATENCY_ON_CLOSE BIT(25) 82 #define MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH BIT(26) 83 84 #define MT_INPUTMODE_TOUCHSCREEN 0x02 85 #define MT_INPUTMODE_TOUCHPAD 0x03 86 87 #define MT_BUTTONTYPE_CLICKPAD 0 88 #define MT_BUTTONTYPE_PRESSUREPAD 1 89 90 enum latency_mode { 91 HID_LATENCY_NORMAL = 0, 92 HID_LATENCY_HIGH = 1, 93 }; 94 95 enum report_mode { 96 TOUCHPAD_REPORT_NONE = 0, 97 TOUCHPAD_REPORT_BUTTONS = BIT(0), 98 TOUCHPAD_REPORT_CONTACTS = BIT(1), 99 TOUCHPAD_REPORT_ALL = TOUCHPAD_REPORT_BUTTONS | TOUCHPAD_REPORT_CONTACTS, 100 }; 101 102 #define MT_IO_FLAGS_RUNNING 0 103 104 static const bool mtrue = true; /* default for true */ 105 static const bool mfalse; /* default for false */ 106 static const __s32 mzero; /* default for 0 */ 107 108 #define DEFAULT_TRUE ((void *)&mtrue) 109 #define DEFAULT_FALSE ((void *)&mfalse) 110 #define DEFAULT_ZERO ((void *)&mzero) 111 112 struct mt_usages { 113 struct list_head list; 114 __s32 *x, *y, *cx, *cy, *p, *w, *h, *a; 115 __s32 *contactid; /* the device ContactID assigned to this slot */ 116 bool *tip_state; /* is the touch valid? */ 117 bool *inrange_state; /* is the finger in proximity of the sensor? */ 118 bool *confidence_state; /* is the touch made by a finger? */ 119 }; 120 121 struct mt_application { 122 struct list_head list; 123 unsigned int application; 124 unsigned int report_id; 125 struct list_head mt_usages; /* mt usages list */ 126 127 __s32 quirks; 128 129 __s32 *scantime; /* scantime reported */ 130 __s32 scantime_logical_max; /* max value for raw scantime */ 131 132 __s32 *raw_cc; /* contact count in the report */ 133 int left_button_state; /* left button state */ 134 unsigned int mt_flags; /* flags to pass to input-mt */ 135 136 unsigned long *pending_palm_slots; /* slots where we reported palm 137 * and need to release */ 138 139 __u8 num_received; /* how many contacts we received */ 140 __u8 num_expected; /* expected last contact index */ 141 __u8 buttons_count; /* number of physical buttons per touchpad */ 142 __u8 touches_by_report; /* how many touches are present in one report: 143 * 1 means we should use a serial protocol 144 * > 1 means hybrid (multitouch) protocol 145 */ 146 147 unsigned long jiffies; /* the frame's jiffies */ 148 int timestamp; /* the timestamp to be sent */ 149 int prev_scantime; /* scantime reported previously */ 150 151 bool have_contact_count; 152 }; 153 154 struct mt_class { 155 __s32 name; /* MT_CLS */ 156 __s32 quirks; 157 __s32 sn_move; /* Signal/noise ratio for move events */ 158 __s32 sn_width; /* Signal/noise ratio for width events */ 159 __s32 sn_height; /* Signal/noise ratio for height events */ 160 __s32 sn_pressure; /* Signal/noise ratio for pressure events */ 161 __u8 maxcontacts; 162 bool is_indirect; /* true for touchpads */ 163 bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ 164 }; 165 166 struct mt_report_data { 167 struct list_head list; 168 struct hid_report *report; 169 struct mt_application *application; 170 bool is_mt_collection; 171 }; 172 173 struct mt_device { 174 struct mt_class mtclass; /* our mt device class */ 175 struct timer_list release_timer; /* to release sticky fingers */ 176 struct hid_haptic_device *haptic; /* haptic related configuration */ 177 struct hid_device *hdev; /* hid_device we're attached to */ 178 unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_RUNNING) */ 179 unsigned long *active_slots; /* bitmap of slots with an active 180 * contact, sized for maxcontacts 181 */ 182 __u8 inputmode_value; /* InputMode HID feature value */ 183 __u8 maxcontacts; 184 bool is_buttonpad; /* is this device a button pad? */ 185 bool is_pressurepad; /* is this device a pressurepad? */ 186 bool is_haptic_touchpad; /* is this device a haptic touchpad? */ 187 bool serial_maybe; /* need to check for serial protocol */ 188 189 struct list_head applications; 190 struct list_head reports; 191 }; 192 193 static void mt_post_parse_default_settings(struct mt_device *td, 194 struct mt_application *app); 195 static void mt_post_parse(struct mt_device *td, struct mt_application *app); 196 197 /* classes of device behavior */ 198 #define MT_CLS_DEFAULT 0x0001 199 200 #define MT_CLS_SERIAL 0x0002 201 #define MT_CLS_CONFIDENCE 0x0003 202 #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 203 #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 204 #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 205 #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 206 /* reserved 0x0008 */ 207 #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 208 #define MT_CLS_NSMU 0x000a 209 /* reserved 0x0010 */ 210 /* reserved 0x0011 */ 211 #define MT_CLS_WIN_8 0x0012 212 #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 213 /* reserved 0x0014 */ 214 #define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015 215 #define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016 216 #define MT_CLS_WIN_8_NO_STICKY_FINGERS 0x0017 217 #define MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU 0x0018 218 #define MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE 0x0019 219 220 /* vendor specific classes */ 221 #define MT_CLS_3M 0x0101 222 /* reserved 0x0102 */ 223 #define MT_CLS_EGALAX 0x0103 224 #define MT_CLS_EGALAX_SERIAL 0x0104 225 #define MT_CLS_TOPSEED 0x0105 226 #define MT_CLS_PANASONIC 0x0106 227 #define MT_CLS_FLATFROG 0x0107 228 #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 229 #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 230 #define MT_CLS_LG 0x010a 231 #define MT_CLS_ASUS 0x010b 232 #define MT_CLS_VTL 0x0110 233 #define MT_CLS_GOOGLE 0x0111 234 #define MT_CLS_RAZER_BLADE_STEALTH 0x0112 235 #define MT_CLS_SMART_TECH 0x0113 236 #define MT_CLS_APPLE_TOUCHBAR 0x0114 237 #define MT_CLS_YOGABOOK9I 0x0115 238 #define MT_CLS_EGALAX_P80H84 0x0116 239 #define MT_CLS_ASUS_ROG_Z13_FOLIO 0x0117 240 #define MT_CLS_SIS 0x0457 241 242 #define MT_DEFAULT_MAXCONTACT 10 243 #define MT_MAX_MAXCONTACT 250 244 245 /* 246 * Resync device and local timestamps after that many microseconds without 247 * receiving data. 248 */ 249 #define MAX_TIMESTAMP_INTERVAL 1000000 250 251 #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) 252 #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) 253 254 /* 255 * these device-dependent functions determine what slot corresponds 256 * to a valid contact that was just read. 257 */ 258 259 static int cypress_compute_slot(struct mt_application *application, 260 struct mt_usages *slot) 261 { 262 if (*slot->contactid != 0 || application->num_received == 0) 263 return *slot->contactid; 264 else 265 return -1; 266 } 267 268 static const struct mt_class mt_classes[] = { 269 { .name = MT_CLS_DEFAULT, 270 .quirks = MT_QUIRK_ALWAYS_VALID | 271 MT_QUIRK_CONTACT_CNT_ACCURATE }, 272 { .name = MT_CLS_NSMU, 273 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, 274 { .name = MT_CLS_SERIAL, 275 .quirks = MT_QUIRK_ALWAYS_VALID}, 276 { .name = MT_CLS_CONFIDENCE, 277 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, 278 { .name = MT_CLS_CONFIDENCE_CONTACT_ID, 279 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | 280 MT_QUIRK_SLOT_IS_CONTACTID }, 281 { .name = MT_CLS_CONFIDENCE_MINUS_ONE, 282 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | 283 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, 284 { .name = MT_CLS_DUAL_INRANGE_CONTACTID, 285 .quirks = MT_QUIRK_VALID_IS_INRANGE | 286 MT_QUIRK_SLOT_IS_CONTACTID, 287 .maxcontacts = 2 }, 288 { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, 289 .quirks = MT_QUIRK_VALID_IS_INRANGE | 290 MT_QUIRK_SLOT_IS_CONTACTNUMBER, 291 .maxcontacts = 2 }, 292 { .name = MT_CLS_INRANGE_CONTACTNUMBER, 293 .quirks = MT_QUIRK_VALID_IS_INRANGE | 294 MT_QUIRK_SLOT_IS_CONTACTNUMBER }, 295 { .name = MT_CLS_WIN_8, 296 .quirks = MT_QUIRK_ALWAYS_VALID | 297 MT_QUIRK_IGNORE_DUPLICATES | 298 MT_QUIRK_HOVERING | 299 MT_QUIRK_CONTACT_CNT_ACCURATE | 300 MT_QUIRK_STICKY_FINGERS | 301 MT_QUIRK_WIN8_PTP_BUTTONS, 302 .export_all_inputs = true }, 303 { .name = MT_CLS_EXPORT_ALL_INPUTS, 304 .quirks = MT_QUIRK_ALWAYS_VALID | 305 MT_QUIRK_CONTACT_CNT_ACCURATE, 306 .export_all_inputs = true }, 307 { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 308 .quirks = MT_QUIRK_ALWAYS_VALID | 309 MT_QUIRK_IGNORE_DUPLICATES | 310 MT_QUIRK_HOVERING | 311 MT_QUIRK_CONTACT_CNT_ACCURATE | 312 MT_QUIRK_STICKY_FINGERS | 313 MT_QUIRK_WIN8_PTP_BUTTONS | 314 MT_QUIRK_FORCE_MULTI_INPUT, 315 .export_all_inputs = true }, 316 { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 317 .quirks = MT_QUIRK_IGNORE_DUPLICATES | 318 MT_QUIRK_HOVERING | 319 MT_QUIRK_CONTACT_CNT_ACCURATE | 320 MT_QUIRK_STICKY_FINGERS | 321 MT_QUIRK_WIN8_PTP_BUTTONS | 322 MT_QUIRK_FORCE_MULTI_INPUT | 323 MT_QUIRK_NOT_SEEN_MEANS_UP, 324 .export_all_inputs = true }, 325 { .name = MT_CLS_WIN_8_DISABLE_WAKEUP, 326 .quirks = MT_QUIRK_ALWAYS_VALID | 327 MT_QUIRK_IGNORE_DUPLICATES | 328 MT_QUIRK_HOVERING | 329 MT_QUIRK_CONTACT_CNT_ACCURATE | 330 MT_QUIRK_STICKY_FINGERS | 331 MT_QUIRK_WIN8_PTP_BUTTONS | 332 MT_QUIRK_DISABLE_WAKEUP, 333 .export_all_inputs = true }, 334 { .name = MT_CLS_WIN_8_NO_STICKY_FINGERS, 335 .quirks = MT_QUIRK_ALWAYS_VALID | 336 MT_QUIRK_IGNORE_DUPLICATES | 337 MT_QUIRK_HOVERING | 338 MT_QUIRK_CONTACT_CNT_ACCURATE | 339 MT_QUIRK_WIN8_PTP_BUTTONS, 340 .export_all_inputs = true }, 341 { .name = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE, 342 .quirks = MT_QUIRK_ALWAYS_VALID | 343 MT_QUIRK_IGNORE_DUPLICATES | 344 MT_QUIRK_HOVERING | 345 MT_QUIRK_CONTACT_CNT_ACCURATE | 346 MT_QUIRK_STICKY_FINGERS | 347 MT_QUIRK_WIN8_PTP_BUTTONS | 348 MT_QUIRK_KEEP_LATENCY_ON_CLOSE, 349 .export_all_inputs = true }, 350 351 /* 352 * vendor specific classes 353 */ 354 { .name = MT_CLS_3M, 355 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | 356 MT_QUIRK_SLOT_IS_CONTACTID | 357 MT_QUIRK_TOUCH_SIZE_SCALING, 358 .sn_move = 2048, 359 .sn_width = 128, 360 .sn_height = 128, 361 .maxcontacts = 60, 362 }, 363 { .name = MT_CLS_EGALAX, 364 .quirks = MT_QUIRK_SLOT_IS_CONTACTID | 365 MT_QUIRK_VALID_IS_INRANGE, 366 .sn_move = 4096, 367 .sn_pressure = 32, 368 }, 369 { .name = MT_CLS_EGALAX_SERIAL, 370 .quirks = MT_QUIRK_SLOT_IS_CONTACTID | 371 MT_QUIRK_ALWAYS_VALID, 372 .sn_move = 4096, 373 .sn_pressure = 32, 374 }, 375 { .name = MT_CLS_TOPSEED, 376 .quirks = MT_QUIRK_ALWAYS_VALID, 377 .is_indirect = true, 378 .maxcontacts = 2, 379 }, 380 { .name = MT_CLS_PANASONIC, 381 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, 382 .maxcontacts = 4 }, 383 { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, 384 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 385 MT_QUIRK_VALID_IS_INRANGE | 386 MT_QUIRK_SLOT_IS_CONTACTID, 387 .maxcontacts = 2 388 }, 389 { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 390 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 391 MT_QUIRK_SLOT_IS_CONTACTID 392 }, 393 394 { .name = MT_CLS_FLATFROG, 395 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 396 MT_QUIRK_NO_AREA, 397 .sn_move = 2048, 398 .maxcontacts = 40, 399 }, 400 { .name = MT_CLS_LG, 401 .quirks = MT_QUIRK_ALWAYS_VALID | 402 MT_QUIRK_FIX_CONST_CONTACT_ID | 403 MT_QUIRK_IGNORE_DUPLICATES | 404 MT_QUIRK_HOVERING | 405 MT_QUIRK_CONTACT_CNT_ACCURATE }, 406 { .name = MT_CLS_ASUS, 407 .quirks = MT_QUIRK_ALWAYS_VALID | 408 MT_QUIRK_CONTACT_CNT_ACCURATE | 409 MT_QUIRK_ASUS_CUSTOM_UP }, 410 { .name = MT_CLS_ASUS_ROG_Z13_FOLIO, 411 .quirks = MT_QUIRK_ALWAYS_VALID | 412 MT_QUIRK_IGNORE_DUPLICATES | 413 MT_QUIRK_HOVERING | 414 MT_QUIRK_CONTACT_CNT_ACCURATE | 415 MT_QUIRK_STICKY_FINGERS | 416 MT_QUIRK_WIN8_PTP_BUTTONS | 417 MT_QUIRK_CONFIDENCE | 418 MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH, 419 .export_all_inputs = true }, 420 { .name = MT_CLS_VTL, 421 .quirks = MT_QUIRK_ALWAYS_VALID | 422 MT_QUIRK_CONTACT_CNT_ACCURATE | 423 MT_QUIRK_STICKY_FINGERS | 424 MT_QUIRK_FORCE_GET_FEATURE, 425 }, 426 { .name = MT_CLS_GOOGLE, 427 .quirks = MT_QUIRK_ALWAYS_VALID | 428 MT_QUIRK_CONTACT_CNT_ACCURATE | 429 MT_QUIRK_SLOT_IS_CONTACTID | 430 MT_QUIRK_HOVERING 431 }, 432 { .name = MT_CLS_RAZER_BLADE_STEALTH, 433 .quirks = MT_QUIRK_ALWAYS_VALID | 434 MT_QUIRK_IGNORE_DUPLICATES | 435 MT_QUIRK_HOVERING | 436 MT_QUIRK_CONTACT_CNT_ACCURATE | 437 MT_QUIRK_WIN8_PTP_BUTTONS, 438 }, 439 { .name = MT_CLS_SMART_TECH, 440 .quirks = MT_QUIRK_ALWAYS_VALID | 441 MT_QUIRK_IGNORE_DUPLICATES | 442 MT_QUIRK_CONTACT_CNT_ACCURATE | 443 MT_QUIRK_SEPARATE_APP_REPORT, 444 }, 445 { .name = MT_CLS_APPLE_TOUCHBAR, 446 .quirks = MT_QUIRK_HOVERING | 447 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE | 448 MT_QUIRK_APPLE_TOUCHBAR, 449 .maxcontacts = 11, 450 }, 451 { .name = MT_CLS_SIS, 452 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 453 MT_QUIRK_ALWAYS_VALID | 454 MT_QUIRK_CONTACT_CNT_ACCURATE, 455 }, 456 { .name = MT_CLS_YOGABOOK9I, 457 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 458 MT_QUIRK_ALWAYS_VALID | 459 MT_QUIRK_CONTACT_CNT_ACCURATE | 460 MT_QUIRK_FORCE_MULTI_INPUT | 461 MT_QUIRK_SEPARATE_APP_REPORT | 462 MT_QUIRK_HOVERING | 463 MT_QUIRK_YOGABOOK9I, 464 .maxcontacts = 10, 465 .export_all_inputs = true 466 }, 467 { .name = MT_CLS_EGALAX_P80H84, 468 .quirks = MT_QUIRK_ALWAYS_VALID | 469 MT_QUIRK_IGNORE_DUPLICATES | 470 MT_QUIRK_CONTACT_CNT_ACCURATE, 471 }, 472 { } 473 }; 474 475 static ssize_t mt_show_quirks(struct device *dev, 476 struct device_attribute *attr, 477 char *buf) 478 { 479 struct hid_device *hdev = to_hid_device(dev); 480 struct mt_device *td = hid_get_drvdata(hdev); 481 482 return sprintf(buf, "%u\n", td->mtclass.quirks); 483 } 484 485 static ssize_t mt_set_quirks(struct device *dev, 486 struct device_attribute *attr, 487 const char *buf, size_t count) 488 { 489 struct hid_device *hdev = to_hid_device(dev); 490 struct mt_device *td = hid_get_drvdata(hdev); 491 struct mt_application *application; 492 493 unsigned long val; 494 495 if (kstrtoul(buf, 0, &val)) 496 return -EINVAL; 497 498 td->mtclass.quirks = val; 499 500 list_for_each_entry(application, &td->applications, list) { 501 application->quirks = val; 502 if (!application->have_contact_count) 503 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; 504 } 505 506 return count; 507 } 508 509 static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); 510 511 static struct attribute *sysfs_attrs[] = { 512 &dev_attr_quirks.attr, 513 NULL 514 }; 515 516 static const struct attribute_group mt_attribute_group = { 517 .attrs = sysfs_attrs 518 }; 519 520 static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) 521 { 522 struct mt_device *td = hid_get_drvdata(hdev); 523 int ret; 524 u32 size = hid_report_len(report); 525 u8 *buf; 526 527 /* 528 * Do not fetch the feature report if the device has been explicitly 529 * marked as non-capable. 530 */ 531 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) 532 return; 533 534 buf = hid_alloc_report_buf(report, GFP_KERNEL); 535 if (!buf) 536 return; 537 538 ret = hid_hw_raw_request(hdev, report->id, buf, size, 539 HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 540 if (ret < 0) { 541 dev_warn(&hdev->dev, "failed to fetch feature %d\n", 542 report->id); 543 } else { 544 /* 545 * The report ID in the request and the response should match. 546 * Some firmware (e.g. the ASUS ROG Z13 Folio 547 * touchpad) returns a mismatched ID on this specific fetch; 548 * tolerate it only for devices explicitly flagged as such. 549 */ 550 if (report->id != buf[0] && 551 !(td->mtclass.quirks & MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH)) { 552 hid_err(hdev, "Returned feature report did not match the request\n"); 553 goto free; 554 } 555 556 ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf, 557 size, size, 0); 558 if (ret) 559 dev_warn(&hdev->dev, "failed to report feature\n"); 560 } 561 562 free: 563 kfree(buf); 564 } 565 566 static void mt_feature_mapping(struct hid_device *hdev, 567 struct hid_field *field, struct hid_usage *usage) 568 { 569 struct mt_device *td = hid_get_drvdata(hdev); 570 571 switch (usage->hid) { 572 case HID_DG_CONTACTMAX: 573 mt_get_feature(hdev, field->report); 574 575 td->maxcontacts = field->value[0]; 576 if (!td->maxcontacts && 577 field->logical_maximum <= MT_MAX_MAXCONTACT) 578 td->maxcontacts = field->logical_maximum; 579 if (td->mtclass.maxcontacts) 580 /* check if the maxcontacts is given by the class */ 581 td->maxcontacts = td->mtclass.maxcontacts; 582 583 break; 584 case HID_DG_BUTTONTYPE: 585 if (usage->usage_index >= field->report_count) { 586 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); 587 break; 588 } 589 590 mt_get_feature(hdev, field->report); 591 switch (field->value[usage->usage_index]) { 592 case MT_BUTTONTYPE_CLICKPAD: 593 td->is_buttonpad = true; 594 break; 595 case MT_BUTTONTYPE_PRESSUREPAD: 596 td->is_pressurepad = true; 597 break; 598 } 599 600 break; 601 case 0xff0000c5: 602 /* Retrieve the Win8 blob once to enable some devices */ 603 if (usage->usage_index == 0) 604 mt_get_feature(hdev, field->report); 605 break; 606 } 607 608 hid_haptic_feature_mapping(hdev, td->haptic, field, usage); 609 } 610 611 static void set_abs(struct input_dev *input, unsigned int code, 612 struct hid_field *field, int snratio) 613 { 614 int fmin = field->logical_minimum; 615 int fmax = field->logical_maximum; 616 int fuzz = snratio ? (fmax - fmin) / snratio : 0; 617 input_set_abs_params(input, code, fmin, fmax, fuzz, 0); 618 input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); 619 } 620 621 static struct mt_usages *mt_allocate_usage(struct hid_device *hdev, 622 struct mt_application *application) 623 { 624 struct mt_usages *usage; 625 626 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); 627 if (!usage) 628 return NULL; 629 630 /* set some defaults so we do not need to check for null pointers */ 631 usage->x = DEFAULT_ZERO; 632 usage->y = DEFAULT_ZERO; 633 usage->cx = DEFAULT_ZERO; 634 usage->cy = DEFAULT_ZERO; 635 usage->p = DEFAULT_ZERO; 636 usage->w = DEFAULT_ZERO; 637 usage->h = DEFAULT_ZERO; 638 usage->a = DEFAULT_ZERO; 639 usage->contactid = DEFAULT_ZERO; 640 usage->tip_state = DEFAULT_FALSE; 641 usage->inrange_state = DEFAULT_FALSE; 642 usage->confidence_state = DEFAULT_TRUE; 643 644 list_add_tail(&usage->list, &application->mt_usages); 645 646 return usage; 647 } 648 649 static struct mt_application *mt_allocate_application(struct mt_device *td, 650 struct hid_report *report) 651 { 652 unsigned int application = report->application; 653 struct mt_application *mt_application; 654 655 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), 656 GFP_KERNEL); 657 if (!mt_application) 658 return NULL; 659 660 mt_application->application = application; 661 INIT_LIST_HEAD(&mt_application->mt_usages); 662 663 if (application == HID_DG_TOUCHSCREEN) 664 mt_application->mt_flags |= INPUT_MT_DIRECT; 665 666 /* 667 * Model touchscreens providing buttons as touchpads. 668 */ 669 if (application == HID_DG_TOUCHPAD) { 670 mt_application->mt_flags |= INPUT_MT_POINTER; 671 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; 672 } 673 674 mt_application->scantime = DEFAULT_ZERO; 675 mt_application->raw_cc = DEFAULT_ZERO; 676 mt_application->quirks = td->mtclass.quirks; 677 mt_application->report_id = report->id; 678 679 list_add_tail(&mt_application->list, &td->applications); 680 681 return mt_application; 682 } 683 684 static struct mt_application *mt_find_application(struct mt_device *td, 685 struct hid_report *report) 686 { 687 unsigned int application = report->application; 688 struct mt_application *tmp, *mt_application = NULL; 689 690 list_for_each_entry(tmp, &td->applications, list) { 691 if (application == tmp->application) { 692 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || 693 tmp->report_id == report->id) { 694 mt_application = tmp; 695 break; 696 } 697 } 698 } 699 700 if (!mt_application) 701 mt_application = mt_allocate_application(td, report); 702 703 return mt_application; 704 } 705 706 static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, 707 struct hid_report *report) 708 { 709 struct mt_class *cls = &td->mtclass; 710 struct mt_report_data *rdata; 711 struct hid_field *field; 712 int r, n; 713 714 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); 715 if (!rdata) 716 return NULL; 717 718 rdata->report = report; 719 rdata->application = mt_find_application(td, report); 720 721 if (!rdata->application) { 722 devm_kfree(&td->hdev->dev, rdata); 723 return NULL; 724 } 725 726 for (r = 0; r < report->maxfield; r++) { 727 field = report->field[r]; 728 729 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) 730 continue; 731 732 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { 733 for (n = 0; n < field->report_count; n++) { 734 unsigned int hid = field->usage[n].hid; 735 736 if (hid == HID_DG_CONTACTID || 737 (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR && 738 hid == HID_DG_TRANSDUCER_INDEX)) { 739 rdata->is_mt_collection = true; 740 break; 741 } 742 } 743 } 744 } 745 746 list_add_tail(&rdata->list, &td->reports); 747 748 return rdata; 749 } 750 751 static struct mt_report_data *mt_find_report_data(struct mt_device *td, 752 struct hid_report *report) 753 { 754 struct mt_report_data *tmp, *rdata = NULL; 755 756 list_for_each_entry(tmp, &td->reports, list) { 757 if (report == tmp->report) { 758 rdata = tmp; 759 break; 760 } 761 } 762 763 if (!rdata) 764 rdata = mt_allocate_report_data(td, report); 765 766 return rdata; 767 } 768 769 static void mt_store_field(struct hid_device *hdev, 770 struct mt_application *application, 771 __s32 *value, 772 size_t offset) 773 { 774 struct mt_usages *usage; 775 __s32 **target; 776 777 if (list_empty(&application->mt_usages)) 778 usage = mt_allocate_usage(hdev, application); 779 else 780 usage = list_last_entry(&application->mt_usages, 781 struct mt_usages, 782 list); 783 784 if (!usage) 785 return; 786 787 target = (__s32 **)((char *)usage + offset); 788 789 /* the value has already been filled, create a new slot */ 790 if (*target != DEFAULT_TRUE && 791 *target != DEFAULT_FALSE && 792 *target != DEFAULT_ZERO) { 793 if (usage->contactid == DEFAULT_ZERO || 794 usage->x == DEFAULT_ZERO || 795 usage->y == DEFAULT_ZERO) { 796 hid_dbg(hdev, 797 "ignoring duplicate usage on incomplete"); 798 return; 799 } 800 usage = mt_allocate_usage(hdev, application); 801 if (!usage) 802 return; 803 804 target = (__s32 **)((char *)usage + offset); 805 } 806 807 *target = value; 808 } 809 810 #define MT_STORE_FIELD(__name) \ 811 mt_store_field(hdev, app, \ 812 &field->value[usage->usage_index], \ 813 offsetof(struct mt_usages, __name)) 814 815 static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, 816 struct hid_field *field, struct hid_usage *usage, 817 unsigned long **bit, int *max, struct mt_application *app) 818 { 819 struct mt_device *td = hid_get_drvdata(hdev); 820 struct mt_class *cls = &td->mtclass; 821 int code; 822 struct hid_usage *prev_usage = NULL; 823 824 /* 825 * Model touchscreens providing buttons as touchpads. 826 */ 827 if (field->application == HID_DG_TOUCHSCREEN && 828 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { 829 app->mt_flags |= INPUT_MT_POINTER; 830 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; 831 } 832 833 /* count the buttons on touchpads */ 834 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) 835 app->buttons_count++; 836 837 if (usage->usage_index) 838 prev_usage = &field->usage[usage->usage_index - 1]; 839 840 switch (usage->hid & HID_USAGE_PAGE) { 841 842 case HID_UP_GENDESK: 843 switch (usage->hid) { 844 case HID_GD_X: 845 if (prev_usage && (prev_usage->hid == usage->hid)) { 846 code = ABS_MT_TOOL_X; 847 MT_STORE_FIELD(cx); 848 } else { 849 code = ABS_MT_POSITION_X; 850 MT_STORE_FIELD(x); 851 } 852 853 set_abs(hi->input, code, field, cls->sn_move); 854 855 /* 856 * A system multi-axis that exports X and Y has a high 857 * chance of being used directly on a surface 858 */ 859 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { 860 __set_bit(INPUT_PROP_DIRECT, 861 hi->input->propbit); 862 input_set_abs_params(hi->input, 863 ABS_MT_TOOL_TYPE, 864 MT_TOOL_DIAL, 865 MT_TOOL_DIAL, 0, 0); 866 } 867 868 return 1; 869 case HID_GD_Y: 870 if (prev_usage && (prev_usage->hid == usage->hid)) { 871 code = ABS_MT_TOOL_Y; 872 MT_STORE_FIELD(cy); 873 } else { 874 code = ABS_MT_POSITION_Y; 875 MT_STORE_FIELD(y); 876 } 877 878 set_abs(hi->input, code, field, cls->sn_move); 879 880 return 1; 881 } 882 return 0; 883 884 case HID_UP_DIGITIZER: 885 switch (usage->hid) { 886 case HID_DG_INRANGE: 887 if (app->quirks & MT_QUIRK_HOVERING) { 888 input_set_abs_params(hi->input, 889 ABS_MT_DISTANCE, 0, 1, 0, 0); 890 } 891 MT_STORE_FIELD(inrange_state); 892 return 1; 893 case HID_DG_CONFIDENCE: 894 if ((cls->name == MT_CLS_WIN_8 || 895 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || 896 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || 897 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP || 898 cls->name == MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE) && 899 (field->application == HID_DG_TOUCHPAD || 900 field->application == HID_DG_TOUCHSCREEN)) 901 app->quirks |= MT_QUIRK_CONFIDENCE; 902 903 if (app->quirks & MT_QUIRK_CONFIDENCE) 904 input_set_abs_params(hi->input, 905 ABS_MT_TOOL_TYPE, 906 MT_TOOL_FINGER, 907 MT_TOOL_PALM, 0, 0); 908 909 MT_STORE_FIELD(confidence_state); 910 return 1; 911 case HID_DG_TOUCH: 912 /* 913 * Legacy devices use TIPSWITCH and not TOUCH. 914 * One special case here is of the Apple Touch Bars. 915 * In these devices, the tip state is contained in 916 * fields with the HID_DG_TOUCH usage. 917 * Let's just ignore this field for other devices. 918 */ 919 if (!(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR)) 920 return -1; 921 fallthrough; 922 case HID_DG_TIPSWITCH: 923 if (field->application != HID_GD_SYSTEM_MULTIAXIS) 924 input_set_capability(hi->input, 925 EV_KEY, BTN_TOUCH); 926 MT_STORE_FIELD(tip_state); 927 return 1; 928 case HID_DG_TRANSDUCER_INDEX: 929 /* 930 * Contact ID in case of Apple Touch Bars is contained 931 * in fields with HID_DG_TRANSDUCER_INDEX usage. 932 */ 933 if (!(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR)) 934 return 0; 935 fallthrough; 936 case HID_DG_CONTACTID: 937 MT_STORE_FIELD(contactid); 938 app->touches_by_report++; 939 return 1; 940 case HID_DG_WIDTH: 941 if (!(app->quirks & MT_QUIRK_NO_AREA)) 942 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, 943 cls->sn_width); 944 MT_STORE_FIELD(w); 945 return 1; 946 case HID_DG_HEIGHT: 947 if (!(app->quirks & MT_QUIRK_NO_AREA)) { 948 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, 949 cls->sn_height); 950 951 /* 952 * Only set ABS_MT_ORIENTATION if it is not 953 * already set by the HID_DG_AZIMUTH usage. 954 */ 955 if (!test_bit(ABS_MT_ORIENTATION, 956 hi->input->absbit)) 957 input_set_abs_params(hi->input, 958 ABS_MT_ORIENTATION, 0, 1, 0, 0); 959 } 960 MT_STORE_FIELD(h); 961 return 1; 962 case HID_DG_TIPPRESSURE: 963 set_abs(hi->input, ABS_MT_PRESSURE, field, 964 cls->sn_pressure); 965 td->is_haptic_touchpad = 966 hid_haptic_check_pressure_unit(td->haptic, 967 hi, field); 968 MT_STORE_FIELD(p); 969 return 1; 970 case HID_DG_SCANTIME: 971 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); 972 app->scantime = &field->value[usage->usage_index]; 973 app->scantime_logical_max = field->logical_maximum; 974 return 1; 975 case HID_DG_CONTACTCOUNT: 976 app->have_contact_count = true; 977 app->raw_cc = &field->value[usage->usage_index]; 978 return 1; 979 case HID_DG_AZIMUTH: 980 /* 981 * Azimuth has the range of [0, MAX) representing a full 982 * revolution. Set ABS_MT_ORIENTATION to a quarter of 983 * MAX according the definition of ABS_MT_ORIENTATION 984 */ 985 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, 986 -field->logical_maximum / 4, 987 field->logical_maximum / 4, 988 cls->sn_move ? 989 field->logical_maximum / cls->sn_move : 0, 0); 990 MT_STORE_FIELD(a); 991 return 1; 992 case HID_DG_CONTACTMAX: 993 /* contact max are global to the report */ 994 return -1; 995 } 996 /* let hid-input decide for the others */ 997 return 0; 998 999 case HID_UP_BUTTON: 1000 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); 1001 /* 1002 * MS PTP spec says that external buttons left and right have 1003 * usages 2 and 3. 1004 */ 1005 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && 1006 field->application == HID_DG_TOUCHPAD && 1007 (usage->hid & HID_USAGE) > 1) 1008 code--; 1009 1010 if (field->application == HID_GD_SYSTEM_MULTIAXIS) 1011 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); 1012 1013 hid_map_usage(hi, usage, bit, max, EV_KEY, code); 1014 if (!*bit) 1015 return -1; 1016 input_set_capability(hi->input, EV_KEY, code); 1017 return 1; 1018 1019 case 0xff000000: 1020 /* we do not want to map these: no input-oriented meaning */ 1021 return -1; 1022 } 1023 1024 return 0; 1025 } 1026 1027 static int mt_compute_slot(struct mt_device *td, struct mt_application *app, 1028 struct mt_usages *slot, 1029 struct input_dev *input) 1030 { 1031 __s32 quirks = app->quirks; 1032 1033 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) 1034 return *slot->contactid; 1035 1036 if (quirks & MT_QUIRK_CYPRESS) 1037 return cypress_compute_slot(app, slot); 1038 1039 if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) 1040 return app->num_received; 1041 1042 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) 1043 return *slot->contactid - 1; 1044 1045 return input_mt_get_slot_by_key(input, *slot->contactid); 1046 } 1047 1048 static void mt_release_pending_palms(struct mt_device *td, 1049 struct mt_application *app, 1050 struct input_dev *input) 1051 { 1052 int slotnum; 1053 bool need_sync = false; 1054 1055 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { 1056 clear_bit(slotnum, app->pending_palm_slots); 1057 clear_bit(slotnum, td->active_slots); 1058 1059 input_mt_slot(input, slotnum); 1060 input_mt_report_slot_inactive(input); 1061 1062 need_sync = true; 1063 } 1064 1065 if (need_sync) { 1066 input_mt_sync_frame(input); 1067 input_sync(input); 1068 } 1069 } 1070 1071 /* 1072 * this function is called when a whole packet has been received and processed, 1073 * so that it can decide what to send to the input layer. 1074 */ 1075 static void mt_sync_frame(struct mt_device *td, struct mt_application *app, 1076 struct input_dev *input) 1077 { 1078 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) 1079 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); 1080 1081 input_mt_sync_frame(input); 1082 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); 1083 input_sync(input); 1084 1085 mt_release_pending_palms(td, app, input); 1086 1087 app->num_received = 0; 1088 app->left_button_state = 0; 1089 if (td->is_haptic_touchpad) 1090 hid_haptic_pressure_reset(td->haptic); 1091 } 1092 1093 static int mt_compute_timestamp(struct mt_application *app, __s32 value) 1094 { 1095 long delta = value - app->prev_scantime; 1096 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); 1097 1098 app->jiffies = jiffies; 1099 1100 if (delta < 0) 1101 delta += app->scantime_logical_max; 1102 1103 /* HID_DG_SCANTIME is expressed in 100us, we want it in us. */ 1104 delta *= 100; 1105 1106 if (jdelta > MAX_TIMESTAMP_INTERVAL) 1107 /* No data received for a while, resync the timestamp. */ 1108 return 0; 1109 else 1110 return app->timestamp + delta; 1111 } 1112 1113 static int mt_touch_event(struct hid_device *hid, struct hid_field *field, 1114 struct hid_usage *usage, __s32 value) 1115 { 1116 /* we will handle the hidinput part later, now remains hiddev */ 1117 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) 1118 hid->hiddev_hid_event(hid, field, usage, value); 1119 1120 return 1; 1121 } 1122 1123 static int mt_process_slot(struct mt_device *td, struct input_dev *input, 1124 struct mt_application *app, 1125 struct mt_usages *slot) 1126 { 1127 struct input_mt *mt = input->mt; 1128 struct hid_device *hdev = td->hdev; 1129 __s32 quirks = app->quirks; 1130 bool valid = true; 1131 bool confidence_state = true; 1132 bool inrange_state = false; 1133 int active; 1134 int slotnum; 1135 int tool = MT_TOOL_FINGER; 1136 1137 if (!slot) 1138 return -EINVAL; 1139 1140 if ((quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && 1141 app->num_received >= app->num_expected) 1142 return -EAGAIN; 1143 1144 if (!(quirks & MT_QUIRK_ALWAYS_VALID)) { 1145 if (quirks & MT_QUIRK_VALID_IS_INRANGE) 1146 valid = *slot->inrange_state; 1147 if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) 1148 valid = *slot->tip_state; 1149 if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) 1150 valid = *slot->confidence_state; 1151 1152 if (!valid) 1153 return 0; 1154 } 1155 1156 slotnum = mt_compute_slot(td, app, slot, input); 1157 if (slotnum < 0 || slotnum >= td->maxcontacts) 1158 return 0; 1159 1160 if ((quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { 1161 struct input_mt_slot *i_slot = &mt->slots[slotnum]; 1162 1163 if (input_mt_is_active(i_slot) && 1164 input_mt_is_used(mt, i_slot)) 1165 return -EAGAIN; 1166 } 1167 1168 if (quirks & MT_QUIRK_CONFIDENCE) 1169 confidence_state = *slot->confidence_state; 1170 1171 if (quirks & MT_QUIRK_HOVERING) 1172 inrange_state = *slot->inrange_state; 1173 1174 active = *slot->tip_state || inrange_state; 1175 1176 if (app->application == HID_GD_SYSTEM_MULTIAXIS) 1177 tool = MT_TOOL_DIAL; 1178 else if (unlikely(!confidence_state)) { 1179 tool = MT_TOOL_PALM; 1180 if (!active && mt && 1181 input_mt_is_active(&mt->slots[slotnum])) { 1182 /* 1183 * The non-confidence was reported for 1184 * previously valid contact that is also no 1185 * longer valid. We can't simply report 1186 * lift-off as userspace will not be aware 1187 * of non-confidence, so we need to split 1188 * it into 2 events: active MT_TOOL_PALM 1189 * and a separate liftoff. 1190 */ 1191 active = true; 1192 set_bit(slotnum, app->pending_palm_slots); 1193 } 1194 } 1195 1196 input_mt_slot(input, slotnum); 1197 input_mt_report_slot_state(input, tool, active); 1198 if (active) { 1199 /* this finger is in proximity of the sensor */ 1200 int wide = (*slot->w > *slot->h); 1201 int major = max(*slot->w, *slot->h); 1202 int minor = min(*slot->w, *slot->h); 1203 int orientation = wide; 1204 int max_azimuth; 1205 int azimuth; 1206 int x; 1207 int y; 1208 int cx; 1209 int cy; 1210 1211 if (slot->a != DEFAULT_ZERO) { 1212 /* 1213 * Azimuth is counter-clockwise and ranges from [0, MAX) 1214 * (a full revolution). Convert it to clockwise ranging 1215 * [-MAX/2, MAX/2]. 1216 * 1217 * Note that ABS_MT_ORIENTATION require us to report 1218 * the limit of [-MAX/4, MAX/4], but the value can go 1219 * out of range to [-MAX/2, MAX/2] to report an upside 1220 * down ellipsis. 1221 */ 1222 azimuth = *slot->a; 1223 max_azimuth = input_abs_get_max(input, 1224 ABS_MT_ORIENTATION); 1225 if (azimuth > max_azimuth * 2) 1226 azimuth -= max_azimuth * 4; 1227 orientation = -azimuth; 1228 if (quirks & MT_QUIRK_ORIENTATION_INVERT) 1229 orientation = -orientation; 1230 1231 } 1232 1233 if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { 1234 /* 1235 * divided by two to match visual scale of touch 1236 * for devices with this quirk 1237 */ 1238 major = major >> 1; 1239 minor = minor >> 1; 1240 } 1241 1242 if (td->is_haptic_touchpad) 1243 hid_haptic_pressure_increase(td->haptic, *slot->p); 1244 1245 x = hdev->quirks & HID_QUIRK_X_INVERT ? 1246 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x : 1247 *slot->x; 1248 y = hdev->quirks & HID_QUIRK_Y_INVERT ? 1249 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->y : 1250 *slot->y; 1251 cx = hdev->quirks & HID_QUIRK_X_INVERT ? 1252 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->cx : 1253 *slot->cx; 1254 cy = hdev->quirks & HID_QUIRK_Y_INVERT ? 1255 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->cy : 1256 *slot->cy; 1257 1258 input_event(input, EV_ABS, ABS_MT_POSITION_X, x); 1259 input_event(input, EV_ABS, ABS_MT_POSITION_Y, y); 1260 input_event(input, EV_ABS, ABS_MT_TOOL_X, cx); 1261 input_event(input, EV_ABS, ABS_MT_TOOL_Y, cy); 1262 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); 1263 input_event(input, EV_ABS, ABS_MT_ORIENTATION, orientation); 1264 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); 1265 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); 1266 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); 1267 1268 set_bit(slotnum, td->active_slots); 1269 } else { 1270 clear_bit(slotnum, td->active_slots); 1271 } 1272 1273 return 0; 1274 } 1275 1276 static void mt_process_mt_event(struct hid_device *hid, 1277 struct mt_application *app, 1278 struct hid_field *field, 1279 struct hid_usage *usage, 1280 __s32 value, 1281 bool first_packet) 1282 { 1283 __s32 quirks = app->quirks; 1284 struct input_dev *input = field->hidinput->input; 1285 1286 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) 1287 return; 1288 1289 if (quirks & MT_QUIRK_WIN8_PTP_BUTTONS) { 1290 1291 /* 1292 * For Win8 PTP touchpads we should only look at 1293 * non finger/touch events in the first_packet of a 1294 * (possible) multi-packet frame. 1295 */ 1296 if (!first_packet) 1297 return; 1298 1299 /* 1300 * For Win8 PTP touchpads we map both the clickpad click 1301 * and any "external" left buttons to BTN_LEFT if a 1302 * device claims to have both we need to report 1 for 1303 * BTN_LEFT if either is pressed, so we or all values 1304 * together and report the result in mt_sync_frame(). 1305 */ 1306 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { 1307 app->left_button_state |= value; 1308 return; 1309 } 1310 } 1311 1312 input_event(input, usage->type, usage->code, value); 1313 } 1314 1315 static void mt_touch_report(struct hid_device *hid, 1316 struct mt_report_data *rdata) 1317 { 1318 struct mt_device *td = hid_get_drvdata(hid); 1319 struct hid_report *report = rdata->report; 1320 struct mt_application *app = rdata->application; 1321 struct hid_field *field; 1322 struct input_dev *input; 1323 struct mt_usages *slot; 1324 bool first_packet; 1325 unsigned count; 1326 int r, n; 1327 int scantime = 0; 1328 int contact_count = -1; 1329 1330 /* sticky fingers release in progress, abort */ 1331 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) 1332 return; 1333 1334 scantime = *app->scantime; 1335 app->timestamp = mt_compute_timestamp(app, scantime); 1336 if (app->raw_cc != DEFAULT_ZERO) 1337 contact_count = *app->raw_cc; 1338 1339 /* 1340 * Includes multi-packet support where subsequent 1341 * packets are sent with zero contactcount. 1342 */ 1343 if (contact_count > 0) 1344 app->num_expected = contact_count; 1345 else if (app->num_received == 0 && app->prev_scantime != scantime) { 1346 /* 1347 * New multi-report frame: 1348 * 1349 * For Win8 PTPs the first packet (td->num_received == 0) may 1350 * have a contactcount of 0 if there only is a button event. 1351 * 1352 * Some other devices use a sentinel frame with 0 to release all contacts 1353 */ 1354 app->num_expected = 0; 1355 } 1356 app->prev_scantime = scantime; 1357 1358 first_packet = app->num_received == 0; 1359 1360 input = report->field[0]->hidinput->input; 1361 1362 list_for_each_entry(slot, &app->mt_usages, list) { 1363 if (!mt_process_slot(td, input, app, slot)) 1364 app->num_received++; 1365 } 1366 1367 for (r = 0; r < report->maxfield; r++) { 1368 field = report->field[r]; 1369 count = field->report_count; 1370 1371 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) 1372 continue; 1373 1374 for (n = 0; n < count; n++) 1375 mt_process_mt_event(hid, app, field, 1376 &field->usage[n], field->value[n], 1377 first_packet); 1378 } 1379 1380 if (app->num_received >= app->num_expected) 1381 mt_sync_frame(td, app, input); 1382 1383 /* 1384 * Windows 8 specs says 2 things: 1385 * - once a contact has been reported, it has to be reported in each 1386 * subsequent report 1387 * - the report rate when fingers are present has to be at least 1388 * the refresh rate of the screen, 60 or 120 Hz 1389 * 1390 * I interprete this that the specification forces a report rate of 1391 * at least 60 Hz for a touchscreen to be certified. 1392 * Which means that if we do not get a report whithin 16 ms, either 1393 * something wrong happens, either the touchscreen forgets to send 1394 * a release. Taking a reasonable margin allows to remove issues 1395 * with USB communication or the load of the machine. 1396 * 1397 * Given that Win 8 devices are forced to send a release, this will 1398 * only affect laggish machines and the ones that have a firmware 1399 * defect. 1400 */ 1401 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { 1402 if (!bitmap_empty(td->active_slots, td->maxcontacts)) 1403 mod_timer(&td->release_timer, 1404 jiffies + msecs_to_jiffies(100)); 1405 else 1406 timer_delete(&td->release_timer); 1407 } 1408 1409 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); 1410 } 1411 1412 static int mt_touch_input_configured(struct hid_device *hdev, 1413 struct hid_input *hi, 1414 struct mt_application *app) 1415 { 1416 struct mt_device *td = hid_get_drvdata(hdev); 1417 struct mt_class *cls = &td->mtclass; 1418 struct input_dev *input = hi->input; 1419 int ret; 1420 1421 /* 1422 * HID_DG_CONTACTMAX field is not present on Apple Touch Bars, 1423 * but the maximum contact count is greater than the default. 1424 */ 1425 if (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR && cls->maxcontacts) 1426 td->maxcontacts = cls->maxcontacts; 1427 1428 if (!td->maxcontacts) 1429 td->maxcontacts = MT_DEFAULT_MAXCONTACT; 1430 1431 mt_post_parse(td, app); 1432 if (td->serial_maybe) 1433 mt_post_parse_default_settings(td, app); 1434 1435 /* 1436 * The application for Apple Touch Bars is HID_DG_TOUCHPAD, 1437 * but these devices are direct. 1438 */ 1439 if (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR) 1440 app->mt_flags |= INPUT_MT_DIRECT; 1441 1442 if (cls->is_indirect) 1443 app->mt_flags |= INPUT_MT_POINTER; 1444 1445 if (td->is_haptic_touchpad) 1446 app->mt_flags |= INPUT_MT_TOTAL_FORCE; 1447 1448 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) 1449 app->mt_flags |= INPUT_MT_DROP_UNUSED; 1450 1451 /* check for clickpads */ 1452 if ((app->mt_flags & INPUT_MT_POINTER) && 1453 (app->buttons_count == 1)) 1454 td->is_buttonpad = true; 1455 1456 if (td->is_buttonpad) 1457 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 1458 if (td->is_pressurepad) 1459 __set_bit(INPUT_PROP_PRESSUREPAD, input->propbit); 1460 1461 if (!td->active_slots) { 1462 td->active_slots = devm_kcalloc(&td->hdev->dev, 1463 BITS_TO_LONGS(td->maxcontacts), 1464 sizeof(long), 1465 GFP_KERNEL); 1466 if (!td->active_slots) 1467 return -ENOMEM; 1468 } 1469 1470 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, 1471 BITS_TO_LONGS(td->maxcontacts), 1472 sizeof(long), 1473 GFP_KERNEL); 1474 if (!app->pending_palm_slots) 1475 return -ENOMEM; 1476 1477 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); 1478 if (ret) 1479 return ret; 1480 1481 app->mt_flags = 0; 1482 return 0; 1483 } 1484 1485 #define mt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ 1486 max, EV_KEY, (c)) 1487 static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, 1488 struct hid_field *field, struct hid_usage *usage, 1489 unsigned long **bit, int *max) 1490 { 1491 struct mt_device *td = hid_get_drvdata(hdev); 1492 struct mt_application *application; 1493 struct mt_report_data *rdata; 1494 int ret; 1495 1496 rdata = mt_find_report_data(td, field->report); 1497 if (!rdata) { 1498 hid_err(hdev, "failed to allocate data for report\n"); 1499 return 0; 1500 } 1501 1502 application = rdata->application; 1503 1504 /* 1505 * If mtclass.export_all_inputs is not set, only map fields from 1506 * TouchScreen or TouchPad collections. We need to ignore fields 1507 * that belong to other collections such as Mouse that might have 1508 * the same GenericDesktop usages. 1509 */ 1510 if (!td->mtclass.export_all_inputs && 1511 field->application != HID_DG_TOUCHSCREEN && 1512 field->application != HID_DG_PEN && 1513 field->application != HID_DG_TOUCHPAD && 1514 field->application != HID_GD_KEYBOARD && 1515 field->application != HID_GD_SYSTEM_CONTROL && 1516 field->application != HID_CP_CONSUMER_CONTROL && 1517 field->application != HID_GD_WIRELESS_RADIO_CTLS && 1518 field->application != HID_GD_SYSTEM_MULTIAXIS && 1519 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && 1520 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) 1521 return -1; 1522 1523 /* 1524 * Some Asus keyboard+touchpad devices have the hotkeys defined in the 1525 * touchpad report descriptor. We need to treat these as an array to 1526 * map usages to input keys. 1527 */ 1528 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && 1529 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && 1530 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { 1531 set_bit(EV_REP, hi->input->evbit); 1532 if (field->flags & HID_MAIN_ITEM_VARIABLE) 1533 field->flags &= ~HID_MAIN_ITEM_VARIABLE; 1534 switch (usage->hid & HID_USAGE) { 1535 case 0x10: mt_map_key_clear(KEY_BRIGHTNESSDOWN); break; 1536 case 0x20: mt_map_key_clear(KEY_BRIGHTNESSUP); break; 1537 case 0x35: mt_map_key_clear(KEY_DISPLAY_OFF); break; 1538 case 0x6b: mt_map_key_clear(KEY_F21); break; 1539 case 0x6c: mt_map_key_clear(KEY_SLEEP); break; 1540 default: 1541 return -1; 1542 } 1543 return 1; 1544 } 1545 1546 if (rdata->is_mt_collection) 1547 return mt_touch_input_mapping(hdev, hi, field, usage, bit, max, 1548 application); 1549 1550 /* 1551 * some egalax touchscreens have "application == DG_TOUCHSCREEN" 1552 * for the stylus. Overwrite the hid_input application 1553 */ 1554 if (field->physical == HID_DG_STYLUS) 1555 hi->application = HID_DG_STYLUS; 1556 1557 ret = hid_haptic_input_mapping(hdev, td->haptic, hi, field, usage, bit, 1558 max); 1559 if (ret != 0) 1560 return ret; 1561 1562 /* let hid-core decide for the others */ 1563 return 0; 1564 } 1565 1566 static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, 1567 struct hid_field *field, struct hid_usage *usage, 1568 unsigned long **bit, int *max) 1569 { 1570 struct mt_device *td = hid_get_drvdata(hdev); 1571 struct mt_report_data *rdata; 1572 1573 rdata = mt_find_report_data(td, field->report); 1574 if (rdata && rdata->is_mt_collection) { 1575 /* We own these mappings, tell hid-input to ignore them */ 1576 return -1; 1577 } 1578 1579 /* let hid-core decide for the others */ 1580 return 0; 1581 } 1582 1583 static int mt_event(struct hid_device *hid, struct hid_field *field, 1584 struct hid_usage *usage, __s32 value) 1585 { 1586 struct mt_device *td = hid_get_drvdata(hid); 1587 struct mt_report_data *rdata; 1588 1589 rdata = mt_find_report_data(td, field->report); 1590 if (rdata && rdata->is_mt_collection) 1591 return mt_touch_event(hid, field, usage, value); 1592 1593 return 0; 1594 } 1595 1596 /* 1597 * Yoga Book 9 14IAH10 descriptor fixup. 1598 * 1599 * The device includes a HID_DG_TOUCHPAD application collection designed for 1600 * the Windows inbox HID driver's Win8 PTP touchpad mode. On Linux we want 1601 * only the HID_DG_TOUCHSCREEN collections. The touchpad collection (and the 1602 * HID_DG_BUTTONTYPE and Win8 compliance blob features it contains) must be 1603 * removed so hid-multitouch does not misclassify the touchscreen nodes as 1604 * indirect buttonpads. 1605 * 1606 * The firmware also resets if any USB control request is received while the 1607 * CDC-ACM interface is initialising (~1.18 s after enumeration). Dropping 1608 * the Win8 blob and Contact Count Max feature reports prevents the 1609 * GET_REPORT calls that hid-multitouch issues at probe. 1610 */ 1611 static void mt_yogabook9_fixup(struct hid_device *hdev, __u8 *rdesc, 1612 unsigned int *size) 1613 { 1614 /* Usage Page (Digitizer), Usage (Touch Pad), Collection (Application) */ 1615 static const __u8 tp_app_hdr[] = { 0x05, 0x0d, 0x09, 0x05, 0xa1, 0x01 }; 1616 /* Vendor Usage Page 0xff00 (Win8 compliance blob header) */ 1617 static const __u8 win8_page[] = { 0x06, 0x00, 0xff }; 1618 /* Usage (Contact Count Max = 0x55) */ 1619 static const __u8 ccmax_usage[] = { 0x09, 0x55 }; 1620 unsigned int i; 1621 1622 /* 1623 * Step 1: find and remove the Touch Pad application collection. 1624 * Walk HID short items from the collection header to its matching 1625 * End Collection, then close the gap with memmove. 1626 */ 1627 for (i = 0; i + sizeof(tp_app_hdr) <= *size; i++) { 1628 if (memcmp(rdesc + i, tp_app_hdr, sizeof(tp_app_hdr)) == 0) { 1629 __u8 *start = rdesc + i; 1630 __u8 *coll_end = NULL; 1631 __u8 *p = start; 1632 unsigned int drop; 1633 int depth = 0; 1634 1635 while (p < rdesc + *size) { 1636 __u8 b = *p; 1637 int ds = b & 3; 1638 int item_len; 1639 1640 if (b == 0xfe) { /* long item */ 1641 if (p + 2 >= rdesc + *size) 1642 break; 1643 item_len = p[1] + 3; 1644 } else { 1645 item_len = (ds == 3) ? 5 : ds + 1; 1646 } 1647 if (p + item_len > rdesc + *size) 1648 break; 1649 1650 if ((b & 0xfc) == 0xa0) 1651 depth++; /* Collection */ 1652 else if (b == 0xc0) { 1653 depth--; /* End Collection */ 1654 if (depth == 0) { 1655 coll_end = p; 1656 break; 1657 } 1658 } 1659 p += item_len; 1660 } 1661 1662 if (!coll_end) { 1663 hid_err(hdev, 1664 "Yoga Book 9: Touch Pad End Collection not found\n"); 1665 break; 1666 } 1667 1668 drop = coll_end - start + 1; 1669 memmove(start, coll_end + 1, rdesc + *size - coll_end - 1); 1670 *size -= drop; 1671 hid_dbg(hdev, 1672 "Yoga Book 9: dropped Touch Pad collection (%u bytes)\n", 1673 drop); 1674 break; 1675 } 1676 } 1677 1678 /* 1679 * Step 2: neutralize Win8 compliance blob feature reports remaining 1680 * in the touchscreen collections. Change Usage Page 0xff00 to 0x0f00 1681 * so the case 0xff0000c5 branch in mt_feature_mapping() is not reached 1682 * and no GET_REPORT is issued. 1683 */ 1684 for (i = 0; i + sizeof(win8_page) <= *size; i++) { 1685 if (memcmp(rdesc + i, win8_page, sizeof(win8_page)) == 0) { 1686 rdesc[i + 2] = 0x0f; /* 0xff00 -> 0x0f00 */ 1687 hid_dbg(hdev, 1688 "Yoga Book 9: neutralized Win8 blob at offset %u\n", 1689 i); 1690 } 1691 } 1692 1693 /* 1694 * Step 3: neutralize Contact Count Max feature reports. Change usage 1695 * 0x55 (HID_DG_CONTACTMAX) to 0x00 so mt_feature_mapping() does not 1696 * issue GET_REPORT. The class maxcontacts field provides the value. 1697 */ 1698 for (i = 0; i + sizeof(ccmax_usage) <= *size; i++) { 1699 if (memcmp(rdesc + i, ccmax_usage, sizeof(ccmax_usage)) == 0) { 1700 rdesc[i + 1] = 0x00; 1701 hid_dbg(hdev, 1702 "Yoga Book 9: neutralized ContactMax at offset %u\n", 1703 i); 1704 } 1705 } 1706 1707 /* 1708 * Step 4: neutralize Surface Switch (0x57) and Button Switch (0x58) 1709 * feature report usages in the Device Configuration collection. 1710 * mt_set_modes() issues HID_REQ_SET_REPORT for these on every 1711 * input-device open/close; those repeated control requests hit the 1712 * firmware's CDC-ACM init window and trigger resets. 1713 * 1714 * Input Mode (0x52) is intentionally left intact. mt_set_modes() 1715 * sends it once at probe to set the device into touchscreen mode, 1716 * which flushes the firmware's contact buffer and clears a persistent 1717 * ghost contact (cid 2, fixed coordinates) that otherwise appears on 1718 * every enumeration. By probe time cdc_acm has already satisfied the 1719 * CDC-ACM init watchdog (~130 ms), so the single SET_REPORT for Input 1720 * Mode arrives safely after the reset window has closed. 1721 */ 1722 for (i = 0; i + 2 <= *size; i++) { 1723 if (rdesc[i] == 0x09 && 1724 (rdesc[i + 1] == 0x57 || 1725 rdesc[i + 1] == 0x58)) { 1726 hid_dbg(hdev, 1727 "Yoga Book 9: neutralized set-modes usage 0x%02x at offset %u\n", 1728 rdesc[i + 1], i); 1729 rdesc[i + 1] = 0x00; 1730 } 1731 } 1732 } 1733 1734 static const __u8 *mt_report_fixup(struct hid_device *hdev, __u8 *rdesc, 1735 unsigned int *size) 1736 { 1737 if (hdev->vendor == I2C_VENDOR_ID_GOODIX && 1738 (hdev->product == I2C_DEVICE_ID_GOODIX_01E8 || 1739 hdev->product == I2C_DEVICE_ID_GOODIX_01E9)) { 1740 if (*size < 608) { 1741 dev_info( 1742 &hdev->dev, 1743 "GT7868Q fixup: report descriptor is only %u bytes, skipping\n", 1744 *size); 1745 return rdesc; 1746 } 1747 1748 if (rdesc[607] == 0x15) { 1749 rdesc[607] = 0x25; 1750 dev_info( 1751 &hdev->dev, 1752 "GT7868Q report descriptor fixup is applied.\n"); 1753 } else { 1754 dev_info( 1755 &hdev->dev, 1756 "The byte is not expected for fixing the report descriptor. \ 1757 It's possible that the touchpad firmware is not suitable for applying the fix. \ 1758 got: %x\n", 1759 rdesc[607]); 1760 } 1761 } 1762 1763 if (hdev->vendor == USB_VENDOR_ID_LENOVO && 1764 hdev->product == USB_DEVICE_ID_LENOVO_YOGABOOK9I) 1765 mt_yogabook9_fixup(hdev, rdesc, size); 1766 1767 return rdesc; 1768 } 1769 1770 static void mt_report(struct hid_device *hid, struct hid_report *report) 1771 { 1772 struct mt_device *td = hid_get_drvdata(hid); 1773 struct hid_field *field = report->field[0]; 1774 struct mt_report_data *rdata; 1775 1776 if (!(hid->claimed & HID_CLAIMED_INPUT)) 1777 return; 1778 1779 rdata = mt_find_report_data(td, report); 1780 if (rdata && rdata->is_mt_collection) 1781 return mt_touch_report(hid, rdata); 1782 1783 /* Lenovo Yoga Book 9i requires consuming and dropping certain bogus reports */ 1784 if (rdata && rdata->application && 1785 (rdata->application->quirks & MT_QUIRK_YOGABOOK9I)) { 1786 1787 bool all_zero_report = true; 1788 1789 for (int f = 0; f < report->maxfield && all_zero_report; f++) { 1790 struct hid_field *fld = report->field[f]; 1791 1792 for (int i = 0; i < fld->report_count; i++) { 1793 unsigned int usage = fld->usage[i].hid; 1794 1795 if (usage == HID_DG_INRANGE || 1796 usage == HID_DG_TIPSWITCH || 1797 usage == HID_DG_BARRELSWITCH || 1798 usage == HID_DG_BARRELSWITCH2 || 1799 usage == HID_DG_CONTACTID || 1800 usage == HID_DG_TILT_X || 1801 usage == HID_DG_TILT_Y) { 1802 1803 if (fld->value[i] != 0) { 1804 all_zero_report = false; 1805 break; 1806 } 1807 } 1808 } 1809 } 1810 1811 if (all_zero_report) 1812 return; 1813 } 1814 1815 if (field && field->hidinput && field->hidinput->input) 1816 input_sync(field->hidinput->input); 1817 } 1818 1819 static bool mt_need_to_apply_feature(struct hid_device *hdev, 1820 struct hid_field *field, 1821 struct hid_usage *usage, 1822 enum latency_mode latency, 1823 enum report_mode report_mode, 1824 bool *inputmode_found) 1825 { 1826 struct mt_device *td = hid_get_drvdata(hdev); 1827 struct mt_class *cls = &td->mtclass; 1828 struct hid_report *report = field->report; 1829 unsigned int index = usage->usage_index; 1830 char *buf; 1831 u32 report_len; 1832 int max; 1833 1834 switch (usage->hid) { 1835 case HID_DG_INPUTMODE: 1836 /* 1837 * Some elan panels wrongly declare 2 input mode features, 1838 * and silently ignore when we set the value in the second 1839 * field. Skip the second feature and hope for the best. 1840 */ 1841 if (*inputmode_found) 1842 return false; 1843 1844 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { 1845 report_len = hid_report_len(report); 1846 buf = hid_alloc_report_buf(report, GFP_KERNEL); 1847 if (!buf) { 1848 hid_err(hdev, 1849 "failed to allocate buffer for report\n"); 1850 return false; 1851 } 1852 hid_hw_raw_request(hdev, report->id, buf, report_len, 1853 HID_FEATURE_REPORT, 1854 HID_REQ_GET_REPORT); 1855 kfree(buf); 1856 } 1857 1858 field->value[index] = td->inputmode_value; 1859 *inputmode_found = true; 1860 return true; 1861 1862 case HID_DG_CONTACTMAX: 1863 if (cls->maxcontacts) { 1864 max = min_t(int, field->logical_maximum, 1865 cls->maxcontacts); 1866 if (field->value[index] != max) { 1867 field->value[index] = max; 1868 return true; 1869 } 1870 } 1871 break; 1872 1873 case HID_DG_LATENCYMODE: 1874 field->value[index] = latency; 1875 return true; 1876 1877 case HID_DG_SURFACESWITCH: 1878 field->value[index] = !!(report_mode & TOUCHPAD_REPORT_CONTACTS); 1879 return true; 1880 1881 case HID_DG_BUTTONSWITCH: 1882 field->value[index] = !!(report_mode & TOUCHPAD_REPORT_BUTTONS); 1883 return true; 1884 } 1885 1886 return false; /* no need to update the report */ 1887 } 1888 1889 static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, 1890 enum report_mode report_mode) 1891 { 1892 struct hid_report_enum *rep_enum; 1893 struct hid_report *rep; 1894 struct hid_usage *usage; 1895 int i, j; 1896 bool update_report; 1897 bool inputmode_found = false; 1898 1899 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; 1900 list_for_each_entry(rep, &rep_enum->report_list, list) { 1901 update_report = false; 1902 1903 for (i = 0; i < rep->maxfield; i++) { 1904 /* Ignore if report count is out of bounds. */ 1905 if (rep->field[i]->report_count < 1) 1906 continue; 1907 1908 for (j = 0; j < rep->field[i]->maxusage; j++) { 1909 usage = &rep->field[i]->usage[j]; 1910 1911 if (mt_need_to_apply_feature(hdev, 1912 rep->field[i], 1913 usage, 1914 latency, 1915 report_mode, 1916 &inputmode_found)) 1917 update_report = true; 1918 } 1919 } 1920 1921 if (update_report) 1922 hid_hw_request(hdev, rep, HID_REQ_SET_REPORT); 1923 } 1924 } 1925 1926 static void mt_post_parse_default_settings(struct mt_device *td, 1927 struct mt_application *app) 1928 { 1929 __s32 quirks = app->quirks; 1930 1931 /* unknown serial device needs special quirks */ 1932 if (list_is_singular(&app->mt_usages)) { 1933 quirks |= MT_QUIRK_ALWAYS_VALID; 1934 quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; 1935 quirks &= ~MT_QUIRK_VALID_IS_INRANGE; 1936 quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; 1937 quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; 1938 } 1939 1940 app->quirks = quirks; 1941 } 1942 1943 static void mt_post_parse(struct mt_device *td, struct mt_application *app) 1944 { 1945 if (!app->have_contact_count) 1946 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; 1947 } 1948 1949 static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) 1950 { 1951 struct mt_device *td = hid_get_drvdata(hdev); 1952 const char *suffix = NULL; 1953 struct mt_report_data *rdata; 1954 struct mt_application *mt_application = NULL; 1955 struct hid_report *report; 1956 int ret; 1957 1958 if (td->is_haptic_touchpad && (td->mtclass.name == MT_CLS_WIN_8 || 1959 td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || 1960 td->mtclass.name == MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE)) { 1961 if (hid_haptic_input_configured(hdev, td->haptic, hi) == 0) 1962 td->is_haptic_touchpad = false; 1963 } else { 1964 td->is_haptic_touchpad = false; 1965 } 1966 1967 list_for_each_entry(report, &hi->reports, hidinput_list) { 1968 rdata = mt_find_report_data(td, report); 1969 if (!rdata) { 1970 hid_err(hdev, "failed to allocate data for report\n"); 1971 return -ENOMEM; 1972 } 1973 1974 mt_application = rdata->application; 1975 1976 if (rdata->is_mt_collection) { 1977 ret = mt_touch_input_configured(hdev, hi, 1978 mt_application); 1979 if (ret) 1980 return ret; 1981 } 1982 } 1983 1984 switch (hi->application) { 1985 case HID_GD_KEYBOARD: 1986 case HID_GD_KEYPAD: 1987 case HID_GD_MOUSE: 1988 case HID_DG_TOUCHPAD: 1989 case HID_GD_SYSTEM_CONTROL: 1990 case HID_CP_CONSUMER_CONTROL: 1991 case HID_GD_WIRELESS_RADIO_CTLS: 1992 case HID_GD_SYSTEM_MULTIAXIS: 1993 case HID_DG_PEN: 1994 /* already handled by hid core */ 1995 break; 1996 case HID_DG_TOUCHSCREEN: 1997 /* we do not set suffix = "Touchscreen" */ 1998 hi->input->name = hdev->name; 1999 break; 2000 case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: 2001 suffix = "Custom Media Keys"; 2002 break; 2003 case HID_DG_STYLUS: 2004 /* force BTN_STYLUS to allow tablet matching in udev */ 2005 __set_bit(BTN_STYLUS, hi->input->keybit); 2006 break; 2007 default: 2008 suffix = "UNKNOWN"; 2009 break; 2010 } 2011 2012 /* Lenovo Yoga Book 9i requires custom naming to allow differentiation in udev */ 2013 if (hi->report && td->mtclass.quirks & MT_QUIRK_YOGABOOK9I) { 2014 switch (hi->report->id) { 2015 case 48: 2016 suffix = "Touchscreen Top"; 2017 break; 2018 case 56: 2019 suffix = "Touchscreen Bottom"; 2020 break; 2021 case 20: 2022 suffix = "Stylus Top"; 2023 break; 2024 case 40: 2025 suffix = "Stylus Bottom"; 2026 break; 2027 case 80: 2028 suffix = "Emulated Touchpad"; 2029 break; 2030 default: 2031 suffix = ""; 2032 break; 2033 } 2034 } 2035 2036 if (suffix) { 2037 hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, 2038 "%s %s", hdev->name, suffix); 2039 if (!hi->input->name) 2040 return -ENOMEM; 2041 } 2042 2043 return 0; 2044 } 2045 2046 static void mt_fix_const_field(struct hid_field *field, unsigned int usage) 2047 { 2048 if (field->usage[0].hid != usage || 2049 !(field->flags & HID_MAIN_ITEM_CONSTANT)) 2050 return; 2051 2052 field->flags &= ~HID_MAIN_ITEM_CONSTANT; 2053 field->flags |= HID_MAIN_ITEM_VARIABLE; 2054 } 2055 2056 static void mt_fix_const_fields(struct hid_device *hdev, unsigned int usage) 2057 { 2058 struct hid_report *report; 2059 int i; 2060 2061 list_for_each_entry(report, 2062 &hdev->report_enum[HID_INPUT_REPORT].report_list, 2063 list) { 2064 2065 if (!report->maxfield) 2066 continue; 2067 2068 for (i = 0; i < report->maxfield; i++) 2069 if (report->field[i]->maxusage >= 1) 2070 mt_fix_const_field(report->field[i], usage); 2071 } 2072 } 2073 2074 static void mt_release_contacts(struct hid_device *hid) 2075 { 2076 struct hid_input *hidinput; 2077 struct mt_application *application; 2078 struct mt_device *td = hid_get_drvdata(hid); 2079 2080 list_for_each_entry(hidinput, &hid->inputs, list) { 2081 struct input_dev *input_dev = hidinput->input; 2082 struct input_mt *mt = input_dev->mt; 2083 int i; 2084 2085 if (mt) { 2086 for (i = 0; i < mt->num_slots; i++) { 2087 input_mt_slot(input_dev, i); 2088 input_mt_report_slot_inactive(input_dev); 2089 clear_bit(i, td->active_slots); 2090 } 2091 input_mt_sync_frame(input_dev); 2092 input_sync(input_dev); 2093 } 2094 } 2095 2096 list_for_each_entry(application, &td->applications, list) { 2097 application->num_received = 0; 2098 } 2099 } 2100 2101 static void mt_expired_timeout(struct timer_list *t) 2102 { 2103 struct mt_device *td = timer_container_of(td, t, release_timer); 2104 struct hid_device *hdev = td->hdev; 2105 2106 /* 2107 * An input report came in just before we release the sticky fingers, 2108 * it will take care of the sticky fingers. 2109 */ 2110 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) 2111 return; 2112 if (!bitmap_empty(td->active_slots, td->maxcontacts)) 2113 mt_release_contacts(hdev); 2114 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); 2115 } 2116 2117 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) 2118 { 2119 int ret, i; 2120 struct mt_device *td; 2121 const struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ 2122 2123 for (i = 0; mt_classes[i].name ; i++) { 2124 if (id->driver_data == mt_classes[i].name) { 2125 mtclass = &(mt_classes[i]); 2126 break; 2127 } 2128 } 2129 2130 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); 2131 if (!td) { 2132 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); 2133 return -ENOMEM; 2134 } 2135 td->haptic = devm_kzalloc(&hdev->dev, sizeof(*(td->haptic)), GFP_KERNEL); 2136 if (!td->haptic) 2137 return -ENOMEM; 2138 2139 td->haptic->hdev = hdev; 2140 td->hdev = hdev; 2141 td->mtclass = *mtclass; 2142 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; 2143 hid_set_drvdata(hdev, td); 2144 2145 INIT_LIST_HEAD(&td->applications); 2146 INIT_LIST_HEAD(&td->reports); 2147 2148 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) 2149 td->serial_maybe = true; 2150 2151 2152 /* Orientation is inverted if the X or Y axes are 2153 * flipped, but normalized if both are inverted. 2154 */ 2155 if (hdev->quirks & (HID_QUIRK_X_INVERT | HID_QUIRK_Y_INVERT) && 2156 !((hdev->quirks & HID_QUIRK_X_INVERT) 2157 && (hdev->quirks & HID_QUIRK_Y_INVERT))) 2158 td->mtclass.quirks = MT_QUIRK_ORIENTATION_INVERT; 2159 2160 /* This allows the driver to correctly support devices 2161 * that emit events over several HID messages. 2162 */ 2163 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; 2164 2165 /* 2166 * This allows the driver to handle different input sensors 2167 * that emits events through different applications on the same HID 2168 * device. 2169 */ 2170 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; 2171 2172 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) 2173 hdev->quirks |= HID_QUIRK_MULTI_INPUT; 2174 2175 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { 2176 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; 2177 hdev->quirks |= HID_QUIRK_MULTI_INPUT; 2178 } 2179 2180 timer_setup(&td->release_timer, mt_expired_timeout, 0); 2181 2182 ret = hid_parse(hdev); 2183 if (ret != 0) 2184 return ret; 2185 2186 if (mtclass->name == MT_CLS_APPLE_TOUCHBAR && 2187 !hid_find_field(hdev, HID_INPUT_REPORT, 2188 HID_DG_TOUCHPAD, HID_DG_TRANSDUCER_INDEX)) 2189 return -ENODEV; 2190 2191 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) 2192 mt_fix_const_fields(hdev, HID_DG_CONTACTID); 2193 2194 if (hdev->vendor == USB_VENDOR_ID_SIS_TOUCH) 2195 hdev->quirks |= HID_QUIRK_NOGET; 2196 2197 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 2198 if (ret) 2199 return ret; 2200 2201 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); 2202 if (ret) 2203 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", 2204 hdev->name); 2205 2206 mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL); 2207 2208 if (!td->is_haptic_touchpad) 2209 devm_kfree(&hdev->dev, td->haptic); 2210 2211 return 0; 2212 } 2213 2214 static int mt_suspend(struct hid_device *hdev, pm_message_t state) 2215 { 2216 struct mt_device *td = hid_get_drvdata(hdev); 2217 2218 /* High latency is desirable for power savings during S3/S0ix */ 2219 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || 2220 !hid_hw_may_wakeup(hdev)) 2221 mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE); 2222 else 2223 mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_ALL); 2224 2225 return 0; 2226 } 2227 2228 static int mt_reset_resume(struct hid_device *hdev) 2229 { 2230 mt_release_contacts(hdev); 2231 mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL); 2232 return 0; 2233 } 2234 2235 static int mt_resume(struct hid_device *hdev) 2236 { 2237 /* Some Elan legacy devices require SET_IDLE to be set on resume. 2238 * It should be safe to send it to other devices too. 2239 * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ 2240 2241 hid_hw_idle(hdev, 0, 0, HID_REQ_SET_IDLE); 2242 2243 mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL); 2244 2245 return 0; 2246 } 2247 2248 static void mt_remove(struct hid_device *hdev) 2249 { 2250 struct mt_device *td = hid_get_drvdata(hdev); 2251 2252 timer_delete_sync(&td->release_timer); 2253 2254 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); 2255 hid_hw_stop(hdev); 2256 } 2257 2258 static void mt_on_hid_hw_open(struct hid_device *hdev) 2259 { 2260 mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL); 2261 } 2262 2263 static void mt_on_hid_hw_close(struct hid_device *hdev) 2264 { 2265 struct mt_device *td = hid_get_drvdata(hdev); 2266 2267 if (td->mtclass.quirks & MT_QUIRK_KEEP_LATENCY_ON_CLOSE) 2268 mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_NONE); 2269 else 2270 mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE); 2271 } 2272 2273 /* 2274 * This list contains only: 2275 * - VID/PID of products not working with the default multitouch handling 2276 * - 2 generic rules. 2277 * So there is no point in adding here any device with MT_CLS_DEFAULT. 2278 */ 2279 static const struct hid_device_id mt_devices[] = { 2280 2281 /* 3M panels */ 2282 { .driver_data = MT_CLS_3M, 2283 MT_USB_DEVICE(USB_VENDOR_ID_3M, 2284 USB_DEVICE_ID_3M1968) }, 2285 { .driver_data = MT_CLS_3M, 2286 MT_USB_DEVICE(USB_VENDOR_ID_3M, 2287 USB_DEVICE_ID_3M2256) }, 2288 { .driver_data = MT_CLS_3M, 2289 MT_USB_DEVICE(USB_VENDOR_ID_3M, 2290 USB_DEVICE_ID_3M3266) }, 2291 2292 /* Anton devices */ 2293 { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 2294 MT_USB_DEVICE(USB_VENDOR_ID_ANTON, 2295 USB_DEVICE_ID_ANTON_TOUCH_PAD) }, 2296 2297 /* Asus T101HA */ 2298 { .driver_data = MT_CLS_WIN_8_DISABLE_WAKEUP, 2299 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2300 USB_VENDOR_ID_ASUSTEK, 2301 USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) }, 2302 2303 /* Asus T304UA */ 2304 { .driver_data = MT_CLS_ASUS, 2305 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2306 USB_VENDOR_ID_ASUSTEK, 2307 USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD) }, 2308 2309 /* Atmel panels */ 2310 { .driver_data = MT_CLS_SERIAL, 2311 MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, 2312 USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, 2313 2314 /* Baanto multitouch devices */ 2315 { .driver_data = MT_CLS_NSMU, 2316 MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, 2317 USB_DEVICE_ID_BAANTO_MT_190W2) }, 2318 2319 /* Cando panels */ 2320 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, 2321 MT_USB_DEVICE(USB_VENDOR_ID_CANDO, 2322 USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 2323 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, 2324 MT_USB_DEVICE(USB_VENDOR_ID_CANDO, 2325 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 2326 2327 /* Chunghwa Telecom touch panels */ 2328 { .driver_data = MT_CLS_NSMU, 2329 MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, 2330 USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 2331 2332 /* CJTouch panels */ 2333 { .driver_data = MT_CLS_NSMU, 2334 MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, 2335 USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020) }, 2336 { .driver_data = MT_CLS_NSMU, 2337 MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, 2338 USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0040) }, 2339 2340 /* CVTouch panels */ 2341 { .driver_data = MT_CLS_NSMU, 2342 MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, 2343 USB_DEVICE_ID_CVTOUCH_SCREEN) }, 2344 2345 /* eGalax devices (SAW) */ 2346 { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 2347 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2348 USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER) }, 2349 2350 /* eGalax devices (resistive) */ 2351 { .driver_data = MT_CLS_EGALAX, 2352 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2353 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, 2354 { .driver_data = MT_CLS_EGALAX, 2355 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2356 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, 2357 2358 /* eGalax devices (capacitive) */ 2359 { .driver_data = MT_CLS_EGALAX_SERIAL, 2360 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2361 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, 2362 { .driver_data = MT_CLS_EGALAX, 2363 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2364 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, 2365 { .driver_data = MT_CLS_EGALAX_SERIAL, 2366 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2367 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, 2368 { .driver_data = MT_CLS_EGALAX_SERIAL, 2369 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2370 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, 2371 { .driver_data = MT_CLS_EGALAX_SERIAL, 2372 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2373 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, 2374 { .driver_data = MT_CLS_EGALAX_SERIAL, 2375 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2376 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, 2377 { .driver_data = MT_CLS_EGALAX, 2378 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2379 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, 2380 { .driver_data = MT_CLS_EGALAX, 2381 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2382 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, 2383 { .driver_data = MT_CLS_EGALAX_SERIAL, 2384 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2385 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, 2386 { .driver_data = MT_CLS_EGALAX, 2387 HID_USB_DEVICE(USB_VENDOR_ID_DWAV, 2388 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, 2389 { .driver_data = MT_CLS_EGALAX, 2390 HID_USB_DEVICE(USB_VENDOR_ID_DWAV, 2391 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, 2392 { .driver_data = MT_CLS_EGALAX, 2393 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2394 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, 2395 { .driver_data = MT_CLS_EGALAX, 2396 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2397 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, 2398 { .driver_data = MT_CLS_EGALAX_SERIAL, 2399 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2400 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, 2401 { .driver_data = MT_CLS_EGALAX_SERIAL, 2402 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2403 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, 2404 { .driver_data = MT_CLS_EGALAX_SERIAL, 2405 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2406 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, 2407 { .driver_data = MT_CLS_EGALAX_SERIAL, 2408 MT_USB_DEVICE(USB_VENDOR_ID_DWAV, 2409 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C000) }, 2410 { .driver_data = MT_CLS_EGALAX_P80H84, 2411 HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, 2412 USB_VENDOR_ID_DWAV, 2413 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) }, 2414 2415 /* Elan devices */ 2416 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2417 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2418 USB_VENDOR_ID_ELAN, 0x313a) }, 2419 2420 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2421 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2422 USB_VENDOR_ID_ELAN, 0x3148) }, 2423 2424 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2425 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2426 USB_VENDOR_ID_ELAN, 0x32ae) }, 2427 2428 /* Elitegroup panel */ 2429 { .driver_data = MT_CLS_SERIAL, 2430 MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP, 2431 USB_DEVICE_ID_ELITEGROUP_05D8) }, 2432 2433 /* Flatfrog Panels */ 2434 { .driver_data = MT_CLS_FLATFROG, 2435 MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, 2436 USB_DEVICE_ID_MULTITOUCH_3200) }, 2437 2438 /* FocalTech Panels */ 2439 { .driver_data = MT_CLS_SERIAL, 2440 MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL, 2441 USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH) }, 2442 2443 /* GeneralTouch panel */ 2444 { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, 2445 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2446 USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 2447 { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 2448 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2449 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, 2450 { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, 2451 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2452 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) }, 2453 { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 2454 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2455 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) }, 2456 { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 2457 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2458 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) }, 2459 { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 2460 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2461 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) }, 2462 { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 2463 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 2464 USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) }, 2465 2466 /* Gametel game controller */ 2467 { .driver_data = MT_CLS_NSMU, 2468 MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, 2469 USB_DEVICE_ID_GAMETEL_MT_MODE) }, 2470 2471 /* Goodix GT7868Q devices */ 2472 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2473 HID_DEVICE(BUS_I2C, HID_GROUP_ANY, I2C_VENDOR_ID_GOODIX, 2474 I2C_DEVICE_ID_GOODIX_01E8) }, 2475 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2476 HID_DEVICE(BUS_I2C, HID_GROUP_ANY, I2C_VENDOR_ID_GOODIX, 2477 I2C_DEVICE_ID_GOODIX_01E9) }, 2478 2479 /* GoodTouch panels */ 2480 { .driver_data = MT_CLS_NSMU, 2481 MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, 2482 USB_DEVICE_ID_GOODTOUCH_000f) }, 2483 2484 /* Hanvon panels */ 2485 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, 2486 MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, 2487 USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, 2488 2489 /* HONOR GLO-GXXX panel */ 2490 { .driver_data = MT_CLS_VTL, 2491 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2492 0x347d, 0x7853) }, 2493 2494 /* HONOR MagicBook Art 14 touchpad */ 2495 { .driver_data = MT_CLS_VTL, 2496 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2497 0x35cc, 0x0104) }, 2498 2499 /* Ilitek dual touch panel */ 2500 { .driver_data = MT_CLS_NSMU, 2501 MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, 2502 USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 2503 2504 /* LG Melfas panel */ 2505 { .driver_data = MT_CLS_LG, 2506 HID_USB_DEVICE(USB_VENDOR_ID_LG, 2507 USB_DEVICE_ID_LG_MELFAS_MT) }, 2508 { .driver_data = MT_CLS_LG, 2509 HID_DEVICE(BUS_I2C, HID_GROUP_GENERIC, 2510 USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_7010) }, 2511 2512 /* Lenovo X1 TAB Gen 1 */ 2513 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2514 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2515 USB_VENDOR_ID_LENOVO, 2516 USB_DEVICE_ID_LENOVO_X1_TAB) }, 2517 2518 /* Lenovo X1 TAB Gen 2 */ 2519 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2520 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2521 USB_VENDOR_ID_LENOVO, 2522 USB_DEVICE_ID_LENOVO_X1_TAB2) }, 2523 2524 /* Lenovo X1 TAB Gen 3 */ 2525 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2526 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2527 USB_VENDOR_ID_LENOVO, 2528 USB_DEVICE_ID_LENOVO_X1_TAB3) }, 2529 2530 /* Lenovo X12 TAB Gen 1 */ 2531 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2532 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2533 USB_VENDOR_ID_LENOVO, 2534 USB_DEVICE_ID_LENOVO_X12_TAB) }, 2535 2536 /* Lenovo X12 TAB Gen 2 */ 2537 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2538 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2539 USB_VENDOR_ID_LENOVO, 2540 USB_DEVICE_ID_LENOVO_X12_TAB2) }, 2541 2542 /* Lenovo Yoga Book 9i */ 2543 { .driver_data = MT_CLS_YOGABOOK9I, 2544 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2545 USB_VENDOR_ID_LENOVO, 2546 USB_DEVICE_ID_LENOVO_YOGABOOK9I) }, 2547 2548 /* Logitech devices */ 2549 { .driver_data = MT_CLS_NSMU, 2550 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH_WIN_8, 2551 USB_VENDOR_ID_LOGITECH, 2552 USB_DEVICE_ID_LOGITECH_CASA_TOUCHPAD) }, 2553 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2554 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2555 USB_VENDOR_ID_LOGITECH, 2556 USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER) }, 2557 2558 /* MosArt panels */ 2559 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 2560 MT_USB_DEVICE(USB_VENDOR_ID_ASUS, 2561 USB_DEVICE_ID_ASUS_T91MT)}, 2562 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 2563 MT_USB_DEVICE(USB_VENDOR_ID_ASUS, 2564 USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 2565 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 2566 MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, 2567 USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 2568 2569 /* Novatek Panel */ 2570 { .driver_data = MT_CLS_NSMU, 2571 MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, 2572 USB_DEVICE_ID_NOVATEK_PCT) }, 2573 2574 /* Ntrig Panel */ 2575 { .driver_data = MT_CLS_NSMU, 2576 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2577 USB_VENDOR_ID_NTRIG, 0x1b05) }, 2578 2579 /* Panasonic panels */ 2580 { .driver_data = MT_CLS_PANASONIC, 2581 MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, 2582 USB_DEVICE_ID_PANABOARD_UBT780) }, 2583 { .driver_data = MT_CLS_PANASONIC, 2584 MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, 2585 USB_DEVICE_ID_PANABOARD_UBT880) }, 2586 2587 /* PixArt optical touch screen */ 2588 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, 2589 MT_USB_DEVICE(USB_VENDOR_ID_PIXART, 2590 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, 2591 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, 2592 MT_USB_DEVICE(USB_VENDOR_ID_PIXART, 2593 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, 2594 { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, 2595 MT_USB_DEVICE(USB_VENDOR_ID_PIXART, 2596 USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, 2597 2598 /* PixCir-based panels */ 2599 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, 2600 MT_USB_DEVICE(USB_VENDOR_ID_CANDO, 2601 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 2602 2603 /* Quanta-based panels */ 2604 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, 2605 MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, 2606 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, 2607 2608 /* Razer touchpads */ 2609 { .driver_data = MT_CLS_RAZER_BLADE_STEALTH, 2610 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2611 USB_VENDOR_ID_SYNAPTICS, 0x8323) }, 2612 2613 /* Smart Tech panels */ 2614 { .driver_data = MT_CLS_SMART_TECH, 2615 MT_USB_DEVICE(0x0b8c, 0x0092)}, 2616 2617 /* Stantum panels */ 2618 { .driver_data = MT_CLS_CONFIDENCE, 2619 MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, 2620 USB_DEVICE_ID_MTP_STM)}, 2621 2622 /* Synaptics devices */ 2623 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2624 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2625 USB_VENDOR_ID_SYNAPTICS, 0xcd7e) }, 2626 2627 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2628 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2629 USB_VENDOR_ID_SYNAPTICS, 0xcddc) }, 2630 2631 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2632 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2633 USB_VENDOR_ID_SYNAPTICS, 0xce08) }, 2634 2635 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, 2636 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2637 USB_VENDOR_ID_SYNAPTICS, 0xce09) }, 2638 2639 /* TopSeed panels */ 2640 { .driver_data = MT_CLS_TOPSEED, 2641 MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, 2642 USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, 2643 2644 /* Touch International panels */ 2645 { .driver_data = MT_CLS_NSMU, 2646 MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, 2647 USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 2648 2649 /* Unitec panels */ 2650 { .driver_data = MT_CLS_NSMU, 2651 MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, 2652 USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 2653 { .driver_data = MT_CLS_NSMU, 2654 MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, 2655 USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 2656 2657 /* Uniwill touchpads */ 2658 { .driver_data = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE, 2659 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2660 USB_VENDOR_ID_PIXART, 0x0255) }, 2661 { .driver_data = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE, 2662 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2663 USB_VENDOR_ID_PIXART, 0x0274) }, 2664 2665 /* VTL panels */ 2666 { .driver_data = MT_CLS_VTL, 2667 MT_USB_DEVICE(USB_VENDOR_ID_VTL, 2668 USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, 2669 2670 /* Winbond Electronics Corp. */ 2671 { .driver_data = MT_CLS_WIN_8_NO_STICKY_FINGERS, 2672 HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, 2673 USB_VENDOR_ID_WINBOND, USB_DEVICE_ID_TSTP_MTOUCH) }, 2674 2675 /* Wistron panels */ 2676 { .driver_data = MT_CLS_NSMU, 2677 MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, 2678 USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, 2679 2680 /* XAT */ 2681 { .driver_data = MT_CLS_NSMU, 2682 MT_USB_DEVICE(USB_VENDOR_ID_XAT, 2683 USB_DEVICE_ID_XAT_CSR) }, 2684 2685 /* Xiroku */ 2686 { .driver_data = MT_CLS_NSMU, 2687 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2688 USB_DEVICE_ID_XIROKU_SPX) }, 2689 { .driver_data = MT_CLS_NSMU, 2690 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2691 USB_DEVICE_ID_XIROKU_MPX) }, 2692 { .driver_data = MT_CLS_NSMU, 2693 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2694 USB_DEVICE_ID_XIROKU_CSR) }, 2695 { .driver_data = MT_CLS_NSMU, 2696 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2697 USB_DEVICE_ID_XIROKU_SPX1) }, 2698 { .driver_data = MT_CLS_NSMU, 2699 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2700 USB_DEVICE_ID_XIROKU_MPX1) }, 2701 { .driver_data = MT_CLS_NSMU, 2702 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2703 USB_DEVICE_ID_XIROKU_CSR1) }, 2704 { .driver_data = MT_CLS_NSMU, 2705 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2706 USB_DEVICE_ID_XIROKU_SPX2) }, 2707 { .driver_data = MT_CLS_NSMU, 2708 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2709 USB_DEVICE_ID_XIROKU_MPX2) }, 2710 { .driver_data = MT_CLS_NSMU, 2711 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 2712 USB_DEVICE_ID_XIROKU_CSR2) }, 2713 2714 /* Apple Touch Bar */ 2715 { .driver_data = MT_CLS_APPLE_TOUCHBAR, 2716 HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 2717 USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, 2718 2719 /* Google MT devices */ 2720 { .driver_data = MT_CLS_GOOGLE, 2721 HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE, 2722 USB_DEVICE_ID_GOOGLE_TOUCH_ROSE) }, 2723 { .driver_data = MT_CLS_GOOGLE, 2724 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, USB_VENDOR_ID_GOOGLE, 2725 USB_DEVICE_ID_GOOGLE_WHISKERS) }, 2726 2727 /* sis */ 2728 { .driver_data = MT_CLS_SIS, 2729 HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_SIS_TOUCH, 2730 HID_ANY_ID) }, 2731 2732 /* Hantick */ 2733 { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2734 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2735 I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288) }, 2736 2737 /* Asus ROG Flow Z13 (2025) GZ302EA keyboard-cover touchpad */ 2738 { .driver_data = MT_CLS_ASUS_ROG_Z13_FOLIO, 2739 HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, 2740 USB_VENDOR_ID_ASUSTEK, 2741 USB_DEVICE_ID_ASUSTEK_ROG_Z13_FOLIO) }, 2742 2743 /* Generic MT device */ 2744 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, 2745 2746 /* Generic Win 8 certified MT device */ 2747 { .driver_data = MT_CLS_WIN_8, 2748 HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, 2749 HID_ANY_ID, HID_ANY_ID) }, 2750 { } 2751 }; 2752 MODULE_DEVICE_TABLE(hid, mt_devices); 2753 2754 static const struct hid_usage_id mt_grabbed_usages[] = { 2755 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, 2756 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} 2757 }; 2758 2759 static struct hid_driver mt_driver = { 2760 .name = "hid-multitouch", 2761 .id_table = mt_devices, 2762 .probe = mt_probe, 2763 .remove = mt_remove, 2764 .input_mapping = mt_input_mapping, 2765 .input_mapped = mt_input_mapped, 2766 .input_configured = mt_input_configured, 2767 .feature_mapping = mt_feature_mapping, 2768 .usage_table = mt_grabbed_usages, 2769 .event = mt_event, 2770 .report_fixup = mt_report_fixup, 2771 .report = mt_report, 2772 .suspend = pm_ptr(mt_suspend), 2773 .reset_resume = pm_ptr(mt_reset_resume), 2774 .resume = pm_ptr(mt_resume), 2775 .on_hid_hw_open = mt_on_hid_hw_open, 2776 .on_hid_hw_close = mt_on_hid_hw_close, 2777 }; 2778 module_hid_driver(mt_driver); 2779