Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1 | /* |
| 2 | * HID driver for multitouch panels |
| 3 | * |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 4 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> |
Benjamin Tissoires | b0a7868 | 2013-02-25 11:31:49 +0100 | [diff] [blame] | 5 | * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 6 | * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France |
Benjamin Tissoires | b0a7868 | 2013-02-25 11:31:49 +0100 | [diff] [blame] | 7 | * Copyright (c) 2012-2013 Red Hat, Inc |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 8 | * |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 9 | * This code is partly based on hid-egalax.c: |
| 10 | * |
| 11 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> |
| 12 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> |
| 13 | * Copyright (c) 2010 Canonical, Ltd. |
| 14 | * |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 15 | * This code is partly based on hid-3m-pct.c: |
| 16 | * |
| 17 | * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr> |
| 18 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> |
| 19 | * Copyright (c) 2010 Canonical, Ltd. |
| 20 | * |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * This program is free software; you can redistribute it and/or modify it |
| 25 | * under the terms of the GNU General Public License as published by the Free |
| 26 | * Software Foundation; either version 2 of the License, or (at your option) |
| 27 | * any later version. |
| 28 | */ |
| 29 | |
Benjamin Tissoires | b0a7868 | 2013-02-25 11:31:49 +0100 | [diff] [blame] | 30 | /* |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 31 | * This driver is regularly tested thanks to the test suite in hid-tools[1]. |
Benjamin Tissoires | b0a7868 | 2013-02-25 11:31:49 +0100 | [diff] [blame] | 32 | * Please run these regression tests before patching this module so that |
| 33 | * your patch won't break existing known devices. |
| 34 | * |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 35 | * [1] https://gitlab.freedesktop.org/libevdev/hid-tools |
Benjamin Tissoires | b0a7868 | 2013-02-25 11:31:49 +0100 | [diff] [blame] | 36 | */ |
| 37 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 38 | #include <linux/device.h> |
| 39 | #include <linux/hid.h> |
| 40 | #include <linux/module.h> |
| 41 | #include <linux/slab.h> |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 42 | #include <linux/input/mt.h> |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 43 | #include <linux/jiffies.h> |
Benjamin Tissoires | 49a5a82 | 2013-03-22 18:38:33 +0100 | [diff] [blame] | 44 | #include <linux/string.h> |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 45 | #include <linux/timer.h> |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 46 | |
| 47 | |
| 48 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); |
Benjamin Tissoires | ef2fafb | 2011-01-31 11:28:21 +0100 | [diff] [blame] | 49 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 50 | MODULE_DESCRIPTION("HID multitouch panels"); |
| 51 | MODULE_LICENSE("GPL"); |
| 52 | |
| 53 | #include "hid-ids.h" |
| 54 | |
| 55 | /* quirks to control the device */ |
Benjamin Tissoires | fd91189 | 2017-06-15 15:32:03 +0200 | [diff] [blame] | 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) |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 72 | #define MT_QUIRK_STICKY_FINGERS BIT(16) |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 73 | #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) |
Benjamin Tissoires | d9c57a7 | 2018-03-20 12:04:45 +0100 | [diff] [blame] | 74 | #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 75 | |
Andrew Duggan | 9abebed | 2014-03-19 13:39:03 -0700 | [diff] [blame] | 76 | #define MT_INPUTMODE_TOUCHSCREEN 0x02 |
| 77 | #define MT_INPUTMODE_TOUCHPAD 0x03 |
| 78 | |
Seth Forshee | 2c6e027 | 2015-03-11 17:26:41 -0500 | [diff] [blame] | 79 | #define MT_BUTTONTYPE_CLICKPAD 0 |
| 80 | |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 81 | enum latency_mode { |
| 82 | HID_LATENCY_NORMAL = 0, |
| 83 | HID_LATENCY_HIGH = 1, |
| 84 | }; |
| 85 | |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 86 | #define MT_IO_FLAGS_RUNNING 0 |
Benjamin Tissoires | 9609827 | 2017-06-15 15:32:05 +0200 | [diff] [blame] | 87 | #define MT_IO_FLAGS_ACTIVE_SLOTS 1 |
| 88 | #define MT_IO_FLAGS_PENDING_SLOTS 2 |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 89 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 90 | static const bool mtrue = true; /* default for true */ |
| 91 | static const bool mfalse; /* default for false */ |
| 92 | static const __s32 mzero; /* default for 0 */ |
| 93 | |
| 94 | #define DEFAULT_TRUE ((void *)&mtrue) |
| 95 | #define DEFAULT_FALSE ((void *)&mfalse) |
| 96 | #define DEFAULT_ZERO ((void *)&mzero) |
| 97 | |
| 98 | struct mt_usages { |
| 99 | struct list_head list; |
| 100 | __s32 *x, *y, *cx, *cy, *p, *w, *h, *a; |
| 101 | __s32 *contactid; /* the device ContactID assigned to this slot */ |
| 102 | bool *tip_state; /* is the touch valid? */ |
| 103 | bool *inrange_state; /* is the finger in proximity of the sensor? */ |
| 104 | bool *confidence_state; /* is the touch made by a finger? */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 107 | struct mt_application { |
| 108 | struct list_head list; |
| 109 | unsigned int application; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 110 | struct list_head mt_usages; /* mt usages list */ |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 111 | |
| 112 | __s32 quirks; |
| 113 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 114 | __s32 *scantime; /* scantime reported */ |
| 115 | __s32 scantime_logical_max; /* max value for raw scantime */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 116 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 117 | __s32 *raw_cc; /* contact count in the report */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 118 | int left_button_state; /* left button state */ |
| 119 | unsigned int mt_flags; /* flags to pass to input-mt */ |
| 120 | |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 121 | unsigned long *pending_palm_slots; /* slots where we reported palm |
| 122 | * and need to release */ |
| 123 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 124 | __u8 num_received; /* how many contacts we received */ |
| 125 | __u8 num_expected; /* expected last contact index */ |
| 126 | __u8 buttons_count; /* number of physical buttons per touchpad */ |
| 127 | __u8 touches_by_report; /* how many touches are present in one report: |
| 128 | * 1 means we should use a serial protocol |
| 129 | * > 1 means hybrid (multitouch) protocol |
| 130 | */ |
| 131 | |
| 132 | __s32 dev_time; /* the scan time provided by the device */ |
| 133 | unsigned long jiffies; /* the frame's jiffies */ |
| 134 | int timestamp; /* the timestamp to be sent */ |
| 135 | int prev_scantime; /* scantime reported previously */ |
| 136 | |
| 137 | bool have_contact_count; |
| 138 | }; |
| 139 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 140 | struct mt_class { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 141 | __s32 name; /* MT_CLS */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 142 | __s32 quirks; |
| 143 | __s32 sn_move; /* Signal/noise ratio for move events */ |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 144 | __s32 sn_width; /* Signal/noise ratio for width events */ |
| 145 | __s32 sn_height; /* Signal/noise ratio for height events */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 146 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ |
| 147 | __u8 maxcontacts; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 148 | bool is_indirect; /* true for touchpads */ |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 149 | bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 152 | struct mt_report_data { |
| 153 | struct list_head list; |
| 154 | struct hid_report *report; |
| 155 | struct mt_application *application; |
| 156 | bool is_mt_collection; |
| 157 | }; |
| 158 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 159 | struct mt_device { |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 160 | struct mt_class mtclass; /* our mt device class */ |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 161 | struct timer_list release_timer; /* to release sticky fingers */ |
Kees Cook | 0ee3277 | 2017-10-04 17:53:24 -0700 | [diff] [blame] | 162 | struct hid_device *hdev; /* hid_device we're attached to */ |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 163 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 164 | __u8 inputmode_value; /* InputMode HID feature value */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 165 | __u8 maxcontacts; |
Seth Forshee | 2c6e027 | 2015-03-11 17:26:41 -0500 | [diff] [blame] | 166 | bool is_buttonpad; /* is this device a button pad? */ |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 167 | bool serial_maybe; /* need to check for serial protocol */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 168 | |
| 169 | struct list_head applications; |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 170 | struct list_head reports; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 171 | }; |
| 172 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 173 | static void mt_post_parse_default_settings(struct mt_device *td, |
| 174 | struct mt_application *app); |
| 175 | static void mt_post_parse(struct mt_device *td, struct mt_application *app); |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 176 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 177 | /* classes of device behavior */ |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 178 | #define MT_CLS_DEFAULT 0x0001 |
| 179 | |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 180 | #define MT_CLS_SERIAL 0x0002 |
| 181 | #define MT_CLS_CONFIDENCE 0x0003 |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 182 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
| 183 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 |
| 184 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 |
| 185 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 |
Benjamin Tissoires | 0fa9c61 | 2014-02-28 11:41:23 -0500 | [diff] [blame] | 186 | /* reserved 0x0008 */ |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 187 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 188 | #define MT_CLS_NSMU 0x000a |
Benjamin Tissoires | 0fa9c61 | 2014-02-28 11:41:23 -0500 | [diff] [blame] | 189 | /* reserved 0x0010 */ |
| 190 | /* reserved 0x0011 */ |
Benjamin Tissoires | f961bd3 | 2013-08-22 14:51:08 +0200 | [diff] [blame] | 191 | #define MT_CLS_WIN_8 0x0012 |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 192 | #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 |
Masaki Ota | 504c932 | 2017-06-16 09:29:39 +0900 | [diff] [blame] | 193 | #define MT_CLS_WIN_8_DUAL 0x0014 |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 194 | |
| 195 | /* vendor specific classes */ |
| 196 | #define MT_CLS_3M 0x0101 |
Benjamin Tissoires | 0fa9c61 | 2014-02-28 11:41:23 -0500 | [diff] [blame] | 197 | /* reserved 0x0102 */ |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 198 | #define MT_CLS_EGALAX 0x0103 |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 199 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 200 | #define MT_CLS_TOPSEED 0x0105 |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 201 | #define MT_CLS_PANASONIC 0x0106 |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 202 | #define MT_CLS_FLATFROG 0x0107 |
Jiri Kosina | cdcd3ac | 2012-10-01 14:38:54 +0200 | [diff] [blame] | 203 | #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 |
| 204 | #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 |
Benjamin Tissoires | f3287a9 | 2017-01-30 10:48:06 +0100 | [diff] [blame] | 205 | #define MT_CLS_LG 0x010a |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 206 | #define MT_CLS_ASUS 0x010b |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 207 | #define MT_CLS_VTL 0x0110 |
Wei-Ning Huang | 0e82232 | 2017-06-21 10:43:25 +0800 | [diff] [blame] | 208 | #define MT_CLS_GOOGLE 0x0111 |
Benjamin Tissoires | 843e475 | 2018-03-20 12:04:46 +0100 | [diff] [blame] | 209 | #define MT_CLS_RAZER_BLADE_STEALTH 0x0112 |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 210 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 211 | #define MT_DEFAULT_MAXCONTACT 10 |
Benjamin Tissoires | afbcb04 | 2012-11-14 16:59:18 +0100 | [diff] [blame] | 212 | #define MT_MAX_MAXCONTACT 250 |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 213 | |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 214 | /* |
| 215 | * Resync device and local timestamps after that many microseconds without |
| 216 | * receiving data. |
| 217 | */ |
| 218 | #define MAX_TIMESTAMP_INTERVAL 1000000 |
| 219 | |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 220 | #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) |
| 221 | #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) |
| 222 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 223 | /* |
| 224 | * these device-dependent functions determine what slot corresponds |
| 225 | * to a valid contact that was just read. |
| 226 | */ |
| 227 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 228 | static int cypress_compute_slot(struct mt_application *application, |
| 229 | struct mt_usages *slot) |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 230 | { |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 231 | if (*slot->contactid != 0 || application->num_received == 0) |
| 232 | return *slot->contactid; |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 233 | else |
| 234 | return -1; |
| 235 | } |
| 236 | |
Benjamin Tissoires | cf6d15d | 2018-07-13 16:13:44 +0200 | [diff] [blame] | 237 | static const struct mt_class mt_classes[] = { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 238 | { .name = MT_CLS_DEFAULT, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 239 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 240 | MT_QUIRK_CONTACT_CNT_ACCURATE }, |
| 241 | { .name = MT_CLS_NSMU, |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 242 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 243 | { .name = MT_CLS_SERIAL, |
| 244 | .quirks = MT_QUIRK_ALWAYS_VALID}, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 245 | { .name = MT_CLS_CONFIDENCE, |
| 246 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 247 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
| 248 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
| 249 | MT_QUIRK_SLOT_IS_CONTACTID }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 250 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 251 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
| 252 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 253 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 254 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 255 | MT_QUIRK_SLOT_IS_CONTACTID, |
| 256 | .maxcontacts = 2 }, |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 257 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 258 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 259 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, |
| 260 | .maxcontacts = 2 }, |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 261 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
| 262 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 263 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, |
Benjamin Tissoires | f961bd3 | 2013-08-22 14:51:08 +0200 | [diff] [blame] | 264 | { .name = MT_CLS_WIN_8, |
| 265 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 266 | MT_QUIRK_IGNORE_DUPLICATES | |
| 267 | MT_QUIRK_HOVERING | |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 268 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
Benjamin Tissoires | d9c57a7 | 2018-03-20 12:04:45 +0100 | [diff] [blame] | 269 | MT_QUIRK_STICKY_FINGERS | |
| 270 | MT_QUIRK_WIN8_PTP_BUTTONS }, |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 271 | { .name = MT_CLS_EXPORT_ALL_INPUTS, |
| 272 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 273 | MT_QUIRK_CONTACT_CNT_ACCURATE, |
| 274 | .export_all_inputs = true }, |
Masaki Ota | 504c932 | 2017-06-16 09:29:39 +0900 | [diff] [blame] | 275 | { .name = MT_CLS_WIN_8_DUAL, |
| 276 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 277 | MT_QUIRK_IGNORE_DUPLICATES | |
| 278 | MT_QUIRK_HOVERING | |
Benjamin Tissoires | d9c57a7 | 2018-03-20 12:04:45 +0100 | [diff] [blame] | 279 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
| 280 | MT_QUIRK_WIN8_PTP_BUTTONS, |
Masaki Ota | 504c932 | 2017-06-16 09:29:39 +0900 | [diff] [blame] | 281 | .export_all_inputs = true }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 282 | |
| 283 | /* |
| 284 | * vendor specific classes |
| 285 | */ |
| 286 | { .name = MT_CLS_3M, |
| 287 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
HungNien Chen | e9d0a26 | 2017-03-06 11:30:14 +0800 | [diff] [blame] | 288 | MT_QUIRK_SLOT_IS_CONTACTID | |
| 289 | MT_QUIRK_TOUCH_SIZE_SCALING, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 290 | .sn_move = 2048, |
| 291 | .sn_width = 128, |
Henrik Rydberg | c5d40be | 2012-09-05 16:58:12 +0200 | [diff] [blame] | 292 | .sn_height = 128, |
| 293 | .maxcontacts = 60, |
| 294 | }, |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 295 | { .name = MT_CLS_EGALAX, |
| 296 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | |
Benjamin Tissoires | 2261bb9 | 2011-11-23 10:54:29 +0100 | [diff] [blame] | 297 | MT_QUIRK_VALID_IS_INRANGE, |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 298 | .sn_move = 4096, |
| 299 | .sn_pressure = 32, |
| 300 | }, |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 301 | { .name = MT_CLS_EGALAX_SERIAL, |
| 302 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | |
| 303 | MT_QUIRK_ALWAYS_VALID, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 304 | .sn_move = 4096, |
| 305 | .sn_pressure = 32, |
| 306 | }, |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 307 | { .name = MT_CLS_TOPSEED, |
| 308 | .quirks = MT_QUIRK_ALWAYS_VALID, |
| 309 | .is_indirect = true, |
| 310 | .maxcontacts = 2, |
| 311 | }, |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 312 | { .name = MT_CLS_PANASONIC, |
| 313 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, |
| 314 | .maxcontacts = 4 }, |
Xianhan Yu | f5ff4e1 | 2012-09-28 10:18:59 +0800 | [diff] [blame] | 315 | { .name = MT_CLS_GENERALTOUCH_TWOFINGERS, |
| 316 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | |
| 317 | MT_QUIRK_VALID_IS_INRANGE | |
Luosong | 7b22629 | 2013-10-02 11:20:00 +0200 | [diff] [blame] | 318 | MT_QUIRK_SLOT_IS_CONTACTID, |
Xianhan Yu | f5ff4e1 | 2012-09-28 10:18:59 +0800 | [diff] [blame] | 319 | .maxcontacts = 2 |
| 320 | }, |
| 321 | { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 322 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | |
Luosong | 7b22629 | 2013-10-02 11:20:00 +0200 | [diff] [blame] | 323 | MT_QUIRK_SLOT_IS_CONTACTID |
Xianhan Yu | f5ff4e1 | 2012-09-28 10:18:59 +0800 | [diff] [blame] | 324 | }, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 325 | |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 326 | { .name = MT_CLS_FLATFROG, |
| 327 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | |
| 328 | MT_QUIRK_NO_AREA, |
| 329 | .sn_move = 2048, |
| 330 | .maxcontacts = 40, |
| 331 | }, |
Benjamin Tissoires | f3287a9 | 2017-01-30 10:48:06 +0100 | [diff] [blame] | 332 | { .name = MT_CLS_LG, |
| 333 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 334 | MT_QUIRK_FIX_CONST_CONTACT_ID | |
| 335 | MT_QUIRK_IGNORE_DUPLICATES | |
| 336 | MT_QUIRK_HOVERING | |
| 337 | MT_QUIRK_CONTACT_CNT_ACCURATE }, |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 338 | { .name = MT_CLS_ASUS, |
| 339 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 340 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
| 341 | MT_QUIRK_ASUS_CUSTOM_UP }, |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 342 | { .name = MT_CLS_VTL, |
| 343 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 344 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
| 345 | MT_QUIRK_FORCE_GET_FEATURE, |
| 346 | }, |
Wei-Ning Huang | 0e82232 | 2017-06-21 10:43:25 +0800 | [diff] [blame] | 347 | { .name = MT_CLS_GOOGLE, |
| 348 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 349 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
| 350 | MT_QUIRK_SLOT_IS_CONTACTID | |
| 351 | MT_QUIRK_HOVERING |
| 352 | }, |
Benjamin Tissoires | 843e475 | 2018-03-20 12:04:46 +0100 | [diff] [blame] | 353 | { .name = MT_CLS_RAZER_BLADE_STEALTH, |
| 354 | .quirks = MT_QUIRK_ALWAYS_VALID | |
| 355 | MT_QUIRK_IGNORE_DUPLICATES | |
| 356 | MT_QUIRK_HOVERING | |
| 357 | MT_QUIRK_CONTACT_CNT_ACCURATE | |
| 358 | MT_QUIRK_WIN8_PTP_BUTTONS, |
| 359 | }, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 360 | { } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 361 | }; |
| 362 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 363 | static ssize_t mt_show_quirks(struct device *dev, |
| 364 | struct device_attribute *attr, |
| 365 | char *buf) |
| 366 | { |
Geliang Tang | ee79a8f | 2015-12-27 17:25:21 +0800 | [diff] [blame] | 367 | struct hid_device *hdev = to_hid_device(dev); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 368 | struct mt_device *td = hid_get_drvdata(hdev); |
| 369 | |
| 370 | return sprintf(buf, "%u\n", td->mtclass.quirks); |
| 371 | } |
| 372 | |
| 373 | static ssize_t mt_set_quirks(struct device *dev, |
| 374 | struct device_attribute *attr, |
| 375 | const char *buf, size_t count) |
| 376 | { |
Geliang Tang | ee79a8f | 2015-12-27 17:25:21 +0800 | [diff] [blame] | 377 | struct hid_device *hdev = to_hid_device(dev); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 378 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 379 | struct mt_application *application; |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 380 | |
| 381 | unsigned long val; |
| 382 | |
| 383 | if (kstrtoul(buf, 0, &val)) |
| 384 | return -EINVAL; |
| 385 | |
| 386 | td->mtclass.quirks = val; |
| 387 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 388 | list_for_each_entry(application, &td->applications, list) { |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 389 | application->quirks = val; |
| 390 | if (!application->have_contact_count) |
| 391 | application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 394 | return count; |
| 395 | } |
| 396 | |
| 397 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); |
| 398 | |
| 399 | static struct attribute *sysfs_attrs[] = { |
| 400 | &dev_attr_quirks.attr, |
| 401 | NULL |
| 402 | }; |
| 403 | |
Arvind Yadav | 9182fb9 | 2017-08-03 16:56:43 +0530 | [diff] [blame] | 404 | static const struct attribute_group mt_attribute_group = { |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 405 | .attrs = sysfs_attrs |
| 406 | }; |
| 407 | |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 408 | static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) |
| 409 | { |
Aaron Ma | 3064a03 | 2018-02-03 23:57:15 +0800 | [diff] [blame] | 410 | int ret; |
| 411 | u32 size = hid_report_len(report); |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 412 | u8 *buf; |
| 413 | |
| 414 | /* |
Benjamin Tissoires | b897f6d | 2016-11-25 14:27:22 +0100 | [diff] [blame] | 415 | * Do not fetch the feature report if the device has been explicitly |
| 416 | * marked as non-capable. |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 417 | */ |
Benjamin Tissoires | adaabbf | 2018-03-20 12:04:50 +0100 | [diff] [blame] | 418 | if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 419 | return; |
| 420 | |
| 421 | buf = hid_alloc_report_buf(report, GFP_KERNEL); |
| 422 | if (!buf) |
| 423 | return; |
| 424 | |
| 425 | ret = hid_hw_raw_request(hdev, report->id, buf, size, |
| 426 | HID_FEATURE_REPORT, HID_REQ_GET_REPORT); |
| 427 | if (ret < 0) { |
| 428 | dev_warn(&hdev->dev, "failed to fetch feature %d\n", |
| 429 | report->id); |
| 430 | } else { |
| 431 | ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf, |
| 432 | size, 0); |
| 433 | if (ret) |
| 434 | dev_warn(&hdev->dev, "failed to report feature\n"); |
| 435 | } |
| 436 | |
| 437 | kfree(buf); |
| 438 | } |
| 439 | |
Henrik Rydberg | f635bd1 | 2011-02-24 19:30:59 +0100 | [diff] [blame] | 440 | static void mt_feature_mapping(struct hid_device *hdev, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 441 | struct hid_field *field, struct hid_usage *usage) |
| 442 | { |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 443 | struct mt_device *td = hid_get_drvdata(hdev); |
| 444 | |
| 445 | switch (usage->hid) { |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 446 | case HID_DG_CONTACTMAX: |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 447 | mt_get_feature(hdev, field->report); |
| 448 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 449 | td->maxcontacts = field->value[0]; |
Benjamin Tissoires | afbcb04 | 2012-11-14 16:59:18 +0100 | [diff] [blame] | 450 | if (!td->maxcontacts && |
| 451 | field->logical_maximum <= MT_MAX_MAXCONTACT) |
| 452 | td->maxcontacts = field->logical_maximum; |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 453 | if (td->mtclass.maxcontacts) |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 454 | /* check if the maxcontacts is given by the class */ |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 455 | td->maxcontacts = td->mtclass.maxcontacts; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 456 | |
| 457 | break; |
Seth Forshee | 2c6e027 | 2015-03-11 17:26:41 -0500 | [diff] [blame] | 458 | case HID_DG_BUTTONTYPE: |
| 459 | if (usage->usage_index >= field->report_count) { |
| 460 | dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); |
| 461 | break; |
| 462 | } |
| 463 | |
Mika Westerberg | 6d4f544 | 2015-10-07 15:33:43 +0300 | [diff] [blame] | 464 | mt_get_feature(hdev, field->report); |
Seth Forshee | 2c6e027 | 2015-03-11 17:26:41 -0500 | [diff] [blame] | 465 | if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) |
| 466 | td->is_buttonpad = true; |
| 467 | |
| 468 | break; |
Benjamin Tissoires | 45c5c68 | 2016-03-07 11:02:38 +0100 | [diff] [blame] | 469 | case 0xff0000c5: |
| 470 | /* Retrieve the Win8 blob once to enable some devices */ |
| 471 | if (usage->usage_index == 0) |
| 472 | mt_get_feature(hdev, field->report); |
| 473 | break; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 474 | } |
| 475 | } |
| 476 | |
| 477 | static void set_abs(struct input_dev *input, unsigned int code, |
| 478 | struct hid_field *field, int snratio) |
| 479 | { |
| 480 | int fmin = field->logical_minimum; |
| 481 | int fmax = field->logical_maximum; |
| 482 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; |
| 483 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); |
Benjamin Tissoires | 37cf6e6 | 2012-11-14 16:59:13 +0100 | [diff] [blame] | 484 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 485 | } |
| 486 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 487 | static struct mt_usages *mt_allocate_usage(struct hid_device *hdev, |
| 488 | struct mt_application *application) |
| 489 | { |
| 490 | struct mt_usages *usage; |
| 491 | |
| 492 | usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); |
| 493 | if (!usage) |
| 494 | return NULL; |
| 495 | |
| 496 | /* set some defaults so we do not need to check for null pointers */ |
| 497 | usage->x = DEFAULT_ZERO; |
| 498 | usage->y = DEFAULT_ZERO; |
| 499 | usage->cx = DEFAULT_ZERO; |
| 500 | usage->cy = DEFAULT_ZERO; |
| 501 | usage->p = DEFAULT_ZERO; |
| 502 | usage->w = DEFAULT_ZERO; |
| 503 | usage->h = DEFAULT_ZERO; |
| 504 | usage->a = DEFAULT_ZERO; |
| 505 | usage->contactid = DEFAULT_ZERO; |
| 506 | usage->tip_state = DEFAULT_FALSE; |
| 507 | usage->inrange_state = DEFAULT_FALSE; |
| 508 | usage->confidence_state = DEFAULT_TRUE; |
| 509 | |
| 510 | list_add_tail(&usage->list, &application->mt_usages); |
| 511 | |
| 512 | return usage; |
| 513 | } |
| 514 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 515 | static struct mt_application *mt_allocate_application(struct mt_device *td, |
| 516 | unsigned int application) |
| 517 | { |
| 518 | struct mt_application *mt_application; |
| 519 | |
| 520 | mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), |
| 521 | GFP_KERNEL); |
| 522 | if (!mt_application) |
| 523 | return NULL; |
| 524 | |
| 525 | mt_application->application = application; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 526 | INIT_LIST_HEAD(&mt_application->mt_usages); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 527 | |
| 528 | if (application == HID_DG_TOUCHSCREEN) |
| 529 | mt_application->mt_flags |= INPUT_MT_DIRECT; |
| 530 | |
| 531 | /* |
| 532 | * Model touchscreens providing buttons as touchpads. |
| 533 | */ |
| 534 | if (application == HID_DG_TOUCHPAD) { |
| 535 | mt_application->mt_flags |= INPUT_MT_POINTER; |
| 536 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; |
| 537 | } |
| 538 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 539 | mt_application->scantime = DEFAULT_ZERO; |
| 540 | mt_application->raw_cc = DEFAULT_ZERO; |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 541 | mt_application->quirks = td->mtclass.quirks; |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 542 | |
| 543 | list_add_tail(&mt_application->list, &td->applications); |
| 544 | |
| 545 | return mt_application; |
| 546 | } |
| 547 | |
| 548 | static struct mt_application *mt_find_application(struct mt_device *td, |
| 549 | unsigned int application) |
| 550 | { |
| 551 | struct mt_application *tmp, *mt_application = NULL; |
| 552 | |
| 553 | list_for_each_entry(tmp, &td->applications, list) { |
| 554 | if (application == tmp->application) { |
| 555 | mt_application = tmp; |
| 556 | break; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | if (!mt_application) |
| 561 | mt_application = mt_allocate_application(td, application); |
| 562 | |
| 563 | return mt_application; |
| 564 | } |
| 565 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 566 | static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, |
| 567 | struct hid_report *report) |
| 568 | { |
| 569 | struct mt_report_data *rdata; |
| 570 | struct hid_field *field; |
| 571 | int r, n; |
| 572 | |
| 573 | rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); |
| 574 | if (!rdata) |
| 575 | return NULL; |
| 576 | |
| 577 | rdata->report = report; |
| 578 | rdata->application = mt_find_application(td, report->application); |
| 579 | |
| 580 | if (!rdata->application) { |
| 581 | devm_kfree(&td->hdev->dev, rdata); |
| 582 | return NULL; |
| 583 | } |
| 584 | |
| 585 | for (r = 0; r < report->maxfield; r++) { |
| 586 | field = report->field[r]; |
| 587 | |
| 588 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 589 | continue; |
| 590 | |
| 591 | for (n = 0; n < field->report_count; n++) { |
| 592 | if (field->usage[n].hid == HID_DG_CONTACTID) |
| 593 | rdata->is_mt_collection = true; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | list_add_tail(&rdata->list, &td->reports); |
| 598 | |
| 599 | return rdata; |
| 600 | } |
| 601 | |
| 602 | static struct mt_report_data *mt_find_report_data(struct mt_device *td, |
| 603 | struct hid_report *report) |
| 604 | { |
| 605 | struct mt_report_data *tmp, *rdata = NULL; |
| 606 | |
| 607 | list_for_each_entry(tmp, &td->reports, list) { |
| 608 | if (report == tmp->report) { |
| 609 | rdata = tmp; |
| 610 | break; |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | if (!rdata) |
| 615 | rdata = mt_allocate_report_data(td, report); |
| 616 | |
| 617 | return rdata; |
| 618 | } |
| 619 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 620 | static void mt_store_field(struct hid_device *hdev, |
| 621 | struct mt_application *application, |
| 622 | __s32 *value, |
| 623 | size_t offset) |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 624 | { |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 625 | struct mt_usages *usage; |
| 626 | __s32 **target; |
Benjamin Tissoires | 3ac36d1 | 2012-05-04 14:53:46 +0200 | [diff] [blame] | 627 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 628 | if (list_empty(&application->mt_usages)) |
| 629 | usage = mt_allocate_usage(hdev, application); |
| 630 | else |
| 631 | usage = list_last_entry(&application->mt_usages, |
| 632 | struct mt_usages, |
| 633 | list); |
| 634 | |
| 635 | if (!usage) |
Benjamin Tissoires | 3ac36d1 | 2012-05-04 14:53:46 +0200 | [diff] [blame] | 636 | return; |
| 637 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 638 | target = (__s32 **)((char *)usage + offset); |
| 639 | |
| 640 | /* the value has already been filled, create a new slot */ |
| 641 | if (*target != DEFAULT_TRUE && |
| 642 | *target != DEFAULT_FALSE && |
| 643 | *target != DEFAULT_ZERO) { |
Benjamin Tissoires | fa212dd | 2019-05-21 15:38:31 +0200 | [diff] [blame^] | 644 | if (usage->contactid == DEFAULT_ZERO || |
| 645 | usage->x == DEFAULT_ZERO || |
| 646 | usage->y == DEFAULT_ZERO) { |
| 647 | hid_dbg(hdev, |
| 648 | "ignoring duplicate usage on incomplete"); |
| 649 | return; |
| 650 | } |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 651 | usage = mt_allocate_usage(hdev, application); |
| 652 | if (!usage) |
| 653 | return; |
| 654 | |
| 655 | target = (__s32 **)((char *)usage + offset); |
| 656 | } |
| 657 | |
| 658 | *target = value; |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 659 | } |
| 660 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 661 | #define MT_STORE_FIELD(__name) \ |
| 662 | mt_store_field(hdev, app, \ |
| 663 | &field->value[usage->usage_index], \ |
| 664 | offsetof(struct mt_usages, __name)) |
| 665 | |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 666 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 667 | struct hid_field *field, struct hid_usage *usage, |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 668 | unsigned long **bit, int *max, struct mt_application *app) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 669 | { |
| 670 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 671 | struct mt_class *cls = &td->mtclass; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 672 | int code; |
Benjamin Tissoires | 349fd670 | 2012-11-14 16:59:19 +0100 | [diff] [blame] | 673 | struct hid_usage *prev_usage = NULL; |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 674 | |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 675 | /* |
| 676 | * Model touchscreens providing buttons as touchpads. |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 677 | */ |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 678 | if (field->application == HID_DG_TOUCHSCREEN && |
| 679 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 680 | app->mt_flags |= INPUT_MT_POINTER; |
Andrew Duggan | 9abebed | 2014-03-19 13:39:03 -0700 | [diff] [blame] | 681 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; |
| 682 | } |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 683 | |
Benjamin Tissoires | 015fdaa | 2015-03-06 11:14:42 -0500 | [diff] [blame] | 684 | /* count the buttons on touchpads */ |
| 685 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 686 | app->buttons_count++; |
Benjamin Tissoires | 015fdaa | 2015-03-06 11:14:42 -0500 | [diff] [blame] | 687 | |
Benjamin Tissoires | 349fd670 | 2012-11-14 16:59:19 +0100 | [diff] [blame] | 688 | if (usage->usage_index) |
| 689 | prev_usage = &field->usage[usage->usage_index - 1]; |
| 690 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 691 | switch (usage->hid & HID_USAGE_PAGE) { |
| 692 | |
| 693 | case HID_UP_GENDESK: |
| 694 | switch (usage->hid) { |
| 695 | case HID_GD_X: |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 696 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 697 | code = ABS_MT_TOOL_X; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 698 | MT_STORE_FIELD(cx); |
| 699 | } else { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 700 | code = ABS_MT_POSITION_X; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 701 | MT_STORE_FIELD(x); |
| 702 | } |
Benjamin Tissoires | 349fd670 | 2012-11-14 16:59:19 +0100 | [diff] [blame] | 703 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 704 | set_abs(hi->input, code, field, cls->sn_move); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 705 | |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 706 | /* |
| 707 | * A system multi-axis that exports X and Y has a high |
| 708 | * chance of being used directly on a surface |
| 709 | */ |
| 710 | if (field->application == HID_GD_SYSTEM_MULTIAXIS) { |
| 711 | __set_bit(INPUT_PROP_DIRECT, |
| 712 | hi->input->propbit); |
| 713 | input_set_abs_params(hi->input, |
| 714 | ABS_MT_TOOL_TYPE, |
| 715 | MT_TOOL_DIAL, |
| 716 | MT_TOOL_DIAL, 0, 0); |
| 717 | } |
| 718 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 719 | return 1; |
| 720 | case HID_GD_Y: |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 721 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 722 | code = ABS_MT_TOOL_Y; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 723 | MT_STORE_FIELD(cy); |
| 724 | } else { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 725 | code = ABS_MT_POSITION_Y; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 726 | MT_STORE_FIELD(y); |
| 727 | } |
Benjamin Tissoires | 349fd670 | 2012-11-14 16:59:19 +0100 | [diff] [blame] | 728 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 729 | set_abs(hi->input, code, field, cls->sn_move); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 730 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 731 | return 1; |
| 732 | } |
| 733 | return 0; |
| 734 | |
| 735 | case HID_UP_DIGITIZER: |
| 736 | switch (usage->hid) { |
| 737 | case HID_DG_INRANGE: |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 738 | if (app->quirks & MT_QUIRK_HOVERING) { |
Benjamin Tissoires | 9b3bb9b8 | 2012-11-14 16:59:24 +0100 | [diff] [blame] | 739 | input_set_abs_params(hi->input, |
| 740 | ABS_MT_DISTANCE, 0, 1, 0, 0); |
| 741 | } |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 742 | MT_STORE_FIELD(inrange_state); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 743 | return 1; |
| 744 | case HID_DG_CONFIDENCE: |
Masaki Ota | 504c932 | 2017-06-16 09:29:39 +0900 | [diff] [blame] | 745 | if ((cls->name == MT_CLS_WIN_8 || |
| 746 | cls->name == MT_CLS_WIN_8_DUAL) && |
Dmitry Torokhov | f902437 | 2018-07-13 16:13:53 +0200 | [diff] [blame] | 747 | (field->application == HID_DG_TOUCHPAD || |
| 748 | field->application == HID_DG_TOUCHSCREEN)) |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 749 | app->quirks |= MT_QUIRK_CONFIDENCE; |
Dmitry Torokhov | 9152c7d | 2018-07-13 16:13:52 +0200 | [diff] [blame] | 750 | |
| 751 | if (app->quirks & MT_QUIRK_CONFIDENCE) |
| 752 | input_set_abs_params(hi->input, |
| 753 | ABS_MT_TOOL_TYPE, |
| 754 | MT_TOOL_FINGER, |
| 755 | MT_TOOL_PALM, 0, 0); |
| 756 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 757 | MT_STORE_FIELD(confidence_state); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 758 | return 1; |
| 759 | case HID_DG_TIPSWITCH: |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 760 | if (field->application != HID_GD_SYSTEM_MULTIAXIS) |
| 761 | input_set_capability(hi->input, |
| 762 | EV_KEY, BTN_TOUCH); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 763 | MT_STORE_FIELD(tip_state); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 764 | return 1; |
| 765 | case HID_DG_CONTACTID: |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 766 | MT_STORE_FIELD(contactid); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 767 | app->touches_by_report++; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 768 | return 1; |
| 769 | case HID_DG_WIDTH: |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 770 | if (!(app->quirks & MT_QUIRK_NO_AREA)) |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 771 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, |
| 772 | cls->sn_width); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 773 | MT_STORE_FIELD(w); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 774 | return 1; |
| 775 | case HID_DG_HEIGHT: |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 776 | if (!(app->quirks & MT_QUIRK_NO_AREA)) { |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 777 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, |
| 778 | cls->sn_height); |
Wei-Ning Huang | 0072027 | 2017-10-12 14:21:43 +0800 | [diff] [blame] | 779 | |
| 780 | /* |
| 781 | * Only set ABS_MT_ORIENTATION if it is not |
| 782 | * already set by the HID_DG_AZIMUTH usage. |
| 783 | */ |
| 784 | if (!test_bit(ABS_MT_ORIENTATION, |
| 785 | hi->input->absbit)) |
| 786 | input_set_abs_params(hi->input, |
| 787 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 788 | } |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 789 | MT_STORE_FIELD(h); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 790 | return 1; |
| 791 | case HID_DG_TIPPRESSURE: |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 792 | set_abs(hi->input, ABS_MT_PRESSURE, field, |
| 793 | cls->sn_pressure); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 794 | MT_STORE_FIELD(p); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 795 | return 1; |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 796 | case HID_DG_SCANTIME: |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 797 | input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 798 | app->scantime = &field->value[usage->usage_index]; |
| 799 | app->scantime_logical_max = field->logical_maximum; |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 800 | return 1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 801 | case HID_DG_CONTACTCOUNT: |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 802 | app->have_contact_count = true; |
| 803 | app->raw_cc = &field->value[usage->usage_index]; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 804 | return 1; |
Wei-Ning Huang | 0072027 | 2017-10-12 14:21:43 +0800 | [diff] [blame] | 805 | case HID_DG_AZIMUTH: |
Wei-Ning Huang | 0072027 | 2017-10-12 14:21:43 +0800 | [diff] [blame] | 806 | /* |
| 807 | * Azimuth has the range of [0, MAX) representing a full |
| 808 | * revolution. Set ABS_MT_ORIENTATION to a quarter of |
| 809 | * MAX according the definition of ABS_MT_ORIENTATION |
| 810 | */ |
| 811 | input_set_abs_params(hi->input, ABS_MT_ORIENTATION, |
| 812 | -field->logical_maximum / 4, |
| 813 | field->logical_maximum / 4, |
| 814 | cls->sn_move ? |
| 815 | field->logical_maximum / cls->sn_move : 0, 0); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 816 | MT_STORE_FIELD(a); |
Wei-Ning Huang | 0072027 | 2017-10-12 14:21:43 +0800 | [diff] [blame] | 817 | return 1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 818 | case HID_DG_CONTACTMAX: |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 819 | /* contact max are global to the report */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 820 | return -1; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 821 | case HID_DG_TOUCH: |
| 822 | /* Legacy devices use TIPSWITCH and not TOUCH. |
| 823 | * Let's just ignore this field. */ |
| 824 | return -1; |
Alan Cox | 65b258e | 2012-10-25 15:35:25 +0100 | [diff] [blame] | 825 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 826 | /* let hid-input decide for the others */ |
| 827 | return 0; |
| 828 | |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 829 | case HID_UP_BUTTON: |
| 830 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); |
Benjamin Tissoires | 594312b | 2016-11-25 11:08:10 +0100 | [diff] [blame] | 831 | /* |
| 832 | * MS PTP spec says that external buttons left and right have |
| 833 | * usages 2 and 3. |
| 834 | */ |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 835 | if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
Benjamin Tissoires | 594312b | 2016-11-25 11:08:10 +0100 | [diff] [blame] | 836 | field->application == HID_DG_TOUCHPAD && |
| 837 | (usage->hid & HID_USAGE) > 1) |
| 838 | code--; |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 839 | |
| 840 | if (field->application == HID_GD_SYSTEM_MULTIAXIS) |
| 841 | code = BTN_0 + ((usage->hid - 1) & HID_USAGE); |
| 842 | |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 843 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); |
| 844 | input_set_capability(hi->input, EV_KEY, code); |
| 845 | return 1; |
| 846 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 847 | case 0xff000000: |
| 848 | /* we do not want to map these: no input-oriented meaning */ |
| 849 | return -1; |
| 850 | } |
| 851 | |
| 852 | return 0; |
| 853 | } |
| 854 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 855 | static int mt_compute_slot(struct mt_device *td, struct mt_application *app, |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 856 | struct mt_usages *slot, |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 857 | struct input_dev *input) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 858 | { |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 859 | __s32 quirks = app->quirks; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 860 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 861 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 862 | return *slot->contactid; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 863 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 864 | if (quirks & MT_QUIRK_CYPRESS) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 865 | return cypress_compute_slot(app, slot); |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 866 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 867 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 868 | return app->num_received; |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 869 | |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 870 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 871 | return *slot->contactid - 1; |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 872 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 873 | return input_mt_get_slot_by_key(input, *slot->contactid); |
Henrik Rydberg | 3e1b501 | 2012-09-01 19:46:58 +0200 | [diff] [blame] | 874 | } |
| 875 | |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 876 | static void mt_release_pending_palms(struct mt_device *td, |
| 877 | struct mt_application *app, |
| 878 | struct input_dev *input) |
| 879 | { |
| 880 | int slotnum; |
| 881 | bool need_sync = false; |
| 882 | |
| 883 | for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { |
| 884 | clear_bit(slotnum, app->pending_palm_slots); |
| 885 | |
| 886 | input_mt_slot(input, slotnum); |
| 887 | input_mt_report_slot_state(input, MT_TOOL_PALM, false); |
| 888 | |
| 889 | need_sync = true; |
| 890 | } |
| 891 | |
| 892 | if (need_sync) { |
| 893 | input_mt_sync_frame(input); |
| 894 | input_sync(input); |
| 895 | } |
| 896 | } |
| 897 | |
Henrik Rydberg | 3e1b501 | 2012-09-01 19:46:58 +0200 | [diff] [blame] | 898 | /* |
| 899 | * this function is called when a whole packet has been received and processed, |
| 900 | * so that it can decide what to send to the input layer. |
| 901 | */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 902 | static void mt_sync_frame(struct mt_device *td, struct mt_application *app, |
| 903 | struct input_dev *input) |
Henrik Rydberg | 3e1b501 | 2012-09-01 19:46:58 +0200 | [diff] [blame] | 904 | { |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 905 | if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 906 | input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); |
Hans de Goede | 127e71b | 2017-11-22 12:57:10 +0100 | [diff] [blame] | 907 | |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 908 | input_mt_sync_frame(input); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 909 | input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 910 | input_sync(input); |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 911 | |
| 912 | mt_release_pending_palms(td, app, input); |
| 913 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 914 | app->num_received = 0; |
| 915 | app->left_button_state = 0; |
| 916 | |
Benjamin Tissoires | 9609827 | 2017-06-15 15:32:05 +0200 | [diff] [blame] | 917 | if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) |
| 918 | set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); |
| 919 | else |
| 920 | clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); |
| 921 | clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 922 | } |
| 923 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 924 | static int mt_compute_timestamp(struct mt_application *app, __s32 value) |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 925 | { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 926 | long delta = value - app->prev_scantime; |
| 927 | unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 928 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 929 | app->jiffies = jiffies; |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 930 | |
| 931 | if (delta < 0) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 932 | delta += app->scantime_logical_max; |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 933 | |
| 934 | /* HID_DG_SCANTIME is expressed in 100us, we want it in us. */ |
| 935 | delta *= 100; |
| 936 | |
| 937 | if (jdelta > MAX_TIMESTAMP_INTERVAL) |
| 938 | /* No data received for a while, resync the timestamp. */ |
| 939 | return 0; |
| 940 | else |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 941 | return app->timestamp + delta; |
Nicolas Boichat | 29cc309 | 2017-08-22 09:10:11 +0800 | [diff] [blame] | 942 | } |
| 943 | |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 944 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 945 | struct hid_usage *usage, __s32 value) |
| 946 | { |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 947 | /* we will handle the hidinput part later, now remains hiddev */ |
| 948 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) |
| 949 | hid->hiddev_hid_event(hid, field, usage, value); |
| 950 | |
| 951 | return 1; |
| 952 | } |
| 953 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 954 | static int mt_process_slot(struct mt_device *td, struct input_dev *input, |
| 955 | struct mt_application *app, |
| 956 | struct mt_usages *slot) |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 957 | { |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 958 | struct input_mt *mt = input->mt; |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 959 | __s32 quirks = app->quirks; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 960 | bool valid = true; |
| 961 | bool confidence_state = true; |
| 962 | bool inrange_state = false; |
| 963 | int active; |
| 964 | int slotnum; |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 965 | int tool = MT_TOOL_FINGER; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 966 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 967 | if (!slot) |
| 968 | return -EINVAL; |
| 969 | |
| 970 | if ((quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && |
| 971 | app->num_received >= app->num_expected) |
| 972 | return -EAGAIN; |
| 973 | |
| 974 | if (!(quirks & MT_QUIRK_ALWAYS_VALID)) { |
| 975 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
| 976 | valid = *slot->inrange_state; |
| 977 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
| 978 | valid = *slot->tip_state; |
| 979 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
| 980 | valid = *slot->confidence_state; |
| 981 | |
| 982 | if (!valid) |
| 983 | return 0; |
| 984 | } |
| 985 | |
| 986 | slotnum = mt_compute_slot(td, app, slot, input); |
| 987 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
| 988 | return 0; |
| 989 | |
| 990 | if ((quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { |
| 991 | struct input_mt_slot *i_slot = &mt->slots[slotnum]; |
| 992 | |
| 993 | if (input_mt_is_active(i_slot) && |
| 994 | input_mt_is_used(mt, i_slot)) |
| 995 | return -EAGAIN; |
| 996 | } |
| 997 | |
| 998 | if (quirks & MT_QUIRK_CONFIDENCE) |
| 999 | confidence_state = *slot->confidence_state; |
| 1000 | |
| 1001 | if (quirks & MT_QUIRK_HOVERING) |
| 1002 | inrange_state = *slot->inrange_state; |
| 1003 | |
Dmitry Torokhov | 9152c7d | 2018-07-13 16:13:52 +0200 | [diff] [blame] | 1004 | active = *slot->tip_state || inrange_state; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1005 | |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1006 | if (app->application == HID_GD_SYSTEM_MULTIAXIS) |
| 1007 | tool = MT_TOOL_DIAL; |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 1008 | else if (unlikely(!confidence_state)) { |
Dmitry Torokhov | 9152c7d | 2018-07-13 16:13:52 +0200 | [diff] [blame] | 1009 | tool = MT_TOOL_PALM; |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 1010 | if (!active && |
| 1011 | input_mt_is_active(&mt->slots[slotnum])) { |
| 1012 | /* |
| 1013 | * The non-confidence was reported for |
| 1014 | * previously valid contact that is also no |
| 1015 | * longer valid. We can't simply report |
| 1016 | * lift-off as userspace will not be aware |
| 1017 | * of non-confidence, so we need to split |
| 1018 | * it into 2 events: active MT_TOOL_PALM |
| 1019 | * and a separate liftoff. |
| 1020 | */ |
| 1021 | active = true; |
| 1022 | set_bit(slotnum, app->pending_palm_slots); |
| 1023 | } |
| 1024 | } |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1025 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1026 | input_mt_slot(input, slotnum); |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1027 | input_mt_report_slot_state(input, tool, active); |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1028 | if (active) { |
| 1029 | /* this finger is in proximity of the sensor */ |
| 1030 | int wide = (*slot->w > *slot->h); |
| 1031 | int major = max(*slot->w, *slot->h); |
| 1032 | int minor = min(*slot->w, *slot->h); |
| 1033 | int orientation = wide; |
| 1034 | int max_azimuth; |
| 1035 | int azimuth; |
| 1036 | |
| 1037 | if (slot->a != DEFAULT_ZERO) { |
Wei-Ning Huang | 0072027 | 2017-10-12 14:21:43 +0800 | [diff] [blame] | 1038 | /* |
| 1039 | * Azimuth is counter-clockwise and ranges from [0, MAX) |
| 1040 | * (a full revolution). Convert it to clockwise ranging |
| 1041 | * [-MAX/2, MAX/2]. |
| 1042 | * |
| 1043 | * Note that ABS_MT_ORIENTATION require us to report |
| 1044 | * the limit of [-MAX/4, MAX/4], but the value can go |
| 1045 | * out of range to [-MAX/2, MAX/2] to report an upside |
| 1046 | * down ellipsis. |
| 1047 | */ |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1048 | azimuth = *slot->a; |
| 1049 | max_azimuth = input_abs_get_max(input, |
| 1050 | ABS_MT_ORIENTATION); |
| 1051 | if (azimuth > max_azimuth * 2) |
| 1052 | azimuth -= max_azimuth * 4; |
| 1053 | orientation = -azimuth; |
| 1054 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1055 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1056 | if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { |
Dmitry Torokhov | 9152c7d | 2018-07-13 16:13:52 +0200 | [diff] [blame] | 1057 | /* |
| 1058 | * divided by two to match visual scale of touch |
| 1059 | * for devices with this quirk |
| 1060 | */ |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1061 | major = major >> 1; |
| 1062 | minor = minor >> 1; |
| 1063 | } |
Hans de Goede | 55746d2 | 2017-11-22 12:57:09 +0100 | [diff] [blame] | 1064 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1065 | input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); |
| 1066 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); |
| 1067 | input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); |
| 1068 | input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); |
| 1069 | input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); |
| 1070 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, orientation); |
| 1071 | input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); |
| 1072 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
| 1073 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); |
Hans de Goede | 127e71b | 2017-11-22 12:57:10 +0100 | [diff] [blame] | 1074 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1075 | set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); |
| 1076 | } |
| 1077 | |
| 1078 | return 0; |
| 1079 | } |
| 1080 | |
| 1081 | static void mt_process_mt_event(struct hid_device *hid, |
| 1082 | struct mt_application *app, |
| 1083 | struct hid_field *field, |
| 1084 | struct hid_usage *usage, |
| 1085 | __s32 value, |
| 1086 | bool first_packet) |
| 1087 | { |
| 1088 | __s32 quirks = app->quirks; |
| 1089 | struct input_dev *input = field->hidinput->input; |
| 1090 | |
| 1091 | if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) |
| 1092 | return; |
| 1093 | |
| 1094 | if (quirks & MT_QUIRK_WIN8_PTP_BUTTONS) { |
| 1095 | |
| 1096 | /* |
| 1097 | * For Win8 PTP touchpads we should only look at |
| 1098 | * non finger/touch events in the first_packet of a |
| 1099 | * (possible) multi-packet frame. |
| 1100 | */ |
| 1101 | if (!first_packet) |
| 1102 | return; |
| 1103 | |
| 1104 | /* |
| 1105 | * For Win8 PTP touchpads we map both the clickpad click |
| 1106 | * and any "external" left buttons to BTN_LEFT if a |
| 1107 | * device claims to have both we need to report 1 for |
| 1108 | * BTN_LEFT if either is pressed, so we or all values |
| 1109 | * together and report the result in mt_sync_frame(). |
| 1110 | */ |
| 1111 | if (usage->type == EV_KEY && usage->code == BTN_LEFT) { |
| 1112 | app->left_button_state |= value; |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1113 | return; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1114 | } |
| 1115 | } |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1116 | |
| 1117 | input_event(input, usage->type, usage->code, value); |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1118 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1119 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1120 | static void mt_touch_report(struct hid_device *hid, |
| 1121 | struct mt_report_data *rdata) |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1122 | { |
| 1123 | struct mt_device *td = hid_get_drvdata(hid); |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1124 | struct hid_report *report = rdata->report; |
| 1125 | struct mt_application *app = rdata->application; |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1126 | struct hid_field *field; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1127 | struct input_dev *input; |
| 1128 | struct mt_usages *slot; |
Hans de Goede | 55746d2 | 2017-11-22 12:57:09 +0100 | [diff] [blame] | 1129 | bool first_packet; |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1130 | unsigned count; |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1131 | int r, n; |
| 1132 | int scantime = 0; |
| 1133 | int contact_count = -1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1134 | |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1135 | /* sticky fingers release in progress, abort */ |
| 1136 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) |
| 1137 | return; |
| 1138 | |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1139 | scantime = *app->scantime; |
| 1140 | app->timestamp = mt_compute_timestamp(app, scantime); |
| 1141 | if (app->raw_cc != DEFAULT_ZERO) |
| 1142 | contact_count = *app->raw_cc; |
| 1143 | |
Benjamin Tissoires | c2517f6 | 2013-01-31 17:22:25 +0100 | [diff] [blame] | 1144 | /* |
| 1145 | * Includes multi-packet support where subsequent |
| 1146 | * packets are sent with zero contactcount. |
| 1147 | */ |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1148 | if (contact_count >= 0) { |
Hans de Goede | af8dc4d | 2017-11-22 12:57:08 +0100 | [diff] [blame] | 1149 | /* |
| 1150 | * For Win8 PTPs the first packet (td->num_received == 0) may |
| 1151 | * have a contactcount of 0 if there only is a button event. |
| 1152 | * We double check that this is not a continuation packet |
| 1153 | * of a possible multi-packet frame be checking that the |
| 1154 | * timestamp has changed. |
| 1155 | */ |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1156 | if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1157 | app->num_received == 0 && |
| 1158 | app->prev_scantime != scantime) |
| 1159 | app->num_expected = contact_count; |
Hans de Goede | af8dc4d | 2017-11-22 12:57:08 +0100 | [diff] [blame] | 1160 | /* A non 0 contact count always indicates a first packet */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1161 | else if (contact_count) |
| 1162 | app->num_expected = contact_count; |
Benjamin Tissoires | 7e3cc44 | 2013-02-06 12:10:47 +0100 | [diff] [blame] | 1163 | } |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1164 | app->prev_scantime = scantime; |
Benjamin Tissoires | c2517f6 | 2013-01-31 17:22:25 +0100 | [diff] [blame] | 1165 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1166 | first_packet = app->num_received == 0; |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1167 | |
| 1168 | input = report->field[0]->hidinput->input; |
| 1169 | |
| 1170 | list_for_each_entry(slot, &app->mt_usages, list) { |
| 1171 | if (!mt_process_slot(td, input, app, slot)) |
| 1172 | app->num_received++; |
| 1173 | } |
| 1174 | |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1175 | for (r = 0; r < report->maxfield; r++) { |
| 1176 | field = report->field[r]; |
| 1177 | count = field->report_count; |
| 1178 | |
| 1179 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 1180 | continue; |
| 1181 | |
| 1182 | for (n = 0; n < count; n++) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1183 | mt_process_mt_event(hid, app, field, |
| 1184 | &field->usage[n], field->value[n], |
| 1185 | first_packet); |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 1186 | } |
Benjamin Tissoires | 5b62efd | 2013-02-27 16:23:15 +0100 | [diff] [blame] | 1187 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1188 | if (app->num_received >= app->num_expected) |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1189 | mt_sync_frame(td, app, input); |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1190 | |
| 1191 | /* |
| 1192 | * Windows 8 specs says 2 things: |
| 1193 | * - once a contact has been reported, it has to be reported in each |
| 1194 | * subsequent report |
| 1195 | * - the report rate when fingers are present has to be at least |
| 1196 | * the refresh rate of the screen, 60 or 120 Hz |
| 1197 | * |
| 1198 | * I interprete this that the specification forces a report rate of |
| 1199 | * at least 60 Hz for a touchscreen to be certified. |
| 1200 | * Which means that if we do not get a report whithin 16 ms, either |
| 1201 | * something wrong happens, either the touchscreen forgets to send |
| 1202 | * a release. Taking a reasonable margin allows to remove issues |
| 1203 | * with USB communication or the load of the machine. |
| 1204 | * |
| 1205 | * Given that Win 8 devices are forced to send a release, this will |
| 1206 | * only affect laggish machines and the ones that have a firmware |
| 1207 | * defect. |
| 1208 | */ |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1209 | if (app->quirks & MT_QUIRK_STICKY_FINGERS) { |
Benjamin Tissoires | 9609827 | 2017-06-15 15:32:05 +0200 | [diff] [blame] | 1210 | if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) |
| 1211 | mod_timer(&td->release_timer, |
| 1212 | jiffies + msecs_to_jiffies(100)); |
| 1213 | else |
| 1214 | del_timer(&td->release_timer); |
| 1215 | } |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1216 | |
| 1217 | clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1218 | } |
| 1219 | |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1220 | static int mt_touch_input_configured(struct hid_device *hdev, |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1221 | struct hid_input *hi, |
| 1222 | struct mt_application *app) |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1223 | { |
| 1224 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1225 | struct mt_class *cls = &td->mtclass; |
| 1226 | struct input_dev *input = hi->input; |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1227 | int ret; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1228 | |
| 1229 | if (!td->maxcontacts) |
| 1230 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; |
| 1231 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1232 | mt_post_parse(td, app); |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1233 | if (td->serial_maybe) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1234 | mt_post_parse_default_settings(td, app); |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1235 | |
| 1236 | if (cls->is_indirect) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1237 | app->mt_flags |= INPUT_MT_POINTER; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1238 | |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1239 | if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1240 | app->mt_flags |= INPUT_MT_DROP_UNUSED; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1241 | |
Benjamin Tissoires | 015fdaa | 2015-03-06 11:14:42 -0500 | [diff] [blame] | 1242 | /* check for clickpads */ |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1243 | if ((app->mt_flags & INPUT_MT_POINTER) && |
| 1244 | (app->buttons_count == 1)) |
Seth Forshee | 2c6e027 | 2015-03-11 17:26:41 -0500 | [diff] [blame] | 1245 | td->is_buttonpad = true; |
| 1246 | |
| 1247 | if (td->is_buttonpad) |
Benjamin Tissoires | 015fdaa | 2015-03-06 11:14:42 -0500 | [diff] [blame] | 1248 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); |
| 1249 | |
Dmitry Torokhov | 28a042a | 2018-07-13 16:13:54 +0200 | [diff] [blame] | 1250 | app->pending_palm_slots = devm_kcalloc(&hi->input->dev, |
| 1251 | BITS_TO_LONGS(td->maxcontacts), |
| 1252 | sizeof(long), |
| 1253 | GFP_KERNEL); |
| 1254 | if (!app->pending_palm_slots) |
| 1255 | return -ENOMEM; |
| 1256 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1257 | ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1258 | if (ret) |
| 1259 | return ret; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1260 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1261 | app->mt_flags = 0; |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1262 | return 0; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1263 | } |
| 1264 | |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1265 | #define mt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ |
| 1266 | max, EV_KEY, (c)) |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1267 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 1268 | struct hid_field *field, struct hid_usage *usage, |
| 1269 | unsigned long **bit, int *max) |
| 1270 | { |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1271 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1272 | struct mt_application *application; |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1273 | struct mt_report_data *rdata; |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1274 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1275 | rdata = mt_find_report_data(td, field->report); |
| 1276 | if (!rdata) { |
| 1277 | hid_err(hdev, "failed to allocate data for report\n"); |
| 1278 | return 0; |
| 1279 | } |
| 1280 | |
| 1281 | application = rdata->application; |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1282 | |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1283 | /* |
| 1284 | * If mtclass.export_all_inputs is not set, only map fields from |
| 1285 | * TouchScreen or TouchPad collections. We need to ignore fields |
| 1286 | * that belong to other collections such as Mouse that might have |
| 1287 | * the same GenericDesktop usages. |
| 1288 | */ |
| 1289 | if (!td->mtclass.export_all_inputs && |
| 1290 | field->application != HID_DG_TOUCHSCREEN && |
Benjamin Tissoires | fa11aa7 | 2013-03-22 18:38:32 +0100 | [diff] [blame] | 1291 | field->application != HID_DG_PEN && |
Benjamin Tissoires | 8fe89ef | 2016-11-25 14:27:23 +0100 | [diff] [blame] | 1292 | field->application != HID_DG_TOUCHPAD && |
| 1293 | field->application != HID_GD_KEYBOARD && |
Hans de Goede | e57f4e6 | 2017-08-22 08:37:52 +0200 | [diff] [blame] | 1294 | field->application != HID_GD_SYSTEM_CONTROL && |
João Paulo Rechi Vita | 1fbf74ef | 2017-07-24 14:22:24 -0700 | [diff] [blame] | 1295 | field->application != HID_CP_CONSUMER_CONTROL && |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1296 | field->application != HID_GD_WIRELESS_RADIO_CTLS && |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1297 | field->application != HID_GD_SYSTEM_MULTIAXIS && |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1298 | !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1299 | application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) |
Benjamin Tissoires | 6f492f2 | 2013-03-22 18:38:30 +0100 | [diff] [blame] | 1300 | return -1; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1301 | |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1302 | /* |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1303 | * Some Asus keyboard+touchpad devices have the hotkeys defined in the |
| 1304 | * touchpad report descriptor. We need to treat these as an array to |
| 1305 | * map usages to input keys. |
| 1306 | */ |
Jiri Kosina | 39bbf40 | 2017-08-03 11:25:32 +0200 | [diff] [blame] | 1307 | if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1308 | application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1309 | (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { |
| 1310 | set_bit(EV_REP, hi->input->evbit); |
| 1311 | if (field->flags & HID_MAIN_ITEM_VARIABLE) |
| 1312 | field->flags &= ~HID_MAIN_ITEM_VARIABLE; |
| 1313 | switch (usage->hid & HID_USAGE) { |
| 1314 | case 0x10: mt_map_key_clear(KEY_BRIGHTNESSDOWN); break; |
| 1315 | case 0x20: mt_map_key_clear(KEY_BRIGHTNESSUP); break; |
| 1316 | case 0x35: mt_map_key_clear(KEY_DISPLAY_OFF); break; |
| 1317 | case 0x6b: mt_map_key_clear(KEY_F21); break; |
| 1318 | case 0x6c: mt_map_key_clear(KEY_SLEEP); break; |
| 1319 | default: |
| 1320 | return -1; |
| 1321 | } |
| 1322 | return 1; |
| 1323 | } |
| 1324 | |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1325 | if (rdata->is_mt_collection) |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1326 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max, |
| 1327 | application); |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1328 | |
| 1329 | /* let hid-core decide for the others */ |
| 1330 | return 0; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1331 | } |
| 1332 | |
| 1333 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 1334 | struct hid_field *field, struct hid_usage *usage, |
| 1335 | unsigned long **bit, int *max) |
| 1336 | { |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1337 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1338 | struct mt_report_data *rdata; |
Benjamin Tissoires | fa11aa7 | 2013-03-22 18:38:32 +0100 | [diff] [blame] | 1339 | |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1340 | rdata = mt_find_report_data(td, field->report); |
| 1341 | if (rdata && rdata->is_mt_collection) { |
Dmitry Torokhov | 4cf56a89c | 2017-07-11 10:02:18 -0700 | [diff] [blame] | 1342 | /* We own these mappings, tell hid-input to ignore them */ |
| 1343 | return -1; |
| 1344 | } |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1345 | |
| 1346 | /* let hid-core decide for the others */ |
| 1347 | return 0; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | static int mt_event(struct hid_device *hid, struct hid_field *field, |
| 1351 | struct hid_usage *usage, __s32 value) |
| 1352 | { |
| 1353 | struct mt_device *td = hid_get_drvdata(hid); |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1354 | struct mt_report_data *rdata; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1355 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1356 | rdata = mt_find_report_data(td, field->report); |
| 1357 | if (rdata && rdata->is_mt_collection) |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1358 | return mt_touch_event(hid, field, usage, value); |
| 1359 | |
Benjamin Tissoires | e55f620 | 2014-02-28 11:41:24 -0500 | [diff] [blame] | 1360 | return 0; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1361 | } |
| 1362 | |
| 1363 | static void mt_report(struct hid_device *hid, struct hid_report *report) |
| 1364 | { |
| 1365 | struct mt_device *td = hid_get_drvdata(hid); |
Benjamin Tissoires | e55f620 | 2014-02-28 11:41:24 -0500 | [diff] [blame] | 1366 | struct hid_field *field = report->field[0]; |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1367 | struct mt_report_data *rdata; |
Benjamin Tissoires | a69c5f8 | 2013-03-22 18:38:29 +0100 | [diff] [blame] | 1368 | |
| 1369 | if (!(hid->claimed & HID_CLAIMED_INPUT)) |
| 1370 | return; |
| 1371 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1372 | rdata = mt_find_report_data(td, report); |
| 1373 | if (rdata && rdata->is_mt_collection) |
| 1374 | return mt_touch_report(hid, rdata); |
Benjamin Tissoires | fa11aa7 | 2013-03-22 18:38:32 +0100 | [diff] [blame] | 1375 | |
Benjamin Tissoires | e55f620 | 2014-02-28 11:41:24 -0500 | [diff] [blame] | 1376 | if (field && field->hidinput && field->hidinput->input) |
| 1377 | input_sync(field->hidinput->input); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1378 | } |
| 1379 | |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1380 | static bool mt_need_to_apply_feature(struct hid_device *hdev, |
| 1381 | struct hid_field *field, |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1382 | struct hid_usage *usage, |
| 1383 | enum latency_mode latency, |
| 1384 | bool surface_switch, |
Benjamin Tissoires | ec6adef | 2018-09-04 15:31:12 +0200 | [diff] [blame] | 1385 | bool button_switch, |
| 1386 | bool *inputmode_found) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1387 | { |
| 1388 | struct mt_device *td = hid_get_drvdata(hdev); |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1389 | struct mt_class *cls = &td->mtclass; |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1390 | struct hid_report *report = field->report; |
| 1391 | unsigned int index = usage->usage_index; |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1392 | char *buf; |
Aaron Ma | 3064a03 | 2018-02-03 23:57:15 +0800 | [diff] [blame] | 1393 | u32 report_len; |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1394 | int max; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1395 | |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1396 | switch (usage->hid) { |
| 1397 | case HID_DG_INPUTMODE: |
Benjamin Tissoires | ec6adef | 2018-09-04 15:31:12 +0200 | [diff] [blame] | 1398 | /* |
| 1399 | * Some elan panels wrongly declare 2 input mode features, |
| 1400 | * and silently ignore when we set the value in the second |
| 1401 | * field. Skip the second feature and hope for the best. |
| 1402 | */ |
| 1403 | if (*inputmode_found) |
| 1404 | return false; |
| 1405 | |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1406 | if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1407 | report_len = hid_report_len(report); |
| 1408 | buf = hid_alloc_report_buf(report, GFP_KERNEL); |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1409 | if (!buf) { |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1410 | hid_err(hdev, |
| 1411 | "failed to allocate buffer for report\n"); |
| 1412 | return false; |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1413 | } |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1414 | hid_hw_raw_request(hdev, report->id, buf, report_len, |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 1415 | HID_FEATURE_REPORT, |
| 1416 | HID_REQ_GET_REPORT); |
| 1417 | kfree(buf); |
| 1418 | } |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1419 | |
| 1420 | field->value[index] = td->inputmode_value; |
Benjamin Tissoires | ec6adef | 2018-09-04 15:31:12 +0200 | [diff] [blame] | 1421 | *inputmode_found = true; |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1422 | return true; |
| 1423 | |
| 1424 | case HID_DG_CONTACTMAX: |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1425 | if (cls->maxcontacts) { |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1426 | max = min_t(int, field->logical_maximum, |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1427 | cls->maxcontacts); |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1428 | if (field->value[index] != max) { |
| 1429 | field->value[index] = max; |
| 1430 | return true; |
| 1431 | } |
| 1432 | } |
| 1433 | break; |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1434 | |
| 1435 | case HID_DG_LATENCYMODE: |
| 1436 | field->value[index] = latency; |
Jiri Kosina | 99c703a | 2018-05-16 11:02:07 +0200 | [diff] [blame] | 1437 | return true; |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1438 | |
| 1439 | case HID_DG_SURFACESWITCH: |
| 1440 | field->value[index] = surface_switch; |
Jiri Kosina | 99c703a | 2018-05-16 11:02:07 +0200 | [diff] [blame] | 1441 | return true; |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1442 | |
| 1443 | case HID_DG_BUTTONSWITCH: |
| 1444 | field->value[index] = button_switch; |
Jiri Kosina | 99c703a | 2018-05-16 11:02:07 +0200 | [diff] [blame] | 1445 | return true; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1446 | } |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1447 | |
| 1448 | return false; /* no need to update the report */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1449 | } |
| 1450 | |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1451 | static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, |
| 1452 | bool surface_switch, bool button_switch) |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1453 | { |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1454 | struct hid_report_enum *rep_enum; |
| 1455 | struct hid_report *rep; |
| 1456 | struct hid_usage *usage; |
| 1457 | int i, j; |
| 1458 | bool update_report; |
Benjamin Tissoires | ec6adef | 2018-09-04 15:31:12 +0200 | [diff] [blame] | 1459 | bool inputmode_found = false; |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1460 | |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1461 | rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; |
| 1462 | list_for_each_entry(rep, &rep_enum->report_list, list) { |
| 1463 | update_report = false; |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1464 | |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1465 | for (i = 0; i < rep->maxfield; i++) { |
| 1466 | /* Ignore if report count is out of bounds. */ |
| 1467 | if (rep->field[i]->report_count < 1) |
| 1468 | continue; |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1469 | |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1470 | for (j = 0; j < rep->field[i]->maxusage; j++) { |
| 1471 | usage = &rep->field[i]->usage[j]; |
| 1472 | |
| 1473 | if (mt_need_to_apply_feature(hdev, |
| 1474 | rep->field[i], |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1475 | usage, |
| 1476 | latency, |
| 1477 | surface_switch, |
Benjamin Tissoires | ec6adef | 2018-09-04 15:31:12 +0200 | [diff] [blame] | 1478 | button_switch, |
| 1479 | &inputmode_found)) |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1480 | update_report = true; |
| 1481 | } |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1482 | } |
Benjamin Tissoires | 7f81c8d | 2018-04-24 10:04:36 +0200 | [diff] [blame] | 1483 | |
| 1484 | if (update_report) |
| 1485 | hid_hw_request(hdev, rep, HID_REQ_SET_REPORT); |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 1486 | } |
| 1487 | } |
| 1488 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1489 | static void mt_post_parse_default_settings(struct mt_device *td, |
| 1490 | struct mt_application *app) |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 1491 | { |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1492 | __s32 quirks = app->quirks; |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 1493 | |
| 1494 | /* unknown serial device needs special quirks */ |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1495 | if (list_is_singular(&app->mt_usages)) { |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 1496 | quirks |= MT_QUIRK_ALWAYS_VALID; |
| 1497 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; |
| 1498 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; |
| 1499 | quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; |
Benjamin Tissoires | e0bb8f9 | 2013-01-31 17:22:27 +0100 | [diff] [blame] | 1500 | quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 1501 | } |
| 1502 | |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1503 | app->quirks = quirks; |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 1504 | } |
| 1505 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1506 | static void mt_post_parse(struct mt_device *td, struct mt_application *app) |
Benjamin Tissoires | 3ac36d1 | 2012-05-04 14:53:46 +0200 | [diff] [blame] | 1507 | { |
Benjamin Tissoires | 01eaac7 | 2018-07-13 16:13:48 +0200 | [diff] [blame] | 1508 | if (!app->have_contact_count) |
Benjamin Tissoires | 3ceb382 | 2018-07-13 16:13:46 +0200 | [diff] [blame] | 1509 | app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
Benjamin Tissoires | 3ac36d1 | 2012-05-04 14:53:46 +0200 | [diff] [blame] | 1510 | } |
| 1511 | |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1512 | static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 1513 | { |
| 1514 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | c08d46a | 2013-07-24 19:38:05 +0200 | [diff] [blame] | 1515 | char *name; |
| 1516 | const char *suffix = NULL; |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1517 | unsigned int application = 0; |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1518 | struct mt_report_data *rdata; |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1519 | struct mt_application *mt_application = NULL; |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1520 | struct hid_report *report; |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1521 | int ret; |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 1522 | |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1523 | list_for_each_entry(report, &hi->reports, hidinput_list) { |
| 1524 | application = report->application; |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1525 | rdata = mt_find_report_data(td, report); |
| 1526 | if (!rdata) { |
| 1527 | hid_err(hdev, "failed to allocate data for report\n"); |
| 1528 | return -ENOMEM; |
| 1529 | } |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1530 | |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1531 | mt_application = rdata->application; |
| 1532 | |
| 1533 | if (rdata->is_mt_collection) { |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1534 | ret = mt_touch_input_configured(hdev, hi, |
| 1535 | mt_application); |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1536 | if (ret) |
| 1537 | return ret; |
| 1538 | } |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 1539 | |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1540 | /* |
| 1541 | * some egalax touchscreens have "application == DG_TOUCHSCREEN" |
| 1542 | * for the stylus. Check this first, and then rely on |
| 1543 | * the application field. |
| 1544 | */ |
| 1545 | if (report->field[0]->physical == HID_DG_STYLUS) { |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1546 | suffix = "Pen"; |
| 1547 | /* force BTN_STYLUS to allow tablet matching in udev */ |
| 1548 | __set_bit(BTN_STYLUS, hi->input->keybit); |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | if (!suffix) { |
| 1553 | switch (application) { |
| 1554 | case HID_GD_KEYBOARD: |
| 1555 | case HID_GD_KEYPAD: |
| 1556 | case HID_GD_MOUSE: |
| 1557 | case HID_DG_TOUCHPAD: |
| 1558 | case HID_GD_SYSTEM_CONTROL: |
| 1559 | case HID_CP_CONSUMER_CONTROL: |
| 1560 | case HID_GD_WIRELESS_RADIO_CTLS: |
Benjamin Tissoires | ba6b055 | 2018-07-13 16:13:49 +0200 | [diff] [blame] | 1561 | case HID_GD_SYSTEM_MULTIAXIS: |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1562 | /* already handled by hid core */ |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1563 | break; |
| 1564 | case HID_DG_TOUCHSCREEN: |
| 1565 | /* we do not set suffix = "Touchscreen" */ |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1566 | hi->input->name = hdev->name; |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1567 | break; |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1568 | case HID_DG_STYLUS: |
| 1569 | /* force BTN_STYLUS to allow tablet matching in udev */ |
| 1570 | __set_bit(BTN_STYLUS, hi->input->keybit); |
João Paulo Rechi Vita | 1fbf74ef | 2017-07-24 14:22:24 -0700 | [diff] [blame] | 1571 | break; |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1572 | case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: |
| 1573 | suffix = "Custom Media Keys"; |
| 1574 | break; |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1575 | default: |
| 1576 | suffix = "UNKNOWN"; |
| 1577 | break; |
| 1578 | } |
Benjamin Tissoires | c08d46a | 2013-07-24 19:38:05 +0200 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | if (suffix) { |
| 1582 | name = devm_kzalloc(&hi->input->dev, |
| 1583 | strlen(hdev->name) + strlen(suffix) + 2, |
| 1584 | GFP_KERNEL); |
| 1585 | if (name) { |
| 1586 | sprintf(name, "%s %s", hdev->name, suffix); |
| 1587 | hi->input->name = name; |
| 1588 | } |
| 1589 | } |
Dmitry Torokhov | b2c68a2 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 1590 | |
| 1591 | return 0; |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 1592 | } |
| 1593 | |
Benjamin Tissoires | f3287a9 | 2017-01-30 10:48:06 +0100 | [diff] [blame] | 1594 | static void mt_fix_const_field(struct hid_field *field, unsigned int usage) |
| 1595 | { |
| 1596 | if (field->usage[0].hid != usage || |
| 1597 | !(field->flags & HID_MAIN_ITEM_CONSTANT)) |
| 1598 | return; |
| 1599 | |
| 1600 | field->flags &= ~HID_MAIN_ITEM_CONSTANT; |
| 1601 | field->flags |= HID_MAIN_ITEM_VARIABLE; |
| 1602 | } |
| 1603 | |
| 1604 | static void mt_fix_const_fields(struct hid_device *hdev, unsigned int usage) |
| 1605 | { |
| 1606 | struct hid_report *report; |
| 1607 | int i; |
| 1608 | |
| 1609 | list_for_each_entry(report, |
| 1610 | &hdev->report_enum[HID_INPUT_REPORT].report_list, |
| 1611 | list) { |
| 1612 | |
| 1613 | if (!report->maxfield) |
| 1614 | continue; |
| 1615 | |
| 1616 | for (i = 0; i < report->maxfield; i++) |
| 1617 | if (report->field[i]->maxusage >= 1) |
| 1618 | mt_fix_const_field(report->field[i], usage); |
| 1619 | } |
| 1620 | } |
| 1621 | |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1622 | static void mt_release_contacts(struct hid_device *hid) |
| 1623 | { |
| 1624 | struct hid_input *hidinput; |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1625 | struct mt_application *application; |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1626 | struct mt_device *td = hid_get_drvdata(hid); |
| 1627 | |
| 1628 | list_for_each_entry(hidinput, &hid->inputs, list) { |
| 1629 | struct input_dev *input_dev = hidinput->input; |
| 1630 | struct input_mt *mt = input_dev->mt; |
| 1631 | int i; |
| 1632 | |
| 1633 | if (mt) { |
| 1634 | for (i = 0; i < mt->num_slots; i++) { |
| 1635 | input_mt_slot(input_dev, i); |
| 1636 | input_mt_report_slot_state(input_dev, |
| 1637 | MT_TOOL_FINGER, |
| 1638 | false); |
| 1639 | } |
| 1640 | input_mt_sync_frame(input_dev); |
| 1641 | input_sync(input_dev); |
| 1642 | } |
| 1643 | } |
| 1644 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1645 | list_for_each_entry(application, &td->applications, list) { |
| 1646 | application->num_received = 0; |
| 1647 | } |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1648 | } |
| 1649 | |
Kees Cook | 0ee3277 | 2017-10-04 17:53:24 -0700 | [diff] [blame] | 1650 | static void mt_expired_timeout(struct timer_list *t) |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1651 | { |
Kees Cook | 0ee3277 | 2017-10-04 17:53:24 -0700 | [diff] [blame] | 1652 | struct mt_device *td = from_timer(td, t, release_timer); |
| 1653 | struct hid_device *hdev = td->hdev; |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1654 | |
| 1655 | /* |
| 1656 | * An input report came in just before we release the sticky fingers, |
| 1657 | * it will take care of the sticky fingers. |
| 1658 | */ |
| 1659 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) |
| 1660 | return; |
Benjamin Tissoires | 9609827 | 2017-06-15 15:32:05 +0200 | [diff] [blame] | 1661 | if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) |
| 1662 | mt_release_contacts(hdev); |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1663 | clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); |
| 1664 | } |
| 1665 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1666 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
| 1667 | { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 1668 | int ret, i; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1669 | struct mt_device *td; |
Benjamin Tissoires | cf6d15d | 2018-07-13 16:13:44 +0200 | [diff] [blame] | 1670 | const struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 1671 | |
Henrik Rydberg | 94b5485c | 2012-08-08 21:45:50 +0200 | [diff] [blame] | 1672 | for (i = 0; mt_classes[i].name ; i++) { |
| 1673 | if (id->driver_data == mt_classes[i].name) { |
| 1674 | mtclass = &(mt_classes[i]); |
| 1675 | break; |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 1676 | } |
| 1677 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1678 | |
Benjamin Tissoires | c08d46a | 2013-07-24 19:38:05 +0200 | [diff] [blame] | 1679 | td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1680 | if (!td) { |
| 1681 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); |
| 1682 | return -ENOMEM; |
| 1683 | } |
Kees Cook | 0ee3277 | 2017-10-04 17:53:24 -0700 | [diff] [blame] | 1684 | td->hdev = hdev; |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 1685 | td->mtclass = *mtclass; |
Andrew Duggan | 9abebed | 2014-03-19 13:39:03 -0700 | [diff] [blame] | 1686 | td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1687 | hid_set_drvdata(hdev, td); |
| 1688 | |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1689 | INIT_LIST_HEAD(&td->applications); |
Benjamin Tissoires | 8dfe14b | 2018-07-13 16:13:47 +0200 | [diff] [blame] | 1690 | INIT_LIST_HEAD(&td->reports); |
Benjamin Tissoires | f146d1c | 2018-07-13 16:13:45 +0200 | [diff] [blame] | 1691 | |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 1692 | if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) |
| 1693 | td->serial_maybe = true; |
| 1694 | |
Benjamin Tissoires | b897f6d | 2016-11-25 14:27:22 +0100 | [diff] [blame] | 1695 | /* This allows the driver to correctly support devices |
| 1696 | * that emit events over several HID messages. |
| 1697 | */ |
| 1698 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; |
| 1699 | |
| 1700 | /* |
| 1701 | * This allows the driver to handle different input sensors |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1702 | * that emits events through different applications on the same HID |
Benjamin Tissoires | b897f6d | 2016-11-25 14:27:22 +0100 | [diff] [blame] | 1703 | * device. |
| 1704 | */ |
Benjamin Tissoires | 40ec260 | 2018-04-24 10:04:35 +0200 | [diff] [blame] | 1705 | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; |
Benjamin Tissoires | b897f6d | 2016-11-25 14:27:22 +0100 | [diff] [blame] | 1706 | |
Benjamin Tissoires | 0d6c301 | 2018-09-04 15:31:14 +0200 | [diff] [blame] | 1707 | if (id->group != HID_GROUP_MULTITOUCH_WIN_8) |
| 1708 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; |
| 1709 | |
Kees Cook | 0ee3277 | 2017-10-04 17:53:24 -0700 | [diff] [blame] | 1710 | timer_setup(&td->release_timer, mt_expired_timeout, 0); |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1711 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1712 | ret = hid_parse(hdev); |
| 1713 | if (ret != 0) |
Benjamin Tissoires | c08d46a | 2013-07-24 19:38:05 +0200 | [diff] [blame] | 1714 | return ret; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1715 | |
Benjamin Tissoires | f3287a9 | 2017-01-30 10:48:06 +0100 | [diff] [blame] | 1716 | if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) |
| 1717 | mt_fix_const_fields(hdev, HID_DG_CONTACTID); |
| 1718 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1719 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 1720 | if (ret) |
Benjamin Tissoires | c08d46a | 2013-07-24 19:38:05 +0200 | [diff] [blame] | 1721 | return ret; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1722 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 1723 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
Nicholas Krause | 0c4b3c6 | 2016-02-04 10:52:40 -0500 | [diff] [blame] | 1724 | if (ret) |
| 1725 | dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", |
| 1726 | hdev->name); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 1727 | |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1728 | mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1729 | |
| 1730 | return 0; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1731 | } |
| 1732 | |
| 1733 | #ifdef CONFIG_PM |
| 1734 | static int mt_reset_resume(struct hid_device *hdev) |
| 1735 | { |
Benson Leung | d3e69b9 | 2016-03-11 14:19:49 -0800 | [diff] [blame] | 1736 | mt_release_contacts(hdev); |
Benjamin Tissoires | 02946f4 | 2018-04-24 10:04:37 +0200 | [diff] [blame] | 1737 | mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1738 | return 0; |
| 1739 | } |
Scott Liu | dfeefd1 | 2012-08-15 17:21:55 +0800 | [diff] [blame] | 1740 | |
| 1741 | static int mt_resume(struct hid_device *hdev) |
| 1742 | { |
Scott Liu | dfeefd1 | 2012-08-15 17:21:55 +0800 | [diff] [blame] | 1743 | /* Some Elan legacy devices require SET_IDLE to be set on resume. |
| 1744 | * It should be safe to send it to other devices too. |
| 1745 | * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ |
| 1746 | |
Benjamin Tissoires | 4ba25d3 | 2013-02-27 16:38:18 +0100 | [diff] [blame] | 1747 | hid_hw_idle(hdev, 0, 0, HID_REQ_SET_IDLE); |
Scott Liu | dfeefd1 | 2012-08-15 17:21:55 +0800 | [diff] [blame] | 1748 | |
| 1749 | return 0; |
| 1750 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1751 | #endif |
| 1752 | |
| 1753 | static void mt_remove(struct hid_device *hdev) |
| 1754 | { |
Benjamin Tissoires | b897f6d | 2016-11-25 14:27:22 +0100 | [diff] [blame] | 1755 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1756 | |
Benjamin Tissoires | 4f4001b | 2017-06-15 15:32:04 +0200 | [diff] [blame] | 1757 | del_timer_sync(&td->release_timer); |
| 1758 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 1759 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
Benjamin Tissoires | 5939212 | 2013-05-29 10:45:09 +0200 | [diff] [blame] | 1760 | hid_hw_stop(hdev); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1761 | } |
| 1762 | |
Benjamin Tissoires | 0fa9c61 | 2014-02-28 11:41:23 -0500 | [diff] [blame] | 1763 | /* |
| 1764 | * This list contains only: |
| 1765 | * - VID/PID of products not working with the default multitouch handling |
| 1766 | * - 2 generic rules. |
| 1767 | * So there is no point in adding here any device with MT_CLS_DEFAULT. |
| 1768 | */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1769 | static const struct hid_device_id mt_devices[] = { |
| 1770 | |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 1771 | /* 3M panels */ |
| 1772 | { .driver_data = MT_CLS_3M, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1773 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 1774 | USB_DEVICE_ID_3M1968) }, |
| 1775 | { .driver_data = MT_CLS_3M, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1776 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 1777 | USB_DEVICE_ID_3M2256) }, |
Benjamin Tissoires | c4fad87 | 2011-12-23 15:41:00 +0100 | [diff] [blame] | 1778 | { .driver_data = MT_CLS_3M, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1779 | MT_USB_DEVICE(USB_VENDOR_ID_3M, |
Benjamin Tissoires | c4fad87 | 2011-12-23 15:41:00 +0100 | [diff] [blame] | 1780 | USB_DEVICE_ID_3M3266) }, |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 1781 | |
Masaki Ota | 504c932 | 2017-06-16 09:29:39 +0900 | [diff] [blame] | 1782 | /* Alps devices */ |
| 1783 | { .driver_data = MT_CLS_WIN_8_DUAL, |
| 1784 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, |
| 1785 | USB_VENDOR_ID_ALPS_JP, |
| 1786 | HID_DEVICE_ID_ALPS_U1_DUAL_PTP) }, |
| 1787 | { .driver_data = MT_CLS_WIN_8_DUAL, |
| 1788 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, |
| 1789 | USB_VENDOR_ID_ALPS_JP, |
| 1790 | HID_DEVICE_ID_ALPS_U1_DUAL_3BTN_PTP) }, |
| 1791 | |
Pavel Tatashin | 56d859e | 2017-08-25 18:06:04 -0400 | [diff] [blame] | 1792 | /* Lenovo X1 TAB Gen 2 */ |
| 1793 | { .driver_data = MT_CLS_WIN_8_DUAL, |
| 1794 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, |
| 1795 | USB_VENDOR_ID_LENOVO, |
| 1796 | USB_DEVICE_ID_LENOVO_X1_TAB) }, |
| 1797 | |
Benjamin Tissoires | 6aef704 | 2014-02-28 11:41:25 -0500 | [diff] [blame] | 1798 | /* Anton devices */ |
| 1799 | { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, |
| 1800 | MT_USB_DEVICE(USB_VENDOR_ID_ANTON, |
| 1801 | USB_DEVICE_ID_ANTON_TOUCH_PAD) }, |
Benjamin Tissoires | e6aac34 | 2011-05-19 14:18:13 +0200 | [diff] [blame] | 1802 | |
João Paulo Rechi Vita | 957b8df | 2017-07-24 14:22:25 -0700 | [diff] [blame] | 1803 | /* Asus T304UA */ |
| 1804 | { .driver_data = MT_CLS_ASUS, |
| 1805 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, |
| 1806 | USB_VENDOR_ID_ASUSTEK, |
| 1807 | USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD) }, |
| 1808 | |
Benjamin Tissoires | b105712 | 2011-12-23 15:40:59 +0100 | [diff] [blame] | 1809 | /* Atmel panels */ |
| 1810 | { .driver_data = MT_CLS_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1811 | MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
Benjamin Tissoires | 841cb15 | 2012-03-06 10:53:45 +0100 | [diff] [blame] | 1812 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
Benjamin Tissoires | b105712 | 2011-12-23 15:40:59 +0100 | [diff] [blame] | 1813 | |
Jiri Kosina | 9ed3269 | 2012-04-20 12:15:44 +0200 | [diff] [blame] | 1814 | /* Baanto multitouch devices */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1815 | { .driver_data = MT_CLS_NSMU, |
Jiri Kosina | 16b79bb | 2012-05-05 23:32:54 +0200 | [diff] [blame] | 1816 | MT_USB_DEVICE(USB_VENDOR_ID_BAANTO, |
Jiri Kosina | 9ed3269 | 2012-04-20 12:15:44 +0200 | [diff] [blame] | 1817 | USB_DEVICE_ID_BAANTO_MT_190W2) }, |
Benjamin Tissoires | 0fa9c61 | 2014-02-28 11:41:23 -0500 | [diff] [blame] | 1818 | |
Benjamin Tissoires | a841b62 | 2011-03-18 14:27:54 +0100 | [diff] [blame] | 1819 | /* Cando panels */ |
| 1820 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1821 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
Benjamin Tissoires | a841b62 | 2011-03-18 14:27:54 +0100 | [diff] [blame] | 1822 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
Benjamin Tissoires | a841b62 | 2011-03-18 14:27:54 +0100 | [diff] [blame] | 1823 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1824 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
Benjamin Tissoires | a841b62 | 2011-03-18 14:27:54 +0100 | [diff] [blame] | 1825 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
| 1826 | |
Austin Zhang | 942fd42 | 2011-05-28 02:03:47 +0800 | [diff] [blame] | 1827 | /* Chunghwa Telecom touch panels */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1828 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1829 | MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
Austin Zhang | 942fd42 | 2011-05-28 02:03:47 +0800 | [diff] [blame] | 1830 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
| 1831 | |
Kai-Heng Feng | d861fe2 | 2018-11-14 05:35:20 +0000 | [diff] [blame] | 1832 | /* Cirque devices */ |
| 1833 | { .driver_data = MT_CLS_WIN_8_DUAL, |
| 1834 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, |
| 1835 | I2C_VENDOR_ID_CIRQUE, |
| 1836 | I2C_PRODUCT_ID_CIRQUE_121F) }, |
| 1837 | |
Yang Bo | 070f63b | 2015-07-20 09:40:28 -0700 | [diff] [blame] | 1838 | /* CJTouch panels */ |
| 1839 | { .driver_data = MT_CLS_NSMU, |
| 1840 | MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, |
| 1841 | USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020) }, |
| 1842 | { .driver_data = MT_CLS_NSMU, |
| 1843 | MT_USB_DEVICE(USB_VENDOR_ID_CJTOUCH, |
| 1844 | USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0040) }, |
| 1845 | |
Benjamin Tissoires | 79603dc | 2011-05-19 14:18:14 +0200 | [diff] [blame] | 1846 | /* CVTouch panels */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1847 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1848 | MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
Benjamin Tissoires | 79603dc | 2011-05-19 14:18:14 +0200 | [diff] [blame] | 1849 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
| 1850 | |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1851 | /* eGalax devices (resistive) */ |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1852 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1853 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1854 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
| 1855 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1856 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1857 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1858 | |
| 1859 | /* eGalax devices (capacitive) */ |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1860 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1861 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1862 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1863 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1864 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1865 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1866 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1867 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1868 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
Benjamin Tissoires | 2ce09df | 2012-03-06 17:57:02 +0100 | [diff] [blame] | 1869 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1870 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | 2ce09df | 2012-03-06 17:57:02 +0100 | [diff] [blame] | 1871 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1872 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1873 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1874 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1875 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1876 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1877 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1878 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1879 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1880 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1881 | { .driver_data = MT_CLS_EGALAX, |
| 1882 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1883 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1884 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1885 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1886 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1887 | { .driver_data = MT_CLS_EGALAX, |
Andy Shevchenko | aa672da | 2013-05-17 14:34:48 +0300 | [diff] [blame] | 1888 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 1889 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4) }, |
| 1890 | { .driver_data = MT_CLS_EGALAX, |
| 1891 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 1892 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0) }, |
| 1893 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1894 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | 66f0612 | 2011-11-23 10:54:33 +0100 | [diff] [blame] | 1895 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
| 1896 | { .driver_data = MT_CLS_EGALAX, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1897 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Marek Vasut | bb9ff21 | 2011-11-23 10:54:32 +0100 | [diff] [blame] | 1898 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 1899 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1900 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 1901 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
| 1902 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1903 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Thierry Reding | ae01c9e | 2012-08-09 08:34:48 +0200 | [diff] [blame] | 1904 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7) }, |
| 1905 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 1906 | MT_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 1907 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 1908 | |
Tomas Sokorai | 7c7606a | 2014-04-23 10:42:41 -0400 | [diff] [blame] | 1909 | /* Elitegroup panel */ |
| 1910 | { .driver_data = MT_CLS_SERIAL, |
| 1911 | MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP, |
| 1912 | USB_DEVICE_ID_ELITEGROUP_05D8) }, |
| 1913 | |
Henrik Rydberg | 77723e3 | 2012-09-07 19:37:40 +0200 | [diff] [blame] | 1914 | /* Flatfrog Panels */ |
| 1915 | { .driver_data = MT_CLS_FLATFROG, |
| 1916 | MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, |
| 1917 | USB_DEVICE_ID_MULTITOUCH_3200) }, |
| 1918 | |
Benjamin Tissoires | 3db187e | 2014-01-23 16:33:14 -0500 | [diff] [blame] | 1919 | /* FocalTech Panels */ |
| 1920 | { .driver_data = MT_CLS_SERIAL, |
| 1921 | MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL, |
| 1922 | USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH) }, |
| 1923 | |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 1924 | /* GeneralTouch panel */ |
Xianhan Yu | f5ff4e1 | 2012-09-28 10:18:59 +0800 | [diff] [blame] | 1925 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1926 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 1927 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
Xianhan Yu | f5ff4e1 | 2012-09-28 10:18:59 +0800 | [diff] [blame] | 1928 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 1929 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1930 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) }, |
Luosong | 7b22629 | 2013-10-02 11:20:00 +0200 | [diff] [blame] | 1931 | { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, |
| 1932 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1933 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) }, |
| 1934 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 1935 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1936 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) }, |
| 1937 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 1938 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1939 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) }, |
| 1940 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 1941 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1942 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) }, |
| 1943 | { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, |
| 1944 | MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 1945 | USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) }, |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 1946 | |
Andreas Nielsen | 4d5df5d | 2012-03-19 15:41:03 +0100 | [diff] [blame] | 1947 | /* Gametel game controller */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1948 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1949 | MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL, |
Andreas Nielsen | 4d5df5d | 2012-03-19 15:41:03 +0100 | [diff] [blame] | 1950 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
| 1951 | |
Benjamin Tissoires | ee0fbd1 | 2011-05-19 14:18:15 +0200 | [diff] [blame] | 1952 | /* GoodTouch panels */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1953 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1954 | MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
Benjamin Tissoires | ee0fbd1 | 2011-05-19 14:18:15 +0200 | [diff] [blame] | 1955 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
| 1956 | |
Benjamin Tissoires | 5458036 | 2011-11-29 13:13:12 +0100 | [diff] [blame] | 1957 | /* Hanvon panels */ |
| 1958 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1959 | MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
Benjamin Tissoires | 5458036 | 2011-11-29 13:13:12 +0100 | [diff] [blame] | 1960 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
| 1961 | |
Austin Zhang | 4e61f0d | 2011-05-09 23:54:14 +0800 | [diff] [blame] | 1962 | /* Ilitek dual touch panel */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1963 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1964 | MT_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
Austin Zhang | 4e61f0d | 2011-05-09 23:54:14 +0800 | [diff] [blame] | 1965 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
| 1966 | |
Benjamin Tissoires | f3287a9 | 2017-01-30 10:48:06 +0100 | [diff] [blame] | 1967 | /* LG Melfas panel */ |
| 1968 | { .driver_data = MT_CLS_LG, |
| 1969 | HID_USB_DEVICE(USB_VENDOR_ID_LG, |
| 1970 | USB_DEVICE_ID_LG_MELFAS_MT) }, |
| 1971 | |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 1972 | /* MosArt panels */ |
| 1973 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1974 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 1975 | USB_DEVICE_ID_ASUS_T91MT)}, |
| 1976 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1977 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 1978 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
| 1979 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 1980 | MT_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 1981 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
| 1982 | |
Austin Hendrix | 4db703e | 2012-06-04 15:27:51 -0700 | [diff] [blame] | 1983 | /* Novatek Panel */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 1984 | { .driver_data = MT_CLS_NSMU, |
Jiri Kosina | 4380d81 | 2012-06-06 16:28:33 +0200 | [diff] [blame] | 1985 | MT_USB_DEVICE(USB_VENDOR_ID_NOVATEK, |
Austin Hendrix | 4db703e | 2012-06-04 15:27:51 -0700 | [diff] [blame] | 1986 | USB_DEVICE_ID_NOVATEK_PCT) }, |
| 1987 | |
Benjamin Tissoires | a80e803 | 2016-05-31 17:31:15 +0200 | [diff] [blame] | 1988 | /* Ntrig Panel */ |
| 1989 | { .driver_data = MT_CLS_NSMU, |
| 1990 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, |
| 1991 | USB_VENDOR_ID_NTRIG, 0x1b05) }, |
| 1992 | |
Hans de Goede | fb55b40 | 2017-11-22 12:57:07 +0100 | [diff] [blame] | 1993 | /* Panasonic panels */ |
| 1994 | { .driver_data = MT_CLS_PANASONIC, |
| 1995 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
| 1996 | USB_DEVICE_ID_PANABOARD_UBT780) }, |
| 1997 | { .driver_data = MT_CLS_PANASONIC, |
| 1998 | MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
| 1999 | USB_DEVICE_ID_PANABOARD_UBT880) }, |
| 2000 | |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 2001 | /* PixArt optical touch screen */ |
| 2002 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2003 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 2004 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
| 2005 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2006 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 2007 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
| 2008 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2009 | MT_USB_DEVICE(USB_VENDOR_ID_PIXART, |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 2010 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
| 2011 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2012 | /* PixCir-based panels */ |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 2013 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2014 | MT_USB_DEVICE(USB_VENDOR_ID_CANDO, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2015 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
| 2016 | |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 2017 | /* Quanta-based panels */ |
| 2018 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2019 | MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 2020 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
Forest Bond | a6802e0 | 2013-10-21 12:38:49 -0400 | [diff] [blame] | 2021 | |
Benjamin Tissoires | 843e475 | 2018-03-20 12:04:46 +0100 | [diff] [blame] | 2022 | /* Razer touchpads */ |
| 2023 | { .driver_data = MT_CLS_RAZER_BLADE_STEALTH, |
| 2024 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, |
| 2025 | USB_VENDOR_ID_SYNAPTICS, 0x8323) }, |
| 2026 | |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 2027 | /* Stantum panels */ |
Benjamin Tissoires | bf5af9b | 2011-05-19 14:18:18 +0200 | [diff] [blame] | 2028 | { .driver_data = MT_CLS_CONFIDENCE, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2029 | MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 2030 | USB_DEVICE_ID_MTP_STM)}, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 2031 | |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 2032 | /* TopSeed panels */ |
| 2033 | { .driver_data = MT_CLS_TOPSEED, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2034 | MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 2035 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
| 2036 | |
Benjamin Tissoires | 5e74e56 | 2011-05-19 14:18:16 +0200 | [diff] [blame] | 2037 | /* Touch International panels */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2038 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2039 | MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
Benjamin Tissoires | 5e74e56 | 2011-05-19 14:18:16 +0200 | [diff] [blame] | 2040 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
| 2041 | |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 2042 | /* Unitec panels */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2043 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2044 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 2045 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2046 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2047 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 2048 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
KaiChung Cheng | bf9d121 | 2013-11-21 10:04:30 +0100 | [diff] [blame] | 2049 | |
Mathieu Magnaudet | da10bc2 | 2014-11-22 12:02:07 +0100 | [diff] [blame] | 2050 | /* VTL panels */ |
| 2051 | { .driver_data = MT_CLS_VTL, |
| 2052 | MT_USB_DEVICE(USB_VENDOR_ID_VTL, |
| 2053 | USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, |
| 2054 | |
KaiChung Cheng | bf9d121 | 2013-11-21 10:04:30 +0100 | [diff] [blame] | 2055 | /* Wistron panels */ |
| 2056 | { .driver_data = MT_CLS_NSMU, |
| 2057 | MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, |
| 2058 | USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, |
| 2059 | |
ice chien | bc8a2a9 | 2011-07-15 16:58:06 +0800 | [diff] [blame] | 2060 | /* XAT */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2061 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2062 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
ice chien | bc8a2a9 | 2011-07-15 16:58:06 +0800 | [diff] [blame] | 2063 | USB_DEVICE_ID_XAT_CSR) }, |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 2064 | |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2065 | /* Xiroku */ |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2066 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2067 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2068 | USB_DEVICE_ID_XIROKU_SPX) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2069 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2070 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2071 | USB_DEVICE_ID_XIROKU_MPX) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2072 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2073 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2074 | USB_DEVICE_ID_XIROKU_CSR) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2075 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2076 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2077 | USB_DEVICE_ID_XIROKU_SPX1) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2078 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2079 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2080 | USB_DEVICE_ID_XIROKU_MPX1) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2081 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2082 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2083 | USB_DEVICE_ID_XIROKU_CSR1) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2084 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2085 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2086 | USB_DEVICE_ID_XIROKU_SPX2) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2087 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2088 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2089 | USB_DEVICE_ID_XIROKU_MPX2) }, |
Benjamin Tissoires | dc3e1d8 | 2013-01-31 17:22:31 +0100 | [diff] [blame] | 2090 | { .driver_data = MT_CLS_NSMU, |
Henrik Rydberg | 2c2110e | 2012-05-04 15:32:04 +0200 | [diff] [blame] | 2091 | MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 2092 | USB_DEVICE_ID_XIROKU_CSR2) }, |
| 2093 | |
Wei-Ning Huang | 0e82232 | 2017-06-21 10:43:25 +0800 | [diff] [blame] | 2094 | /* Google MT devices */ |
| 2095 | { .driver_data = MT_CLS_GOOGLE, |
| 2096 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE, |
| 2097 | USB_DEVICE_ID_GOOGLE_TOUCH_ROSE) }, |
| 2098 | |
Henrik Rydberg | 4fa3a58 | 2012-05-01 08:40:01 +0200 | [diff] [blame] | 2099 | /* Generic MT device */ |
| 2100 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, |
Benjamin Tissoires | f961bd3 | 2013-08-22 14:51:08 +0200 | [diff] [blame] | 2101 | |
| 2102 | /* Generic Win 8 certified MT device */ |
| 2103 | { .driver_data = MT_CLS_WIN_8, |
| 2104 | HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, |
| 2105 | HID_ANY_ID, HID_ANY_ID) }, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2106 | { } |
| 2107 | }; |
| 2108 | MODULE_DEVICE_TABLE(hid, mt_devices); |
| 2109 | |
| 2110 | static const struct hid_usage_id mt_grabbed_usages[] = { |
| 2111 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, |
| 2112 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} |
| 2113 | }; |
| 2114 | |
| 2115 | static struct hid_driver mt_driver = { |
| 2116 | .name = "hid-multitouch", |
| 2117 | .id_table = mt_devices, |
| 2118 | .probe = mt_probe, |
| 2119 | .remove = mt_remove, |
| 2120 | .input_mapping = mt_input_mapping, |
| 2121 | .input_mapped = mt_input_mapped, |
Henrik Rydberg | 76f5902 | 2012-09-01 20:11:34 +0200 | [diff] [blame] | 2122 | .input_configured = mt_input_configured, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2123 | .feature_mapping = mt_feature_mapping, |
| 2124 | .usage_table = mt_grabbed_usages, |
| 2125 | .event = mt_event, |
Benjamin Tissoires | 55978fa | 2013-01-31 17:22:24 +0100 | [diff] [blame] | 2126 | .report = mt_report, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2127 | #ifdef CONFIG_PM |
| 2128 | .reset_resume = mt_reset_resume, |
Scott Liu | dfeefd1 | 2012-08-15 17:21:55 +0800 | [diff] [blame] | 2129 | .resume = mt_resume, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 2130 | #endif |
| 2131 | }; |
H Hartley Sweeten | f425458 | 2012-12-17 15:28:26 -0700 | [diff] [blame] | 2132 | module_hid_driver(mt_driver); |