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