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> |
| 5 | * Copyright (c) 2010-2012 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
| 6 | * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 7 | * |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 8 | * This code is partly based on hid-egalax.c: |
| 9 | * |
| 10 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> |
| 11 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> |
| 12 | * Copyright (c) 2010 Canonical, Ltd. |
| 13 | * |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 14 | * This code is partly based on hid-3m-pct.c: |
| 15 | * |
| 16 | * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr> |
| 17 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> |
| 18 | * Copyright (c) 2010 Canonical, Ltd. |
| 19 | * |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This program is free software; you can redistribute it and/or modify it |
| 24 | * under the terms of the GNU General Public License as published by the Free |
| 25 | * Software Foundation; either version 2 of the License, or (at your option) |
| 26 | * any later version. |
| 27 | */ |
| 28 | |
| 29 | #include <linux/device.h> |
| 30 | #include <linux/hid.h> |
| 31 | #include <linux/module.h> |
| 32 | #include <linux/slab.h> |
| 33 | #include <linux/usb.h> |
| 34 | #include <linux/input/mt.h> |
| 35 | #include "usbhid/usbhid.h" |
| 36 | |
| 37 | |
| 38 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); |
Benjamin Tissoires | ef2fafb | 2011-01-31 11:28:21 +0100 | [diff] [blame] | 39 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 40 | MODULE_DESCRIPTION("HID multitouch panels"); |
| 41 | MODULE_LICENSE("GPL"); |
| 42 | |
| 43 | #include "hid-ids.h" |
| 44 | |
| 45 | /* quirks to control the device */ |
| 46 | #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0) |
| 47 | #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1) |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 48 | #define MT_QUIRK_CYPRESS (1 << 2) |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 49 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 50 | #define MT_QUIRK_ALWAYS_VALID (1 << 4) |
| 51 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) |
| 52 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 53 | #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 54 | |
| 55 | struct mt_slot { |
| 56 | __s32 x, y, p, w, h; |
| 57 | __s32 contactid; /* the device ContactID assigned to this slot */ |
| 58 | bool touch_state; /* is the touch valid? */ |
| 59 | bool seen_in_this_frame;/* has this slot been updated */ |
| 60 | }; |
| 61 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 62 | struct mt_class { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 63 | __s32 name; /* MT_CLS */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 64 | __s32 quirks; |
| 65 | __s32 sn_move; /* Signal/noise ratio for move events */ |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 66 | __s32 sn_width; /* Signal/noise ratio for width events */ |
| 67 | __s32 sn_height; /* Signal/noise ratio for height events */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 68 | __s32 sn_pressure; /* Signal/noise ratio for pressure events */ |
| 69 | __u8 maxcontacts; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 70 | bool is_indirect; /* true for touchpads */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 73 | struct mt_device { |
| 74 | struct mt_slot curdata; /* placeholder of incoming data */ |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 75 | struct mt_class mtclass; /* our mt device class */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 76 | unsigned last_field_index; /* last field index of the report */ |
| 77 | unsigned last_slot_field; /* the last field of a slot */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 78 | __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 79 | __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, |
| 80 | -1 if non-existent */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 81 | __u8 num_received; /* how many contacts we received */ |
| 82 | __u8 num_expected; /* expected last contact index */ |
| 83 | __u8 maxcontacts; |
Benjamin Tissoires | 9e87f22 | 2012-03-06 17:57:06 +0100 | [diff] [blame] | 84 | __u8 touches_by_report; /* how many touches are present in one report: |
| 85 | * 1 means we should use a serial protocol |
| 86 | * > 1 means hybrid (multitouch) protocol */ |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 87 | bool curvalid; /* is the current contact valid? */ |
| 88 | struct mt_slot *slots; |
| 89 | }; |
| 90 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 91 | /* classes of device behavior */ |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 92 | #define MT_CLS_DEFAULT 0x0001 |
| 93 | |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 94 | #define MT_CLS_SERIAL 0x0002 |
| 95 | #define MT_CLS_CONFIDENCE 0x0003 |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 96 | #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004 |
| 97 | #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005 |
| 98 | #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006 |
| 99 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007 |
| 100 | #define MT_CLS_DUAL_NSMU_CONTACTID 0x0008 |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 101 | #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009 |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 102 | |
| 103 | /* vendor specific classes */ |
| 104 | #define MT_CLS_3M 0x0101 |
| 105 | #define MT_CLS_CYPRESS 0x0102 |
| 106 | #define MT_CLS_EGALAX 0x0103 |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 107 | #define MT_CLS_EGALAX_SERIAL 0x0104 |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 108 | #define MT_CLS_TOPSEED 0x0105 |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 109 | #define MT_CLS_PANASONIC 0x0106 |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 110 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 111 | #define MT_DEFAULT_MAXCONTACT 10 |
| 112 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 113 | /* |
| 114 | * these device-dependent functions determine what slot corresponds |
| 115 | * to a valid contact that was just read. |
| 116 | */ |
| 117 | |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 118 | static int cypress_compute_slot(struct mt_device *td) |
| 119 | { |
| 120 | if (td->curdata.contactid != 0 || td->num_received == 0) |
| 121 | return td->curdata.contactid; |
| 122 | else |
| 123 | return -1; |
| 124 | } |
| 125 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 126 | static int find_slot_from_contactid(struct mt_device *td) |
| 127 | { |
| 128 | int i; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 129 | for (i = 0; i < td->maxcontacts; ++i) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 130 | if (td->slots[i].contactid == td->curdata.contactid && |
| 131 | td->slots[i].touch_state) |
| 132 | return i; |
| 133 | } |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 134 | for (i = 0; i < td->maxcontacts; ++i) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 135 | if (!td->slots[i].seen_in_this_frame && |
| 136 | !td->slots[i].touch_state) |
| 137 | return i; |
| 138 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 139 | /* should not occurs. If this happens that means |
| 140 | * that the device sent more touches that it says |
| 141 | * in the report descriptor. It is ignored then. */ |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 142 | return -1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Jiri Kosina | b3c21d2 | 2011-11-22 23:23:37 +0100 | [diff] [blame] | 145 | static struct mt_class mt_classes[] = { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 146 | { .name = MT_CLS_DEFAULT, |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 147 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP }, |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 148 | { .name = MT_CLS_SERIAL, |
| 149 | .quirks = MT_QUIRK_ALWAYS_VALID}, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 150 | { .name = MT_CLS_CONFIDENCE, |
| 151 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 152 | { .name = MT_CLS_CONFIDENCE_CONTACT_ID, |
| 153 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
| 154 | MT_QUIRK_SLOT_IS_CONTACTID }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 155 | { .name = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 156 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
| 157 | MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 158 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 159 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 160 | MT_QUIRK_SLOT_IS_CONTACTID, |
| 161 | .maxcontacts = 2 }, |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 162 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 163 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 164 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, |
| 165 | .maxcontacts = 2 }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 166 | { .name = MT_CLS_DUAL_NSMU_CONTACTID, |
| 167 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | |
| 168 | MT_QUIRK_SLOT_IS_CONTACTID, |
| 169 | .maxcontacts = 2 }, |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 170 | { .name = MT_CLS_INRANGE_CONTACTNUMBER, |
| 171 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
| 172 | MT_QUIRK_SLOT_IS_CONTACTNUMBER }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 173 | |
| 174 | /* |
| 175 | * vendor specific classes |
| 176 | */ |
| 177 | { .name = MT_CLS_3M, |
| 178 | .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | |
| 179 | MT_QUIRK_SLOT_IS_CONTACTID, |
| 180 | .sn_move = 2048, |
| 181 | .sn_width = 128, |
| 182 | .sn_height = 128 }, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 183 | { .name = MT_CLS_CYPRESS, |
| 184 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | |
| 185 | MT_QUIRK_CYPRESS, |
| 186 | .maxcontacts = 10 }, |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 187 | { .name = MT_CLS_EGALAX, |
| 188 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | |
Benjamin Tissoires | 2261bb9 | 2011-11-23 10:54:29 +0100 | [diff] [blame] | 189 | MT_QUIRK_VALID_IS_INRANGE, |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 190 | .sn_move = 4096, |
| 191 | .sn_pressure = 32, |
| 192 | }, |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 193 | { .name = MT_CLS_EGALAX_SERIAL, |
| 194 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | |
| 195 | MT_QUIRK_ALWAYS_VALID, |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 196 | .sn_move = 4096, |
| 197 | .sn_pressure = 32, |
| 198 | }, |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 199 | { .name = MT_CLS_TOPSEED, |
| 200 | .quirks = MT_QUIRK_ALWAYS_VALID, |
| 201 | .is_indirect = true, |
| 202 | .maxcontacts = 2, |
| 203 | }, |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 204 | { .name = MT_CLS_PANASONIC, |
| 205 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, |
| 206 | .maxcontacts = 4 }, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 207 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 208 | { } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 209 | }; |
| 210 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 211 | static ssize_t mt_show_quirks(struct device *dev, |
| 212 | struct device_attribute *attr, |
| 213 | char *buf) |
| 214 | { |
| 215 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 216 | struct mt_device *td = hid_get_drvdata(hdev); |
| 217 | |
| 218 | return sprintf(buf, "%u\n", td->mtclass.quirks); |
| 219 | } |
| 220 | |
| 221 | static ssize_t mt_set_quirks(struct device *dev, |
| 222 | struct device_attribute *attr, |
| 223 | const char *buf, size_t count) |
| 224 | { |
| 225 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 226 | struct mt_device *td = hid_get_drvdata(hdev); |
| 227 | |
| 228 | unsigned long val; |
| 229 | |
| 230 | if (kstrtoul(buf, 0, &val)) |
| 231 | return -EINVAL; |
| 232 | |
| 233 | td->mtclass.quirks = val; |
| 234 | |
| 235 | return count; |
| 236 | } |
| 237 | |
| 238 | static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks); |
| 239 | |
| 240 | static struct attribute *sysfs_attrs[] = { |
| 241 | &dev_attr_quirks.attr, |
| 242 | NULL |
| 243 | }; |
| 244 | |
| 245 | static struct attribute_group mt_attribute_group = { |
| 246 | .attrs = sysfs_attrs |
| 247 | }; |
| 248 | |
Henrik Rydberg | f635bd1 | 2011-02-24 19:30:59 +0100 | [diff] [blame] | 249 | static void mt_feature_mapping(struct hid_device *hdev, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 250 | struct hid_field *field, struct hid_usage *usage) |
| 251 | { |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 252 | struct mt_device *td = hid_get_drvdata(hdev); |
| 253 | |
| 254 | switch (usage->hid) { |
| 255 | case HID_DG_INPUTMODE: |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 256 | td->inputmode = field->report->id; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 257 | break; |
| 258 | case HID_DG_CONTACTMAX: |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 259 | td->maxcontact_report_id = field->report->id; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 260 | td->maxcontacts = field->value[0]; |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 261 | if (td->mtclass.maxcontacts) |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 262 | /* check if the maxcontacts is given by the class */ |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 263 | td->maxcontacts = td->mtclass.maxcontacts; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 264 | |
| 265 | break; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | |
| 269 | static void set_abs(struct input_dev *input, unsigned int code, |
| 270 | struct hid_field *field, int snratio) |
| 271 | { |
| 272 | int fmin = field->logical_minimum; |
| 273 | int fmax = field->logical_maximum; |
| 274 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; |
| 275 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); |
| 276 | } |
| 277 | |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 278 | static void set_last_slot_field(struct hid_usage *usage, struct mt_device *td, |
| 279 | struct hid_input *hi) |
| 280 | { |
| 281 | if (!test_bit(usage->hid, hi->input->absbit)) |
| 282 | td->last_slot_field = usage->hid; |
| 283 | } |
| 284 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 285 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 286 | struct hid_field *field, struct hid_usage *usage, |
| 287 | unsigned long **bit, int *max) |
| 288 | { |
| 289 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 290 | struct mt_class *cls = &td->mtclass; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 291 | int code; |
Richard Nauber | 4875ac1 | 2011-03-09 06:20:57 +0100 | [diff] [blame] | 292 | |
Jeff Brown | 658d4ae | 2011-08-15 16:44:28 -0700 | [diff] [blame] | 293 | /* Only map fields from TouchScreen or TouchPad collections. |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 294 | * We need to ignore fields that belong to other collections |
| 295 | * such as Mouse that might have the same GenericDesktop usages. */ |
Jeff Brown | 658d4ae | 2011-08-15 16:44:28 -0700 | [diff] [blame] | 296 | if (field->application == HID_DG_TOUCHSCREEN) |
| 297 | set_bit(INPUT_PROP_DIRECT, hi->input->propbit); |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 298 | else if (field->application != HID_DG_TOUCHPAD) |
Jeff Brown | 658d4ae | 2011-08-15 16:44:28 -0700 | [diff] [blame] | 299 | return 0; |
| 300 | |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 301 | /* In case of an indirect device (touchpad), we need to add |
| 302 | * specific BTN_TOOL_* to be handled by the synaptics xorg |
| 303 | * driver. |
| 304 | * We also consider that touchscreens providing buttons are touchpads. |
| 305 | */ |
| 306 | if (field->application == HID_DG_TOUCHPAD || |
| 307 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON || |
| 308 | cls->is_indirect) { |
| 309 | set_bit(INPUT_PROP_POINTER, hi->input->propbit); |
| 310 | set_bit(BTN_TOOL_FINGER, hi->input->keybit); |
| 311 | set_bit(BTN_TOOL_DOUBLETAP, hi->input->keybit); |
| 312 | set_bit(BTN_TOOL_TRIPLETAP, hi->input->keybit); |
| 313 | set_bit(BTN_TOOL_QUADTAP, hi->input->keybit); |
| 314 | } |
| 315 | |
Benjamin Tissoires | 2261bb9 | 2011-11-23 10:54:29 +0100 | [diff] [blame] | 316 | /* eGalax devices provide a Digitizer.Stylus input which overrides |
| 317 | * the correct Digitizers.Finger X/Y ranges. |
| 318 | * Let's just ignore this input. */ |
| 319 | if (field->physical == HID_DG_STYLUS) |
| 320 | return -1; |
| 321 | |
Jeff Brown | 73f1329 | 2011-07-24 14:31:14 -0700 | [diff] [blame] | 322 | /* Only map fields from TouchScreen or TouchPad collections. |
| 323 | * We need to ignore fields that belong to other collections |
| 324 | * such as Mouse that might have the same GenericDesktop usages. */ |
| 325 | if (field->application == HID_DG_TOUCHSCREEN) |
| 326 | set_bit(INPUT_PROP_DIRECT, hi->input->propbit); |
| 327 | else if (field->application == HID_DG_TOUCHPAD) |
| 328 | set_bit(INPUT_PROP_POINTER, hi->input->propbit); |
| 329 | else |
| 330 | return 0; |
| 331 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 332 | switch (usage->hid & HID_USAGE_PAGE) { |
| 333 | |
| 334 | case HID_UP_GENDESK: |
| 335 | switch (usage->hid) { |
| 336 | case HID_GD_X: |
| 337 | hid_map_usage(hi, usage, bit, max, |
| 338 | EV_ABS, ABS_MT_POSITION_X); |
| 339 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
| 340 | cls->sn_move); |
| 341 | /* touchscreen emulation */ |
| 342 | set_abs(hi->input, ABS_X, field, cls->sn_move); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 343 | set_last_slot_field(usage, td, hi); |
| 344 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 345 | return 1; |
| 346 | case HID_GD_Y: |
| 347 | hid_map_usage(hi, usage, bit, max, |
| 348 | EV_ABS, ABS_MT_POSITION_Y); |
| 349 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
| 350 | cls->sn_move); |
| 351 | /* touchscreen emulation */ |
| 352 | set_abs(hi->input, ABS_Y, field, cls->sn_move); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 353 | set_last_slot_field(usage, td, hi); |
| 354 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 355 | return 1; |
| 356 | } |
| 357 | return 0; |
| 358 | |
| 359 | case HID_UP_DIGITIZER: |
| 360 | switch (usage->hid) { |
| 361 | case HID_DG_INRANGE: |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 362 | set_last_slot_field(usage, td, hi); |
| 363 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 364 | return 1; |
| 365 | case HID_DG_CONFIDENCE: |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 366 | set_last_slot_field(usage, td, hi); |
| 367 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 368 | return 1; |
| 369 | case HID_DG_TIPSWITCH: |
| 370 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); |
| 371 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 372 | set_last_slot_field(usage, td, hi); |
| 373 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 374 | return 1; |
| 375 | case HID_DG_CONTACTID: |
Benjamin Tissoires | 50bc03a | 2011-06-21 15:01:53 +0200 | [diff] [blame] | 376 | if (!td->maxcontacts) |
| 377 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 378 | input_mt_init_slots(hi->input, td->maxcontacts); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 379 | td->last_slot_field = usage->hid; |
Benjamin Tissoires | 2955cae | 2011-04-21 14:15:59 +0200 | [diff] [blame] | 380 | td->last_field_index = field->index; |
Benjamin Tissoires | 9e87f22 | 2012-03-06 17:57:06 +0100 | [diff] [blame] | 381 | td->touches_by_report++; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 382 | return 1; |
| 383 | case HID_DG_WIDTH: |
| 384 | hid_map_usage(hi, usage, bit, max, |
| 385 | EV_ABS, ABS_MT_TOUCH_MAJOR); |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 386 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, |
| 387 | cls->sn_width); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 388 | set_last_slot_field(usage, td, hi); |
| 389 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 390 | return 1; |
| 391 | case HID_DG_HEIGHT: |
| 392 | hid_map_usage(hi, usage, bit, max, |
| 393 | EV_ABS, ABS_MT_TOUCH_MINOR); |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 394 | set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, |
| 395 | cls->sn_height); |
Benjamin Tissoires | 1e648a1 | 2011-03-18 14:27:55 +0100 | [diff] [blame] | 396 | input_set_abs_params(hi->input, |
| 397 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 398 | set_last_slot_field(usage, td, hi); |
| 399 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 400 | return 1; |
| 401 | case HID_DG_TIPPRESSURE: |
| 402 | hid_map_usage(hi, usage, bit, max, |
| 403 | EV_ABS, ABS_MT_PRESSURE); |
| 404 | set_abs(hi->input, ABS_MT_PRESSURE, field, |
| 405 | cls->sn_pressure); |
| 406 | /* touchscreen emulation */ |
| 407 | set_abs(hi->input, ABS_PRESSURE, field, |
| 408 | cls->sn_pressure); |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 409 | set_last_slot_field(usage, td, hi); |
| 410 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 411 | return 1; |
| 412 | case HID_DG_CONTACTCOUNT: |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 413 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 414 | return 1; |
| 415 | case HID_DG_CONTACTMAX: |
| 416 | /* we don't set td->last_slot_field as contactcount and |
| 417 | * contact max are global to the report */ |
Benjamin Tissoires | ed9d5c9 | 2012-03-06 17:57:03 +0100 | [diff] [blame] | 418 | td->last_field_index = field->index; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 419 | return -1; |
| 420 | } |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 421 | case HID_DG_TOUCH: |
| 422 | /* Legacy devices use TIPSWITCH and not TOUCH. |
| 423 | * Let's just ignore this field. */ |
| 424 | return -1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 425 | /* let hid-input decide for the others */ |
| 426 | return 0; |
| 427 | |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 428 | case HID_UP_BUTTON: |
| 429 | code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); |
| 430 | hid_map_usage(hi, usage, bit, max, EV_KEY, code); |
| 431 | input_set_capability(hi->input, EV_KEY, code); |
| 432 | return 1; |
| 433 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 434 | case 0xff000000: |
| 435 | /* we do not want to map these: no input-oriented meaning */ |
| 436 | return -1; |
| 437 | } |
| 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 443 | struct hid_field *field, struct hid_usage *usage, |
| 444 | unsigned long **bit, int *max) |
| 445 | { |
| 446 | if (usage->type == EV_KEY || usage->type == EV_ABS) |
| 447 | set_bit(usage->type, hi->input->evbit); |
| 448 | |
| 449 | return -1; |
| 450 | } |
| 451 | |
| 452 | static int mt_compute_slot(struct mt_device *td) |
| 453 | { |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 454 | __s32 quirks = td->mtclass.quirks; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 455 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 456 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
| 457 | return td->curdata.contactid; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 458 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 459 | if (quirks & MT_QUIRK_CYPRESS) |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 460 | return cypress_compute_slot(td); |
| 461 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 462 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
| 463 | return td->num_received; |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 464 | |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 465 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
| 466 | return td->curdata.contactid - 1; |
| 467 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 468 | return find_slot_from_contactid(td); |
| 469 | } |
| 470 | |
| 471 | /* |
| 472 | * this function is called when a whole contact has been processed, |
| 473 | * so that it can assign it to a slot and store the data there |
| 474 | */ |
| 475 | static void mt_complete_slot(struct mt_device *td) |
| 476 | { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 477 | td->curdata.seen_in_this_frame = true; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 478 | if (td->curvalid) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 479 | int slotnum = mt_compute_slot(td); |
| 480 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 481 | if (slotnum >= 0 && slotnum < td->maxcontacts) |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 482 | td->slots[slotnum] = td->curdata; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 483 | } |
| 484 | td->num_received++; |
| 485 | } |
| 486 | |
| 487 | |
| 488 | /* |
| 489 | * this function is called when a whole packet has been received and processed, |
| 490 | * so that it can decide what to send to the input layer. |
| 491 | */ |
| 492 | static void mt_emit_event(struct mt_device *td, struct input_dev *input) |
| 493 | { |
| 494 | int i; |
| 495 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 496 | for (i = 0; i < td->maxcontacts; ++i) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 497 | struct mt_slot *s = &(td->slots[i]); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 498 | if ((td->mtclass.quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) && |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 499 | !s->seen_in_this_frame) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 500 | s->touch_state = false; |
| 501 | } |
| 502 | |
| 503 | input_mt_slot(input, i); |
| 504 | input_mt_report_slot_state(input, MT_TOOL_FINGER, |
| 505 | s->touch_state); |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 506 | if (s->touch_state) { |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 507 | /* this finger is on the screen */ |
| 508 | int wide = (s->w > s->h); |
| 509 | /* divided by two to match visual scale of touch */ |
| 510 | int major = max(s->w, s->h) >> 1; |
| 511 | int minor = min(s->w, s->h) >> 1; |
| 512 | |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 513 | input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); |
| 514 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 515 | input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 516 | input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p); |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 517 | input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); |
| 518 | input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 519 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 520 | s->seen_in_this_frame = false; |
| 521 | |
| 522 | } |
| 523 | |
| 524 | input_mt_report_pointer_emulation(input, true); |
| 525 | input_sync(input); |
| 526 | td->num_received = 0; |
| 527 | } |
| 528 | |
| 529 | |
| 530 | |
| 531 | static int mt_event(struct hid_device *hid, struct hid_field *field, |
| 532 | struct hid_usage *usage, __s32 value) |
| 533 | { |
| 534 | struct mt_device *td = hid_get_drvdata(hid); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 535 | __s32 quirks = td->mtclass.quirks; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 536 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 537 | if (hid->claimed & HID_CLAIMED_INPUT && td->slots) { |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 538 | switch (usage->hid) { |
| 539 | case HID_DG_INRANGE: |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 540 | if (quirks & MT_QUIRK_ALWAYS_VALID) |
| 541 | td->curvalid = true; |
| 542 | else if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 543 | td->curvalid = value; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 544 | break; |
| 545 | case HID_DG_TIPSWITCH: |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 546 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
| 547 | td->curvalid = value; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 548 | td->curdata.touch_state = value; |
| 549 | break; |
| 550 | case HID_DG_CONFIDENCE: |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 551 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
| 552 | td->curvalid = value; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 553 | break; |
| 554 | case HID_DG_CONTACTID: |
| 555 | td->curdata.contactid = value; |
| 556 | break; |
| 557 | case HID_DG_TIPPRESSURE: |
| 558 | td->curdata.p = value; |
| 559 | break; |
| 560 | case HID_GD_X: |
| 561 | td->curdata.x = value; |
| 562 | break; |
| 563 | case HID_GD_Y: |
| 564 | td->curdata.y = value; |
| 565 | break; |
| 566 | case HID_DG_WIDTH: |
| 567 | td->curdata.w = value; |
| 568 | break; |
| 569 | case HID_DG_HEIGHT: |
| 570 | td->curdata.h = value; |
| 571 | break; |
| 572 | case HID_DG_CONTACTCOUNT: |
| 573 | /* |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 574 | * Includes multi-packet support where subsequent |
| 575 | * packets are sent with zero contactcount. |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 576 | */ |
| 577 | if (value) |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 578 | td->num_expected = value; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 579 | break; |
Benjamin Tissoires | c2ef8f2 | 2012-02-04 17:08:48 +0100 | [diff] [blame] | 580 | case HID_DG_TOUCH: |
| 581 | /* do nothing */ |
| 582 | break; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 583 | |
| 584 | default: |
| 585 | /* fallback to the generic hidinput handling */ |
| 586 | return 0; |
| 587 | } |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 588 | |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 589 | if (usage->hid == td->last_slot_field) |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 590 | mt_complete_slot(td); |
| 591 | |
| 592 | if (field->index == td->last_field_index |
| 593 | && td->num_received >= td->num_expected) |
| 594 | mt_emit_event(td, field->hidinput->input); |
| 595 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 596 | } |
| 597 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 598 | /* we have handled the hidinput part, now remains hiddev */ |
| 599 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) |
| 600 | hid->hiddev_hid_event(hid, field, usage, value); |
| 601 | |
| 602 | return 1; |
| 603 | } |
| 604 | |
| 605 | static void mt_set_input_mode(struct hid_device *hdev) |
| 606 | { |
| 607 | struct mt_device *td = hid_get_drvdata(hdev); |
| 608 | struct hid_report *r; |
| 609 | struct hid_report_enum *re; |
| 610 | |
| 611 | if (td->inputmode < 0) |
| 612 | return; |
| 613 | |
| 614 | re = &(hdev->report_enum[HID_FEATURE_REPORT]); |
| 615 | r = re->report_id_hash[td->inputmode]; |
| 616 | if (r) { |
| 617 | r->field[0]->value[0] = 0x02; |
| 618 | usbhid_submit_report(hdev, r, USB_DIR_OUT); |
| 619 | } |
| 620 | } |
| 621 | |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 622 | static void mt_set_maxcontacts(struct hid_device *hdev) |
| 623 | { |
| 624 | struct mt_device *td = hid_get_drvdata(hdev); |
| 625 | struct hid_report *r; |
| 626 | struct hid_report_enum *re; |
| 627 | int fieldmax, max; |
| 628 | |
| 629 | if (td->maxcontact_report_id < 0) |
| 630 | return; |
| 631 | |
| 632 | if (!td->mtclass.maxcontacts) |
| 633 | return; |
| 634 | |
| 635 | re = &hdev->report_enum[HID_FEATURE_REPORT]; |
| 636 | r = re->report_id_hash[td->maxcontact_report_id]; |
| 637 | if (r) { |
| 638 | max = td->mtclass.maxcontacts; |
| 639 | fieldmax = r->field[0]->logical_maximum; |
| 640 | max = min(fieldmax, max); |
| 641 | if (r->field[0]->value[0] != max) { |
| 642 | r->field[0]->value[0] = max; |
| 643 | usbhid_submit_report(hdev, r, USB_DIR_OUT); |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 648 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
| 649 | { |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 650 | int ret, i; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 651 | struct mt_device *td; |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 652 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
| 653 | |
Benjamin Tissoires | 8d179a9 | 2012-03-06 17:57:04 +0100 | [diff] [blame] | 654 | if (id) { |
| 655 | for (i = 0; mt_classes[i].name ; i++) { |
| 656 | if (id->driver_data == mt_classes[i].name) { |
| 657 | mtclass = &(mt_classes[i]); |
| 658 | break; |
| 659 | } |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 660 | } |
| 661 | } |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 662 | |
Henrik Rydberg | d682bd7 | 2011-11-01 15:26:31 +0100 | [diff] [blame] | 663 | /* This allows the driver to correctly support devices |
| 664 | * that emit events over several HID messages. |
| 665 | */ |
| 666 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; |
Benjamin Tissoires | 8d179a9 | 2012-03-06 17:57:04 +0100 | [diff] [blame] | 667 | hdev->quirks &= ~HID_QUIRK_MULTITOUCH; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 668 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 669 | td = kzalloc(sizeof(struct mt_device), GFP_KERNEL); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 670 | if (!td) { |
| 671 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); |
| 672 | return -ENOMEM; |
| 673 | } |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 674 | td->mtclass = *mtclass; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 675 | td->inputmode = -1; |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 676 | td->maxcontact_report_id = -1; |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 677 | hid_set_drvdata(hdev, td); |
| 678 | |
| 679 | ret = hid_parse(hdev); |
| 680 | if (ret != 0) |
| 681 | goto fail; |
| 682 | |
| 683 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
Benjamin Tissoires | 2d93666 | 2011-01-11 16:45:54 +0100 | [diff] [blame] | 684 | if (ret) |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 685 | goto fail; |
| 686 | |
Benjamin Tissoires | 9e87f22 | 2012-03-06 17:57:06 +0100 | [diff] [blame] | 687 | if (!id && td->touches_by_report == 1) { |
| 688 | /* the device has been sent by hid-generic */ |
| 689 | mtclass = &td->mtclass; |
| 690 | mtclass->quirks |= MT_QUIRK_ALWAYS_VALID; |
| 691 | mtclass->quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; |
| 692 | mtclass->quirks &= ~MT_QUIRK_VALID_IS_INRANGE; |
| 693 | mtclass->quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE; |
| 694 | } |
| 695 | |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 696 | td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot), |
| 697 | GFP_KERNEL); |
| 698 | if (!td->slots) { |
| 699 | dev_err(&hdev->dev, "cannot allocate multitouch slots\n"); |
| 700 | hid_hw_stop(hdev); |
| 701 | ret = -ENOMEM; |
| 702 | goto fail; |
| 703 | } |
| 704 | |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 705 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
| 706 | |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 707 | mt_set_maxcontacts(hdev); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 708 | mt_set_input_mode(hdev); |
| 709 | |
| 710 | return 0; |
| 711 | |
| 712 | fail: |
| 713 | kfree(td); |
| 714 | return ret; |
| 715 | } |
| 716 | |
| 717 | #ifdef CONFIG_PM |
| 718 | static int mt_reset_resume(struct hid_device *hdev) |
| 719 | { |
Benjamin Tissoires | 31ae9bd | 2012-02-04 17:08:49 +0100 | [diff] [blame] | 720 | mt_set_maxcontacts(hdev); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 721 | mt_set_input_mode(hdev); |
| 722 | return 0; |
| 723 | } |
| 724 | #endif |
| 725 | |
| 726 | static void mt_remove(struct hid_device *hdev) |
| 727 | { |
| 728 | struct mt_device *td = hid_get_drvdata(hdev); |
Benjamin Tissoires | eec29e3 | 2011-11-23 10:54:28 +0100 | [diff] [blame] | 729 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 730 | hid_hw_stop(hdev); |
Benjamin Tissoires | 9498f95 | 2011-03-18 14:27:52 +0100 | [diff] [blame] | 731 | kfree(td->slots); |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 732 | kfree(td); |
| 733 | hid_set_drvdata(hdev, NULL); |
| 734 | } |
| 735 | |
| 736 | static const struct hid_device_id mt_devices[] = { |
| 737 | |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 738 | /* 3M panels */ |
| 739 | { .driver_data = MT_CLS_3M, |
| 740 | HID_USB_DEVICE(USB_VENDOR_ID_3M, |
| 741 | USB_DEVICE_ID_3M1968) }, |
| 742 | { .driver_data = MT_CLS_3M, |
| 743 | HID_USB_DEVICE(USB_VENDOR_ID_3M, |
| 744 | USB_DEVICE_ID_3M2256) }, |
Benjamin Tissoires | c4fad87 | 2011-12-23 15:41:00 +0100 | [diff] [blame] | 745 | { .driver_data = MT_CLS_3M, |
| 746 | HID_USB_DEVICE(USB_VENDOR_ID_3M, |
| 747 | USB_DEVICE_ID_3M3266) }, |
Benjamin Tissoires | f786bba | 2011-03-22 17:34:01 +0100 | [diff] [blame] | 748 | |
Benjamin Tissoires | e6aac34 | 2011-05-19 14:18:13 +0200 | [diff] [blame] | 749 | /* ActionStar panels */ |
| 750 | { .driver_data = MT_CLS_DEFAULT, |
| 751 | HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, |
| 752 | USB_DEVICE_ID_ACTIONSTAR_1011) }, |
| 753 | |
Benjamin Tissoires | b105712 | 2011-12-23 15:40:59 +0100 | [diff] [blame] | 754 | /* Atmel panels */ |
| 755 | { .driver_data = MT_CLS_SERIAL, |
| 756 | HID_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
| 757 | USB_DEVICE_ID_ATMEL_MULTITOUCH) }, |
Benjamin Tissoires | 841cb15 | 2012-03-06 10:53:45 +0100 | [diff] [blame] | 758 | { .driver_data = MT_CLS_SERIAL, |
| 759 | HID_USB_DEVICE(USB_VENDOR_ID_ATMEL, |
| 760 | USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) }, |
Benjamin Tissoires | b105712 | 2011-12-23 15:40:59 +0100 | [diff] [blame] | 761 | |
Benjamin Tissoires | a841b62 | 2011-03-18 14:27:54 +0100 | [diff] [blame] | 762 | /* Cando panels */ |
| 763 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
| 764 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
| 765 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
| 766 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
| 767 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
| 768 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, |
| 769 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
| 770 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
| 771 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
| 772 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
| 773 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
| 774 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
| 775 | |
Austin Zhang | 942fd42 | 2011-05-28 02:03:47 +0800 | [diff] [blame] | 776 | /* Chunghwa Telecom touch panels */ |
| 777 | { .driver_data = MT_CLS_DEFAULT, |
| 778 | HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, |
| 779 | USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, |
| 780 | |
Benjamin Tissoires | 79603dc | 2011-05-19 14:18:14 +0200 | [diff] [blame] | 781 | /* CVTouch panels */ |
| 782 | { .driver_data = MT_CLS_DEFAULT, |
| 783 | HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, |
| 784 | USB_DEVICE_ID_CVTOUCH_SCREEN) }, |
| 785 | |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 786 | /* Cypress panel */ |
| 787 | { .driver_data = MT_CLS_CYPRESS, |
| 788 | HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, |
| 789 | USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, |
| 790 | |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 791 | /* eGalax devices (resistive) */ |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 792 | { .driver_data = MT_CLS_EGALAX, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 793 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 794 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, |
| 795 | { .driver_data = MT_CLS_EGALAX, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 796 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 797 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 798 | |
| 799 | /* eGalax devices (capacitive) */ |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 800 | { .driver_data = MT_CLS_EGALAX, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 801 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 802 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 803 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 804 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 805 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) }, |
| 806 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 807 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 808 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, |
| 809 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 810 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 811 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, |
Benjamin Tissoires | 2ce09df | 2012-03-06 17:57:02 +0100 | [diff] [blame] | 812 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 813 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 814 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 815 | { .driver_data = MT_CLS_EGALAX, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 816 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 817 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 818 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 819 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 820 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 821 | { .driver_data = MT_CLS_EGALAX, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 822 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 823 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 824 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 825 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
| 826 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) }, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 827 | { .driver_data = MT_CLS_EGALAX, |
Chris Bagwell | 1fd8f04 | 2011-11-23 10:54:27 +0100 | [diff] [blame] | 828 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | 66f0612 | 2011-11-23 10:54:33 +0100 | [diff] [blame] | 829 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) }, |
| 830 | { .driver_data = MT_CLS_EGALAX, |
| 831 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Marek Vasut | bb9ff21 | 2011-11-23 10:54:32 +0100 | [diff] [blame] | 832 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, |
Benjamin Tissoires | 1b723e8 | 2011-11-23 10:54:34 +0100 | [diff] [blame] | 833 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
Marek Vasut | bb9ff21 | 2011-11-23 10:54:32 +0100 | [diff] [blame] | 834 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | fd1d152 | 2012-03-06 10:53:47 +0100 | [diff] [blame] | 835 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) }, |
| 836 | { .driver_data = MT_CLS_EGALAX_SERIAL, |
| 837 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, |
Benjamin Tissoires | e36f690 | 2011-11-23 10:54:31 +0100 | [diff] [blame] | 838 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, |
Benjamin Tissoires | 2240828 | 2011-05-20 15:59:34 +0200 | [diff] [blame] | 839 | |
Benjamin Tissoires | c04abee | 2011-05-19 11:37:29 +0200 | [diff] [blame] | 840 | /* Elo TouchSystems IntelliTouch Plus panel */ |
| 841 | { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID, |
| 842 | HID_USB_DEVICE(USB_VENDOR_ID_ELO, |
| 843 | USB_DEVICE_ID_ELO_TS2515) }, |
| 844 | |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 845 | /* GeneralTouch panel */ |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 846 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 847 | HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
| 848 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
| 849 | |
Andreas Nielsen | 4d5df5d | 2012-03-19 15:41:03 +0100 | [diff] [blame] | 850 | /* Gametel game controller */ |
| 851 | { .driver_data = MT_CLS_DEFAULT, |
| 852 | HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_FRUCTEL, |
| 853 | USB_DEVICE_ID_GAMETEL_MT_MODE) }, |
| 854 | |
Benjamin Tissoires | ee0fbd1 | 2011-05-19 14:18:15 +0200 | [diff] [blame] | 855 | /* GoodTouch panels */ |
| 856 | { .driver_data = MT_CLS_DEFAULT, |
| 857 | HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, |
| 858 | USB_DEVICE_ID_GOODTOUCH_000f) }, |
| 859 | |
Benjamin Tissoires | 5458036 | 2011-11-29 13:13:12 +0100 | [diff] [blame] | 860 | /* Hanvon panels */ |
| 861 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
| 862 | HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, |
| 863 | USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, |
| 864 | |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 865 | /* Ideacom panel */ |
| 866 | { .driver_data = MT_CLS_SERIAL, |
| 867 | HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, |
| 868 | USB_DEVICE_ID_IDEACOM_IDC6650) }, |
Benjamin Tissoires | 71078b0 | 2012-03-06 10:53:46 +0100 | [diff] [blame] | 869 | { .driver_data = MT_CLS_SERIAL, |
| 870 | HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, |
| 871 | USB_DEVICE_ID_IDEACOM_IDC6651) }, |
Stephane Chatty | a062cc5 | 2011-09-17 22:27:30 +0200 | [diff] [blame] | 872 | |
Austin Zhang | 4e61f0d | 2011-05-09 23:54:14 +0800 | [diff] [blame] | 873 | /* Ilitek dual touch panel */ |
| 874 | { .driver_data = MT_CLS_DEFAULT, |
| 875 | HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, |
| 876 | USB_DEVICE_ID_ILITEK_MULTITOUCH) }, |
| 877 | |
Benjamin Tissoires | 4dfcced | 2011-01-31 11:28:22 +0100 | [diff] [blame] | 878 | /* IRTOUCH panels */ |
| 879 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
| 880 | HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, |
| 881 | USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, |
| 882 | |
Jeff Brown | c50bb1a | 2011-08-15 21:12:09 -0700 | [diff] [blame] | 883 | /* LG Display panels */ |
| 884 | { .driver_data = MT_CLS_DEFAULT, |
| 885 | HID_USB_DEVICE(USB_VENDOR_ID_LG, |
| 886 | USB_DEVICE_ID_LG_MULTITOUCH) }, |
| 887 | |
Benjamin Tissoires | df167c4 | 2011-05-18 15:27:24 +0200 | [diff] [blame] | 888 | /* Lumio panels */ |
| 889 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 890 | HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, |
| 891 | USB_DEVICE_ID_CRYSTALTOUCH) }, |
Benjamin Tissoires | c3ead6d | 2011-06-21 15:01:55 +0200 | [diff] [blame] | 892 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 893 | HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, |
| 894 | USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, |
Benjamin Tissoires | df167c4 | 2011-05-18 15:27:24 +0200 | [diff] [blame] | 895 | |
Benjamin Tissoires | 4a6ee68 | 2011-04-22 11:51:48 +0200 | [diff] [blame] | 896 | /* MosArt panels */ |
| 897 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 898 | HID_USB_DEVICE(USB_VENDOR_ID_ASUS, |
| 899 | USB_DEVICE_ID_ASUS_T91MT)}, |
| 900 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 901 | HID_USB_DEVICE(USB_VENDOR_ID_ASUS, |
| 902 | USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
| 903 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, |
| 904 | HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, |
| 905 | USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
| 906 | |
Denis Kovalev | 2258e86 | 2012-02-14 00:50:33 -0800 | [diff] [blame] | 907 | /* Panasonic panels */ |
| 908 | { .driver_data = MT_CLS_PANASONIC, |
| 909 | HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
| 910 | USB_DEVICE_ID_PANABOARD_UBT780) }, |
| 911 | { .driver_data = MT_CLS_PANASONIC, |
| 912 | HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, |
| 913 | USB_DEVICE_ID_PANABOARD_UBT880) }, |
| 914 | |
John Sung | 6ab3a9a | 2011-04-21 16:21:52 +0200 | [diff] [blame] | 915 | /* PenMount panels */ |
| 916 | { .driver_data = MT_CLS_CONFIDENCE, |
| 917 | HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, |
| 918 | USB_DEVICE_ID_PENMOUNT_PCI) }, |
| 919 | |
Aaron Tian | b7ea95f | 2011-12-15 11:09:06 +0800 | [diff] [blame] | 920 | /* PixArt optical touch screen */ |
| 921 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
| 922 | HID_USB_DEVICE(USB_VENDOR_ID_PIXART, |
| 923 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, |
| 924 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
| 925 | HID_USB_DEVICE(USB_VENDOR_ID_PIXART, |
| 926 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, |
| 927 | { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER, |
| 928 | HID_USB_DEVICE(USB_VENDOR_ID_PIXART, |
| 929 | USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, |
| 930 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 931 | /* PixCir-based panels */ |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 932 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 933 | HID_USB_DEVICE(USB_VENDOR_ID_HANVON, |
| 934 | USB_DEVICE_ID_HANVON_MULTITOUCH) }, |
Benjamin Tissoires | 1e9cf35 | 2011-01-31 11:28:20 +0100 | [diff] [blame] | 935 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 936 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
| 937 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
| 938 | |
Benjamin Tissoires | 5e7ea11 | 2011-11-29 13:13:10 +0100 | [diff] [blame] | 939 | /* Quanta-based panels */ |
| 940 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
| 941 | HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
| 942 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
| 943 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
| 944 | HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
| 945 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, |
| 946 | { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, |
| 947 | HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, |
| 948 | USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) }, |
| 949 | |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 950 | /* Stantum panels */ |
Benjamin Tissoires | bf5af9b | 2011-05-19 14:18:18 +0200 | [diff] [blame] | 951 | { .driver_data = MT_CLS_CONFIDENCE, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 952 | HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, |
| 953 | USB_DEVICE_ID_MTP)}, |
Benjamin Tissoires | bf5af9b | 2011-05-19 14:18:18 +0200 | [diff] [blame] | 954 | { .driver_data = MT_CLS_CONFIDENCE, |
Benjamin Tissoires | 85a6008 | 2011-06-21 15:01:54 +0200 | [diff] [blame] | 955 | HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 956 | USB_DEVICE_ID_MTP_STM)}, |
Benjamin Tissoires | bf5af9b | 2011-05-19 14:18:18 +0200 | [diff] [blame] | 957 | { .driver_data = MT_CLS_CONFIDENCE, |
Benjamin Tissoires | 85a6008 | 2011-06-21 15:01:54 +0200 | [diff] [blame] | 958 | HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, |
Benjamin Tissoires | 043b403 | 2011-03-18 14:27:53 +0100 | [diff] [blame] | 959 | USB_DEVICE_ID_MTP_SITRONIX)}, |
| 960 | |
Benjamin Tissoires | 847672c | 2012-02-04 17:08:50 +0100 | [diff] [blame] | 961 | /* TopSeed panels */ |
| 962 | { .driver_data = MT_CLS_TOPSEED, |
| 963 | HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, |
| 964 | USB_DEVICE_ID_TOPSEED2_PERIPAD_701) }, |
| 965 | |
Benjamin Tissoires | 5e74e56 | 2011-05-19 14:18:16 +0200 | [diff] [blame] | 966 | /* Touch International panels */ |
| 967 | { .driver_data = MT_CLS_DEFAULT, |
| 968 | HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, |
| 969 | USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, |
| 970 | |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 971 | /* Unitec panels */ |
| 972 | { .driver_data = MT_CLS_DEFAULT, |
| 973 | HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
| 974 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, |
| 975 | { .driver_data = MT_CLS_DEFAULT, |
| 976 | HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
| 977 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
ice chien | bc8a2a9 | 2011-07-15 16:58:06 +0800 | [diff] [blame] | 978 | /* XAT */ |
| 979 | { .driver_data = MT_CLS_DEFAULT, |
| 980 | HID_USB_DEVICE(USB_VENDOR_ID_XAT, |
| 981 | USB_DEVICE_ID_XAT_CSR) }, |
Benjamin Tissoires | 617b64f | 2011-05-19 14:18:17 +0200 | [diff] [blame] | 982 | |
Masatoshi Hoshikawa | 11576c6 | 2012-01-05 11:53:46 +0900 | [diff] [blame] | 983 | /* Xiroku */ |
| 984 | { .driver_data = MT_CLS_DEFAULT, |
| 985 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 986 | USB_DEVICE_ID_XIROKU_SPX) }, |
| 987 | { .driver_data = MT_CLS_DEFAULT, |
| 988 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 989 | USB_DEVICE_ID_XIROKU_MPX) }, |
| 990 | { .driver_data = MT_CLS_DEFAULT, |
| 991 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 992 | USB_DEVICE_ID_XIROKU_CSR) }, |
| 993 | { .driver_data = MT_CLS_DEFAULT, |
| 994 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 995 | USB_DEVICE_ID_XIROKU_SPX1) }, |
| 996 | { .driver_data = MT_CLS_DEFAULT, |
| 997 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 998 | USB_DEVICE_ID_XIROKU_MPX1) }, |
| 999 | { .driver_data = MT_CLS_DEFAULT, |
| 1000 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 1001 | USB_DEVICE_ID_XIROKU_CSR1) }, |
| 1002 | { .driver_data = MT_CLS_DEFAULT, |
| 1003 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 1004 | USB_DEVICE_ID_XIROKU_SPX2) }, |
| 1005 | { .driver_data = MT_CLS_DEFAULT, |
| 1006 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 1007 | USB_DEVICE_ID_XIROKU_MPX2) }, |
| 1008 | { .driver_data = MT_CLS_DEFAULT, |
| 1009 | HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, |
| 1010 | USB_DEVICE_ID_XIROKU_CSR2) }, |
| 1011 | |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1012 | { } |
| 1013 | }; |
| 1014 | MODULE_DEVICE_TABLE(hid, mt_devices); |
| 1015 | |
| 1016 | static const struct hid_usage_id mt_grabbed_usages[] = { |
| 1017 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, |
| 1018 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} |
| 1019 | }; |
| 1020 | |
| 1021 | static struct hid_driver mt_driver = { |
| 1022 | .name = "hid-multitouch", |
| 1023 | .id_table = mt_devices, |
| 1024 | .probe = mt_probe, |
| 1025 | .remove = mt_remove, |
| 1026 | .input_mapping = mt_input_mapping, |
| 1027 | .input_mapped = mt_input_mapped, |
| 1028 | .feature_mapping = mt_feature_mapping, |
| 1029 | .usage_table = mt_grabbed_usages, |
| 1030 | .event = mt_event, |
| 1031 | #ifdef CONFIG_PM |
| 1032 | .reset_resume = mt_reset_resume, |
| 1033 | #endif |
| 1034 | }; |
| 1035 | |
| 1036 | static int __init mt_init(void) |
| 1037 | { |
| 1038 | return hid_register_driver(&mt_driver); |
| 1039 | } |
| 1040 | |
| 1041 | static void __exit mt_exit(void) |
| 1042 | { |
| 1043 | hid_unregister_driver(&mt_driver); |
| 1044 | } |
| 1045 | |
| 1046 | module_init(mt_init); |
| 1047 | module_exit(mt_exit); |