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