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