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