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