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