| 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * USB Wacom tablet support - Wacom specific code |
| 4 | */ |
| 5 | |
| 6 | #include "wacom_wac.h" |
| 7 | #include "wacom.h" |
| 8 | #include <linux/input/mt.h> |
| 9 | #include <linux/jiffies.h> |
| 10 | |
| 11 | /* resolution for penabled devices */ |
| 12 | #define WACOM_PL_RES 20 |
| 13 | #define WACOM_PENPRTN_RES 40 |
| 14 | #define WACOM_VOLITO_RES 50 |
| 15 | #define WACOM_GRAPHIRE_RES 80 |
| 16 | #define WACOM_INTUOS_RES 100 |
| 17 | #define WACOM_INTUOS3_RES 200 |
| 18 | |
| 19 | /* Newer Cintiq and DTU have an offset between tablet and screen areas */ |
| 20 | #define WACOM_DTU_OFFSET 200 |
| 21 | #define WACOM_CINTIQ_OFFSET 400 |
| 22 | |
| 23 | /* |
| 24 | * Scale factor relating reported contact size to logical contact area. |
| 25 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo |
| 26 | */ |
| 27 | #define WACOM_CONTACT_AREA_SCALE 2607 |
| 28 | |
| 29 | static bool touch_arbitration = 1; |
| 30 | module_param(touch_arbitration, bool, 0644); |
| 31 | MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)" ); |
| 32 | |
| 33 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 34 | int button_count, int mask); |
| 35 | |
| 36 | static int wacom_numbered_button_to_key(int n); |
| 37 | |
| 38 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 39 | int group); |
| 40 | |
| 41 | static void wacom_force_proxout(struct wacom_wac *wacom_wac) |
| 42 | { |
| 43 | struct input_dev *input = wacom_wac->pen_input; |
| 44 | |
| 45 | wacom_wac->shared->stylus_in_proximity = 0; |
| 46 | |
| 47 | input_report_key(dev: input, BTN_TOUCH, value: 0); |
| 48 | input_report_key(dev: input, BTN_STYLUS, value: 0); |
| 49 | input_report_key(dev: input, BTN_STYLUS2, value: 0); |
| 50 | input_report_key(dev: input, BTN_STYLUS3, value: 0); |
| 51 | input_report_key(dev: input, code: wacom_wac->tool[0], value: 0); |
| 52 | if (wacom_wac->serial[0]) { |
| 53 | input_report_abs(dev: input, ABS_MISC, value: 0); |
| 54 | } |
| 55 | input_report_abs(dev: input, ABS_PRESSURE, value: 0); |
| 56 | |
| 57 | wacom_wac->tool[0] = 0; |
| 58 | wacom_wac->id[0] = 0; |
| 59 | wacom_wac->serial[0] = 0; |
| 60 | |
| 61 | input_sync(dev: input); |
| 62 | } |
| 63 | |
| 64 | void wacom_idleprox_timeout(struct timer_list *list) |
| 65 | { |
| 66 | struct wacom *wacom = timer_container_of(wacom, list, idleprox_timer); |
| 67 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 68 | |
| 69 | if (!wacom_wac->hid_data.sense_state) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n" , __func__); |
| 74 | wacom_force_proxout(wacom_wac); |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Percent of battery capacity for Graphire. |
| 79 | * 8th value means AC online and show 100% capacity. |
| 80 | */ |
| 81 | static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; |
| 82 | |
| 83 | /* |
| 84 | * Percent of battery capacity for Intuos4 WL, AC has a separate bit. |
| 85 | */ |
| 86 | static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; |
| 87 | |
| 88 | static void __wacom_notify_battery(struct wacom_battery *battery, |
| 89 | int bat_status, int bat_capacity, |
| 90 | bool bat_charging, bool bat_connected, |
| 91 | bool ps_connected) |
| 92 | { |
| 93 | bool changed = battery->bat_status != bat_status || |
| 94 | battery->battery_capacity != bat_capacity || |
| 95 | battery->bat_charging != bat_charging || |
| 96 | battery->bat_connected != bat_connected || |
| 97 | battery->ps_connected != ps_connected; |
| 98 | |
| 99 | if (changed) { |
| 100 | battery->bat_status = bat_status; |
| 101 | battery->battery_capacity = bat_capacity; |
| 102 | battery->bat_charging = bat_charging; |
| 103 | battery->bat_connected = bat_connected; |
| 104 | battery->ps_connected = ps_connected; |
| 105 | |
| 106 | if (battery->battery) |
| 107 | power_supply_changed(psy: battery->battery); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | static void wacom_notify_battery(struct wacom_wac *wacom_wac, |
| 112 | int bat_status, int bat_capacity, bool bat_charging, |
| 113 | bool bat_connected, bool ps_connected) |
| 114 | { |
| 115 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 116 | bool bat_initialized = wacom->battery.battery; |
| 117 | bool has_quirk = wacom_wac->features.quirks & WACOM_QUIRK_BATTERY; |
| 118 | |
| 119 | if (bat_initialized != has_quirk) |
| 120 | wacom_schedule_work(wacom_wac, which: WACOM_WORKER_BATTERY); |
| 121 | |
| 122 | __wacom_notify_battery(battery: &wacom->battery, bat_status, bat_capacity, |
| 123 | bat_charging, bat_connected, ps_connected); |
| 124 | } |
| 125 | |
| 126 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
| 127 | { |
| 128 | unsigned char *data = wacom->data; |
| 129 | struct input_dev *input = wacom->pen_input; |
| 130 | |
| 131 | switch (data[0]) { |
| 132 | case 1: |
| 133 | if (data[5] & 0x80) { |
| 134 | wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 135 | wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; |
| 136 | input_report_key(dev: input, code: wacom->tool[0], value: 1); |
| 137 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); /* report tool id */ |
| 138 | input_report_abs(dev: input, ABS_X, value: get_unaligned_le16(p: &data[1])); |
| 139 | input_report_abs(dev: input, ABS_Y, value: get_unaligned_le16(p: &data[3])); |
| 140 | input_report_abs(dev: input, ABS_PRESSURE, value: (signed char)data[6] + 127); |
| 141 | input_report_key(dev: input, BTN_TOUCH, value: ((signed char)data[6] > -127)); |
| 142 | input_report_key(dev: input, BTN_STYLUS, value: (data[5] & 0x40)); |
| 143 | } else { |
| 144 | input_report_key(dev: input, code: wacom->tool[0], value: 0); |
| 145 | input_report_abs(dev: input, ABS_MISC, value: 0); /* report tool id */ |
| 146 | input_report_abs(dev: input, ABS_PRESSURE, value: -1); |
| 147 | input_report_key(dev: input, BTN_TOUCH, value: 0); |
| 148 | } |
| 149 | break; |
| 150 | |
| 151 | case 2: |
| 152 | input_report_key(dev: input, BTN_TOOL_PEN, value: 1); |
| 153 | input_report_abs(dev: input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ |
| 154 | input_report_abs(dev: input, ABS_X, value: get_unaligned_le16(p: &data[1])); |
| 155 | input_report_abs(dev: input, ABS_Y, value: get_unaligned_le16(p: &data[3])); |
| 156 | input_report_abs(dev: input, ABS_PRESSURE, value: (signed char)data[6] + 127); |
| 157 | input_report_key(dev: input, BTN_TOUCH, value: ((signed char)data[6] > -80) && !(data[5] & 0x20)); |
| 158 | input_report_key(dev: input, BTN_STYLUS, value: (data[5] & 0x40)); |
| 159 | break; |
| 160 | |
| 161 | default: |
| 162 | dev_dbg(input->dev.parent, |
| 163 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | return 1; |
| 168 | } |
| 169 | |
| 170 | static int wacom_pl_irq(struct wacom_wac *wacom) |
| 171 | { |
| 172 | struct wacom_features *features = &wacom->features; |
| 173 | unsigned char *data = wacom->data; |
| 174 | struct input_dev *input = wacom->pen_input; |
| 175 | int prox, pressure; |
| 176 | |
| 177 | if (data[0] != WACOM_REPORT_PENABLED) { |
| 178 | dev_dbg(input->dev.parent, |
| 179 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | prox = data[1] & 0x40; |
| 184 | |
| 185 | if (!wacom->id[0]) { |
| 186 | if ((data[0] & 0x10) || (data[4] & 0x20)) { |
| 187 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 188 | wacom->id[0] = ERASER_DEVICE_ID; |
| 189 | } |
| 190 | else { |
| 191 | wacom->tool[0] = BTN_TOOL_PEN; |
| 192 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | /* If the eraser is in prox, STYLUS2 is always set. If we |
| 197 | * mis-detected the type and notice that STYLUS2 isn't set |
| 198 | * then force the eraser out of prox and let the pen in. |
| 199 | */ |
| 200 | if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { |
| 201 | input_report_key(dev: input, BTN_TOOL_RUBBER, value: 0); |
| 202 | input_report_abs(dev: input, ABS_MISC, value: 0); |
| 203 | input_sync(dev: input); |
| 204 | wacom->tool[0] = BTN_TOOL_PEN; |
| 205 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 206 | } |
| 207 | |
| 208 | if (prox) { |
| 209 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); |
| 210 | if (features->pressure_max > 255) |
| 211 | pressure = (pressure << 1) | ((data[4] >> 6) & 1); |
| 212 | pressure += (features->pressure_max + 1) / 2; |
| 213 | |
| 214 | input_report_abs(dev: input, ABS_X, value: data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); |
| 215 | input_report_abs(dev: input, ABS_Y, value: data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); |
| 216 | input_report_abs(dev: input, ABS_PRESSURE, value: pressure); |
| 217 | |
| 218 | input_report_key(dev: input, BTN_TOUCH, value: data[4] & 0x08); |
| 219 | input_report_key(dev: input, BTN_STYLUS, value: data[4] & 0x10); |
| 220 | /* Only allow the stylus2 button to be reported for the pen tool. */ |
| 221 | input_report_key(dev: input, BTN_STYLUS2, value: (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20)); |
| 222 | } |
| 223 | |
| 224 | if (!prox) |
| 225 | wacom->id[0] = 0; |
| 226 | input_report_key(dev: input, code: wacom->tool[0], value: prox); |
| 227 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); |
| 228 | return 1; |
| 229 | } |
| 230 | |
| 231 | static int wacom_ptu_irq(struct wacom_wac *wacom) |
| 232 | { |
| 233 | unsigned char *data = wacom->data; |
| 234 | struct input_dev *input = wacom->pen_input; |
| 235 | |
| 236 | if (data[0] != WACOM_REPORT_PENABLED) { |
| 237 | dev_dbg(input->dev.parent, |
| 238 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | if (data[1] & 0x04) { |
| 243 | input_report_key(dev: input, BTN_TOOL_RUBBER, value: data[1] & 0x20); |
| 244 | input_report_key(dev: input, BTN_TOUCH, value: data[1] & 0x08); |
| 245 | wacom->id[0] = ERASER_DEVICE_ID; |
| 246 | } else { |
| 247 | input_report_key(dev: input, BTN_TOOL_PEN, value: data[1] & 0x20); |
| 248 | input_report_key(dev: input, BTN_TOUCH, value: data[1] & 0x01); |
| 249 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 250 | } |
| 251 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); /* report tool id */ |
| 252 | input_report_abs(dev: input, ABS_X, le16_to_cpup(p: (__le16 *)&data[2])); |
| 253 | input_report_abs(dev: input, ABS_Y, le16_to_cpup(p: (__le16 *)&data[4])); |
| 254 | input_report_abs(dev: input, ABS_PRESSURE, le16_to_cpup(p: (__le16 *)&data[6])); |
| 255 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 0x02); |
| 256 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 0x10); |
| 257 | return 1; |
| 258 | } |
| 259 | |
| 260 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
| 261 | { |
| 262 | unsigned char *data = wacom->data; |
| 263 | struct input_dev *input = wacom->pen_input; |
| 264 | int prox = data[1] & 0x20; |
| 265 | |
| 266 | dev_dbg(input->dev.parent, |
| 267 | "%s: received report #%d" , __func__, data[0]); |
| 268 | |
| 269 | if (prox) { |
| 270 | /* Going into proximity select tool */ |
| 271 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 272 | if (wacom->tool[0] == BTN_TOOL_PEN) |
| 273 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 274 | else |
| 275 | wacom->id[0] = ERASER_DEVICE_ID; |
| 276 | } |
| 277 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 0x02); |
| 278 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 0x10); |
| 279 | input_report_abs(dev: input, ABS_X, le16_to_cpup(p: (__le16 *)&data[2])); |
| 280 | input_report_abs(dev: input, ABS_Y, le16_to_cpup(p: (__le16 *)&data[4])); |
| 281 | input_report_abs(dev: input, ABS_PRESSURE, value: ((data[7] & 0x01) << 8) | data[6]); |
| 282 | input_report_key(dev: input, BTN_TOUCH, value: data[1] & 0x05); |
| 283 | if (!prox) /* out-prox */ |
| 284 | wacom->id[0] = 0; |
| 285 | input_report_key(dev: input, code: wacom->tool[0], value: prox); |
| 286 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); |
| 287 | return 1; |
| 288 | } |
| 289 | |
| 290 | static int wacom_dtus_irq(struct wacom_wac *wacom) |
| 291 | { |
| 292 | unsigned char *data = wacom->data; |
| 293 | struct input_dev *input = wacom->pen_input; |
| 294 | unsigned short prox, pressure = 0; |
| 295 | |
| 296 | if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { |
| 297 | dev_dbg(input->dev.parent, |
| 298 | "%s: received unknown report #%d" , __func__, data[0]); |
| 299 | return 0; |
| 300 | } else if (data[0] == WACOM_REPORT_DTUSPAD) { |
| 301 | input = wacom->pad_input; |
| 302 | input_report_key(dev: input, BTN_0, value: (data[1] & 0x01)); |
| 303 | input_report_key(dev: input, BTN_1, value: (data[1] & 0x02)); |
| 304 | input_report_key(dev: input, BTN_2, value: (data[1] & 0x04)); |
| 305 | input_report_key(dev: input, BTN_3, value: (data[1] & 0x08)); |
| 306 | input_report_abs(dev: input, ABS_MISC, |
| 307 | value: data[1] & 0x0f ? PAD_DEVICE_ID : 0); |
| 308 | return 1; |
| 309 | } else { |
| 310 | prox = data[1] & 0x80; |
| 311 | if (prox) { |
| 312 | switch ((data[1] >> 3) & 3) { |
| 313 | case 1: /* Rubber */ |
| 314 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 315 | wacom->id[0] = ERASER_DEVICE_ID; |
| 316 | break; |
| 317 | |
| 318 | case 2: /* Pen */ |
| 319 | wacom->tool[0] = BTN_TOOL_PEN; |
| 320 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 321 | break; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 0x20); |
| 326 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 0x40); |
| 327 | input_report_abs(dev: input, ABS_X, value: get_unaligned_be16(p: &data[3])); |
| 328 | input_report_abs(dev: input, ABS_Y, value: get_unaligned_be16(p: &data[5])); |
| 329 | pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff); |
| 330 | input_report_abs(dev: input, ABS_PRESSURE, value: pressure); |
| 331 | input_report_key(dev: input, BTN_TOUCH, value: pressure > 10); |
| 332 | |
| 333 | if (!prox) /* out-prox */ |
| 334 | wacom->id[0] = 0; |
| 335 | input_report_key(dev: input, code: wacom->tool[0], value: prox); |
| 336 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); |
| 337 | return 1; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | static int wacom_graphire_irq(struct wacom_wac *wacom) |
| 342 | { |
| 343 | struct wacom_features *features = &wacom->features; |
| 344 | unsigned char *data = wacom->data; |
| 345 | struct input_dev *input = wacom->pen_input; |
| 346 | struct input_dev *pad_input = wacom->pad_input; |
| 347 | int battery_capacity, ps_connected; |
| 348 | int prox; |
| 349 | int rw = 0; |
| 350 | int retval = 0; |
| 351 | |
| 352 | if (features->type == GRAPHIRE_BT) { |
| 353 | if (data[0] != WACOM_REPORT_PENABLED_BT) { |
| 354 | dev_dbg(input->dev.parent, |
| 355 | "%s: received unknown report #%d\n" , __func__, |
| 356 | data[0]); |
| 357 | goto exit; |
| 358 | } |
| 359 | } else if (data[0] != WACOM_REPORT_PENABLED) { |
| 360 | dev_dbg(input->dev.parent, |
| 361 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 362 | goto exit; |
| 363 | } |
| 364 | |
| 365 | prox = data[1] & 0x80; |
| 366 | if (prox || wacom->id[0]) { |
| 367 | if (prox) { |
| 368 | switch ((data[1] >> 5) & 3) { |
| 369 | |
| 370 | case 0: /* Pen */ |
| 371 | wacom->tool[0] = BTN_TOOL_PEN; |
| 372 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 373 | break; |
| 374 | |
| 375 | case 1: /* Rubber */ |
| 376 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 377 | wacom->id[0] = ERASER_DEVICE_ID; |
| 378 | break; |
| 379 | |
| 380 | case 2: /* Mouse with wheel */ |
| 381 | input_report_key(dev: input, BTN_MIDDLE, value: data[1] & 0x04); |
| 382 | fallthrough; |
| 383 | |
| 384 | case 3: /* Mouse without wheel */ |
| 385 | wacom->tool[0] = BTN_TOOL_MOUSE; |
| 386 | wacom->id[0] = CURSOR_DEVICE_ID; |
| 387 | break; |
| 388 | } |
| 389 | } |
| 390 | input_report_abs(dev: input, ABS_X, le16_to_cpup(p: (__le16 *)&data[2])); |
| 391 | input_report_abs(dev: input, ABS_Y, le16_to_cpup(p: (__le16 *)&data[4])); |
| 392 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
| 393 | if (features->type == GRAPHIRE_BT) |
| 394 | input_report_abs(dev: input, ABS_PRESSURE, value: data[6] | |
| 395 | (((__u16) (data[1] & 0x08)) << 5)); |
| 396 | else |
| 397 | input_report_abs(dev: input, ABS_PRESSURE, value: data[6] | |
| 398 | ((data[7] & 0x03) << 8)); |
| 399 | input_report_key(dev: input, BTN_TOUCH, value: data[1] & 0x01); |
| 400 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 0x02); |
| 401 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 0x04); |
| 402 | } else { |
| 403 | input_report_key(dev: input, BTN_LEFT, value: data[1] & 0x01); |
| 404 | input_report_key(dev: input, BTN_RIGHT, value: data[1] & 0x02); |
| 405 | if (features->type == WACOM_G4 || |
| 406 | features->type == WACOM_MO) { |
| 407 | input_report_abs(dev: input, ABS_DISTANCE, value: data[6] & 0x3f); |
| 408 | rw = (data[7] & 0x04) - (data[7] & 0x03); |
| 409 | } else if (features->type == GRAPHIRE_BT) { |
| 410 | /* Compute distance between mouse and tablet */ |
| 411 | rw = 44 - (data[6] >> 2); |
| 412 | rw = clamp_val(rw, 0, 31); |
| 413 | input_report_abs(dev: input, ABS_DISTANCE, value: rw); |
| 414 | if (((data[1] >> 5) & 3) == 2) { |
| 415 | /* Mouse with wheel */ |
| 416 | input_report_key(dev: input, BTN_MIDDLE, |
| 417 | value: data[1] & 0x04); |
| 418 | rw = (data[6] & 0x01) ? -1 : |
| 419 | (data[6] & 0x02) ? 1 : 0; |
| 420 | } else { |
| 421 | rw = 0; |
| 422 | } |
| 423 | } else { |
| 424 | input_report_abs(dev: input, ABS_DISTANCE, value: data[7] & 0x3f); |
| 425 | rw = -(signed char)data[6]; |
| 426 | } |
| 427 | input_report_rel(dev: input, REL_WHEEL, value: rw); |
| 428 | } |
| 429 | |
| 430 | if (!prox) |
| 431 | wacom->id[0] = 0; |
| 432 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); /* report tool id */ |
| 433 | input_report_key(dev: input, code: wacom->tool[0], value: prox); |
| 434 | input_sync(dev: input); /* sync last event */ |
| 435 | } |
| 436 | |
| 437 | /* send pad data */ |
| 438 | switch (features->type) { |
| 439 | case WACOM_G4: |
| 440 | prox = data[7] & 0xf8; |
| 441 | if (prox || wacom->id[1]) { |
| 442 | wacom->id[1] = PAD_DEVICE_ID; |
| 443 | input_report_key(dev: pad_input, BTN_BACK, value: (data[7] & 0x40)); |
| 444 | input_report_key(dev: pad_input, BTN_FORWARD, value: (data[7] & 0x80)); |
| 445 | rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); |
| 446 | input_report_rel(dev: pad_input, REL_WHEEL, value: rw); |
| 447 | if (!prox) |
| 448 | wacom->id[1] = 0; |
| 449 | input_report_abs(dev: pad_input, ABS_MISC, value: wacom->id[1]); |
| 450 | retval = 1; |
| 451 | } |
| 452 | break; |
| 453 | |
| 454 | case WACOM_MO: |
| 455 | prox = (data[7] & 0xf8) || data[8]; |
| 456 | if (prox || wacom->id[1]) { |
| 457 | wacom->id[1] = PAD_DEVICE_ID; |
| 458 | input_report_key(dev: pad_input, BTN_BACK, value: (data[7] & 0x08)); |
| 459 | input_report_key(dev: pad_input, BTN_LEFT, value: (data[7] & 0x20)); |
| 460 | input_report_key(dev: pad_input, BTN_FORWARD, value: (data[7] & 0x10)); |
| 461 | input_report_key(dev: pad_input, BTN_RIGHT, value: (data[7] & 0x40)); |
| 462 | input_report_abs(dev: pad_input, ABS_WHEEL, value: (data[8] & 0x7f)); |
| 463 | if (!prox) |
| 464 | wacom->id[1] = 0; |
| 465 | input_report_abs(dev: pad_input, ABS_MISC, value: wacom->id[1]); |
| 466 | retval = 1; |
| 467 | } |
| 468 | break; |
| 469 | case GRAPHIRE_BT: |
| 470 | prox = data[7] & 0x03; |
| 471 | if (prox || wacom->id[1]) { |
| 472 | wacom->id[1] = PAD_DEVICE_ID; |
| 473 | input_report_key(dev: pad_input, BTN_0, value: (data[7] & 0x02)); |
| 474 | input_report_key(dev: pad_input, BTN_1, value: (data[7] & 0x01)); |
| 475 | if (!prox) |
| 476 | wacom->id[1] = 0; |
| 477 | input_report_abs(dev: pad_input, ABS_MISC, value: wacom->id[1]); |
| 478 | retval = 1; |
| 479 | } |
| 480 | break; |
| 481 | } |
| 482 | |
| 483 | /* Store current battery capacity and power supply state */ |
| 484 | if (features->type == GRAPHIRE_BT) { |
| 485 | rw = (data[7] >> 2 & 0x07); |
| 486 | battery_capacity = batcap_gr[rw]; |
| 487 | ps_connected = rw == 7; |
| 488 | wacom_notify_battery(wacom_wac: wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 489 | bat_capacity: battery_capacity, bat_charging: ps_connected, bat_connected: 1, |
| 490 | ps_connected); |
| 491 | } |
| 492 | exit: |
| 493 | return retval; |
| 494 | } |
| 495 | |
| 496 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) |
| 497 | { |
| 498 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 499 | struct wacom_features *features = &wacom_wac->features; |
| 500 | struct hid_report *r; |
| 501 | struct hid_report_enum *re; |
| 502 | |
| 503 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); |
| 504 | if (features->type == INTUOSHT2) |
| 505 | r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; |
| 506 | else |
| 507 | r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; |
| 508 | if (r) { |
| 509 | hid_hw_request(hdev: wacom->hdev, report: r, reqtype: HID_REQ_GET_REPORT); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | static int wacom_intuos_pad(struct wacom_wac *wacom) |
| 514 | { |
| 515 | struct wacom_features *features = &wacom->features; |
| 516 | unsigned char *data = wacom->data; |
| 517 | struct input_dev *input = wacom->pad_input; |
| 518 | int i; |
| 519 | int buttons = 0, nbuttons = features->numbered_buttons; |
| 520 | int keys = 0, nkeys = 0; |
| 521 | int ring1 = 0, ring2 = 0; |
| 522 | int strip1 = 0, strip2 = 0; |
| 523 | bool prox = false; |
| 524 | bool wrench = false, keyboard = false, mute_touch = false, = false, |
| 525 | info = false; |
| 526 | |
| 527 | /* pad packets. Works as a second tool and is always in prox */ |
| 528 | if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || |
| 529 | data[0] == WACOM_REPORT_CINTIQPAD)) |
| 530 | return 0; |
| 531 | |
| 532 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { |
| 533 | buttons = (data[3] << 1) | (data[2] & 0x01); |
| 534 | ring1 = data[1]; |
| 535 | } else if (features->type == DTK) { |
| 536 | buttons = data[6]; |
| 537 | } else if (features->type == WACOM_13HD) { |
| 538 | buttons = (data[4] << 1) | (data[3] & 0x01); |
| 539 | } else if (features->type == WACOM_24HD) { |
| 540 | buttons = (data[8] << 8) | data[6]; |
| 541 | ring1 = data[1]; |
| 542 | ring2 = data[2]; |
| 543 | |
| 544 | /* |
| 545 | * Three "buttons" are available on the 24HD which are |
| 546 | * physically implemented as a touchstrip. Each button |
| 547 | * is approximately 3 bits wide with a 2 bit spacing. |
| 548 | * The raw touchstrip bits are stored at: |
| 549 | * ((data[3] & 0x1f) << 8) | data[4]) |
| 550 | */ |
| 551 | nkeys = 3; |
| 552 | keys = ((data[3] & 0x1C) ? 1<<2 : 0) | |
| 553 | ((data[4] & 0xE0) ? 1<<1 : 0) | |
| 554 | ((data[4] & 0x07) ? 1<<0 : 0); |
| 555 | keyboard = !!(data[4] & 0xE0); |
| 556 | info = !!(data[3] & 0x1C); |
| 557 | |
| 558 | if (features->oPid) { |
| 559 | mute_touch = !!(data[4] & 0x07); |
| 560 | if (mute_touch) |
| 561 | wacom->shared->is_touch_on = |
| 562 | !wacom->shared->is_touch_on; |
| 563 | } else { |
| 564 | wrench = !!(data[4] & 0x07); |
| 565 | } |
| 566 | } else if (features->type == WACOM_27QHD) { |
| 567 | nkeys = 3; |
| 568 | keys = data[2] & 0x07; |
| 569 | |
| 570 | wrench = !!(data[2] & 0x01); |
| 571 | keyboard = !!(data[2] & 0x02); |
| 572 | |
| 573 | if (features->oPid) { |
| 574 | mute_touch = !!(data[2] & 0x04); |
| 575 | if (mute_touch) |
| 576 | wacom->shared->is_touch_on = |
| 577 | !wacom->shared->is_touch_on; |
| 578 | } else { |
| 579 | menu = !!(data[2] & 0x04); |
| 580 | } |
| 581 | input_report_abs(dev: input, ABS_X, be16_to_cpup(p: (__be16 *)&data[4])); |
| 582 | input_report_abs(dev: input, ABS_Y, be16_to_cpup(p: (__be16 *)&data[6])); |
| 583 | input_report_abs(dev: input, ABS_Z, be16_to_cpup(p: (__be16 *)&data[8])); |
| 584 | } else if (features->type == CINTIQ_HYBRID) { |
| 585 | /* |
| 586 | * Do not send hardware buttons under Android. They |
| 587 | * are already sent to the system through GPIO (and |
| 588 | * have different meaning). |
| 589 | * |
| 590 | * d-pad right -> data[4] & 0x10 |
| 591 | * d-pad up -> data[4] & 0x20 |
| 592 | * d-pad left -> data[4] & 0x40 |
| 593 | * d-pad down -> data[4] & 0x80 |
| 594 | * d-pad center -> data[3] & 0x01 |
| 595 | */ |
| 596 | buttons = (data[4] << 1) | (data[3] & 0x01); |
| 597 | } else if (features->type == CINTIQ_COMPANION_2) { |
| 598 | /* d-pad right -> data[2] & 0x10 |
| 599 | * d-pad up -> data[2] & 0x20 |
| 600 | * d-pad left -> data[2] & 0x40 |
| 601 | * d-pad down -> data[2] & 0x80 |
| 602 | * d-pad center -> data[1] & 0x01 |
| 603 | */ |
| 604 | buttons = ((data[2] >> 4) << 7) | |
| 605 | ((data[1] & 0x04) << 4) | |
| 606 | ((data[2] & 0x0F) << 2) | |
| 607 | (data[1] & 0x03); |
| 608 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { |
| 609 | /* |
| 610 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in |
| 611 | * addition to the mechanical switch. Switch data is |
| 612 | * stored in data[4], capacitive data in data[5]. |
| 613 | * |
| 614 | * Touch ring mode switch (data[3]) has no capacitive sensor |
| 615 | */ |
| 616 | buttons = (data[4] << 1) | (data[3] & 0x01); |
| 617 | ring1 = data[2]; |
| 618 | } else { |
| 619 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { |
| 620 | buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) | |
| 621 | (data[6] << 1) | (data[5] & 0x01); |
| 622 | |
| 623 | if (features->type == WACOM_22HD) { |
| 624 | nkeys = 3; |
| 625 | keys = data[9] & 0x07; |
| 626 | |
| 627 | info = !!(data[9] & 0x01); |
| 628 | wrench = !!(data[9] & 0x02); |
| 629 | } |
| 630 | } else { |
| 631 | buttons = ((data[6] & 0x10) << 5) | |
| 632 | ((data[5] & 0x10) << 4) | |
| 633 | ((data[6] & 0x0F) << 4) | |
| 634 | (data[5] & 0x0F); |
| 635 | } |
| 636 | strip1 = ((data[1] & 0x1f) << 8) | data[2]; |
| 637 | strip2 = ((data[3] & 0x1f) << 8) | data[4]; |
| 638 | } |
| 639 | |
| 640 | prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) | |
| 641 | (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2; |
| 642 | |
| 643 | wacom_report_numbered_buttons(input_dev: input, button_count: nbuttons, mask: buttons); |
| 644 | |
| 645 | for (i = 0; i < nkeys; i++) |
| 646 | input_report_key(dev: input, KEY_PROG1 + i, value: keys & (1 << i)); |
| 647 | |
| 648 | input_report_key(dev: input, KEY_BUTTONCONFIG, value: wrench); |
| 649 | input_report_key(dev: input, KEY_ONSCREEN_KEYBOARD, value: keyboard); |
| 650 | input_report_key(dev: input, KEY_CONTROLPANEL, value: menu); |
| 651 | input_report_key(dev: input, KEY_INFO, value: info); |
| 652 | |
| 653 | if (wacom->shared && wacom->shared->touch_input) { |
| 654 | input_report_switch(dev: wacom->shared->touch_input, |
| 655 | SW_MUTE_DEVICE, |
| 656 | value: !wacom->shared->is_touch_on); |
| 657 | input_sync(dev: wacom->shared->touch_input); |
| 658 | } |
| 659 | |
| 660 | input_report_abs(dev: input, ABS_RX, value: strip1); |
| 661 | input_report_abs(dev: input, ABS_RY, value: strip2); |
| 662 | |
| 663 | input_report_abs(dev: input, ABS_WHEEL, value: (ring1 & 0x80) ? (ring1 & 0x7f) : 0); |
| 664 | input_report_abs(dev: input, ABS_THROTTLE, value: (ring2 & 0x80) ? (ring2 & 0x7f) : 0); |
| 665 | |
| 666 | input_report_key(dev: input, code: wacom->tool[1], value: prox ? 1 : 0); |
| 667 | input_report_abs(dev: input, ABS_MISC, value: prox ? PAD_DEVICE_ID : 0); |
| 668 | |
| 669 | input_event(dev: input, EV_MSC, MSC_SERIAL, value: 0xffffffff); |
| 670 | |
| 671 | return 1; |
| 672 | } |
| 673 | |
| 674 | static int wacom_intuos_id_mangle(int tool_id) |
| 675 | { |
| 676 | return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); |
| 677 | } |
| 678 | |
| 679 | static bool wacom_is_art_pen(int tool_id) |
| 680 | { |
| 681 | bool is_art_pen = false; |
| 682 | |
| 683 | switch (tool_id) { |
| 684 | case 0x885: /* Intuos3 Marker Pen */ |
| 685 | case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ |
| 686 | case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ |
| 687 | case 0x204: /* Art Pen 2 */ |
| 688 | is_art_pen = true; |
| 689 | break; |
| 690 | } |
| 691 | return is_art_pen; |
| 692 | } |
| 693 | |
| 694 | static int wacom_intuos_get_tool_type(int tool_id) |
| 695 | { |
| 696 | switch (tool_id) { |
| 697 | case 0x812: /* Inking pen */ |
| 698 | case 0x801: /* Intuos3 Inking pen */ |
| 699 | case 0x12802: /* Intuos4/5 Inking Pen */ |
| 700 | case 0x012: |
| 701 | return BTN_TOOL_PENCIL; |
| 702 | |
| 703 | case 0x832: /* Stroke pen */ |
| 704 | case 0x032: |
| 705 | return BTN_TOOL_BRUSH; |
| 706 | |
| 707 | case 0x007: /* Mouse 4D and 2D */ |
| 708 | case 0x09c: |
| 709 | case 0x094: |
| 710 | case 0x017: /* Intuos3 2D Mouse */ |
| 711 | case 0x806: /* Intuos4 Mouse */ |
| 712 | return BTN_TOOL_MOUSE; |
| 713 | |
| 714 | case 0x096: /* Lens cursor */ |
| 715 | case 0x097: /* Intuos3 Lens cursor */ |
| 716 | case 0x006: /* Intuos4 Lens cursor */ |
| 717 | return BTN_TOOL_LENS; |
| 718 | |
| 719 | case 0xd12: |
| 720 | case 0x912: |
| 721 | case 0x112: |
| 722 | case 0x913: /* Intuos3 Airbrush */ |
| 723 | case 0x902: /* Intuos4/5 13HD/24HD Airbrush */ |
| 724 | case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ |
| 725 | return BTN_TOOL_AIRBRUSH; |
| 726 | |
| 727 | default: |
| 728 | if (tool_id & 0x0008) |
| 729 | return BTN_TOOL_RUBBER; |
| 730 | return BTN_TOOL_PEN; |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | static void wacom_exit_report(struct wacom_wac *wacom) |
| 735 | { |
| 736 | struct input_dev *input = wacom->pen_input; |
| 737 | struct wacom_features *features = &wacom->features; |
| 738 | unsigned char *data = wacom->data; |
| 739 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
| 740 | |
| 741 | /* |
| 742 | * Reset all states otherwise we lose the initial states |
| 743 | * when in-prox next time |
| 744 | */ |
| 745 | input_report_abs(dev: input, ABS_X, value: 0); |
| 746 | input_report_abs(dev: input, ABS_Y, value: 0); |
| 747 | input_report_abs(dev: input, ABS_DISTANCE, value: 0); |
| 748 | input_report_abs(dev: input, ABS_TILT_X, value: 0); |
| 749 | input_report_abs(dev: input, ABS_TILT_Y, value: 0); |
| 750 | if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { |
| 751 | input_report_key(dev: input, BTN_LEFT, value: 0); |
| 752 | input_report_key(dev: input, BTN_MIDDLE, value: 0); |
| 753 | input_report_key(dev: input, BTN_RIGHT, value: 0); |
| 754 | input_report_key(dev: input, BTN_SIDE, value: 0); |
| 755 | input_report_key(dev: input, BTN_EXTRA, value: 0); |
| 756 | input_report_abs(dev: input, ABS_THROTTLE, value: 0); |
| 757 | input_report_abs(dev: input, ABS_RZ, value: 0); |
| 758 | } else { |
| 759 | input_report_abs(dev: input, ABS_PRESSURE, value: 0); |
| 760 | input_report_key(dev: input, BTN_STYLUS, value: 0); |
| 761 | input_report_key(dev: input, BTN_STYLUS2, value: 0); |
| 762 | input_report_key(dev: input, BTN_TOUCH, value: 0); |
| 763 | input_report_abs(dev: input, ABS_WHEEL, value: 0); |
| 764 | if (features->type >= INTUOS3S) |
| 765 | input_report_abs(dev: input, ABS_Z, value: 0); |
| 766 | } |
| 767 | input_report_key(dev: input, code: wacom->tool[idx], value: 0); |
| 768 | input_report_abs(dev: input, ABS_MISC, value: 0); /* reset tool id */ |
| 769 | input_event(dev: input, EV_MSC, MSC_SERIAL, value: wacom->serial[idx]); |
| 770 | wacom->id[idx] = 0; |
| 771 | } |
| 772 | |
| 773 | static int wacom_intuos_inout(struct wacom_wac *wacom) |
| 774 | { |
| 775 | struct wacom_features *features = &wacom->features; |
| 776 | unsigned char *data = wacom->data; |
| 777 | struct input_dev *input = wacom->pen_input; |
| 778 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
| 779 | |
| 780 | if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */ |
| 781 | ((data[1] & 0xfe) == 0x20) || /* in range */ |
| 782 | ((data[1] & 0xfe) == 0x80))) /* out prox */ |
| 783 | return 0; |
| 784 | |
| 785 | /* Enter report */ |
| 786 | if ((data[1] & 0xfc) == 0xc0) { |
| 787 | /* serial number of the tool */ |
| 788 | wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) + |
| 789 | (data[4] << 20) + (data[5] << 12) + |
| 790 | (data[6] << 4) + (data[7] >> 4); |
| 791 | |
| 792 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) | |
| 793 | ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8); |
| 794 | |
| 795 | wacom->tool[idx] = wacom_intuos_get_tool_type(tool_id: wacom->id[idx]); |
| 796 | |
| 797 | wacom->shared->stylus_in_proximity = true; |
| 798 | return 1; |
| 799 | } |
| 800 | |
| 801 | /* in Range */ |
| 802 | if ((data[1] & 0xfe) == 0x20) { |
| 803 | if (features->type != INTUOSHT2) |
| 804 | wacom->shared->stylus_in_proximity = true; |
| 805 | |
| 806 | /* in Range while exiting */ |
| 807 | if (wacom->reporting_data) { |
| 808 | input_report_key(dev: input, BTN_TOUCH, value: 0); |
| 809 | input_report_abs(dev: input, ABS_PRESSURE, value: 0); |
| 810 | input_report_abs(dev: input, ABS_DISTANCE, value: wacom->features.distance_max); |
| 811 | return 2; |
| 812 | } |
| 813 | return 1; |
| 814 | } |
| 815 | |
| 816 | /* Exit report */ |
| 817 | if ((data[1] & 0xfe) == 0x80) { |
| 818 | wacom->shared->stylus_in_proximity = false; |
| 819 | wacom->reporting_data = false; |
| 820 | |
| 821 | /* don't report exit if we don't know the ID */ |
| 822 | if (!wacom->id[idx]) |
| 823 | return 1; |
| 824 | |
| 825 | wacom_exit_report(wacom); |
| 826 | return 2; |
| 827 | } |
| 828 | |
| 829 | return 0; |
| 830 | } |
| 831 | |
| 832 | static inline bool touch_is_muted(struct wacom_wac *wacom_wac) |
| 833 | { |
| 834 | return wacom_wac->probe_complete && |
| 835 | wacom_wac->shared->has_mute_touch_switch && |
| 836 | !wacom_wac->shared->is_touch_on; |
| 837 | } |
| 838 | |
| 839 | static inline bool report_touch_events(struct wacom_wac *wacom) |
| 840 | { |
| 841 | return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); |
| 842 | } |
| 843 | |
| 844 | static inline bool delay_pen_events(struct wacom_wac *wacom) |
| 845 | { |
| 846 | return (wacom->shared->touch_down && touch_arbitration); |
| 847 | } |
| 848 | |
| 849 | static int wacom_intuos_general(struct wacom_wac *wacom) |
| 850 | { |
| 851 | struct wacom_features *features = &wacom->features; |
| 852 | unsigned char *data = wacom->data; |
| 853 | struct input_dev *input = wacom->pen_input; |
| 854 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
| 855 | unsigned char type = (data[1] >> 1) & 0x0F; |
| 856 | unsigned int x, y, distance, t; |
| 857 | |
| 858 | if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && |
| 859 | data[0] != WACOM_REPORT_INTUOS_PEN) |
| 860 | return 0; |
| 861 | |
| 862 | if (delay_pen_events(wacom)) |
| 863 | return 1; |
| 864 | |
| 865 | /* don't report events if we don't know the tool ID */ |
| 866 | if (!wacom->id[idx]) { |
| 867 | /* but reschedule a read of the current tool */ |
| 868 | wacom_intuos_schedule_prox_event(wacom_wac: wacom); |
| 869 | return 1; |
| 870 | } |
| 871 | |
| 872 | /* |
| 873 | * don't report events for invalid data |
| 874 | */ |
| 875 | /* older I4 styli don't work with new Cintiqs */ |
| 876 | if ((!((wacom->id[idx] >> 16) & 0x01) && |
| 877 | (features->type == WACOM_21UX2)) || |
| 878 | /* Only large Intuos support Lense Cursor */ |
| 879 | (wacom->tool[idx] == BTN_TOOL_LENS && |
| 880 | (features->type == INTUOS3 || |
| 881 | features->type == INTUOS3S || |
| 882 | features->type == INTUOS4 || |
| 883 | features->type == INTUOS4S || |
| 884 | features->type == INTUOS5 || |
| 885 | features->type == INTUOS5S || |
| 886 | features->type == INTUOSPM || |
| 887 | features->type == INTUOSPS)) || |
| 888 | /* Cintiq doesn't send data when RDY bit isn't set */ |
| 889 | (features->type == CINTIQ && !(data[1] & 0x40))) |
| 890 | return 1; |
| 891 | |
| 892 | x = (be16_to_cpup(p: (__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); |
| 893 | y = (be16_to_cpup(p: (__be16 *)&data[4]) << 1) | (data[9] & 1); |
| 894 | distance = data[9] >> 2; |
| 895 | if (features->type < INTUOS3S) { |
| 896 | x >>= 1; |
| 897 | y >>= 1; |
| 898 | distance >>= 1; |
| 899 | } |
| 900 | if (features->type == INTUOSHT2) |
| 901 | distance = features->distance_max - distance; |
| 902 | input_report_abs(dev: input, ABS_X, value: x); |
| 903 | input_report_abs(dev: input, ABS_Y, value: y); |
| 904 | input_report_abs(dev: input, ABS_DISTANCE, value: distance); |
| 905 | |
| 906 | switch (type) { |
| 907 | case 0x00: |
| 908 | case 0x01: |
| 909 | case 0x02: |
| 910 | case 0x03: |
| 911 | /* general pen packet */ |
| 912 | t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1); |
| 913 | if (features->pressure_max < 2047) |
| 914 | t >>= 1; |
| 915 | input_report_abs(dev: input, ABS_PRESSURE, value: t); |
| 916 | if (features->type != INTUOSHT2) { |
| 917 | input_report_abs(dev: input, ABS_TILT_X, |
| 918 | value: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 919 | input_report_abs(dev: input, ABS_TILT_Y, value: (data[8] & 0x7f) - 64); |
| 920 | } |
| 921 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 2); |
| 922 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 4); |
| 923 | input_report_key(dev: input, BTN_TOUCH, value: t > 10); |
| 924 | break; |
| 925 | |
| 926 | case 0x0a: |
| 927 | /* airbrush second packet */ |
| 928 | input_report_abs(dev: input, ABS_WHEEL, |
| 929 | value: (data[6] << 2) | ((data[7] >> 6) & 3)); |
| 930 | input_report_abs(dev: input, ABS_TILT_X, |
| 931 | value: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 932 | input_report_abs(dev: input, ABS_TILT_Y, value: (data[8] & 0x7f) - 64); |
| 933 | break; |
| 934 | |
| 935 | case 0x05: |
| 936 | /* Rotation packet */ |
| 937 | if (features->type >= INTUOS3S) { |
| 938 | /* I3 marker pen rotation */ |
| 939 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 940 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : |
| 941 | ((t-1) / 2 + 450)) : (450 - t / 2) ; |
| 942 | input_report_abs(dev: input, ABS_Z, value: t); |
| 943 | } else { |
| 944 | /* 4D mouse 2nd packet */ |
| 945 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 946 | input_report_abs(dev: input, ABS_RZ, value: (data[7] & 0x20) ? |
| 947 | ((t - 1) / 2) : -t / 2); |
| 948 | } |
| 949 | break; |
| 950 | |
| 951 | case 0x04: |
| 952 | /* 4D mouse 1st packet */ |
| 953 | input_report_key(dev: input, BTN_LEFT, value: data[8] & 0x01); |
| 954 | input_report_key(dev: input, BTN_MIDDLE, value: data[8] & 0x02); |
| 955 | input_report_key(dev: input, BTN_RIGHT, value: data[8] & 0x04); |
| 956 | |
| 957 | input_report_key(dev: input, BTN_SIDE, value: data[8] & 0x20); |
| 958 | input_report_key(dev: input, BTN_EXTRA, value: data[8] & 0x10); |
| 959 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
| 960 | input_report_abs(dev: input, ABS_THROTTLE, value: (data[8] & 0x08) ? -t : t); |
| 961 | break; |
| 962 | |
| 963 | case 0x06: |
| 964 | /* I4 mouse */ |
| 965 | input_report_key(dev: input, BTN_LEFT, value: data[6] & 0x01); |
| 966 | input_report_key(dev: input, BTN_MIDDLE, value: data[6] & 0x02); |
| 967 | input_report_key(dev: input, BTN_RIGHT, value: data[6] & 0x04); |
| 968 | input_report_rel(dev: input, REL_WHEEL, value: ((data[7] & 0x80) >> 7) |
| 969 | - ((data[7] & 0x40) >> 6)); |
| 970 | input_report_key(dev: input, BTN_SIDE, value: data[6] & 0x08); |
| 971 | input_report_key(dev: input, BTN_EXTRA, value: data[6] & 0x10); |
| 972 | |
| 973 | input_report_abs(dev: input, ABS_TILT_X, |
| 974 | value: (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 975 | input_report_abs(dev: input, ABS_TILT_Y, value: (data[8] & 0x7f) - 64); |
| 976 | break; |
| 977 | |
| 978 | case 0x08: |
| 979 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { |
| 980 | /* 2D mouse packet */ |
| 981 | input_report_key(dev: input, BTN_LEFT, value: data[8] & 0x04); |
| 982 | input_report_key(dev: input, BTN_MIDDLE, value: data[8] & 0x08); |
| 983 | input_report_key(dev: input, BTN_RIGHT, value: data[8] & 0x10); |
| 984 | input_report_rel(dev: input, REL_WHEEL, value: (data[8] & 0x01) |
| 985 | - ((data[8] & 0x02) >> 1)); |
| 986 | |
| 987 | /* I3 2D mouse side buttons */ |
| 988 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { |
| 989 | input_report_key(dev: input, BTN_SIDE, value: data[8] & 0x40); |
| 990 | input_report_key(dev: input, BTN_EXTRA, value: data[8] & 0x20); |
| 991 | } |
| 992 | } |
| 993 | else if (wacom->tool[idx] == BTN_TOOL_LENS) { |
| 994 | /* Lens cursor packets */ |
| 995 | input_report_key(dev: input, BTN_LEFT, value: data[8] & 0x01); |
| 996 | input_report_key(dev: input, BTN_MIDDLE, value: data[8] & 0x02); |
| 997 | input_report_key(dev: input, BTN_RIGHT, value: data[8] & 0x04); |
| 998 | input_report_key(dev: input, BTN_SIDE, value: data[8] & 0x10); |
| 999 | input_report_key(dev: input, BTN_EXTRA, value: data[8] & 0x08); |
| 1000 | } |
| 1001 | break; |
| 1002 | |
| 1003 | case 0x07: |
| 1004 | case 0x09: |
| 1005 | case 0x0b: |
| 1006 | case 0x0c: |
| 1007 | case 0x0d: |
| 1008 | case 0x0e: |
| 1009 | case 0x0f: |
| 1010 | /* unhandled */ |
| 1011 | break; |
| 1012 | } |
| 1013 | |
| 1014 | input_report_abs(dev: input, ABS_MISC, |
| 1015 | value: wacom_intuos_id_mangle(tool_id: wacom->id[idx])); /* report tool id */ |
| 1016 | input_report_key(dev: input, code: wacom->tool[idx], value: 1); |
| 1017 | input_event(dev: input, EV_MSC, MSC_SERIAL, value: wacom->serial[idx]); |
| 1018 | wacom->reporting_data = true; |
| 1019 | return 2; |
| 1020 | } |
| 1021 | |
| 1022 | static int wacom_intuos_irq(struct wacom_wac *wacom) |
| 1023 | { |
| 1024 | unsigned char *data = wacom->data; |
| 1025 | struct input_dev *input = wacom->pen_input; |
| 1026 | int result; |
| 1027 | |
| 1028 | if (data[0] != WACOM_REPORT_PENABLED && |
| 1029 | data[0] != WACOM_REPORT_INTUOS_ID1 && |
| 1030 | data[0] != WACOM_REPORT_INTUOS_ID2 && |
| 1031 | data[0] != WACOM_REPORT_INTUOSPAD && |
| 1032 | data[0] != WACOM_REPORT_INTUOS_PEN && |
| 1033 | data[0] != WACOM_REPORT_CINTIQ && |
| 1034 | data[0] != WACOM_REPORT_CINTIQPAD && |
| 1035 | data[0] != WACOM_REPORT_INTUOS5PAD) { |
| 1036 | dev_dbg(input->dev.parent, |
| 1037 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 1038 | return 0; |
| 1039 | } |
| 1040 | |
| 1041 | /* process pad events */ |
| 1042 | result = wacom_intuos_pad(wacom); |
| 1043 | if (result) |
| 1044 | return result; |
| 1045 | |
| 1046 | /* process in/out prox events */ |
| 1047 | result = wacom_intuos_inout(wacom); |
| 1048 | if (result) |
| 1049 | return result - 1; |
| 1050 | |
| 1051 | /* process general packets */ |
| 1052 | result = wacom_intuos_general(wacom); |
| 1053 | if (result) |
| 1054 | return result - 1; |
| 1055 | |
| 1056 | return 0; |
| 1057 | } |
| 1058 | |
| 1059 | static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) |
| 1060 | { |
| 1061 | unsigned char *data = wacom_wac->data; |
| 1062 | struct input_dev *input; |
| 1063 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 1064 | struct wacom_remote *remote = wacom->remote; |
| 1065 | int bat_charging, bat_percent, touch_ring_mode; |
| 1066 | __u32 serial; |
| 1067 | int i, index = -1; |
| 1068 | unsigned long flags; |
| 1069 | |
| 1070 | if (data[0] != WACOM_REPORT_REMOTE) { |
| 1071 | hid_dbg(wacom->hdev, "%s: received unknown report #%d" , |
| 1072 | __func__, data[0]); |
| 1073 | return 0; |
| 1074 | } |
| 1075 | |
| 1076 | serial = data[3] + (data[4] << 8) + (data[5] << 16); |
| 1077 | wacom_wac->id[0] = PAD_DEVICE_ID; |
| 1078 | |
| 1079 | spin_lock_irqsave(&remote->remote_lock, flags); |
| 1080 | |
| 1081 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1082 | if (remote->remotes[i].serial == serial) { |
| 1083 | index = i; |
| 1084 | break; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | if (index < 0 || !remote->remotes[index].registered) |
| 1089 | goto out; |
| 1090 | |
| 1091 | remote->remotes[i].active_time = ktime_get(); |
| 1092 | input = remote->remotes[index].input; |
| 1093 | |
| 1094 | input_report_key(dev: input, BTN_0, value: (data[9] & 0x01)); |
| 1095 | input_report_key(dev: input, BTN_1, value: (data[9] & 0x02)); |
| 1096 | input_report_key(dev: input, BTN_2, value: (data[9] & 0x04)); |
| 1097 | input_report_key(dev: input, BTN_3, value: (data[9] & 0x08)); |
| 1098 | input_report_key(dev: input, BTN_4, value: (data[9] & 0x10)); |
| 1099 | input_report_key(dev: input, BTN_5, value: (data[9] & 0x20)); |
| 1100 | input_report_key(dev: input, BTN_6, value: (data[9] & 0x40)); |
| 1101 | input_report_key(dev: input, BTN_7, value: (data[9] & 0x80)); |
| 1102 | |
| 1103 | input_report_key(dev: input, BTN_8, value: (data[10] & 0x01)); |
| 1104 | input_report_key(dev: input, BTN_9, value: (data[10] & 0x02)); |
| 1105 | input_report_key(dev: input, BTN_A, value: (data[10] & 0x04)); |
| 1106 | input_report_key(dev: input, BTN_B, value: (data[10] & 0x08)); |
| 1107 | input_report_key(dev: input, BTN_C, value: (data[10] & 0x10)); |
| 1108 | input_report_key(dev: input, BTN_X, value: (data[10] & 0x20)); |
| 1109 | input_report_key(dev: input, BTN_Y, value: (data[10] & 0x40)); |
| 1110 | input_report_key(dev: input, BTN_Z, value: (data[10] & 0x80)); |
| 1111 | |
| 1112 | input_report_key(dev: input, BTN_BASE, value: (data[11] & 0x01)); |
| 1113 | input_report_key(dev: input, BTN_BASE2, value: (data[11] & 0x02)); |
| 1114 | |
| 1115 | if (data[12] & 0x80) |
| 1116 | input_report_abs(dev: input, ABS_WHEEL, value: (data[12] & 0x7f) - 1); |
| 1117 | else |
| 1118 | input_report_abs(dev: input, ABS_WHEEL, value: 0); |
| 1119 | |
| 1120 | bat_percent = data[7] & 0x7f; |
| 1121 | bat_charging = !!(data[7] & 0x80); |
| 1122 | |
| 1123 | if (data[9] | data[10] | (data[11] & 0x03) | data[12]) |
| 1124 | input_report_abs(dev: input, ABS_MISC, PAD_DEVICE_ID); |
| 1125 | else |
| 1126 | input_report_abs(dev: input, ABS_MISC, value: 0); |
| 1127 | |
| 1128 | input_event(dev: input, EV_MSC, MSC_SERIAL, value: serial); |
| 1129 | |
| 1130 | input_sync(dev: input); |
| 1131 | |
| 1132 | /*Which mode select (LED light) is currently on?*/ |
| 1133 | touch_ring_mode = (data[11] & 0xC0) >> 6; |
| 1134 | |
| 1135 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1136 | if (remote->remotes[i].serial == serial) |
| 1137 | wacom->led.groups[i].select = touch_ring_mode; |
| 1138 | } |
| 1139 | |
| 1140 | __wacom_notify_battery(battery: &remote->remotes[index].battery, |
| 1141 | WACOM_POWER_SUPPLY_STATUS_AUTO, bat_capacity: bat_percent, |
| 1142 | bat_charging, bat_connected: 1, ps_connected: bat_charging); |
| 1143 | |
| 1144 | out: |
| 1145 | spin_unlock_irqrestore(lock: &remote->remote_lock, flags); |
| 1146 | return 0; |
| 1147 | } |
| 1148 | |
| 1149 | static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) |
| 1150 | { |
| 1151 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 1152 | unsigned char *data = wacom_wac->data; |
| 1153 | struct wacom_remote *remote = wacom->remote; |
| 1154 | struct wacom_remote_work_data remote_data; |
| 1155 | unsigned long flags; |
| 1156 | int i, ret; |
| 1157 | |
| 1158 | if (data[0] != WACOM_REPORT_DEVICE_LIST) |
| 1159 | return; |
| 1160 | |
| 1161 | memset(&remote_data, 0, sizeof(struct wacom_remote_work_data)); |
| 1162 | |
| 1163 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1164 | int j = i * 6; |
| 1165 | int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4]; |
| 1166 | |
| 1167 | remote_data.remote[i].serial = serial; |
| 1168 | } |
| 1169 | |
| 1170 | spin_lock_irqsave(&remote->remote_lock, flags); |
| 1171 | |
| 1172 | ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data)); |
| 1173 | if (ret != sizeof(remote_data)) { |
| 1174 | spin_unlock_irqrestore(lock: &remote->remote_lock, flags); |
| 1175 | hid_err(wacom->hdev, "Can't queue Remote status event.\n" ); |
| 1176 | return; |
| 1177 | } |
| 1178 | |
| 1179 | spin_unlock_irqrestore(lock: &remote->remote_lock, flags); |
| 1180 | |
| 1181 | wacom_schedule_work(wacom_wac, which: WACOM_WORKER_REMOTE); |
| 1182 | } |
| 1183 | |
| 1184 | static int int_dist(int x1, int y1, int x2, int y2) |
| 1185 | { |
| 1186 | int x = x2 - x1; |
| 1187 | int y = y2 - y1; |
| 1188 | |
| 1189 | return int_sqrt(x*x + y*y); |
| 1190 | } |
| 1191 | |
| 1192 | static void wacom_intuos_bt_process_data(struct wacom_wac *wacom, |
| 1193 | unsigned char *data) |
| 1194 | { |
| 1195 | memcpy(wacom->data, data, 10); |
| 1196 | wacom_intuos_irq(wacom); |
| 1197 | |
| 1198 | input_sync(dev: wacom->pen_input); |
| 1199 | if (wacom->pad_input) |
| 1200 | input_sync(dev: wacom->pad_input); |
| 1201 | } |
| 1202 | |
| 1203 | static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1204 | { |
| 1205 | u8 *data = kmemdup(wacom->data, len, GFP_KERNEL); |
| 1206 | int i = 1; |
| 1207 | unsigned power_raw, battery_capacity, bat_charging, ps_connected; |
| 1208 | |
| 1209 | switch (data[0]) { |
| 1210 | case 0x04: |
| 1211 | wacom_intuos_bt_process_data(wacom, data: data + i); |
| 1212 | i += 10; |
| 1213 | fallthrough; |
| 1214 | case 0x03: |
| 1215 | wacom_intuos_bt_process_data(wacom, data: data + i); |
| 1216 | i += 10; |
| 1217 | wacom_intuos_bt_process_data(wacom, data: data + i); |
| 1218 | i += 10; |
| 1219 | power_raw = data[i]; |
| 1220 | bat_charging = (power_raw & 0x08) ? 1 : 0; |
| 1221 | ps_connected = (power_raw & 0x10) ? 1 : 0; |
| 1222 | battery_capacity = batcap_i4[power_raw & 0x07]; |
| 1223 | wacom_notify_battery(wacom_wac: wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1224 | bat_capacity: battery_capacity, bat_charging, |
| 1225 | bat_connected: battery_capacity || bat_charging, |
| 1226 | ps_connected); |
| 1227 | break; |
| 1228 | default: |
| 1229 | dev_dbg(wacom->pen_input->dev.parent, |
| 1230 | "Unknown report: %d,%d size:%zu\n" , |
| 1231 | data[0], data[1], len); |
| 1232 | break; |
| 1233 | } |
| 1234 | |
| 1235 | kfree(objp: data); |
| 1236 | return 0; |
| 1237 | } |
| 1238 | |
| 1239 | static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) |
| 1240 | { |
| 1241 | struct input_dev *input = wacom->touch_input; |
| 1242 | unsigned touch_max = wacom->features.touch_max; |
| 1243 | int count = 0; |
| 1244 | int i; |
| 1245 | |
| 1246 | if (!touch_max) |
| 1247 | return 0; |
| 1248 | |
| 1249 | if (touch_max == 1) |
| 1250 | return test_bit(BTN_TOUCH, input->key) && |
| 1251 | report_touch_events(wacom); |
| 1252 | |
| 1253 | for (i = 0; i < input->mt->num_slots; i++) { |
| 1254 | struct input_mt_slot *ps = &input->mt->slots[i]; |
| 1255 | int id = input_mt_get_value(slot: ps, ABS_MT_TRACKING_ID); |
| 1256 | if (id >= 0) |
| 1257 | count++; |
| 1258 | } |
| 1259 | |
| 1260 | return count; |
| 1261 | } |
| 1262 | |
| 1263 | static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) |
| 1264 | { |
| 1265 | int pen_frame_len, pen_frames; |
| 1266 | |
| 1267 | struct input_dev *pen_input = wacom->pen_input; |
| 1268 | unsigned char *data = wacom->data; |
| 1269 | int number_of_valid_frames = 0; |
| 1270 | ktime_t time_interval = 15000000; |
| 1271 | ktime_t time_packet_received = ktime_get(); |
| 1272 | int i; |
| 1273 | |
| 1274 | if (wacom->features.type == INTUOSP2_BT || |
| 1275 | wacom->features.type == INTUOSP2S_BT) { |
| 1276 | wacom->serial[0] = get_unaligned_le64(p: &data[99]); |
| 1277 | wacom->id[0] = get_unaligned_le16(p: &data[107]); |
| 1278 | pen_frame_len = 14; |
| 1279 | pen_frames = 7; |
| 1280 | } else { |
| 1281 | wacom->serial[0] = get_unaligned_le64(p: &data[33]); |
| 1282 | wacom->id[0] = get_unaligned_le16(p: &data[41]); |
| 1283 | pen_frame_len = 8; |
| 1284 | pen_frames = 4; |
| 1285 | } |
| 1286 | |
| 1287 | if (wacom->serial[0] >> 52 == 1) { |
| 1288 | /* Add back in missing bits of ID for non-USI pens */ |
| 1289 | wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; |
| 1290 | } |
| 1291 | |
| 1292 | /* number of valid frames */ |
| 1293 | for (i = 0; i < pen_frames; i++) { |
| 1294 | unsigned char *frame = &data[i*pen_frame_len + 1]; |
| 1295 | bool valid = frame[0] & 0x80; |
| 1296 | |
| 1297 | if (valid) |
| 1298 | number_of_valid_frames++; |
| 1299 | } |
| 1300 | |
| 1301 | if (number_of_valid_frames) { |
| 1302 | if (wacom->hid_data.time_delayed) |
| 1303 | time_interval = ktime_get() - wacom->hid_data.time_delayed; |
| 1304 | time_interval = div_u64(dividend: time_interval, divisor: number_of_valid_frames); |
| 1305 | wacom->hid_data.time_delayed = time_packet_received; |
| 1306 | } |
| 1307 | |
| 1308 | for (i = 0; i < number_of_valid_frames; i++) { |
| 1309 | unsigned char *frame = &data[i*pen_frame_len + 1]; |
| 1310 | bool valid = frame[0] & 0x80; |
| 1311 | bool prox = frame[0] & 0x40; |
| 1312 | bool range = frame[0] & 0x20; |
| 1313 | bool invert = frame[0] & 0x10; |
| 1314 | int frames_number_reversed = number_of_valid_frames - i - 1; |
| 1315 | ktime_t event_timestamp = time_packet_received - frames_number_reversed * time_interval; |
| 1316 | |
| 1317 | if (!valid) |
| 1318 | continue; |
| 1319 | |
| 1320 | if (!prox) { |
| 1321 | wacom->shared->stylus_in_proximity = false; |
| 1322 | wacom_exit_report(wacom); |
| 1323 | input_sync(dev: pen_input); |
| 1324 | |
| 1325 | wacom->tool[0] = 0; |
| 1326 | wacom->id[0] = 0; |
| 1327 | wacom->serial[0] = 0; |
| 1328 | wacom->hid_data.time_delayed = 0; |
| 1329 | return; |
| 1330 | } |
| 1331 | |
| 1332 | if (range) { |
| 1333 | if (!wacom->tool[0]) { /* first in range */ |
| 1334 | /* Going into range select tool */ |
| 1335 | if (invert) |
| 1336 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 1337 | else if (wacom->id[0]) |
| 1338 | wacom->tool[0] = wacom_intuos_get_tool_type(tool_id: wacom->id[0]); |
| 1339 | else |
| 1340 | wacom->tool[0] = BTN_TOOL_PEN; |
| 1341 | } |
| 1342 | |
| 1343 | input_report_abs(dev: pen_input, ABS_X, value: get_unaligned_le16(p: &frame[1])); |
| 1344 | input_report_abs(dev: pen_input, ABS_Y, value: get_unaligned_le16(p: &frame[3])); |
| 1345 | |
| 1346 | if (wacom->features.type == INTUOSP2_BT || |
| 1347 | wacom->features.type == INTUOSP2S_BT) { |
| 1348 | /* Fix rotation alignment: userspace expects zero at left */ |
| 1349 | int16_t rotation = |
| 1350 | (int16_t)get_unaligned_le16(p: &frame[9]); |
| 1351 | rotation += 1800/4; |
| 1352 | |
| 1353 | if (rotation > 899) |
| 1354 | rotation -= 1800; |
| 1355 | |
| 1356 | input_report_abs(dev: pen_input, ABS_TILT_X, |
| 1357 | value: (signed char)frame[7]); |
| 1358 | input_report_abs(dev: pen_input, ABS_TILT_Y, |
| 1359 | value: (signed char)frame[8]); |
| 1360 | input_report_abs(dev: pen_input, ABS_Z, value: rotation); |
| 1361 | input_report_abs(dev: pen_input, ABS_WHEEL, |
| 1362 | value: get_unaligned_le16(p: &frame[11])); |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | if (wacom->tool[0]) { |
| 1367 | input_report_abs(dev: pen_input, ABS_PRESSURE, value: get_unaligned_le16(p: &frame[5])); |
| 1368 | if (wacom->features.type == INTUOSP2_BT || |
| 1369 | wacom->features.type == INTUOSP2S_BT) { |
| 1370 | input_report_abs(dev: pen_input, ABS_DISTANCE, |
| 1371 | value: range ? frame[13] : wacom->features.distance_max); |
| 1372 | } else { |
| 1373 | input_report_abs(dev: pen_input, ABS_DISTANCE, |
| 1374 | value: range ? frame[7] : wacom->features.distance_max); |
| 1375 | } |
| 1376 | |
| 1377 | input_report_key(dev: pen_input, BTN_TOUCH, value: frame[0] & 0x09); |
| 1378 | input_report_key(dev: pen_input, BTN_STYLUS, value: frame[0] & 0x02); |
| 1379 | input_report_key(dev: pen_input, BTN_STYLUS2, value: frame[0] & 0x04); |
| 1380 | |
| 1381 | input_report_key(dev: pen_input, code: wacom->tool[0], value: prox); |
| 1382 | input_event(dev: pen_input, EV_MSC, MSC_SERIAL, value: wacom->serial[0]); |
| 1383 | input_report_abs(dev: pen_input, ABS_MISC, |
| 1384 | value: wacom_intuos_id_mangle(tool_id: wacom->id[0])); /* report tool id */ |
| 1385 | } |
| 1386 | |
| 1387 | wacom->shared->stylus_in_proximity = prox; |
| 1388 | |
| 1389 | /* add timestamp to unpack the frames */ |
| 1390 | input_set_timestamp(dev: pen_input, timestamp: event_timestamp); |
| 1391 | |
| 1392 | input_sync(dev: pen_input); |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom) |
| 1397 | { |
| 1398 | const int finger_touch_len = 8; |
| 1399 | const int finger_frames = 4; |
| 1400 | const int finger_frame_len = 43; |
| 1401 | |
| 1402 | struct input_dev *touch_input = wacom->touch_input; |
| 1403 | unsigned char *data = wacom->data; |
| 1404 | int num_contacts_left = 5; |
| 1405 | int i, j; |
| 1406 | |
| 1407 | for (i = 0; i < finger_frames; i++) { |
| 1408 | unsigned char *frame = &data[i*finger_frame_len + 109]; |
| 1409 | int current_num_contacts = frame[0] & 0x7F; |
| 1410 | int contacts_to_send; |
| 1411 | |
| 1412 | if (!(frame[0] & 0x80)) |
| 1413 | continue; |
| 1414 | |
| 1415 | /* |
| 1416 | * First packet resets the counter since only the first |
| 1417 | * packet in series will have non-zero current_num_contacts. |
| 1418 | */ |
| 1419 | if (current_num_contacts) |
| 1420 | wacom->num_contacts_left = current_num_contacts; |
| 1421 | |
| 1422 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
| 1423 | |
| 1424 | for (j = 0; j < contacts_to_send; j++) { |
| 1425 | unsigned char *touch = &frame[j*finger_touch_len + 1]; |
| 1426 | int slot = input_mt_get_slot_by_key(dev: touch_input, key: touch[0]); |
| 1427 | int x = get_unaligned_le16(p: &touch[2]); |
| 1428 | int y = get_unaligned_le16(p: &touch[4]); |
| 1429 | int w = touch[6] * input_abs_get_res(dev: touch_input, ABS_MT_POSITION_X); |
| 1430 | int h = touch[7] * input_abs_get_res(dev: touch_input, ABS_MT_POSITION_Y); |
| 1431 | |
| 1432 | if (slot < 0) |
| 1433 | continue; |
| 1434 | |
| 1435 | input_mt_slot(dev: touch_input, slot); |
| 1436 | input_mt_report_slot_state(dev: touch_input, MT_TOOL_FINGER, active: touch[1] & 0x01); |
| 1437 | input_report_abs(dev: touch_input, ABS_MT_POSITION_X, value: x); |
| 1438 | input_report_abs(dev: touch_input, ABS_MT_POSITION_Y, value: y); |
| 1439 | input_report_abs(dev: touch_input, ABS_MT_TOUCH_MAJOR, max(w, h)); |
| 1440 | input_report_abs(dev: touch_input, ABS_MT_TOUCH_MINOR, min(w, h)); |
| 1441 | input_report_abs(dev: touch_input, ABS_MT_ORIENTATION, value: w > h); |
| 1442 | } |
| 1443 | |
| 1444 | input_mt_sync_frame(dev: touch_input); |
| 1445 | |
| 1446 | wacom->num_contacts_left -= contacts_to_send; |
| 1447 | if (wacom->num_contacts_left <= 0) { |
| 1448 | wacom->num_contacts_left = 0; |
| 1449 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 1450 | input_sync(dev: touch_input); |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | if (wacom->num_contacts_left == 0) { |
| 1455 | // Be careful that we don't accidentally call input_sync with |
| 1456 | // only a partial set of fingers of processed |
| 1457 | input_report_switch(dev: touch_input, SW_MUTE_DEVICE, value: !(data[281] >> 7)); |
| 1458 | input_sync(dev: touch_input); |
| 1459 | } |
| 1460 | |
| 1461 | } |
| 1462 | |
| 1463 | static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom) |
| 1464 | { |
| 1465 | struct input_dev *pad_input = wacom->pad_input; |
| 1466 | unsigned char *data = wacom->data; |
| 1467 | int nbuttons = wacom->features.numbered_buttons; |
| 1468 | |
| 1469 | int expresskeys = data[282]; |
| 1470 | int center = (data[281] & 0x40) >> 6; |
| 1471 | int ring = data[285] & 0x7F; |
| 1472 | bool ringstatus = data[285] & 0x80; |
| 1473 | bool prox = expresskeys || center || ringstatus; |
| 1474 | |
| 1475 | /* Fix touchring data: userspace expects 0 at left and increasing clockwise */ |
| 1476 | ring = 71 - ring; |
| 1477 | ring += 3*72/16; |
| 1478 | if (ring > 71) |
| 1479 | ring -= 72; |
| 1480 | |
| 1481 | wacom_report_numbered_buttons(input_dev: pad_input, button_count: nbuttons, |
| 1482 | mask: expresskeys | (center << (nbuttons - 1))); |
| 1483 | |
| 1484 | input_report_abs(dev: pad_input, ABS_WHEEL, value: ringstatus ? ring : 0); |
| 1485 | |
| 1486 | input_report_key(dev: pad_input, code: wacom->tool[1], value: prox ? 1 : 0); |
| 1487 | input_report_abs(dev: pad_input, ABS_MISC, value: prox ? PAD_DEVICE_ID : 0); |
| 1488 | input_event(dev: pad_input, EV_MSC, MSC_SERIAL, value: 0xffffffff); |
| 1489 | |
| 1490 | input_sync(dev: pad_input); |
| 1491 | } |
| 1492 | |
| 1493 | static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom) |
| 1494 | { |
| 1495 | unsigned char *data = wacom->data; |
| 1496 | |
| 1497 | bool chg = data[284] & 0x80; |
| 1498 | int battery_status = data[284] & 0x7F; |
| 1499 | |
| 1500 | wacom_notify_battery(wacom_wac: wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1501 | bat_capacity: battery_status, bat_charging: chg, bat_connected: 1, ps_connected: chg); |
| 1502 | } |
| 1503 | |
| 1504 | static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom) |
| 1505 | { |
| 1506 | struct input_dev *pad_input = wacom->pad_input; |
| 1507 | unsigned char *data = wacom->data; |
| 1508 | |
| 1509 | int buttons = data[44]; |
| 1510 | |
| 1511 | wacom_report_numbered_buttons(input_dev: pad_input, button_count: 4, mask: buttons); |
| 1512 | |
| 1513 | input_report_key(dev: pad_input, code: wacom->tool[1], value: buttons ? 1 : 0); |
| 1514 | input_report_abs(dev: pad_input, ABS_MISC, value: buttons ? PAD_DEVICE_ID : 0); |
| 1515 | input_event(dev: pad_input, EV_MSC, MSC_SERIAL, value: 0xffffffff); |
| 1516 | |
| 1517 | input_sync(dev: pad_input); |
| 1518 | } |
| 1519 | |
| 1520 | static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom) |
| 1521 | { |
| 1522 | unsigned char *data = wacom->data; |
| 1523 | |
| 1524 | bool chg = data[45] & 0x80; |
| 1525 | int battery_status = data[45] & 0x7F; |
| 1526 | |
| 1527 | wacom_notify_battery(wacom_wac: wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1528 | bat_capacity: battery_status, bat_charging: chg, bat_connected: 1, ps_connected: chg); |
| 1529 | } |
| 1530 | |
| 1531 | static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1532 | { |
| 1533 | unsigned char *data = wacom->data; |
| 1534 | |
| 1535 | if (data[0] != 0x80 && data[0] != 0x81) { |
| 1536 | dev_dbg(wacom->pen_input->dev.parent, |
| 1537 | "%s: received unknown report #%d\n" , __func__, data[0]); |
| 1538 | return 0; |
| 1539 | } |
| 1540 | |
| 1541 | wacom_intuos_pro2_bt_pen(wacom); |
| 1542 | if (wacom->features.type == INTUOSP2_BT || |
| 1543 | wacom->features.type == INTUOSP2S_BT) { |
| 1544 | wacom_intuos_pro2_bt_touch(wacom); |
| 1545 | wacom_intuos_pro2_bt_pad(wacom); |
| 1546 | wacom_intuos_pro2_bt_battery(wacom); |
| 1547 | } else { |
| 1548 | wacom_intuos_gen3_bt_pad(wacom); |
| 1549 | wacom_intuos_gen3_bt_battery(wacom); |
| 1550 | } |
| 1551 | return 0; |
| 1552 | } |
| 1553 | |
| 1554 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
| 1555 | { |
| 1556 | struct input_dev *input = wacom->touch_input; |
| 1557 | unsigned char *data = wacom->data; |
| 1558 | int i; |
| 1559 | int current_num_contacts = data[61]; |
| 1560 | int contacts_to_send = 0; |
| 1561 | int num_contacts_left = 4; /* maximum contacts per packet */ |
| 1562 | int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; |
| 1563 | int y_offset = 2; |
| 1564 | |
| 1565 | if (touch_is_muted(wacom_wac: wacom) && !wacom->shared->touch_down) |
| 1566 | return 0; |
| 1567 | |
| 1568 | if (wacom->features.type == WACOM_27QHDT) { |
| 1569 | current_num_contacts = data[63]; |
| 1570 | num_contacts_left = 10; |
| 1571 | byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET; |
| 1572 | y_offset = 0; |
| 1573 | } |
| 1574 | |
| 1575 | /* |
| 1576 | * First packet resets the counter since only the first |
| 1577 | * packet in series will have non-zero current_num_contacts. |
| 1578 | */ |
| 1579 | if (current_num_contacts) |
| 1580 | wacom->num_contacts_left = current_num_contacts; |
| 1581 | |
| 1582 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
| 1583 | |
| 1584 | for (i = 0; i < contacts_to_send; i++) { |
| 1585 | int offset = (byte_per_packet * i) + 1; |
| 1586 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
| 1587 | int slot = input_mt_get_slot_by_key(dev: input, key: data[offset + 1]); |
| 1588 | |
| 1589 | if (slot < 0) |
| 1590 | continue; |
| 1591 | input_mt_slot(dev: input, slot); |
| 1592 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: touch); |
| 1593 | |
| 1594 | if (touch) { |
| 1595 | int t_x = get_unaligned_le16(p: &data[offset + 2]); |
| 1596 | int t_y = get_unaligned_le16(p: &data[offset + 4 + y_offset]); |
| 1597 | |
| 1598 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: t_x); |
| 1599 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: t_y); |
| 1600 | |
| 1601 | if (wacom->features.type != WACOM_27QHDT) { |
| 1602 | int c_x = get_unaligned_le16(p: &data[offset + 4]); |
| 1603 | int c_y = get_unaligned_le16(p: &data[offset + 8]); |
| 1604 | int w = get_unaligned_le16(p: &data[offset + 10]); |
| 1605 | int h = get_unaligned_le16(p: &data[offset + 12]); |
| 1606 | |
| 1607 | input_report_abs(dev: input, ABS_MT_TOUCH_MAJOR, min(w,h)); |
| 1608 | input_report_abs(dev: input, ABS_MT_WIDTH_MAJOR, |
| 1609 | min(w, h) + int_dist(x1: t_x, y1: t_y, x2: c_x, y2: c_y)); |
| 1610 | input_report_abs(dev: input, ABS_MT_WIDTH_MINOR, min(w, h)); |
| 1611 | input_report_abs(dev: input, ABS_MT_ORIENTATION, value: w > h); |
| 1612 | } |
| 1613 | } |
| 1614 | } |
| 1615 | input_mt_sync_frame(dev: input); |
| 1616 | |
| 1617 | wacom->num_contacts_left -= contacts_to_send; |
| 1618 | if (wacom->num_contacts_left <= 0) { |
| 1619 | wacom->num_contacts_left = 0; |
| 1620 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 1621 | } |
| 1622 | return 1; |
| 1623 | } |
| 1624 | |
| 1625 | static int wacom_mt_touch(struct wacom_wac *wacom) |
| 1626 | { |
| 1627 | struct input_dev *input = wacom->touch_input; |
| 1628 | unsigned char *data = wacom->data; |
| 1629 | int i; |
| 1630 | int current_num_contacts = data[2]; |
| 1631 | int contacts_to_send = 0; |
| 1632 | int x_offset = 0; |
| 1633 | |
| 1634 | /* MTTPC does not support Height and Width */ |
| 1635 | if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B) |
| 1636 | x_offset = -4; |
| 1637 | |
| 1638 | /* |
| 1639 | * First packet resets the counter since only the first |
| 1640 | * packet in series will have non-zero current_num_contacts. |
| 1641 | */ |
| 1642 | if (current_num_contacts) |
| 1643 | wacom->num_contacts_left = current_num_contacts; |
| 1644 | |
| 1645 | /* There are at most 5 contacts per packet */ |
| 1646 | contacts_to_send = min(5, wacom->num_contacts_left); |
| 1647 | |
| 1648 | for (i = 0; i < contacts_to_send; i++) { |
| 1649 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; |
| 1650 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
| 1651 | int id = get_unaligned_le16(p: &data[offset + 1]); |
| 1652 | int slot = input_mt_get_slot_by_key(dev: input, key: id); |
| 1653 | |
| 1654 | if (slot < 0) |
| 1655 | continue; |
| 1656 | |
| 1657 | input_mt_slot(dev: input, slot); |
| 1658 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: touch); |
| 1659 | if (touch) { |
| 1660 | int x = get_unaligned_le16(p: &data[offset + x_offset + 7]); |
| 1661 | int y = get_unaligned_le16(p: &data[offset + x_offset + 9]); |
| 1662 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: x); |
| 1663 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: y); |
| 1664 | } |
| 1665 | } |
| 1666 | input_mt_sync_frame(dev: input); |
| 1667 | |
| 1668 | wacom->num_contacts_left -= contacts_to_send; |
| 1669 | if (wacom->num_contacts_left <= 0) { |
| 1670 | wacom->num_contacts_left = 0; |
| 1671 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 1672 | } |
| 1673 | return 1; |
| 1674 | } |
| 1675 | |
| 1676 | static int wacom_tpc_mt_touch(struct wacom_wac *wacom) |
| 1677 | { |
| 1678 | struct input_dev *input = wacom->touch_input; |
| 1679 | unsigned char *data = wacom->data; |
| 1680 | int i; |
| 1681 | |
| 1682 | for (i = 0; i < 2; i++) { |
| 1683 | int p = data[1] & (1 << i); |
| 1684 | bool touch = p && report_touch_events(wacom); |
| 1685 | |
| 1686 | input_mt_slot(dev: input, slot: i); |
| 1687 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: touch); |
| 1688 | if (touch) { |
| 1689 | int x = le16_to_cpup(p: (__le16 *)&data[i * 2 + 2]) & 0x7fff; |
| 1690 | int y = le16_to_cpup(p: (__le16 *)&data[i * 2 + 6]) & 0x7fff; |
| 1691 | |
| 1692 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: x); |
| 1693 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: y); |
| 1694 | } |
| 1695 | } |
| 1696 | input_mt_sync_frame(dev: input); |
| 1697 | |
| 1698 | /* keep touch state for pen event */ |
| 1699 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 1700 | |
| 1701 | return 1; |
| 1702 | } |
| 1703 | |
| 1704 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
| 1705 | { |
| 1706 | unsigned char *data = wacom->data; |
| 1707 | struct input_dev *input = wacom->touch_input; |
| 1708 | bool prox = report_touch_events(wacom); |
| 1709 | int x = 0, y = 0; |
| 1710 | |
| 1711 | if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG) |
| 1712 | return 0; |
| 1713 | |
| 1714 | if (len == WACOM_PKGLEN_TPC1FG) { |
| 1715 | prox = prox && (data[0] & 0x01); |
| 1716 | x = get_unaligned_le16(p: &data[1]); |
| 1717 | y = get_unaligned_le16(p: &data[3]); |
| 1718 | } else if (len == WACOM_PKGLEN_TPC1FG_B) { |
| 1719 | prox = prox && (data[2] & 0x01); |
| 1720 | x = get_unaligned_le16(p: &data[3]); |
| 1721 | y = get_unaligned_le16(p: &data[5]); |
| 1722 | } else { |
| 1723 | prox = prox && (data[1] & 0x01); |
| 1724 | x = le16_to_cpup(p: (__le16 *)&data[2]); |
| 1725 | y = le16_to_cpup(p: (__le16 *)&data[4]); |
| 1726 | } |
| 1727 | |
| 1728 | if (prox) { |
| 1729 | input_report_abs(dev: input, ABS_X, value: x); |
| 1730 | input_report_abs(dev: input, ABS_Y, value: y); |
| 1731 | } |
| 1732 | input_report_key(dev: input, BTN_TOUCH, value: prox); |
| 1733 | |
| 1734 | /* keep touch state for pen events */ |
| 1735 | wacom->shared->touch_down = prox; |
| 1736 | |
| 1737 | return 1; |
| 1738 | } |
| 1739 | |
| 1740 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
| 1741 | { |
| 1742 | unsigned char *data = wacom->data; |
| 1743 | struct input_dev *input = wacom->pen_input; |
| 1744 | bool prox = data[1] & 0x20; |
| 1745 | |
| 1746 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
| 1747 | /* Going into proximity select tool */ |
| 1748 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 1749 | |
| 1750 | /* keep pen state for touch events */ |
| 1751 | wacom->shared->stylus_in_proximity = prox; |
| 1752 | |
| 1753 | /* send pen events only when touch is up or forced out |
| 1754 | * or touch arbitration is off |
| 1755 | */ |
| 1756 | if (!delay_pen_events(wacom)) { |
| 1757 | input_report_key(dev: input, BTN_STYLUS, value: data[1] & 0x02); |
| 1758 | input_report_key(dev: input, BTN_STYLUS2, value: data[1] & 0x10); |
| 1759 | input_report_abs(dev: input, ABS_X, le16_to_cpup(p: (__le16 *)&data[2])); |
| 1760 | input_report_abs(dev: input, ABS_Y, le16_to_cpup(p: (__le16 *)&data[4])); |
| 1761 | input_report_abs(dev: input, ABS_PRESSURE, value: ((data[7] & 0x07) << 8) | data[6]); |
| 1762 | input_report_key(dev: input, BTN_TOUCH, value: data[1] & 0x05); |
| 1763 | input_report_key(dev: input, code: wacom->tool[0], value: prox); |
| 1764 | return 1; |
| 1765 | } |
| 1766 | |
| 1767 | return 0; |
| 1768 | } |
| 1769 | |
| 1770 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) |
| 1771 | { |
| 1772 | unsigned char *data = wacom->data; |
| 1773 | |
| 1774 | if (wacom->pen_input) { |
| 1775 | dev_dbg(wacom->pen_input->dev.parent, |
| 1776 | "%s: received report #%d\n" , __func__, data[0]); |
| 1777 | |
| 1778 | if (len == WACOM_PKGLEN_PENABLED || |
| 1779 | data[0] == WACOM_REPORT_PENABLED) |
| 1780 | return wacom_tpc_pen(wacom); |
| 1781 | } |
| 1782 | else if (wacom->touch_input) { |
| 1783 | dev_dbg(wacom->touch_input->dev.parent, |
| 1784 | "%s: received report #%d\n" , __func__, data[0]); |
| 1785 | |
| 1786 | switch (len) { |
| 1787 | case WACOM_PKGLEN_TPC1FG: |
| 1788 | return wacom_tpc_single_touch(wacom, len); |
| 1789 | |
| 1790 | case WACOM_PKGLEN_TPC2FG: |
| 1791 | return wacom_tpc_mt_touch(wacom); |
| 1792 | |
| 1793 | default: |
| 1794 | switch (data[0]) { |
| 1795 | case WACOM_REPORT_TPC1FG: |
| 1796 | case WACOM_REPORT_TPCHID: |
| 1797 | case WACOM_REPORT_TPCST: |
| 1798 | case WACOM_REPORT_TPC1FGE: |
| 1799 | return wacom_tpc_single_touch(wacom, len); |
| 1800 | |
| 1801 | case WACOM_REPORT_TPCMT: |
| 1802 | case WACOM_REPORT_TPCMT2: |
| 1803 | return wacom_mt_touch(wacom); |
| 1804 | |
| 1805 | } |
| 1806 | } |
| 1807 | } |
| 1808 | |
| 1809 | return 0; |
| 1810 | } |
| 1811 | |
| 1812 | static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage, |
| 1813 | int value, int num, int denom) |
| 1814 | { |
| 1815 | struct input_absinfo *abs = &input->absinfo[usage->code]; |
| 1816 | int range = (abs->maximum - abs->minimum + 1); |
| 1817 | |
| 1818 | value += num*range/denom; |
| 1819 | if (value > abs->maximum) |
| 1820 | value -= range; |
| 1821 | else if (value < abs->minimum) |
| 1822 | value += range; |
| 1823 | return value; |
| 1824 | } |
| 1825 | |
| 1826 | int wacom_equivalent_usage(int usage) |
| 1827 | { |
| 1828 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) { |
| 1829 | int subpage = (usage & 0xFF00) << 8; |
| 1830 | int subusage = (usage & 0xFF); |
| 1831 | |
| 1832 | if (subpage == WACOM_HID_SP_PAD || |
| 1833 | subpage == WACOM_HID_SP_BUTTON || |
| 1834 | subpage == WACOM_HID_SP_DIGITIZER || |
| 1835 | subpage == WACOM_HID_SP_DIGITIZERINFO || |
| 1836 | usage == WACOM_HID_WD_SENSE || |
| 1837 | usage == WACOM_HID_WD_SERIALHI || |
| 1838 | usage == WACOM_HID_WD_TOOLTYPE || |
| 1839 | usage == WACOM_HID_WD_DISTANCE || |
| 1840 | usage == WACOM_HID_WD_TOUCHSTRIP || |
| 1841 | usage == WACOM_HID_WD_TOUCHSTRIP2 || |
| 1842 | usage == WACOM_HID_WD_TOUCHRING || |
| 1843 | usage == WACOM_HID_WD_TOUCHRINGSTATUS || |
| 1844 | usage == WACOM_HID_WD_REPORT_VALID || |
| 1845 | usage == WACOM_HID_WD_BARRELSWITCH3 || |
| 1846 | usage == WACOM_HID_WD_SEQUENCENUMBER) { |
| 1847 | return usage; |
| 1848 | } |
| 1849 | |
| 1850 | if (subpage == HID_UP_UNDEFINED) |
| 1851 | subpage = HID_UP_DIGITIZER; |
| 1852 | |
| 1853 | return subpage | subusage; |
| 1854 | } |
| 1855 | |
| 1856 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) { |
| 1857 | int subpage = (usage & 0xFF00) << 8; |
| 1858 | int subusage = (usage & 0xFF); |
| 1859 | |
| 1860 | if (usage == WACOM_HID_WT_REPORT_VALID) |
| 1861 | return usage; |
| 1862 | |
| 1863 | if (subpage == HID_UP_UNDEFINED) |
| 1864 | subpage = WACOM_HID_SP_DIGITIZER; |
| 1865 | |
| 1866 | return subpage | subusage; |
| 1867 | } |
| 1868 | |
| 1869 | return usage; |
| 1870 | } |
| 1871 | |
| 1872 | static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, |
| 1873 | struct hid_field *field, __u8 type, __u16 code, int fuzz) |
| 1874 | { |
| 1875 | struct wacom *wacom = input_get_drvdata(dev: input); |
| 1876 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1877 | struct wacom_features *features = &wacom_wac->features; |
| 1878 | int fmin = field->logical_minimum; |
| 1879 | int fmax = field->logical_maximum; |
| 1880 | unsigned int equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 1881 | int resolution_code = code; |
| 1882 | int resolution; |
| 1883 | |
| 1884 | if (equivalent_usage == HID_DG_TWIST) { |
| 1885 | resolution_code = ABS_RZ; |
| 1886 | } |
| 1887 | |
| 1888 | resolution = hidinput_calc_abs_res(field, code: resolution_code); |
| 1889 | |
| 1890 | if (equivalent_usage == HID_GD_X) { |
| 1891 | fmin += features->offset_left; |
| 1892 | fmax -= features->offset_right; |
| 1893 | } |
| 1894 | if (equivalent_usage == HID_GD_Y) { |
| 1895 | fmin += features->offset_top; |
| 1896 | fmax -= features->offset_bottom; |
| 1897 | } |
| 1898 | |
| 1899 | usage->type = type; |
| 1900 | usage->code = code; |
| 1901 | |
| 1902 | switch (type) { |
| 1903 | case EV_ABS: |
| 1904 | input_set_abs_params(dev: input, axis: code, min: fmin, max: fmax, fuzz, flat: 0); |
| 1905 | |
| 1906 | /* older tablet may miss physical usage */ |
| 1907 | if ((code == ABS_X || code == ABS_Y) && !resolution) { |
| 1908 | resolution = WACOM_INTUOS_RES; |
| 1909 | hid_warn(input, |
| 1910 | "Using default resolution for axis type 0x%x code 0x%x\n" , |
| 1911 | type, code); |
| 1912 | } |
| 1913 | input_abs_set_res(dev: input, axis: code, val: resolution); |
| 1914 | break; |
| 1915 | case EV_REL: |
| 1916 | case EV_KEY: |
| 1917 | case EV_MSC: |
| 1918 | case EV_SW: |
| 1919 | input_set_capability(dev: input, type, code); |
| 1920 | break; |
| 1921 | } |
| 1922 | } |
| 1923 | |
| 1924 | static void wacom_wac_battery_usage_mapping(struct hid_device *hdev, |
| 1925 | struct hid_field *field, struct hid_usage *usage) |
| 1926 | { |
| 1927 | return; |
| 1928 | } |
| 1929 | |
| 1930 | static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field, |
| 1931 | struct hid_usage *usage, __s32 value) |
| 1932 | { |
| 1933 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1934 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1935 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 1936 | |
| 1937 | switch (equivalent_usage) { |
| 1938 | case HID_DG_BATTERYSTRENGTH: |
| 1939 | if (value == 0) { |
| 1940 | wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN; |
| 1941 | } |
| 1942 | else { |
| 1943 | value = value * 100 / (field->logical_maximum - field->logical_minimum); |
| 1944 | wacom_wac->hid_data.battery_capacity = value; |
| 1945 | wacom_wac->hid_data.bat_connected = 1; |
| 1946 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1947 | } |
| 1948 | wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; |
| 1949 | break; |
| 1950 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1951 | value = value * 100 / (field->logical_maximum - field->logical_minimum); |
| 1952 | wacom_wac->hid_data.battery_capacity = value; |
| 1953 | wacom_wac->hid_data.bat_connected = 1; |
| 1954 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1955 | wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; |
| 1956 | break; |
| 1957 | case WACOM_HID_WD_BATTERY_CHARGING: |
| 1958 | wacom_wac->hid_data.bat_charging = value; |
| 1959 | wacom_wac->hid_data.ps_connected = value; |
| 1960 | wacom_wac->hid_data.bat_connected = 1; |
| 1961 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1962 | wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; |
| 1963 | break; |
| 1964 | } |
| 1965 | } |
| 1966 | |
| 1967 | static void wacom_wac_battery_pre_report(struct hid_device *hdev, |
| 1968 | struct hid_report *report) |
| 1969 | { |
| 1970 | return; |
| 1971 | } |
| 1972 | |
| 1973 | static void wacom_wac_battery_report(struct hid_device *hdev, |
| 1974 | struct hid_report *report) |
| 1975 | { |
| 1976 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1977 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1978 | |
| 1979 | int status = wacom_wac->hid_data.bat_status; |
| 1980 | int capacity = wacom_wac->hid_data.battery_capacity; |
| 1981 | bool charging = wacom_wac->hid_data.bat_charging; |
| 1982 | bool connected = wacom_wac->hid_data.bat_connected; |
| 1983 | bool powered = wacom_wac->hid_data.ps_connected; |
| 1984 | |
| 1985 | wacom_notify_battery(wacom_wac, bat_status: status, bat_capacity: capacity, bat_charging: charging, |
| 1986 | bat_connected: connected, ps_connected: powered); |
| 1987 | } |
| 1988 | |
| 1989 | static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, |
| 1990 | struct hid_field *field, struct hid_usage *usage) |
| 1991 | { |
| 1992 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1993 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1994 | struct wacom_features *features = &wacom_wac->features; |
| 1995 | struct input_dev *input = wacom_wac->pad_input; |
| 1996 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 1997 | |
| 1998 | switch (equivalent_usage) { |
| 1999 | case WACOM_HID_WD_ACCELEROMETER_X: |
| 2000 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 2001 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, fuzz: 0); |
| 2002 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2003 | break; |
| 2004 | case WACOM_HID_WD_ACCELEROMETER_Y: |
| 2005 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 2006 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, fuzz: 0); |
| 2007 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2008 | break; |
| 2009 | case WACOM_HID_WD_ACCELEROMETER_Z: |
| 2010 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 2011 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, fuzz: 0); |
| 2012 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2013 | break; |
| 2014 | case WACOM_HID_WD_BUTTONCENTER: |
| 2015 | case WACOM_HID_WD_BUTTONHOME: |
| 2016 | case WACOM_HID_WD_BUTTONUP: |
| 2017 | case WACOM_HID_WD_BUTTONDOWN: |
| 2018 | case WACOM_HID_WD_BUTTONLEFT: |
| 2019 | case WACOM_HID_WD_BUTTONRIGHT: |
| 2020 | wacom_map_usage(input, usage, field, EV_KEY, |
| 2021 | code: wacom_numbered_button_to_key(n: features->numbered_buttons), |
| 2022 | fuzz: 0); |
| 2023 | features->numbered_buttons++; |
| 2024 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2025 | break; |
| 2026 | case WACOM_HID_WD_MUTE_DEVICE: |
| 2027 | /* softkey touch switch */ |
| 2028 | wacom_wac->is_soft_touch_switch = true; |
| 2029 | fallthrough; |
| 2030 | case WACOM_HID_WD_TOUCHONOFF: |
| 2031 | /* |
| 2032 | * These two usages, which are used to mute touch events, come |
| 2033 | * from the pad packet, but are reported on the touch |
| 2034 | * interface. Because the touch interface may not have |
| 2035 | * been created yet, we cannot call wacom_map_usage(). In |
| 2036 | * order to process the usages when we receive them, we set |
| 2037 | * the usage type and code directly. |
| 2038 | */ |
| 2039 | wacom_wac->has_mute_touch_switch = true; |
| 2040 | usage->type = EV_SW; |
| 2041 | usage->code = SW_MUTE_DEVICE; |
| 2042 | break; |
| 2043 | case WACOM_HID_WD_TOUCHSTRIP: |
| 2044 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, fuzz: 0); |
| 2045 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2046 | break; |
| 2047 | case WACOM_HID_WD_TOUCHSTRIP2: |
| 2048 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, fuzz: 0); |
| 2049 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2050 | break; |
| 2051 | case WACOM_HID_WD_TOUCHRING: |
| 2052 | if (field->flags & HID_MAIN_ITEM_RELATIVE) { |
| 2053 | wacom_wac->relring_count++; |
| 2054 | if (wacom_wac->relring_count == 1) { |
| 2055 | wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, fuzz: 0); |
| 2056 | set_bit(REL_WHEEL, addr: input->relbit); |
| 2057 | } |
| 2058 | else if (wacom_wac->relring_count == 2) { |
| 2059 | wacom_map_usage(input, usage, field, EV_REL, REL_HWHEEL_HI_RES, fuzz: 0); |
| 2060 | set_bit(REL_HWHEEL, addr: input->relbit); |
| 2061 | } |
| 2062 | } else { |
| 2063 | wacom_wac->absring_count++; |
| 2064 | if (wacom_wac->absring_count == 1) |
| 2065 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, fuzz: 0); |
| 2066 | else if (wacom_wac->absring_count == 2) |
| 2067 | wacom_map_usage(input, usage, field, EV_ABS, ABS_THROTTLE, fuzz: 0); |
| 2068 | } |
| 2069 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2070 | break; |
| 2071 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
| 2072 | /* |
| 2073 | * Only set up type/code association. Completely mapping |
| 2074 | * this usage may overwrite the axis resolution and range. |
| 2075 | */ |
| 2076 | usage->type = EV_ABS; |
| 2077 | usage->code = ABS_WHEEL; |
| 2078 | set_bit(EV_ABS, addr: input->evbit); |
| 2079 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2080 | break; |
| 2081 | case WACOM_HID_WD_BUTTONCONFIG: |
| 2082 | wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, fuzz: 0); |
| 2083 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2084 | break; |
| 2085 | case WACOM_HID_WD_ONSCREEN_KEYBOARD: |
| 2086 | wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, fuzz: 0); |
| 2087 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2088 | break; |
| 2089 | case WACOM_HID_WD_CONTROLPANEL: |
| 2090 | wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, fuzz: 0); |
| 2091 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2092 | break; |
| 2093 | case WACOM_HID_WD_MODE_CHANGE: |
| 2094 | /* do not overwrite previous data */ |
| 2095 | if (!wacom_wac->has_mode_change) { |
| 2096 | wacom_wac->has_mode_change = true; |
| 2097 | wacom_wac->is_direct_mode = true; |
| 2098 | } |
| 2099 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2100 | break; |
| 2101 | } |
| 2102 | |
| 2103 | switch (equivalent_usage & 0xfffffff0) { |
| 2104 | case WACOM_HID_WD_EXPRESSKEY00: |
| 2105 | wacom_map_usage(input, usage, field, EV_KEY, |
| 2106 | code: wacom_numbered_button_to_key(n: features->numbered_buttons), |
| 2107 | fuzz: 0); |
| 2108 | features->numbered_buttons++; |
| 2109 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2110 | break; |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, |
| 2115 | struct hid_usage *usage, __s32 value) |
| 2116 | { |
| 2117 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2118 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2119 | struct input_dev *input = wacom_wac->pad_input; |
| 2120 | struct wacom_features *features = &wacom_wac->features; |
| 2121 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 2122 | int i; |
| 2123 | bool do_report = false; |
| 2124 | |
| 2125 | /* |
| 2126 | * Avoid reporting this event and setting inrange_state if this usage |
| 2127 | * hasn't been mapped. |
| 2128 | */ |
| 2129 | if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE) |
| 2130 | return; |
| 2131 | |
| 2132 | if (wacom_equivalent_usage(usage: field->physical) == HID_DG_TABLETFUNCTIONKEY) { |
| 2133 | bool is_abs_touchring = usage->hid == WACOM_HID_WD_TOUCHRING && |
| 2134 | !(field->flags & HID_MAIN_ITEM_RELATIVE); |
| 2135 | |
| 2136 | if (!is_abs_touchring) |
| 2137 | wacom_wac->hid_data.inrange_state |= value; |
| 2138 | } |
| 2139 | |
| 2140 | /* Process touch switch state first since it is reported through touch interface, |
| 2141 | * which is indepentent of pad interface. In the case when there are no other pad |
| 2142 | * events, the pad interface will not even be created. |
| 2143 | */ |
| 2144 | if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) || |
| 2145 | (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) { |
| 2146 | if (wacom_wac->shared->touch_input) { |
| 2147 | bool *is_touch_on = &wacom_wac->shared->is_touch_on; |
| 2148 | |
| 2149 | if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) |
| 2150 | *is_touch_on = !(*is_touch_on); |
| 2151 | else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) |
| 2152 | *is_touch_on = value; |
| 2153 | |
| 2154 | input_report_switch(dev: wacom_wac->shared->touch_input, |
| 2155 | SW_MUTE_DEVICE, value: !(*is_touch_on)); |
| 2156 | input_sync(dev: wacom_wac->shared->touch_input); |
| 2157 | } |
| 2158 | return; |
| 2159 | } |
| 2160 | |
| 2161 | if (!input) |
| 2162 | return; |
| 2163 | |
| 2164 | switch (equivalent_usage) { |
| 2165 | case WACOM_HID_WD_TOUCHRING: |
| 2166 | /* |
| 2167 | * Userspace expects touchrings to increase in value with |
| 2168 | * clockwise gestures and have their zero point at the |
| 2169 | * tablet's left. HID events "should" be clockwise- |
| 2170 | * increasing and zero at top, though the MobileStudio |
| 2171 | * Pro and 2nd-gen Intuos Pro don't do this... |
| 2172 | */ |
| 2173 | if (hdev->vendor == 0x56a && |
| 2174 | (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */ |
| 2175 | hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */ |
| 2176 | hdev->product == 0x392 || /* Intuos Pro 2 */ |
| 2177 | hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */ |
| 2178 | hdev->product == 0x3AA)) { /* MobileStudio Pro */ |
| 2179 | value = (field->logical_maximum - value); |
| 2180 | |
| 2181 | if (hdev->product == 0x357 || hdev->product == 0x358 || |
| 2182 | hdev->product == 0x392) |
| 2183 | value = wacom_offset_rotation(input, usage, value, num: 3, denom: 16); |
| 2184 | else if (hdev->product == 0x34d || hdev->product == 0x34e || |
| 2185 | hdev->product == 0x398 || hdev->product == 0x399 || |
| 2186 | hdev->product == 0x3AA) |
| 2187 | value = wacom_offset_rotation(input, usage, value, num: 1, denom: 2); |
| 2188 | } |
| 2189 | else if (field->flags & HID_MAIN_ITEM_RELATIVE) { |
| 2190 | int hires_value = value * 120 / usage->resolution_multiplier; |
| 2191 | int *ring_value; |
| 2192 | int lowres_code; |
| 2193 | |
| 2194 | if (usage->code == REL_WHEEL_HI_RES) { |
| 2195 | /* We must invert the sign for vertical |
| 2196 | * relative scrolling. Clockwise |
| 2197 | * rotation produces positive values |
| 2198 | * from HW, but userspace treats |
| 2199 | * positive REL_WHEEL as a scroll *up*! |
| 2200 | */ |
| 2201 | hires_value = -hires_value; |
| 2202 | ring_value = &wacom_wac->hid_data.ring_value; |
| 2203 | lowres_code = REL_WHEEL; |
| 2204 | } |
| 2205 | else if (usage->code == REL_HWHEEL_HI_RES) { |
| 2206 | /* No need to invert the sign for |
| 2207 | * horizontal relative scrolling. |
| 2208 | * Clockwise rotation produces positive |
| 2209 | * values from HW and userspace treats |
| 2210 | * positive REL_HWHEEL as a scroll |
| 2211 | * right. |
| 2212 | */ |
| 2213 | ring_value = &wacom_wac->hid_data.ring2_value; |
| 2214 | lowres_code = REL_HWHEEL; |
| 2215 | } |
| 2216 | else { |
| 2217 | hid_err(wacom->hdev, "unrecognized relative wheel with code %d\n" , |
| 2218 | usage->code); |
| 2219 | break; |
| 2220 | } |
| 2221 | |
| 2222 | value = hires_value; |
| 2223 | *ring_value += hires_value; |
| 2224 | |
| 2225 | /* Emulate a legacy wheel click for every 120 |
| 2226 | * units of hi-res travel. |
| 2227 | */ |
| 2228 | if (*ring_value >= 120 || *ring_value <= -120) { |
| 2229 | int clicks = *ring_value / 120; |
| 2230 | |
| 2231 | input_event(dev: input, type: usage->type, code: lowres_code, value: clicks); |
| 2232 | *ring_value -= clicks * 120; |
| 2233 | } |
| 2234 | } |
| 2235 | else { |
| 2236 | value = wacom_offset_rotation(input, usage, value, num: 1, denom: 4); |
| 2237 | } |
| 2238 | do_report = true; |
| 2239 | break; |
| 2240 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
| 2241 | if (!value) |
| 2242 | input_event(dev: input, type: usage->type, code: usage->code, value: 0); |
| 2243 | break; |
| 2244 | |
| 2245 | case WACOM_HID_WD_MODE_CHANGE: |
| 2246 | if (wacom_wac->is_direct_mode != value) { |
| 2247 | wacom_wac->is_direct_mode = value; |
| 2248 | wacom_schedule_work(wacom_wac: &wacom->wacom_wac, which: WACOM_WORKER_MODE_CHANGE); |
| 2249 | } |
| 2250 | break; |
| 2251 | |
| 2252 | case WACOM_HID_WD_BUTTONCENTER: |
| 2253 | for (i = 0; i < wacom->led.count; i++) |
| 2254 | wacom_update_led(wacom, button_count: features->numbered_buttons, |
| 2255 | mask: value, group: i); |
| 2256 | fallthrough; |
| 2257 | default: |
| 2258 | do_report = true; |
| 2259 | break; |
| 2260 | } |
| 2261 | |
| 2262 | if (do_report) { |
| 2263 | input_event(dev: input, type: usage->type, code: usage->code, value); |
| 2264 | if (value) |
| 2265 | wacom_wac->hid_data.pad_input_event_flag = true; |
| 2266 | } |
| 2267 | } |
| 2268 | |
| 2269 | static void wacom_wac_pad_pre_report(struct hid_device *hdev, |
| 2270 | struct hid_report *report) |
| 2271 | { |
| 2272 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2273 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2274 | |
| 2275 | wacom_wac->hid_data.inrange_state = 0; |
| 2276 | } |
| 2277 | |
| 2278 | static void wacom_wac_pad_report(struct hid_device *hdev, |
| 2279 | struct hid_report *report, struct hid_field *field) |
| 2280 | { |
| 2281 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2282 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2283 | struct input_dev *input = wacom_wac->pad_input; |
| 2284 | bool active = wacom_wac->hid_data.inrange_state != 0; |
| 2285 | |
| 2286 | /* report prox for expresskey events */ |
| 2287 | if (wacom_wac->hid_data.pad_input_event_flag) { |
| 2288 | input_event(dev: input, EV_ABS, ABS_MISC, value: active ? PAD_DEVICE_ID : 0); |
| 2289 | input_sync(dev: input); |
| 2290 | if (!active) |
| 2291 | wacom_wac->hid_data.pad_input_event_flag = false; |
| 2292 | } |
| 2293 | } |
| 2294 | |
| 2295 | static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac) |
| 2296 | { |
| 2297 | struct input_dev *input = wacom_wac->pen_input; |
| 2298 | struct wacom_features *features = &wacom_wac->features; |
| 2299 | |
| 2300 | if (!(features->quirks & WACOM_QUIRK_AESPEN) && |
| 2301 | wacom_wac->hid_data.barrelswitch && |
| 2302 | wacom_wac->hid_data.barrelswitch2 && |
| 2303 | wacom_wac->hid_data.serialhi && |
| 2304 | !wacom_wac->hid_data.barrelswitch3) { |
| 2305 | input_set_capability(dev: input, EV_KEY, BTN_STYLUS3); |
| 2306 | features->quirks |= WACOM_QUIRK_PEN_BUTTON3; |
| 2307 | } |
| 2308 | } |
| 2309 | |
| 2310 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, |
| 2311 | struct hid_field *field, struct hid_usage *usage) |
| 2312 | { |
| 2313 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2314 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2315 | struct wacom_features *features = &wacom_wac->features; |
| 2316 | struct input_dev *input = wacom_wac->pen_input; |
| 2317 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 2318 | |
| 2319 | switch (equivalent_usage) { |
| 2320 | case HID_GD_X: |
| 2321 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, fuzz: 4); |
| 2322 | break; |
| 2323 | case HID_GD_Y: |
| 2324 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, fuzz: 4); |
| 2325 | break; |
| 2326 | case WACOM_HID_WD_DISTANCE: |
| 2327 | case HID_GD_Z: |
| 2328 | wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, fuzz: 0); |
| 2329 | break; |
| 2330 | case HID_DG_TIPPRESSURE: |
| 2331 | wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, fuzz: 0); |
| 2332 | break; |
| 2333 | case HID_DG_INRANGE: |
| 2334 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, fuzz: 0); |
| 2335 | break; |
| 2336 | case HID_DG_INVERT: |
| 2337 | wacom_map_usage(input, usage, field, EV_KEY, |
| 2338 | BTN_TOOL_RUBBER, fuzz: 0); |
| 2339 | break; |
| 2340 | case HID_DG_TILT_X: |
| 2341 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, fuzz: 0); |
| 2342 | break; |
| 2343 | case HID_DG_TILT_Y: |
| 2344 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, fuzz: 0); |
| 2345 | break; |
| 2346 | case HID_DG_TWIST: |
| 2347 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, fuzz: 0); |
| 2348 | break; |
| 2349 | case HID_DG_ERASER: |
| 2350 | input_set_capability(dev: input, EV_KEY, BTN_TOOL_RUBBER); |
| 2351 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, fuzz: 0); |
| 2352 | break; |
| 2353 | case HID_DG_TIPSWITCH: |
| 2354 | input_set_capability(dev: input, EV_KEY, BTN_TOOL_PEN); |
| 2355 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, fuzz: 0); |
| 2356 | break; |
| 2357 | case HID_DG_BARRELSWITCH: |
| 2358 | wacom_wac->hid_data.barrelswitch = true; |
| 2359 | wacom_set_barrel_switch3_usage(wacom_wac); |
| 2360 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, fuzz: 0); |
| 2361 | break; |
| 2362 | case HID_DG_BARRELSWITCH2: |
| 2363 | wacom_wac->hid_data.barrelswitch2 = true; |
| 2364 | wacom_set_barrel_switch3_usage(wacom_wac); |
| 2365 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, fuzz: 0); |
| 2366 | break; |
| 2367 | case HID_DG_TOOLSERIALNUMBER: |
| 2368 | features->quirks |= WACOM_QUIRK_TOOLSERIAL; |
| 2369 | wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, fuzz: 0); |
| 2370 | break; |
| 2371 | case HID_DG_SCANTIME: |
| 2372 | wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, fuzz: 0); |
| 2373 | break; |
| 2374 | case WACOM_HID_WD_SENSE: |
| 2375 | features->quirks |= WACOM_QUIRK_SENSE; |
| 2376 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, fuzz: 0); |
| 2377 | break; |
| 2378 | case WACOM_HID_WD_SERIALHI: |
| 2379 | wacom_wac->hid_data.serialhi = true; |
| 2380 | wacom_set_barrel_switch3_usage(wacom_wac); |
| 2381 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, fuzz: 0); |
| 2382 | break; |
| 2383 | case WACOM_HID_WD_FINGERWHEEL: |
| 2384 | input_set_capability(dev: input, EV_KEY, BTN_TOOL_AIRBRUSH); |
| 2385 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, fuzz: 0); |
| 2386 | break; |
| 2387 | case WACOM_HID_WD_BARRELSWITCH3: |
| 2388 | wacom_wac->hid_data.barrelswitch3 = true; |
| 2389 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, fuzz: 0); |
| 2390 | features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3; |
| 2391 | break; |
| 2392 | case WACOM_HID_WD_SEQUENCENUMBER: |
| 2393 | wacom_wac->hid_data.sequence_number = -1; |
| 2394 | break; |
| 2395 | } |
| 2396 | } |
| 2397 | |
| 2398 | static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field, |
| 2399 | struct hid_usage *usage, __s32 value) |
| 2400 | { |
| 2401 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2402 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2403 | struct wacom_features *features = &wacom_wac->features; |
| 2404 | struct input_dev *input = wacom_wac->pen_input; |
| 2405 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 2406 | |
| 2407 | if (wacom_wac->is_invalid_bt_frame) |
| 2408 | return; |
| 2409 | |
| 2410 | switch (equivalent_usage) { |
| 2411 | case HID_GD_Z: |
| 2412 | /* |
| 2413 | * HID_GD_Z "should increase as the control's position is |
| 2414 | * moved from high to low", while ABS_DISTANCE instead |
| 2415 | * increases in value as the tool moves from low to high. |
| 2416 | */ |
| 2417 | value = field->logical_maximum - value; |
| 2418 | break; |
| 2419 | case HID_DG_INRANGE: |
| 2420 | mod_timer(timer: &wacom->idleprox_timer, expires: jiffies + msecs_to_jiffies(m: 100)); |
| 2421 | wacom_wac->hid_data.inrange_state = value; |
| 2422 | if (!(features->quirks & WACOM_QUIRK_SENSE)) |
| 2423 | wacom_wac->hid_data.sense_state = value; |
| 2424 | return; |
| 2425 | case HID_DG_INVERT: |
| 2426 | wacom_wac->hid_data.eraser |= value; |
| 2427 | return; |
| 2428 | case HID_DG_ERASER: |
| 2429 | wacom_wac->hid_data.eraser |= value; |
| 2430 | fallthrough; |
| 2431 | case HID_DG_TIPSWITCH: |
| 2432 | wacom_wac->hid_data.tipswitch |= value; |
| 2433 | return; |
| 2434 | case HID_DG_BARRELSWITCH: |
| 2435 | wacom_wac->hid_data.barrelswitch = value; |
| 2436 | return; |
| 2437 | case HID_DG_BARRELSWITCH2: |
| 2438 | wacom_wac->hid_data.barrelswitch2 = value; |
| 2439 | return; |
| 2440 | case HID_DG_TOOLSERIALNUMBER: |
| 2441 | if (value) { |
| 2442 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
| 2443 | wacom_wac->serial[0] |= wacom_s32tou(value, n: field->report_size); |
| 2444 | } |
| 2445 | return; |
| 2446 | case HID_DG_TWIST: |
| 2447 | /* don't modify the value if the pen doesn't support the feature */ |
| 2448 | if (!wacom_is_art_pen(tool_id: wacom_wac->id[0])) return; |
| 2449 | |
| 2450 | /* |
| 2451 | * Userspace expects pen twist to have its zero point when |
| 2452 | * the buttons/finger is on the tablet's left. HID values |
| 2453 | * are zero when buttons are toward the top. |
| 2454 | */ |
| 2455 | value = wacom_offset_rotation(input, usage, value, num: 1, denom: 4); |
| 2456 | break; |
| 2457 | case WACOM_HID_WD_SENSE: |
| 2458 | wacom_wac->hid_data.sense_state = value; |
| 2459 | return; |
| 2460 | case WACOM_HID_WD_SERIALHI: |
| 2461 | if (value) { |
| 2462 | __u32 raw_value = wacom_s32tou(value, n: field->report_size); |
| 2463 | |
| 2464 | wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); |
| 2465 | wacom_wac->serial[0] |= ((__u64)raw_value) << 32; |
| 2466 | /* |
| 2467 | * Non-USI EMR devices may contain additional tool type |
| 2468 | * information here. See WACOM_HID_WD_TOOLTYPE case for |
| 2469 | * more details. |
| 2470 | */ |
| 2471 | if (value >> 20 == 1) { |
| 2472 | wacom_wac->id[0] |= raw_value & 0xFFFFF; |
| 2473 | } |
| 2474 | } |
| 2475 | return; |
| 2476 | case WACOM_HID_WD_TOOLTYPE: |
| 2477 | /* |
| 2478 | * Some devices (MobileStudio Pro, and possibly later |
| 2479 | * devices as well) do not return the complete tool |
| 2480 | * type in their WACOM_HID_WD_TOOLTYPE usage. Use a |
| 2481 | * bitwise OR so the complete value can be built |
| 2482 | * up over time :( |
| 2483 | */ |
| 2484 | wacom_wac->id[0] |= wacom_s32tou(value, n: field->report_size); |
| 2485 | return; |
| 2486 | case WACOM_HID_WD_OFFSETLEFT: |
| 2487 | if (features->offset_left && value != features->offset_left) |
| 2488 | hid_warn(hdev, "%s: overriding existing left offset " |
| 2489 | "%d -> %d\n" , __func__, value, |
| 2490 | features->offset_left); |
| 2491 | features->offset_left = value; |
| 2492 | return; |
| 2493 | case WACOM_HID_WD_OFFSETRIGHT: |
| 2494 | if (features->offset_right && value != features->offset_right) |
| 2495 | hid_warn(hdev, "%s: overriding existing right offset " |
| 2496 | "%d -> %d\n" , __func__, value, |
| 2497 | features->offset_right); |
| 2498 | features->offset_right = value; |
| 2499 | return; |
| 2500 | case WACOM_HID_WD_OFFSETTOP: |
| 2501 | if (features->offset_top && value != features->offset_top) |
| 2502 | hid_warn(hdev, "%s: overriding existing top offset " |
| 2503 | "%d -> %d\n" , __func__, value, |
| 2504 | features->offset_top); |
| 2505 | features->offset_top = value; |
| 2506 | return; |
| 2507 | case WACOM_HID_WD_OFFSETBOTTOM: |
| 2508 | if (features->offset_bottom && value != features->offset_bottom) |
| 2509 | hid_warn(hdev, "%s: overriding existing bottom offset " |
| 2510 | "%d -> %d\n" , __func__, value, |
| 2511 | features->offset_bottom); |
| 2512 | features->offset_bottom = value; |
| 2513 | return; |
| 2514 | case WACOM_HID_WD_REPORT_VALID: |
| 2515 | wacom_wac->is_invalid_bt_frame = !value; |
| 2516 | return; |
| 2517 | case WACOM_HID_WD_BARRELSWITCH3: |
| 2518 | wacom_wac->hid_data.barrelswitch3 = value; |
| 2519 | return; |
| 2520 | case WACOM_HID_WD_SEQUENCENUMBER: |
| 2521 | if (wacom_wac->hid_data.sequence_number != value && |
| 2522 | wacom_wac->hid_data.sequence_number >= 0) { |
| 2523 | int sequence_size = field->logical_maximum - field->logical_minimum + 1; |
| 2524 | int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; |
| 2525 | hid_warn(hdev, "Dropped %d packets" , drop_count); |
| 2526 | } |
| 2527 | wacom_wac->hid_data.sequence_number = value + 1; |
| 2528 | if (wacom_wac->hid_data.sequence_number > field->logical_maximum) |
| 2529 | wacom_wac->hid_data.sequence_number = field->logical_minimum; |
| 2530 | return; |
| 2531 | } |
| 2532 | |
| 2533 | /* send pen events only when touch is up or forced out |
| 2534 | * or touch arbitration is off |
| 2535 | */ |
| 2536 | if (!usage->type || delay_pen_events(wacom: wacom_wac)) |
| 2537 | return; |
| 2538 | |
| 2539 | /* send pen events only when the pen is in range */ |
| 2540 | if (wacom_wac->hid_data.inrange_state) |
| 2541 | input_event(dev: input, type: usage->type, code: usage->code, value); |
| 2542 | else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state) |
| 2543 | input_event(dev: input, type: usage->type, code: usage->code, value: 0); |
| 2544 | } |
| 2545 | |
| 2546 | static void wacom_wac_pen_pre_report(struct hid_device *hdev, |
| 2547 | struct hid_report *report) |
| 2548 | { |
| 2549 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2550 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2551 | |
| 2552 | wacom_wac->is_invalid_bt_frame = false; |
| 2553 | return; |
| 2554 | } |
| 2555 | |
| 2556 | static void wacom_wac_pen_report(struct hid_device *hdev, |
| 2557 | struct hid_report *report) |
| 2558 | { |
| 2559 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2560 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2561 | struct input_dev *input = wacom_wac->pen_input; |
| 2562 | bool range = wacom_wac->hid_data.inrange_state; |
| 2563 | bool sense = wacom_wac->hid_data.sense_state; |
| 2564 | bool entering_range = !wacom_wac->tool[0] && range; |
| 2565 | |
| 2566 | if (wacom_wac->is_invalid_bt_frame) |
| 2567 | return; |
| 2568 | |
| 2569 | if (entering_range) { /* first in range */ |
| 2570 | /* Going into range select tool */ |
| 2571 | if (wacom_wac->hid_data.eraser) |
| 2572 | wacom_wac->tool[0] = BTN_TOOL_RUBBER; |
| 2573 | else if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN) |
| 2574 | wacom_wac->tool[0] = BTN_TOOL_PEN; |
| 2575 | else if (wacom_wac->id[0]) |
| 2576 | wacom_wac->tool[0] = wacom_intuos_get_tool_type(tool_id: wacom_wac->id[0]); |
| 2577 | else |
| 2578 | wacom_wac->tool[0] = BTN_TOOL_PEN; |
| 2579 | } |
| 2580 | |
| 2581 | /* keep pen state for touch events */ |
| 2582 | wacom_wac->shared->stylus_in_proximity = sense; |
| 2583 | |
| 2584 | if (!delay_pen_events(wacom: wacom_wac) && wacom_wac->tool[0]) { |
| 2585 | int id = wacom_wac->id[0]; |
| 2586 | if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3) { |
| 2587 | int sw_state = wacom_wac->hid_data.barrelswitch | |
| 2588 | (wacom_wac->hid_data.barrelswitch2 << 1); |
| 2589 | wacom_wac->hid_data.barrelswitch = sw_state == 1; |
| 2590 | wacom_wac->hid_data.barrelswitch2 = sw_state == 2; |
| 2591 | wacom_wac->hid_data.barrelswitch3 = sw_state == 3; |
| 2592 | } |
| 2593 | input_report_key(dev: input, BTN_STYLUS, value: wacom_wac->hid_data.barrelswitch); |
| 2594 | input_report_key(dev: input, BTN_STYLUS2, value: wacom_wac->hid_data.barrelswitch2); |
| 2595 | input_report_key(dev: input, BTN_STYLUS3, value: wacom_wac->hid_data.barrelswitch3); |
| 2596 | |
| 2597 | /* |
| 2598 | * Non-USI EMR tools should have their IDs mangled to |
| 2599 | * match the legacy behavior of wacom_intuos_general |
| 2600 | */ |
| 2601 | if (wacom_wac->serial[0] >> 52 == 1) |
| 2602 | id = wacom_intuos_id_mangle(tool_id: id); |
| 2603 | |
| 2604 | /* |
| 2605 | * To ensure compatibility with xf86-input-wacom, we should |
| 2606 | * report the BTN_TOOL_* event prior to the ABS_MISC or |
| 2607 | * MSC_SERIAL events. |
| 2608 | */ |
| 2609 | input_report_key(dev: input, BTN_TOUCH, |
| 2610 | value: wacom_wac->hid_data.tipswitch); |
| 2611 | input_report_key(dev: input, code: wacom_wac->tool[0], value: sense); |
| 2612 | if (wacom_wac->serial[0]) { |
| 2613 | /* |
| 2614 | * xf86-input-wacom does not accept a serial number |
| 2615 | * of '0'. Report the low 32 bits if possible, but |
| 2616 | * if they are zero, report the upper ones instead. |
| 2617 | */ |
| 2618 | __u32 serial_lo = wacom_wac->serial[0] & 0xFFFFFFFFu; |
| 2619 | __u32 serial_hi = wacom_wac->serial[0] >> 32; |
| 2620 | input_event(dev: input, EV_MSC, MSC_SERIAL, value: (int)(serial_lo ? serial_lo : serial_hi)); |
| 2621 | input_report_abs(dev: input, ABS_MISC, value: sense ? id : 0); |
| 2622 | } |
| 2623 | |
| 2624 | wacom_wac->hid_data.tipswitch = false; |
| 2625 | wacom_wac->hid_data.eraser = false; |
| 2626 | |
| 2627 | input_sync(dev: input); |
| 2628 | } |
| 2629 | |
| 2630 | /* Handle AES battery timeout behavior */ |
| 2631 | if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN) { |
| 2632 | if (entering_range) |
| 2633 | cancel_delayed_work(dwork: &wacom->aes_battery_work); |
| 2634 | if (!sense) |
| 2635 | schedule_delayed_work(dwork: &wacom->aes_battery_work, |
| 2636 | delay: msecs_to_jiffies(WACOM_AES_BATTERY_TIMEOUT)); |
| 2637 | } |
| 2638 | |
| 2639 | if (!sense) { |
| 2640 | wacom_wac->tool[0] = 0; |
| 2641 | wacom_wac->id[0] = 0; |
| 2642 | wacom_wac->serial[0] = 0; |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, |
| 2647 | struct hid_field *field, struct hid_usage *usage) |
| 2648 | { |
| 2649 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2650 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2651 | struct input_dev *input = wacom_wac->touch_input; |
| 2652 | unsigned touch_max = wacom_wac->features.touch_max; |
| 2653 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 2654 | |
| 2655 | switch (equivalent_usage) { |
| 2656 | case HID_GD_X: |
| 2657 | if (touch_max == 1) |
| 2658 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, fuzz: 4); |
| 2659 | else |
| 2660 | wacom_map_usage(input, usage, field, EV_ABS, |
| 2661 | ABS_MT_POSITION_X, fuzz: 4); |
| 2662 | break; |
| 2663 | case HID_GD_Y: |
| 2664 | if (touch_max == 1) |
| 2665 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, fuzz: 4); |
| 2666 | else |
| 2667 | wacom_map_usage(input, usage, field, EV_ABS, |
| 2668 | ABS_MT_POSITION_Y, fuzz: 4); |
| 2669 | break; |
| 2670 | case HID_DG_WIDTH: |
| 2671 | case HID_DG_HEIGHT: |
| 2672 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, fuzz: 0); |
| 2673 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, fuzz: 0); |
| 2674 | input_set_abs_params(dev: input, ABS_MT_ORIENTATION, min: 0, max: 1, fuzz: 0, flat: 0); |
| 2675 | break; |
| 2676 | case HID_DG_TIPSWITCH: |
| 2677 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, fuzz: 0); |
| 2678 | break; |
| 2679 | case HID_DG_CONTACTCOUNT: |
| 2680 | wacom_wac->hid_data.cc_report = field->report->id; |
| 2681 | wacom_wac->hid_data.cc_index = field->index; |
| 2682 | wacom_wac->hid_data.cc_value_index = usage->usage_index; |
| 2683 | break; |
| 2684 | case HID_DG_CONTACTID: |
| 2685 | if ((field->logical_maximum - field->logical_minimum) < touch_max) { |
| 2686 | /* |
| 2687 | * The HID descriptor for G11 sensors leaves logical |
| 2688 | * maximum set to '1' despite it being a multitouch |
| 2689 | * device. Override to a sensible number. |
| 2690 | */ |
| 2691 | field->logical_maximum = 255; |
| 2692 | } |
| 2693 | break; |
| 2694 | case HID_DG_SCANTIME: |
| 2695 | wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, fuzz: 0); |
| 2696 | break; |
| 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, |
| 2701 | struct input_dev *input) |
| 2702 | { |
| 2703 | struct hid_data *hid_data = &wacom_wac->hid_data; |
| 2704 | bool mt = wacom_wac->features.touch_max > 1; |
| 2705 | bool touch_down = hid_data->tipswitch && hid_data->confidence; |
| 2706 | bool prox = touch_down && report_touch_events(wacom: wacom_wac); |
| 2707 | |
| 2708 | if (touch_is_muted(wacom_wac)) { |
| 2709 | if (!wacom_wac->shared->touch_down) |
| 2710 | return; |
| 2711 | prox = false; |
| 2712 | } |
| 2713 | |
| 2714 | wacom_wac->hid_data.num_received++; |
| 2715 | if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) |
| 2716 | return; |
| 2717 | |
| 2718 | if (mt) { |
| 2719 | int slot; |
| 2720 | |
| 2721 | slot = input_mt_get_slot_by_key(dev: input, key: hid_data->id); |
| 2722 | if (slot < 0) { |
| 2723 | return; |
| 2724 | } else { |
| 2725 | struct input_mt_slot *ps = &input->mt->slots[slot]; |
| 2726 | int mt_id = input_mt_get_value(slot: ps, ABS_MT_TRACKING_ID); |
| 2727 | |
| 2728 | if (!prox && mt_id < 0) { |
| 2729 | // No data to send for this slot; short-circuit |
| 2730 | return; |
| 2731 | } |
| 2732 | } |
| 2733 | |
| 2734 | input_mt_slot(dev: input, slot); |
| 2735 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: prox); |
| 2736 | } |
| 2737 | else { |
| 2738 | input_report_key(dev: input, BTN_TOUCH, value: prox); |
| 2739 | } |
| 2740 | |
| 2741 | if (prox) { |
| 2742 | input_report_abs(dev: input, code: mt ? ABS_MT_POSITION_X : ABS_X, |
| 2743 | value: hid_data->x); |
| 2744 | input_report_abs(dev: input, code: mt ? ABS_MT_POSITION_Y : ABS_Y, |
| 2745 | value: hid_data->y); |
| 2746 | |
| 2747 | if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { |
| 2748 | input_report_abs(dev: input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); |
| 2749 | input_report_abs(dev: input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); |
| 2750 | if (hid_data->width != hid_data->height) |
| 2751 | input_report_abs(dev: input, ABS_MT_ORIENTATION, value: hid_data->width <= hid_data->height ? 0 : 1); |
| 2752 | } |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | static void wacom_wac_finger_event(struct hid_device *hdev, |
| 2757 | struct hid_field *field, struct hid_usage *usage, __s32 value) |
| 2758 | { |
| 2759 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2760 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2761 | unsigned equivalent_usage = wacom_equivalent_usage(usage: usage->hid); |
| 2762 | struct wacom_features *features = &wacom->wacom_wac.features; |
| 2763 | |
| 2764 | if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) |
| 2765 | return; |
| 2766 | |
| 2767 | if (wacom_wac->is_invalid_bt_frame) |
| 2768 | return; |
| 2769 | |
| 2770 | switch (equivalent_usage) { |
| 2771 | case HID_DG_CONFIDENCE: |
| 2772 | wacom_wac->hid_data.confidence = value; |
| 2773 | break; |
| 2774 | case HID_GD_X: |
| 2775 | wacom_wac->hid_data.x = value; |
| 2776 | break; |
| 2777 | case HID_GD_Y: |
| 2778 | wacom_wac->hid_data.y = value; |
| 2779 | break; |
| 2780 | case HID_DG_WIDTH: |
| 2781 | wacom_wac->hid_data.width = value; |
| 2782 | break; |
| 2783 | case HID_DG_HEIGHT: |
| 2784 | wacom_wac->hid_data.height = value; |
| 2785 | break; |
| 2786 | case HID_DG_CONTACTID: |
| 2787 | wacom_wac->hid_data.id = value; |
| 2788 | break; |
| 2789 | case HID_DG_TIPSWITCH: |
| 2790 | wacom_wac->hid_data.tipswitch = value; |
| 2791 | break; |
| 2792 | case WACOM_HID_WT_REPORT_VALID: |
| 2793 | wacom_wac->is_invalid_bt_frame = !value; |
| 2794 | return; |
| 2795 | case HID_DG_CONTACTMAX: |
| 2796 | if (!features->touch_max) { |
| 2797 | features->touch_max = value; |
| 2798 | } else { |
| 2799 | hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " |
| 2800 | "%d -> %d\n" , __func__, features->touch_max, value); |
| 2801 | } |
| 2802 | return; |
| 2803 | } |
| 2804 | |
| 2805 | if (usage->usage_index + 1 == field->report_count) { |
| 2806 | if (equivalent_usage == wacom_wac->hid_data.last_slot_field) |
| 2807 | wacom_wac_finger_slot(wacom_wac, input: wacom_wac->touch_input); |
| 2808 | } |
| 2809 | } |
| 2810 | |
| 2811 | static void wacom_wac_finger_pre_report(struct hid_device *hdev, |
| 2812 | struct hid_report *report) |
| 2813 | { |
| 2814 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2815 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2816 | struct hid_data* hid_data = &wacom_wac->hid_data; |
| 2817 | int i; |
| 2818 | |
| 2819 | if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) |
| 2820 | return; |
| 2821 | |
| 2822 | wacom_wac->is_invalid_bt_frame = false; |
| 2823 | |
| 2824 | hid_data->confidence = true; |
| 2825 | |
| 2826 | hid_data->cc_report = 0; |
| 2827 | hid_data->cc_index = -1; |
| 2828 | hid_data->cc_value_index = -1; |
| 2829 | |
| 2830 | for (i = 0; i < report->maxfield; i++) { |
| 2831 | struct hid_field *field = report->field[i]; |
| 2832 | int j; |
| 2833 | |
| 2834 | for (j = 0; j < field->maxusage; j++) { |
| 2835 | struct hid_usage *usage = &field->usage[j]; |
| 2836 | unsigned int equivalent_usage = |
| 2837 | wacom_equivalent_usage(usage: usage->hid); |
| 2838 | |
| 2839 | switch (equivalent_usage) { |
| 2840 | case HID_GD_X: |
| 2841 | case HID_GD_Y: |
| 2842 | case HID_DG_WIDTH: |
| 2843 | case HID_DG_HEIGHT: |
| 2844 | case HID_DG_CONTACTID: |
| 2845 | case HID_DG_INRANGE: |
| 2846 | case HID_DG_INVERT: |
| 2847 | case HID_DG_TIPSWITCH: |
| 2848 | hid_data->last_slot_field = equivalent_usage; |
| 2849 | break; |
| 2850 | case HID_DG_CONTACTCOUNT: |
| 2851 | hid_data->cc_report = report->id; |
| 2852 | hid_data->cc_index = i; |
| 2853 | hid_data->cc_value_index = j; |
| 2854 | break; |
| 2855 | } |
| 2856 | } |
| 2857 | } |
| 2858 | |
| 2859 | if (hid_data->cc_report != 0 && |
| 2860 | hid_data->cc_index >= 0) { |
| 2861 | struct hid_field *field = report->field[hid_data->cc_index]; |
| 2862 | int value = field->value[hid_data->cc_value_index]; |
| 2863 | if (value) { |
| 2864 | hid_data->num_expected = value; |
| 2865 | hid_data->num_received = 0; |
| 2866 | } |
| 2867 | } |
| 2868 | else { |
| 2869 | hid_data->num_expected = wacom_wac->features.touch_max; |
| 2870 | hid_data->num_received = 0; |
| 2871 | } |
| 2872 | } |
| 2873 | |
| 2874 | static void wacom_wac_finger_report(struct hid_device *hdev, |
| 2875 | struct hid_report *report) |
| 2876 | { |
| 2877 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2878 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2879 | struct input_dev *input = wacom_wac->touch_input; |
| 2880 | unsigned touch_max = wacom_wac->features.touch_max; |
| 2881 | |
| 2882 | /* if there was nothing to process, don't send an empty sync */ |
| 2883 | if (wacom_wac->hid_data.num_expected == 0) |
| 2884 | return; |
| 2885 | |
| 2886 | /* If more packets of data are expected, give us a chance to |
| 2887 | * process them rather than immediately syncing a partial |
| 2888 | * update. |
| 2889 | */ |
| 2890 | if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected) |
| 2891 | return; |
| 2892 | |
| 2893 | if (touch_max > 1) |
| 2894 | input_mt_sync_frame(dev: input); |
| 2895 | |
| 2896 | input_sync(dev: input); |
| 2897 | wacom_wac->hid_data.num_received = 0; |
| 2898 | wacom_wac->hid_data.num_expected = 0; |
| 2899 | |
| 2900 | /* keep touch state for pen event */ |
| 2901 | wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom: wacom_wac); |
| 2902 | } |
| 2903 | |
| 2904 | void wacom_wac_usage_mapping(struct hid_device *hdev, |
| 2905 | struct hid_field *field, struct hid_usage *usage) |
| 2906 | { |
| 2907 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2908 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2909 | struct wacom_features *features = &wacom_wac->features; |
| 2910 | |
| 2911 | if (WACOM_DIRECT_DEVICE(field)) |
| 2912 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
| 2913 | |
| 2914 | /* usage tests must precede field tests */ |
| 2915 | if (WACOM_BATTERY_USAGE(usage)) |
| 2916 | wacom_wac_battery_usage_mapping(hdev, field, usage); |
| 2917 | else if (WACOM_PAD_FIELD(field)) |
| 2918 | wacom_wac_pad_usage_mapping(hdev, field, usage); |
| 2919 | else if (WACOM_PEN_FIELD(field)) |
| 2920 | wacom_wac_pen_usage_mapping(hdev, field, usage); |
| 2921 | else if (WACOM_FINGER_FIELD(field)) |
| 2922 | wacom_wac_finger_usage_mapping(hdev, field, usage); |
| 2923 | } |
| 2924 | |
| 2925 | void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, |
| 2926 | struct hid_usage *usage, __s32 value) |
| 2927 | { |
| 2928 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2929 | |
| 2930 | if (wacom->wacom_wac.features.type != HID_GENERIC) |
| 2931 | return; |
| 2932 | |
| 2933 | if (value > field->logical_maximum || value < field->logical_minimum) |
| 2934 | return; |
| 2935 | |
| 2936 | /* usage tests must precede field tests */ |
| 2937 | if (WACOM_BATTERY_USAGE(usage)) |
| 2938 | wacom_wac_battery_event(hdev, field, usage, value); |
| 2939 | else if (WACOM_PAD_FIELD(field)) |
| 2940 | wacom_wac_pad_event(hdev, field, usage, value); |
| 2941 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
| 2942 | wacom_wac_pen_event(hdev, field, usage, value); |
| 2943 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
| 2944 | wacom_wac_finger_event(hdev, field, usage, value); |
| 2945 | } |
| 2946 | |
| 2947 | static void wacom_report_events(struct hid_device *hdev, |
| 2948 | struct hid_report *report, int collection_index, |
| 2949 | int field_index) |
| 2950 | { |
| 2951 | int r; |
| 2952 | |
| 2953 | for (r = field_index; r < report->maxfield; r++) { |
| 2954 | struct hid_field *field; |
| 2955 | unsigned count, n; |
| 2956 | |
| 2957 | field = report->field[r]; |
| 2958 | count = field->report_count; |
| 2959 | |
| 2960 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 2961 | continue; |
| 2962 | |
| 2963 | for (n = 0 ; n < count; n++) { |
| 2964 | if (field->usage[n].collection_index == collection_index) |
| 2965 | wacom_wac_event(hdev, field, usage: &field->usage[n], |
| 2966 | value: field->value[n]); |
| 2967 | else |
| 2968 | return; |
| 2969 | } |
| 2970 | } |
| 2971 | } |
| 2972 | |
| 2973 | static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report, |
| 2974 | int collection_index, struct hid_field *field, |
| 2975 | int field_index) |
| 2976 | { |
| 2977 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2978 | |
| 2979 | wacom_report_events(hdev, report, collection_index, field_index); |
| 2980 | |
| 2981 | /* |
| 2982 | * Non-input reports may be sent prior to the device being |
| 2983 | * completely initialized. Since only their events need |
| 2984 | * to be processed, exit after 'wacom_report_events' has |
| 2985 | * been called to prevent potential crashes in the report- |
| 2986 | * processing functions. |
| 2987 | */ |
| 2988 | if (report->type != HID_INPUT_REPORT) |
| 2989 | return -1; |
| 2990 | |
| 2991 | if (WACOM_PAD_FIELD(field)) |
| 2992 | return 0; |
| 2993 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
| 2994 | wacom_wac_pen_report(hdev, report); |
| 2995 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
| 2996 | wacom_wac_finger_report(hdev, report); |
| 2997 | |
| 2998 | return 0; |
| 2999 | } |
| 3000 | |
| 3001 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) |
| 3002 | { |
| 3003 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 3004 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 3005 | struct hid_field *field; |
| 3006 | bool pad_in_hid_field = false, pen_in_hid_field = false, |
| 3007 | finger_in_hid_field = false, true_pad = false; |
| 3008 | int r; |
| 3009 | int prev_collection = -1; |
| 3010 | |
| 3011 | if (wacom_wac->features.type != HID_GENERIC) |
| 3012 | return; |
| 3013 | |
| 3014 | for (r = 0; r < report->maxfield; r++) { |
| 3015 | field = report->field[r]; |
| 3016 | |
| 3017 | if (WACOM_PAD_FIELD(field)) |
| 3018 | pad_in_hid_field = true; |
| 3019 | if (WACOM_PEN_FIELD(field)) |
| 3020 | pen_in_hid_field = true; |
| 3021 | if (WACOM_FINGER_FIELD(field)) |
| 3022 | finger_in_hid_field = true; |
| 3023 | if (wacom_equivalent_usage(usage: field->physical) == HID_DG_TABLETFUNCTIONKEY) |
| 3024 | true_pad = true; |
| 3025 | } |
| 3026 | |
| 3027 | wacom_wac_battery_pre_report(hdev, report); |
| 3028 | |
| 3029 | if (pad_in_hid_field && wacom_wac->pad_input) |
| 3030 | wacom_wac_pad_pre_report(hdev, report); |
| 3031 | if (pen_in_hid_field && wacom_wac->pen_input) |
| 3032 | wacom_wac_pen_pre_report(hdev, report); |
| 3033 | if (finger_in_hid_field && wacom_wac->touch_input) |
| 3034 | wacom_wac_finger_pre_report(hdev, report); |
| 3035 | |
| 3036 | for (r = 0; r < report->maxfield; r++) { |
| 3037 | field = report->field[r]; |
| 3038 | |
| 3039 | if (field->usage[0].collection_index != prev_collection) { |
| 3040 | if (wacom_wac_collection(hdev, report, |
| 3041 | collection_index: field->usage[0].collection_index, field, field_index: r) < 0) |
| 3042 | return; |
| 3043 | prev_collection = field->usage[0].collection_index; |
| 3044 | } |
| 3045 | } |
| 3046 | |
| 3047 | wacom_wac_battery_report(hdev, report); |
| 3048 | |
| 3049 | if (true_pad && wacom_wac->pad_input) |
| 3050 | wacom_wac_pad_report(hdev, report, field); |
| 3051 | } |
| 3052 | |
| 3053 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
| 3054 | { |
| 3055 | struct wacom_features *features = &wacom->features; |
| 3056 | struct input_dev *input = wacom->touch_input; |
| 3057 | struct input_dev *pad_input = wacom->pad_input; |
| 3058 | unsigned char *data = wacom->data; |
| 3059 | int i; |
| 3060 | |
| 3061 | if (data[0] != 0x02) |
| 3062 | return 0; |
| 3063 | |
| 3064 | for (i = 0; i < 2; i++) { |
| 3065 | int offset = (data[1] & 0x80) ? (8 * i) : (9 * i); |
| 3066 | bool touch = report_touch_events(wacom) |
| 3067 | && (data[offset + 3] & 0x80); |
| 3068 | |
| 3069 | input_mt_slot(dev: input, slot: i); |
| 3070 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: touch); |
| 3071 | if (touch) { |
| 3072 | int x = get_unaligned_be16(p: &data[offset + 3]) & 0x7ff; |
| 3073 | int y = get_unaligned_be16(p: &data[offset + 5]) & 0x7ff; |
| 3074 | if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { |
| 3075 | x <<= 5; |
| 3076 | y <<= 5; |
| 3077 | } |
| 3078 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: x); |
| 3079 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: y); |
| 3080 | } |
| 3081 | } |
| 3082 | |
| 3083 | input_mt_sync_frame(dev: input); |
| 3084 | |
| 3085 | input_report_key(dev: pad_input, BTN_LEFT, value: (data[1] & 0x08) != 0); |
| 3086 | input_report_key(dev: pad_input, BTN_FORWARD, value: (data[1] & 0x04) != 0); |
| 3087 | input_report_key(dev: pad_input, BTN_BACK, value: (data[1] & 0x02) != 0); |
| 3088 | input_report_key(dev: pad_input, BTN_RIGHT, value: (data[1] & 0x01) != 0); |
| 3089 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 3090 | |
| 3091 | return 1; |
| 3092 | } |
| 3093 | |
| 3094 | static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) |
| 3095 | { |
| 3096 | struct wacom_features *features = &wacom->features; |
| 3097 | struct input_dev *input = wacom->touch_input; |
| 3098 | bool touch = data[1] & 0x80; |
| 3099 | int slot = input_mt_get_slot_by_key(dev: input, key: data[0]); |
| 3100 | |
| 3101 | if (slot < 0) |
| 3102 | return; |
| 3103 | |
| 3104 | touch = touch && report_touch_events(wacom); |
| 3105 | |
| 3106 | input_mt_slot(dev: input, slot); |
| 3107 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: touch); |
| 3108 | |
| 3109 | if (touch) { |
| 3110 | int x = (data[2] << 4) | (data[4] >> 4); |
| 3111 | int y = (data[3] << 4) | (data[4] & 0x0f); |
| 3112 | int width, height; |
| 3113 | |
| 3114 | if (features->type >= INTUOSPS && features->type <= INTUOSHT2) { |
| 3115 | width = data[5] * 100; |
| 3116 | height = data[6] * 100; |
| 3117 | } else { |
| 3118 | /* |
| 3119 | * "a" is a scaled-down area which we assume is |
| 3120 | * roughly circular and which can be described as: |
| 3121 | * a=(pi*r^2)/C. |
| 3122 | */ |
| 3123 | int a = data[5]; |
| 3124 | int x_res = input_abs_get_res(dev: input, ABS_MT_POSITION_X); |
| 3125 | int y_res = input_abs_get_res(dev: input, ABS_MT_POSITION_Y); |
| 3126 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); |
| 3127 | height = width * y_res / x_res; |
| 3128 | } |
| 3129 | |
| 3130 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: x); |
| 3131 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: y); |
| 3132 | input_report_abs(dev: input, ABS_MT_TOUCH_MAJOR, value: width); |
| 3133 | input_report_abs(dev: input, ABS_MT_TOUCH_MINOR, value: height); |
| 3134 | } |
| 3135 | } |
| 3136 | |
| 3137 | static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) |
| 3138 | { |
| 3139 | struct input_dev *input = wacom->pad_input; |
| 3140 | struct wacom_features *features = &wacom->features; |
| 3141 | |
| 3142 | if (features->type == INTUOSHT || features->type == INTUOSHT2) { |
| 3143 | input_report_key(dev: input, BTN_LEFT, value: (data[1] & 0x02) != 0); |
| 3144 | input_report_key(dev: input, BTN_BACK, value: (data[1] & 0x08) != 0); |
| 3145 | } else { |
| 3146 | input_report_key(dev: input, BTN_BACK, value: (data[1] & 0x02) != 0); |
| 3147 | input_report_key(dev: input, BTN_LEFT, value: (data[1] & 0x08) != 0); |
| 3148 | } |
| 3149 | input_report_key(dev: input, BTN_FORWARD, value: (data[1] & 0x04) != 0); |
| 3150 | input_report_key(dev: input, BTN_RIGHT, value: (data[1] & 0x01) != 0); |
| 3151 | } |
| 3152 | |
| 3153 | static int wacom_bpt3_touch(struct wacom_wac *wacom) |
| 3154 | { |
| 3155 | unsigned char *data = wacom->data; |
| 3156 | int count = data[1] & 0x07; |
| 3157 | int touch_changed = 0, i; |
| 3158 | |
| 3159 | if (data[0] != 0x02) |
| 3160 | return 0; |
| 3161 | |
| 3162 | /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ |
| 3163 | for (i = 0; i < count; i++) { |
| 3164 | int offset = (8 * i) + 2; |
| 3165 | int msg_id = data[offset]; |
| 3166 | |
| 3167 | if (msg_id >= 2 && msg_id <= 17) { |
| 3168 | wacom_bpt3_touch_msg(wacom, data: data + offset); |
| 3169 | touch_changed++; |
| 3170 | } else if (msg_id == 128) |
| 3171 | wacom_bpt3_button_msg(wacom, data: data + offset); |
| 3172 | |
| 3173 | } |
| 3174 | |
| 3175 | /* only update touch if we actually have a touchpad and touch data changed */ |
| 3176 | if (wacom->touch_input && touch_changed) { |
| 3177 | input_mt_sync_frame(dev: wacom->touch_input); |
| 3178 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 3179 | } |
| 3180 | |
| 3181 | return 1; |
| 3182 | } |
| 3183 | |
| 3184 | static int wacom_bpt_pen(struct wacom_wac *wacom) |
| 3185 | { |
| 3186 | struct wacom_features *features = &wacom->features; |
| 3187 | struct input_dev *input = wacom->pen_input; |
| 3188 | unsigned char *data = wacom->data; |
| 3189 | int x = 0, y = 0, p = 0, d = 0; |
| 3190 | bool pen = false, btn1 = false, btn2 = false; |
| 3191 | bool range, prox, rdy; |
| 3192 | |
| 3193 | if (data[0] != WACOM_REPORT_PENABLED) |
| 3194 | return 0; |
| 3195 | |
| 3196 | range = (data[1] & 0x80) == 0x80; |
| 3197 | prox = (data[1] & 0x40) == 0x40; |
| 3198 | rdy = (data[1] & 0x20) == 0x20; |
| 3199 | |
| 3200 | wacom->shared->stylus_in_proximity = range; |
| 3201 | if (delay_pen_events(wacom)) |
| 3202 | return 0; |
| 3203 | |
| 3204 | if (rdy) { |
| 3205 | p = le16_to_cpup(p: (__le16 *)&data[6]); |
| 3206 | pen = data[1] & 0x01; |
| 3207 | btn1 = data[1] & 0x02; |
| 3208 | btn2 = data[1] & 0x04; |
| 3209 | } |
| 3210 | if (prox) { |
| 3211 | x = le16_to_cpup(p: (__le16 *)&data[2]); |
| 3212 | y = le16_to_cpup(p: (__le16 *)&data[4]); |
| 3213 | |
| 3214 | if (data[1] & 0x08) { |
| 3215 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 3216 | wacom->id[0] = ERASER_DEVICE_ID; |
| 3217 | } else { |
| 3218 | wacom->tool[0] = BTN_TOOL_PEN; |
| 3219 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 3220 | } |
| 3221 | wacom->reporting_data = true; |
| 3222 | } |
| 3223 | if (range) { |
| 3224 | /* |
| 3225 | * Convert distance from out prox to distance from tablet. |
| 3226 | * distance will be greater than distance_max once |
| 3227 | * touching and applying pressure; do not report negative |
| 3228 | * distance. |
| 3229 | */ |
| 3230 | if (data[8] <= features->distance_max) |
| 3231 | d = features->distance_max - data[8]; |
| 3232 | } else { |
| 3233 | wacom->id[0] = 0; |
| 3234 | } |
| 3235 | |
| 3236 | if (wacom->reporting_data) { |
| 3237 | input_report_key(dev: input, BTN_TOUCH, value: pen); |
| 3238 | input_report_key(dev: input, BTN_STYLUS, value: btn1); |
| 3239 | input_report_key(dev: input, BTN_STYLUS2, value: btn2); |
| 3240 | |
| 3241 | if (prox || !range) { |
| 3242 | input_report_abs(dev: input, ABS_X, value: x); |
| 3243 | input_report_abs(dev: input, ABS_Y, value: y); |
| 3244 | } |
| 3245 | input_report_abs(dev: input, ABS_PRESSURE, value: p); |
| 3246 | input_report_abs(dev: input, ABS_DISTANCE, value: d); |
| 3247 | |
| 3248 | input_report_key(dev: input, code: wacom->tool[0], value: range); /* PEN or RUBBER */ |
| 3249 | input_report_abs(dev: input, ABS_MISC, value: wacom->id[0]); /* TOOL ID */ |
| 3250 | } |
| 3251 | |
| 3252 | if (!range) { |
| 3253 | wacom->reporting_data = false; |
| 3254 | } |
| 3255 | |
| 3256 | return 1; |
| 3257 | } |
| 3258 | |
| 3259 | static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) |
| 3260 | { |
| 3261 | struct wacom_features *features = &wacom->features; |
| 3262 | |
| 3263 | if ((features->type == INTUOSHT2) && |
| 3264 | (features->device_type & WACOM_DEVICETYPE_PEN)) |
| 3265 | return wacom_intuos_irq(wacom); |
| 3266 | else if (len == WACOM_PKGLEN_BBTOUCH) |
| 3267 | return wacom_bpt_touch(wacom); |
| 3268 | else if (len == WACOM_PKGLEN_BBTOUCH3) |
| 3269 | return wacom_bpt3_touch(wacom); |
| 3270 | else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN) |
| 3271 | return wacom_bpt_pen(wacom); |
| 3272 | |
| 3273 | return 0; |
| 3274 | } |
| 3275 | |
| 3276 | static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom, |
| 3277 | unsigned char *data) |
| 3278 | { |
| 3279 | unsigned char prefix; |
| 3280 | |
| 3281 | /* |
| 3282 | * We need to reroute the event from the debug interface to the |
| 3283 | * pen interface. |
| 3284 | * We need to add the report ID to the actual pen report, so we |
| 3285 | * temporary overwrite the first byte to prevent having to kzalloc/kfree |
| 3286 | * and memcpy the report. |
| 3287 | */ |
| 3288 | prefix = data[0]; |
| 3289 | data[0] = WACOM_REPORT_BPAD_PEN; |
| 3290 | |
| 3291 | /* |
| 3292 | * actually reroute the event. |
| 3293 | * No need to check if wacom->shared->pen is valid, hid_input_report() |
| 3294 | * will check for us. |
| 3295 | */ |
| 3296 | hid_input_report(hid: wacom->shared->pen, type: HID_INPUT_REPORT, data, |
| 3297 | WACOM_PKGLEN_PENABLED, interrupt: 1); |
| 3298 | |
| 3299 | data[0] = prefix; |
| 3300 | } |
| 3301 | |
| 3302 | static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, |
| 3303 | unsigned char *data) |
| 3304 | { |
| 3305 | struct input_dev *input = wacom->touch_input; |
| 3306 | unsigned char *finger_data, prefix; |
| 3307 | unsigned id; |
| 3308 | int x, y; |
| 3309 | bool valid; |
| 3310 | |
| 3311 | prefix = data[0]; |
| 3312 | |
| 3313 | for (id = 0; id < wacom->features.touch_max; id++) { |
| 3314 | valid = !!(prefix & BIT(id)) && |
| 3315 | report_touch_events(wacom); |
| 3316 | |
| 3317 | input_mt_slot(dev: input, slot: id); |
| 3318 | input_mt_report_slot_state(dev: input, MT_TOOL_FINGER, active: valid); |
| 3319 | |
| 3320 | if (!valid) |
| 3321 | continue; |
| 3322 | |
| 3323 | finger_data = data + 1 + id * 3; |
| 3324 | x = finger_data[0] | ((finger_data[1] & 0x0f) << 8); |
| 3325 | y = (finger_data[2] << 4) | (finger_data[1] >> 4); |
| 3326 | |
| 3327 | input_report_abs(dev: input, ABS_MT_POSITION_X, value: x); |
| 3328 | input_report_abs(dev: input, ABS_MT_POSITION_Y, value: y); |
| 3329 | } |
| 3330 | |
| 3331 | input_mt_sync_frame(dev: input); |
| 3332 | |
| 3333 | input_report_key(dev: input, BTN_LEFT, value: prefix & 0x40); |
| 3334 | input_report_key(dev: input, BTN_RIGHT, value: prefix & 0x80); |
| 3335 | |
| 3336 | /* keep touch state for pen event */ |
| 3337 | wacom->shared->touch_down = !!prefix && report_touch_events(wacom); |
| 3338 | |
| 3339 | return 1; |
| 3340 | } |
| 3341 | |
| 3342 | static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len) |
| 3343 | { |
| 3344 | unsigned char *data = wacom->data; |
| 3345 | |
| 3346 | if (!((len == WACOM_PKGLEN_BPAD_TOUCH) || |
| 3347 | (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) || |
| 3348 | (data[0] != WACOM_REPORT_BPAD_TOUCH)) |
| 3349 | return 0; |
| 3350 | |
| 3351 | if (data[1] & 0x01) |
| 3352 | wacom_bamboo_pad_pen_event(wacom, data: &data[1]); |
| 3353 | |
| 3354 | if (data[1] & 0x02) |
| 3355 | return wacom_bamboo_pad_touch_event(wacom, data: &data[9]); |
| 3356 | |
| 3357 | return 0; |
| 3358 | } |
| 3359 | |
| 3360 | static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) |
| 3361 | { |
| 3362 | unsigned char *data = wacom->data; |
| 3363 | int connected; |
| 3364 | |
| 3365 | if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL) |
| 3366 | return 0; |
| 3367 | |
| 3368 | connected = data[1] & 0x01; |
| 3369 | if (connected) { |
| 3370 | int pid, battery, charging; |
| 3371 | |
| 3372 | if ((wacom->shared->type == INTUOSHT || |
| 3373 | wacom->shared->type == INTUOSHT2) && |
| 3374 | wacom->shared->touch_input && |
| 3375 | wacom->shared->touch_max) { |
| 3376 | input_report_switch(dev: wacom->shared->touch_input, |
| 3377 | SW_MUTE_DEVICE, value: data[5] & 0x40); |
| 3378 | input_sync(dev: wacom->shared->touch_input); |
| 3379 | } |
| 3380 | |
| 3381 | pid = get_unaligned_be16(p: &data[6]); |
| 3382 | battery = (data[5] & 0x3f) * 100 / 31; |
| 3383 | charging = !!(data[5] & 0x80); |
| 3384 | if (wacom->pid != pid) { |
| 3385 | wacom->pid = pid; |
| 3386 | wacom_schedule_work(wacom_wac: wacom, which: WACOM_WORKER_WIRELESS); |
| 3387 | } |
| 3388 | |
| 3389 | wacom_notify_battery(wacom_wac: wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 3390 | bat_capacity: battery, bat_charging: charging, bat_connected: 1, ps_connected: 0); |
| 3391 | |
| 3392 | } else if (wacom->pid != 0) { |
| 3393 | /* disconnected while previously connected */ |
| 3394 | wacom->pid = 0; |
| 3395 | wacom_schedule_work(wacom_wac: wacom, which: WACOM_WORKER_WIRELESS); |
| 3396 | wacom_notify_battery(wacom_wac: wacom, bat_status: POWER_SUPPLY_STATUS_UNKNOWN, bat_capacity: 0, bat_charging: 0, bat_connected: 0, ps_connected: 0); |
| 3397 | } |
| 3398 | |
| 3399 | return 0; |
| 3400 | } |
| 3401 | |
| 3402 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) |
| 3403 | { |
| 3404 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 3405 | struct wacom_features *features = &wacom_wac->features; |
| 3406 | unsigned char *data = wacom_wac->data; |
| 3407 | |
| 3408 | if (data[0] != WACOM_REPORT_USB) |
| 3409 | return 0; |
| 3410 | |
| 3411 | if ((features->type == INTUOSHT || |
| 3412 | features->type == INTUOSHT2) && |
| 3413 | wacom_wac->shared->touch_input && |
| 3414 | features->touch_max) { |
| 3415 | input_report_switch(dev: wacom_wac->shared->touch_input, |
| 3416 | SW_MUTE_DEVICE, value: data[8] & 0x40); |
| 3417 | input_sync(dev: wacom_wac->shared->touch_input); |
| 3418 | } |
| 3419 | |
| 3420 | if (data[9] & 0x02) { /* wireless module is attached */ |
| 3421 | int battery = (data[8] & 0x3f) * 100 / 31; |
| 3422 | bool charging = !!(data[8] & 0x80); |
| 3423 | |
| 3424 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3425 | wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 3426 | bat_capacity: battery, bat_charging: charging, bat_connected: battery || charging, ps_connected: 1); |
| 3427 | } |
| 3428 | else if ((features->quirks & WACOM_QUIRK_BATTERY) && |
| 3429 | wacom->battery.battery) { |
| 3430 | features->quirks &= ~WACOM_QUIRK_BATTERY; |
| 3431 | wacom_notify_battery(wacom_wac, bat_status: POWER_SUPPLY_STATUS_UNKNOWN, bat_capacity: 0, bat_charging: 0, bat_connected: 0, ps_connected: 0); |
| 3432 | } |
| 3433 | return 0; |
| 3434 | } |
| 3435 | |
| 3436 | void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) |
| 3437 | { |
| 3438 | bool sync; |
| 3439 | |
| 3440 | switch (wacom_wac->features.type) { |
| 3441 | case PENPARTNER: |
| 3442 | sync = wacom_penpartner_irq(wacom: wacom_wac); |
| 3443 | break; |
| 3444 | |
| 3445 | case PL: |
| 3446 | sync = wacom_pl_irq(wacom: wacom_wac); |
| 3447 | break; |
| 3448 | |
| 3449 | case WACOM_G4: |
| 3450 | case GRAPHIRE: |
| 3451 | case GRAPHIRE_BT: |
| 3452 | case WACOM_MO: |
| 3453 | sync = wacom_graphire_irq(wacom: wacom_wac); |
| 3454 | break; |
| 3455 | |
| 3456 | case PTU: |
| 3457 | sync = wacom_ptu_irq(wacom: wacom_wac); |
| 3458 | break; |
| 3459 | |
| 3460 | case DTU: |
| 3461 | sync = wacom_dtu_irq(wacom: wacom_wac); |
| 3462 | break; |
| 3463 | |
| 3464 | case DTUS: |
| 3465 | case DTUSX: |
| 3466 | sync = wacom_dtus_irq(wacom: wacom_wac); |
| 3467 | break; |
| 3468 | |
| 3469 | case INTUOS: |
| 3470 | case INTUOS3S: |
| 3471 | case INTUOS3: |
| 3472 | case INTUOS3L: |
| 3473 | case INTUOS4S: |
| 3474 | case INTUOS4: |
| 3475 | case INTUOS4L: |
| 3476 | case CINTIQ: |
| 3477 | case WACOM_BEE: |
| 3478 | case WACOM_13HD: |
| 3479 | case WACOM_21UX2: |
| 3480 | case WACOM_22HD: |
| 3481 | case WACOM_24HD: |
| 3482 | case WACOM_27QHD: |
| 3483 | case DTK: |
| 3484 | case CINTIQ_HYBRID: |
| 3485 | case CINTIQ_COMPANION_2: |
| 3486 | sync = wacom_intuos_irq(wacom: wacom_wac); |
| 3487 | break; |
| 3488 | |
| 3489 | case INTUOS4WL: |
| 3490 | sync = wacom_intuos_bt_irq(wacom: wacom_wac, len); |
| 3491 | break; |
| 3492 | |
| 3493 | case WACOM_24HDT: |
| 3494 | case WACOM_27QHDT: |
| 3495 | sync = wacom_24hdt_irq(wacom: wacom_wac); |
| 3496 | break; |
| 3497 | |
| 3498 | case INTUOS5S: |
| 3499 | case INTUOS5: |
| 3500 | case INTUOS5L: |
| 3501 | case INTUOSPS: |
| 3502 | case INTUOSPM: |
| 3503 | case INTUOSPL: |
| 3504 | if (len == WACOM_PKGLEN_BBTOUCH3) |
| 3505 | sync = wacom_bpt3_touch(wacom: wacom_wac); |
| 3506 | else if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 3507 | sync = wacom_status_irq(wacom_wac, len); |
| 3508 | else |
| 3509 | sync = wacom_intuos_irq(wacom: wacom_wac); |
| 3510 | break; |
| 3511 | |
| 3512 | case INTUOSP2_BT: |
| 3513 | case INTUOSP2S_BT: |
| 3514 | case INTUOSHT3_BT: |
| 3515 | sync = wacom_intuos_pro2_bt_irq(wacom: wacom_wac, len); |
| 3516 | break; |
| 3517 | |
| 3518 | case TABLETPC: |
| 3519 | case TABLETPCE: |
| 3520 | case TABLETPC2FG: |
| 3521 | case MTSCREEN: |
| 3522 | case MTTPC: |
| 3523 | case MTTPC_B: |
| 3524 | sync = wacom_tpc_irq(wacom: wacom_wac, len); |
| 3525 | break; |
| 3526 | |
| 3527 | case BAMBOO_PT: |
| 3528 | case BAMBOO_PEN: |
| 3529 | case BAMBOO_TOUCH: |
| 3530 | case INTUOSHT: |
| 3531 | case INTUOSHT2: |
| 3532 | if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 3533 | sync = wacom_status_irq(wacom_wac, len); |
| 3534 | else |
| 3535 | sync = wacom_bpt_irq(wacom: wacom_wac, len); |
| 3536 | break; |
| 3537 | |
| 3538 | case BAMBOO_PAD: |
| 3539 | sync = wacom_bamboo_pad_irq(wacom: wacom_wac, len); |
| 3540 | break; |
| 3541 | |
| 3542 | case WIRELESS: |
| 3543 | sync = wacom_wireless_irq(wacom: wacom_wac, len); |
| 3544 | break; |
| 3545 | |
| 3546 | case REMOTE: |
| 3547 | sync = false; |
| 3548 | if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST) |
| 3549 | wacom_remote_status_irq(wacom_wac, len); |
| 3550 | else |
| 3551 | sync = wacom_remote_irq(wacom_wac, len); |
| 3552 | break; |
| 3553 | |
| 3554 | default: |
| 3555 | sync = false; |
| 3556 | break; |
| 3557 | } |
| 3558 | |
| 3559 | if (sync) { |
| 3560 | if (wacom_wac->pen_input) |
| 3561 | input_sync(dev: wacom_wac->pen_input); |
| 3562 | if (wacom_wac->touch_input) |
| 3563 | input_sync(dev: wacom_wac->touch_input); |
| 3564 | if (wacom_wac->pad_input) |
| 3565 | input_sync(dev: wacom_wac->pad_input); |
| 3566 | } |
| 3567 | } |
| 3568 | |
| 3569 | static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac) |
| 3570 | { |
| 3571 | struct input_dev *input_dev = wacom_wac->pen_input; |
| 3572 | |
| 3573 | input_set_capability(dev: input_dev, EV_MSC, MSC_SERIAL); |
| 3574 | |
| 3575 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3576 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3577 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3578 | |
| 3579 | input_set_abs_params(dev: input_dev, ABS_DISTANCE, |
| 3580 | min: 0, max: wacom_wac->features.distance_max, fuzz: wacom_wac->features.distance_fuzz, flat: 0); |
| 3581 | } |
| 3582 | |
| 3583 | static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) |
| 3584 | { |
| 3585 | struct input_dev *input_dev = wacom_wac->pen_input; |
| 3586 | struct wacom_features *features = &wacom_wac->features; |
| 3587 | |
| 3588 | wacom_setup_basic_pro_pen(wacom_wac); |
| 3589 | |
| 3590 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3591 | __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); |
| 3592 | __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); |
| 3593 | __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); |
| 3594 | |
| 3595 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 1023, fuzz: 0, flat: 0); |
| 3596 | input_set_abs_params(dev: input_dev, ABS_TILT_X, min: -64, max: 63, fuzz: features->tilt_fuzz, flat: 0); |
| 3597 | input_abs_set_res(dev: input_dev, ABS_TILT_X, val: 57); |
| 3598 | input_set_abs_params(dev: input_dev, ABS_TILT_Y, min: -64, max: 63, fuzz: features->tilt_fuzz, flat: 0); |
| 3599 | input_abs_set_res(dev: input_dev, ABS_TILT_Y, val: 57); |
| 3600 | } |
| 3601 | |
| 3602 | static void wacom_setup_intuos(struct wacom_wac *wacom_wac) |
| 3603 | { |
| 3604 | struct input_dev *input_dev = wacom_wac->pen_input; |
| 3605 | |
| 3606 | input_set_capability(dev: input_dev, EV_REL, REL_WHEEL); |
| 3607 | |
| 3608 | wacom_setup_cintiq(wacom_wac); |
| 3609 | |
| 3610 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3611 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3612 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 3613 | __set_bit(BTN_SIDE, input_dev->keybit); |
| 3614 | __set_bit(BTN_EXTRA, input_dev->keybit); |
| 3615 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 3616 | __set_bit(BTN_TOOL_LENS, input_dev->keybit); |
| 3617 | |
| 3618 | input_set_abs_params(dev: input_dev, ABS_RZ, min: -900, max: 899, fuzz: 0, flat: 0); |
| 3619 | input_abs_set_res(dev: input_dev, ABS_RZ, val: 287); |
| 3620 | input_set_abs_params(dev: input_dev, ABS_THROTTLE, min: -1023, max: 1023, fuzz: 0, flat: 0); |
| 3621 | } |
| 3622 | |
| 3623 | void wacom_setup_device_quirks(struct wacom *wacom) |
| 3624 | { |
| 3625 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 3626 | struct wacom_features *features = &wacom->wacom_wac.features; |
| 3627 | |
| 3628 | /* The pen and pad share the same interface on most devices */ |
| 3629 | if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || |
| 3630 | features->type == DTUS || |
| 3631 | (features->type >= INTUOS3S && features->type <= WACOM_MO)) { |
| 3632 | if (features->device_type & WACOM_DEVICETYPE_PEN) |
| 3633 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3634 | } |
| 3635 | |
| 3636 | /* touch device found but size is not defined. use default */ |
| 3637 | if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { |
| 3638 | features->x_max = 1023; |
| 3639 | features->y_max = 1023; |
| 3640 | } |
| 3641 | |
| 3642 | /* |
| 3643 | * Intuos5/Pro and Bamboo 3rd gen have no useful data about its |
| 3644 | * touch interface in its HID descriptor. If this is the touch |
| 3645 | * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the |
| 3646 | * tablet values. |
| 3647 | */ |
| 3648 | if ((features->type >= INTUOS5S && features->type <= INTUOSPL) || |
| 3649 | (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) { |
| 3650 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 3651 | if (features->touch_max) |
| 3652 | features->device_type |= WACOM_DEVICETYPE_TOUCH; |
| 3653 | if (features->type >= INTUOSHT && features->type <= BAMBOO_PT) |
| 3654 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3655 | |
| 3656 | if (features->type == INTUOSHT2) { |
| 3657 | features->x_max = features->x_max / 10; |
| 3658 | features->y_max = features->y_max / 10; |
| 3659 | } |
| 3660 | else { |
| 3661 | features->x_max = 4096; |
| 3662 | features->y_max = 4096; |
| 3663 | } |
| 3664 | } |
| 3665 | else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
| 3666 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3667 | } |
| 3668 | } |
| 3669 | |
| 3670 | /* |
| 3671 | * Hack for the Bamboo One: |
| 3672 | * the device presents a PAD/Touch interface as most Bamboos and even |
| 3673 | * sends ghosts PAD data on it. However, later, we must disable this |
| 3674 | * ghost interface, and we can not detect it unless we set it here |
| 3675 | * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH. |
| 3676 | */ |
| 3677 | if (features->type == BAMBOO_PEN && |
| 3678 | features->pktlen == WACOM_PKGLEN_BBTOUCH3) |
| 3679 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3680 | |
| 3681 | /* |
| 3682 | * Raw Wacom-mode pen and touch events both come from interface |
| 3683 | * 0, whose HID descriptor has an application usage of 0xFF0D |
| 3684 | * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back |
| 3685 | * out through the HID_GENERIC device created for interface 1, |
| 3686 | * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH. |
| 3687 | */ |
| 3688 | if (features->type == BAMBOO_PAD) |
| 3689 | features->device_type = WACOM_DEVICETYPE_TOUCH; |
| 3690 | |
| 3691 | if (features->type == REMOTE) |
| 3692 | features->device_type = WACOM_DEVICETYPE_PAD; |
| 3693 | |
| 3694 | if (features->type == INTUOSP2_BT || |
| 3695 | features->type == INTUOSP2S_BT) { |
| 3696 | features->device_type |= WACOM_DEVICETYPE_PEN | |
| 3697 | WACOM_DEVICETYPE_PAD | |
| 3698 | WACOM_DEVICETYPE_TOUCH; |
| 3699 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3700 | } |
| 3701 | |
| 3702 | if (features->type == INTUOSHT3_BT) { |
| 3703 | features->device_type |= WACOM_DEVICETYPE_PEN | |
| 3704 | WACOM_DEVICETYPE_PAD; |
| 3705 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3706 | } |
| 3707 | |
| 3708 | switch (features->type) { |
| 3709 | case PL: |
| 3710 | case DTU: |
| 3711 | case DTUS: |
| 3712 | case DTUSX: |
| 3713 | case WACOM_21UX2: |
| 3714 | case WACOM_22HD: |
| 3715 | case DTK: |
| 3716 | case WACOM_24HD: |
| 3717 | case WACOM_27QHD: |
| 3718 | case CINTIQ_HYBRID: |
| 3719 | case CINTIQ_COMPANION_2: |
| 3720 | case CINTIQ: |
| 3721 | case WACOM_BEE: |
| 3722 | case WACOM_13HD: |
| 3723 | case WACOM_24HDT: |
| 3724 | case WACOM_27QHDT: |
| 3725 | case TABLETPC: |
| 3726 | case TABLETPCE: |
| 3727 | case TABLETPC2FG: |
| 3728 | case MTSCREEN: |
| 3729 | case MTTPC: |
| 3730 | case MTTPC_B: |
| 3731 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
| 3732 | break; |
| 3733 | } |
| 3734 | |
| 3735 | if (wacom->hdev->bus == BUS_BLUETOOTH) |
| 3736 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3737 | |
| 3738 | /* quirk for bamboo touch with 2 low res touches */ |
| 3739 | if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && |
| 3740 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
| 3741 | features->x_max <<= 5; |
| 3742 | features->y_max <<= 5; |
| 3743 | features->x_fuzz <<= 5; |
| 3744 | features->y_fuzz <<= 5; |
| 3745 | features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; |
| 3746 | } |
| 3747 | |
| 3748 | if (features->type == WIRELESS) { |
| 3749 | if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) { |
| 3750 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3751 | } |
| 3752 | } |
| 3753 | |
| 3754 | if (features->type == REMOTE) |
| 3755 | features->device_type |= WACOM_DEVICETYPE_WL_MONITOR; |
| 3756 | |
| 3757 | /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots |
| 3758 | * of things it shouldn't. Lets fix up the damage... |
| 3759 | */ |
| 3760 | if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) { |
| 3761 | features->quirks &= ~WACOM_QUIRK_TOOLSERIAL; |
| 3762 | __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit); |
| 3763 | __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit); |
| 3764 | __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit); |
| 3765 | __clear_bit(ABS_Z, wacom_wac->pen_input->absbit); |
| 3766 | __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit); |
| 3767 | __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit); |
| 3768 | __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit); |
| 3769 | __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit); |
| 3770 | __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit); |
| 3771 | __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit); |
| 3772 | __clear_bit(EV_MSC, wacom_wac->pen_input->evbit); |
| 3773 | } |
| 3774 | } |
| 3775 | |
| 3776 | int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, |
| 3777 | struct wacom_wac *wacom_wac) |
| 3778 | { |
| 3779 | struct wacom_features *features = &wacom_wac->features; |
| 3780 | |
| 3781 | if (!(features->device_type & WACOM_DEVICETYPE_PEN)) |
| 3782 | return -ENODEV; |
| 3783 | |
| 3784 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3785 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3786 | else |
| 3787 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3788 | |
| 3789 | if (features->type == HID_GENERIC) |
| 3790 | /* setup has already been done */ |
| 3791 | return 0; |
| 3792 | |
| 3793 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 3794 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 3795 | __set_bit(ABS_MISC, input_dev->absbit); |
| 3796 | |
| 3797 | input_set_abs_params(dev: input_dev, ABS_X, min: 0 + features->offset_left, |
| 3798 | max: features->x_max - features->offset_right, |
| 3799 | fuzz: features->x_fuzz, flat: 0); |
| 3800 | input_set_abs_params(dev: input_dev, ABS_Y, min: 0 + features->offset_top, |
| 3801 | max: features->y_max - features->offset_bottom, |
| 3802 | fuzz: features->y_fuzz, flat: 0); |
| 3803 | input_set_abs_params(dev: input_dev, ABS_PRESSURE, min: 0, |
| 3804 | max: features->pressure_max, fuzz: features->pressure_fuzz, flat: 0); |
| 3805 | |
| 3806 | /* penabled devices have fixed resolution for each model */ |
| 3807 | input_abs_set_res(dev: input_dev, ABS_X, val: features->x_resolution); |
| 3808 | input_abs_set_res(dev: input_dev, ABS_Y, val: features->y_resolution); |
| 3809 | |
| 3810 | switch (features->type) { |
| 3811 | case GRAPHIRE_BT: |
| 3812 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3813 | fallthrough; |
| 3814 | |
| 3815 | case WACOM_MO: |
| 3816 | case WACOM_G4: |
| 3817 | input_set_abs_params(dev: input_dev, ABS_DISTANCE, min: 0, |
| 3818 | max: features->distance_max, |
| 3819 | fuzz: features->distance_fuzz, flat: 0); |
| 3820 | fallthrough; |
| 3821 | |
| 3822 | case GRAPHIRE: |
| 3823 | input_set_capability(dev: input_dev, EV_REL, REL_WHEEL); |
| 3824 | |
| 3825 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3826 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3827 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 3828 | |
| 3829 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3830 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3831 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 3832 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3833 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3834 | break; |
| 3835 | |
| 3836 | case WACOM_27QHD: |
| 3837 | case WACOM_24HD: |
| 3838 | case DTK: |
| 3839 | case WACOM_22HD: |
| 3840 | case WACOM_21UX2: |
| 3841 | case WACOM_BEE: |
| 3842 | case CINTIQ: |
| 3843 | case WACOM_13HD: |
| 3844 | case CINTIQ_HYBRID: |
| 3845 | case CINTIQ_COMPANION_2: |
| 3846 | input_set_abs_params(dev: input_dev, ABS_Z, min: -900, max: 899, fuzz: 0, flat: 0); |
| 3847 | input_abs_set_res(dev: input_dev, ABS_Z, val: 287); |
| 3848 | wacom_setup_cintiq(wacom_wac); |
| 3849 | break; |
| 3850 | |
| 3851 | case INTUOS3: |
| 3852 | case INTUOS3L: |
| 3853 | case INTUOS3S: |
| 3854 | case INTUOS4: |
| 3855 | case INTUOS4WL: |
| 3856 | case INTUOS4L: |
| 3857 | case INTUOS4S: |
| 3858 | input_set_abs_params(dev: input_dev, ABS_Z, min: -900, max: 899, fuzz: 0, flat: 0); |
| 3859 | input_abs_set_res(dev: input_dev, ABS_Z, val: 287); |
| 3860 | fallthrough; |
| 3861 | |
| 3862 | case INTUOS: |
| 3863 | wacom_setup_intuos(wacom_wac); |
| 3864 | break; |
| 3865 | |
| 3866 | case INTUOS5: |
| 3867 | case INTUOS5L: |
| 3868 | case INTUOSPM: |
| 3869 | case INTUOSPL: |
| 3870 | case INTUOS5S: |
| 3871 | case INTUOSPS: |
| 3872 | case INTUOSP2_BT: |
| 3873 | case INTUOSP2S_BT: |
| 3874 | input_set_abs_params(dev: input_dev, ABS_DISTANCE, min: 0, |
| 3875 | max: features->distance_max, |
| 3876 | fuzz: features->distance_fuzz, flat: 0); |
| 3877 | |
| 3878 | input_set_abs_params(dev: input_dev, ABS_Z, min: -900, max: 899, fuzz: 0, flat: 0); |
| 3879 | input_abs_set_res(dev: input_dev, ABS_Z, val: 287); |
| 3880 | |
| 3881 | wacom_setup_intuos(wacom_wac); |
| 3882 | break; |
| 3883 | |
| 3884 | case WACOM_24HDT: |
| 3885 | case WACOM_27QHDT: |
| 3886 | case MTSCREEN: |
| 3887 | case MTTPC: |
| 3888 | case MTTPC_B: |
| 3889 | case TABLETPC2FG: |
| 3890 | case TABLETPC: |
| 3891 | case TABLETPCE: |
| 3892 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3893 | fallthrough; |
| 3894 | |
| 3895 | case DTUS: |
| 3896 | case DTUSX: |
| 3897 | case PL: |
| 3898 | case DTU: |
| 3899 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3900 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3901 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3902 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3903 | break; |
| 3904 | |
| 3905 | case PTU: |
| 3906 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3907 | fallthrough; |
| 3908 | |
| 3909 | case PENPARTNER: |
| 3910 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3911 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3912 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3913 | break; |
| 3914 | |
| 3915 | case INTUOSHT: |
| 3916 | case BAMBOO_PT: |
| 3917 | case BAMBOO_PEN: |
| 3918 | case INTUOSHT2: |
| 3919 | case INTUOSHT3_BT: |
| 3920 | if (features->type == INTUOSHT2 || |
| 3921 | features->type == INTUOSHT3_BT) { |
| 3922 | wacom_setup_basic_pro_pen(wacom_wac); |
| 3923 | } else { |
| 3924 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3925 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3926 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3927 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3928 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3929 | input_set_abs_params(dev: input_dev, ABS_DISTANCE, min: 0, |
| 3930 | max: features->distance_max, |
| 3931 | fuzz: features->distance_fuzz, flat: 0); |
| 3932 | } |
| 3933 | break; |
| 3934 | case BAMBOO_PAD: |
| 3935 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3936 | break; |
| 3937 | } |
| 3938 | return 0; |
| 3939 | } |
| 3940 | |
| 3941 | int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, |
| 3942 | struct wacom_wac *wacom_wac) |
| 3943 | { |
| 3944 | struct wacom_features *features = &wacom_wac->features; |
| 3945 | |
| 3946 | if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) |
| 3947 | return -ENODEV; |
| 3948 | |
| 3949 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3950 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3951 | else |
| 3952 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3953 | |
| 3954 | if (features->type == HID_GENERIC) |
| 3955 | /* setup has already been done */ |
| 3956 | return 0; |
| 3957 | |
| 3958 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 3959 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 3960 | |
| 3961 | if (features->touch_max == 1) { |
| 3962 | input_set_abs_params(dev: input_dev, ABS_X, min: 0, |
| 3963 | max: features->x_max, fuzz: features->x_fuzz, flat: 0); |
| 3964 | input_set_abs_params(dev: input_dev, ABS_Y, min: 0, |
| 3965 | max: features->y_max, fuzz: features->y_fuzz, flat: 0); |
| 3966 | input_abs_set_res(dev: input_dev, ABS_X, |
| 3967 | val: features->x_resolution); |
| 3968 | input_abs_set_res(dev: input_dev, ABS_Y, |
| 3969 | val: features->y_resolution); |
| 3970 | } |
| 3971 | else if (features->touch_max > 1) { |
| 3972 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_X, min: 0, |
| 3973 | max: features->x_max, fuzz: features->x_fuzz, flat: 0); |
| 3974 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_Y, min: 0, |
| 3975 | max: features->y_max, fuzz: features->y_fuzz, flat: 0); |
| 3976 | input_abs_set_res(dev: input_dev, ABS_MT_POSITION_X, |
| 3977 | val: features->x_resolution); |
| 3978 | input_abs_set_res(dev: input_dev, ABS_MT_POSITION_Y, |
| 3979 | val: features->y_resolution); |
| 3980 | } |
| 3981 | |
| 3982 | switch (features->type) { |
| 3983 | case INTUOSP2_BT: |
| 3984 | case INTUOSP2S_BT: |
| 3985 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3986 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 3987 | |
| 3988 | if (wacom_wac->shared->touch->product == 0x361) { |
| 3989 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_X, |
| 3990 | min: 0, max: 12440, fuzz: 4, flat: 0); |
| 3991 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_Y, |
| 3992 | min: 0, max: 8640, fuzz: 4, flat: 0); |
| 3993 | } |
| 3994 | else if (wacom_wac->shared->touch->product == 0x360) { |
| 3995 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_X, |
| 3996 | min: 0, max: 8960, fuzz: 4, flat: 0); |
| 3997 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_Y, |
| 3998 | min: 0, max: 5920, fuzz: 4, flat: 0); |
| 3999 | } |
| 4000 | else if (wacom_wac->shared->touch->product == 0x393) { |
| 4001 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_X, |
| 4002 | min: 0, max: 6400, fuzz: 4, flat: 0); |
| 4003 | input_set_abs_params(dev: input_dev, ABS_MT_POSITION_Y, |
| 4004 | min: 0, max: 4000, fuzz: 4, flat: 0); |
| 4005 | } |
| 4006 | input_abs_set_res(dev: input_dev, ABS_MT_POSITION_X, val: 40); |
| 4007 | input_abs_set_res(dev: input_dev, ABS_MT_POSITION_Y, val: 40); |
| 4008 | |
| 4009 | fallthrough; |
| 4010 | |
| 4011 | case INTUOS5: |
| 4012 | case INTUOS5L: |
| 4013 | case INTUOSPM: |
| 4014 | case INTUOSPL: |
| 4015 | case INTUOS5S: |
| 4016 | case INTUOSPS: |
| 4017 | input_set_abs_params(dev: input_dev, ABS_MT_TOUCH_MAJOR, min: 0, max: features->x_max, fuzz: 0, flat: 0); |
| 4018 | input_set_abs_params(dev: input_dev, ABS_MT_TOUCH_MINOR, min: 0, max: features->y_max, fuzz: 0, flat: 0); |
| 4019 | input_mt_init_slots(dev: input_dev, num_slots: features->touch_max, INPUT_MT_POINTER); |
| 4020 | break; |
| 4021 | |
| 4022 | case WACOM_24HDT: |
| 4023 | input_set_abs_params(dev: input_dev, ABS_MT_TOUCH_MAJOR, min: 0, max: features->x_max, fuzz: 0, flat: 0); |
| 4024 | input_set_abs_params(dev: input_dev, ABS_MT_WIDTH_MAJOR, min: 0, max: features->x_max, fuzz: 0, flat: 0); |
| 4025 | input_set_abs_params(dev: input_dev, ABS_MT_WIDTH_MINOR, min: 0, max: features->y_max, fuzz: 0, flat: 0); |
| 4026 | input_set_abs_params(dev: input_dev, ABS_MT_ORIENTATION, min: 0, max: 1, fuzz: 0, flat: 0); |
| 4027 | fallthrough; |
| 4028 | |
| 4029 | case WACOM_27QHDT: |
| 4030 | if (wacom_wac->shared->touch->product == 0x32C || |
| 4031 | wacom_wac->shared->touch->product == 0xF6) { |
| 4032 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 4033 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 4034 | wacom_wac->has_mute_touch_switch = true; |
| 4035 | wacom_wac->is_soft_touch_switch = true; |
| 4036 | } |
| 4037 | fallthrough; |
| 4038 | |
| 4039 | case MTSCREEN: |
| 4040 | case MTTPC: |
| 4041 | case MTTPC_B: |
| 4042 | case TABLETPC2FG: |
| 4043 | input_mt_init_slots(dev: input_dev, num_slots: features->touch_max, INPUT_MT_DIRECT); |
| 4044 | fallthrough; |
| 4045 | |
| 4046 | case TABLETPC: |
| 4047 | case TABLETPCE: |
| 4048 | break; |
| 4049 | |
| 4050 | case INTUOSHT: |
| 4051 | case INTUOSHT2: |
| 4052 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 4053 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 4054 | fallthrough; |
| 4055 | |
| 4056 | case BAMBOO_PT: |
| 4057 | case BAMBOO_TOUCH: |
| 4058 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 4059 | input_set_abs_params(dev: input_dev, |
| 4060 | ABS_MT_TOUCH_MAJOR, |
| 4061 | min: 0, max: features->x_max, fuzz: 0, flat: 0); |
| 4062 | input_set_abs_params(dev: input_dev, |
| 4063 | ABS_MT_TOUCH_MINOR, |
| 4064 | min: 0, max: features->y_max, fuzz: 0, flat: 0); |
| 4065 | } |
| 4066 | input_mt_init_slots(dev: input_dev, num_slots: features->touch_max, INPUT_MT_POINTER); |
| 4067 | break; |
| 4068 | |
| 4069 | case BAMBOO_PAD: |
| 4070 | input_mt_init_slots(dev: input_dev, num_slots: features->touch_max, |
| 4071 | INPUT_MT_POINTER); |
| 4072 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 4073 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 4074 | break; |
| 4075 | } |
| 4076 | return 0; |
| 4077 | } |
| 4078 | |
| 4079 | static int wacom_numbered_button_to_key(int n) |
| 4080 | { |
| 4081 | if (n < 10) |
| 4082 | return BTN_0 + n; |
| 4083 | else if (n < 16) |
| 4084 | return BTN_A + (n-10); |
| 4085 | else if (n < 18) |
| 4086 | return BTN_BASE + (n-16); |
| 4087 | else |
| 4088 | return 0; |
| 4089 | } |
| 4090 | |
| 4091 | static void wacom_setup_numbered_buttons(struct input_dev *input_dev, |
| 4092 | int button_count) |
| 4093 | { |
| 4094 | int i; |
| 4095 | |
| 4096 | for (i = 0; i < button_count; i++) { |
| 4097 | int key = wacom_numbered_button_to_key(n: i); |
| 4098 | |
| 4099 | if (key) |
| 4100 | __set_bit(key, input_dev->keybit); |
| 4101 | } |
| 4102 | } |
| 4103 | |
| 4104 | static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group) |
| 4105 | { |
| 4106 | struct wacom_led *led; |
| 4107 | int i; |
| 4108 | bool updated = false; |
| 4109 | |
| 4110 | /* |
| 4111 | * 24HD has LED group 1 to the left and LED group 0 to the right. |
| 4112 | * So group 0 matches the second half of the buttons and thus the mask |
| 4113 | * needs to be shifted. |
| 4114 | */ |
| 4115 | if (group == 0) |
| 4116 | mask >>= 8; |
| 4117 | |
| 4118 | for (i = 0; i < 3; i++) { |
| 4119 | led = wacom_led_find(wacom, group, id: i); |
| 4120 | if (!led) { |
| 4121 | hid_err(wacom->hdev, "can't find LED %d in group %d\n" , |
| 4122 | i, group); |
| 4123 | continue; |
| 4124 | } |
| 4125 | if (!updated && mask & BIT(i)) { |
| 4126 | led->held = true; |
| 4127 | led_trigger_event(trigger: &led->trigger, event: LED_FULL); |
| 4128 | } else { |
| 4129 | led->held = false; |
| 4130 | } |
| 4131 | } |
| 4132 | } |
| 4133 | |
| 4134 | static bool wacom_is_led_toggled(struct wacom *wacom, int button_count, |
| 4135 | int mask, int group) |
| 4136 | { |
| 4137 | int group_button; |
| 4138 | |
| 4139 | /* |
| 4140 | * 21UX2 has LED group 1 to the left and LED group 0 |
| 4141 | * to the right. We need to reverse the group to match this |
| 4142 | * historical behavior. |
| 4143 | */ |
| 4144 | if (wacom->wacom_wac.features.type == WACOM_21UX2) |
| 4145 | group = 1 - group; |
| 4146 | |
| 4147 | group_button = group * (button_count/wacom->led.count); |
| 4148 | |
| 4149 | if (wacom->wacom_wac.features.type == INTUOSP2_BT) |
| 4150 | group_button = 8; |
| 4151 | |
| 4152 | return mask & (1 << group_button); |
| 4153 | } |
| 4154 | |
| 4155 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 4156 | int group) |
| 4157 | { |
| 4158 | struct wacom_led *led, *next_led; |
| 4159 | int cur; |
| 4160 | bool pressed; |
| 4161 | |
| 4162 | if (wacom->wacom_wac.features.type == WACOM_24HD) |
| 4163 | return wacom_24hd_update_leds(wacom, mask, group); |
| 4164 | |
| 4165 | pressed = wacom_is_led_toggled(wacom, button_count, mask, group); |
| 4166 | cur = wacom->led.groups[group].select; |
| 4167 | |
| 4168 | led = wacom_led_find(wacom, group, id: cur); |
| 4169 | if (!led) { |
| 4170 | hid_err(wacom->hdev, "can't find current LED %d in group %d\n" , |
| 4171 | cur, group); |
| 4172 | return; |
| 4173 | } |
| 4174 | |
| 4175 | if (!pressed) { |
| 4176 | led->held = false; |
| 4177 | return; |
| 4178 | } |
| 4179 | |
| 4180 | if (led->held && pressed) |
| 4181 | return; |
| 4182 | |
| 4183 | next_led = wacom_led_next(wacom, cur: led); |
| 4184 | if (!next_led) { |
| 4185 | hid_err(wacom->hdev, "can't find next LED in group %d\n" , |
| 4186 | group); |
| 4187 | return; |
| 4188 | } |
| 4189 | if (next_led == led) |
| 4190 | return; |
| 4191 | |
| 4192 | next_led->held = true; |
| 4193 | led_trigger_event(trigger: &next_led->trigger, |
| 4194 | event: wacom_leds_brightness_get(led: next_led)); |
| 4195 | } |
| 4196 | |
| 4197 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 4198 | int button_count, int mask) |
| 4199 | { |
| 4200 | struct wacom *wacom = input_get_drvdata(dev: input_dev); |
| 4201 | int i; |
| 4202 | |
| 4203 | for (i = 0; i < wacom->led.count; i++) |
| 4204 | wacom_update_led(wacom, button_count, mask, group: i); |
| 4205 | |
| 4206 | for (i = 0; i < button_count; i++) { |
| 4207 | int key = wacom_numbered_button_to_key(n: i); |
| 4208 | |
| 4209 | if (key) |
| 4210 | input_report_key(dev: input_dev, code: key, value: mask & (1 << i)); |
| 4211 | } |
| 4212 | } |
| 4213 | |
| 4214 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, |
| 4215 | struct wacom_wac *wacom_wac) |
| 4216 | { |
| 4217 | struct wacom_features *features = &wacom_wac->features; |
| 4218 | |
| 4219 | if ((features->type == HID_GENERIC) && features->numbered_buttons > 0) |
| 4220 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 4221 | |
| 4222 | if (!(features->device_type & WACOM_DEVICETYPE_PAD)) |
| 4223 | return -ENODEV; |
| 4224 | |
| 4225 | if (features->type == REMOTE && input_dev == wacom_wac->pad_input) |
| 4226 | return -ENODEV; |
| 4227 | |
| 4228 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 4229 | |
| 4230 | /* kept for making legacy xf86-input-wacom working with the wheels */ |
| 4231 | __set_bit(ABS_MISC, input_dev->absbit); |
| 4232 | |
| 4233 | /* kept for making legacy xf86-input-wacom accepting the pad */ |
| 4234 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum || |
| 4235 | input_dev->absinfo[ABS_X].maximum))) |
| 4236 | input_set_abs_params(dev: input_dev, ABS_X, min: 0, max: 1, fuzz: 0, flat: 0); |
| 4237 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum || |
| 4238 | input_dev->absinfo[ABS_Y].maximum))) |
| 4239 | input_set_abs_params(dev: input_dev, ABS_Y, min: 0, max: 1, fuzz: 0, flat: 0); |
| 4240 | |
| 4241 | /* kept for making udev and libwacom accepting the pad */ |
| 4242 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 4243 | |
| 4244 | wacom_setup_numbered_buttons(input_dev, button_count: features->numbered_buttons); |
| 4245 | |
| 4246 | switch (features->type) { |
| 4247 | |
| 4248 | case CINTIQ_HYBRID: |
| 4249 | case CINTIQ_COMPANION_2: |
| 4250 | case DTK: |
| 4251 | case DTUS: |
| 4252 | case GRAPHIRE_BT: |
| 4253 | break; |
| 4254 | |
| 4255 | case WACOM_MO: |
| 4256 | __set_bit(BTN_BACK, input_dev->keybit); |
| 4257 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 4258 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 4259 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 4260 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4261 | break; |
| 4262 | |
| 4263 | case WACOM_G4: |
| 4264 | __set_bit(BTN_BACK, input_dev->keybit); |
| 4265 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 4266 | input_set_capability(dev: input_dev, EV_REL, REL_WHEEL); |
| 4267 | break; |
| 4268 | |
| 4269 | case WACOM_24HD: |
| 4270 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4271 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4272 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 4273 | |
| 4274 | __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); |
| 4275 | __set_bit(KEY_INFO, input_dev->keybit); |
| 4276 | |
| 4277 | if (!features->oPid) |
| 4278 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4279 | |
| 4280 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4281 | input_set_abs_params(dev: input_dev, ABS_THROTTLE, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4282 | break; |
| 4283 | |
| 4284 | case WACOM_27QHD: |
| 4285 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4286 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4287 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 4288 | |
| 4289 | __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); |
| 4290 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4291 | |
| 4292 | if (!features->oPid) |
| 4293 | __set_bit(KEY_CONTROLPANEL, input_dev->keybit); |
| 4294 | input_set_abs_params(dev: input_dev, ABS_X, min: -2048, max: 2048, fuzz: 0, flat: 0); |
| 4295 | input_abs_set_res(dev: input_dev, ABS_X, val: 1024); /* points/g */ |
| 4296 | input_set_abs_params(dev: input_dev, ABS_Y, min: -2048, max: 2048, fuzz: 0, flat: 0); |
| 4297 | input_abs_set_res(dev: input_dev, ABS_Y, val: 1024); |
| 4298 | input_set_abs_params(dev: input_dev, ABS_Z, min: -2048, max: 2048, fuzz: 0, flat: 0); |
| 4299 | input_abs_set_res(dev: input_dev, ABS_Z, val: 1024); |
| 4300 | __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); |
| 4301 | break; |
| 4302 | |
| 4303 | case WACOM_22HD: |
| 4304 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4305 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4306 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 4307 | |
| 4308 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4309 | __set_bit(KEY_INFO, input_dev->keybit); |
| 4310 | fallthrough; |
| 4311 | |
| 4312 | case WACOM_21UX2: |
| 4313 | case WACOM_BEE: |
| 4314 | case CINTIQ: |
| 4315 | input_set_abs_params(dev: input_dev, ABS_RX, min: 0, max: 4096, fuzz: 0, flat: 0); |
| 4316 | input_set_abs_params(dev: input_dev, ABS_RY, min: 0, max: 4096, fuzz: 0, flat: 0); |
| 4317 | break; |
| 4318 | |
| 4319 | case WACOM_13HD: |
| 4320 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4321 | break; |
| 4322 | |
| 4323 | case INTUOS3: |
| 4324 | case INTUOS3L: |
| 4325 | input_set_abs_params(dev: input_dev, ABS_RY, min: 0, max: 4096, fuzz: 0, flat: 0); |
| 4326 | fallthrough; |
| 4327 | |
| 4328 | case INTUOS3S: |
| 4329 | input_set_abs_params(dev: input_dev, ABS_RX, min: 0, max: 4096, fuzz: 0, flat: 0); |
| 4330 | break; |
| 4331 | |
| 4332 | case INTUOS5: |
| 4333 | case INTUOS5L: |
| 4334 | case INTUOSPM: |
| 4335 | case INTUOSPL: |
| 4336 | case INTUOS5S: |
| 4337 | case INTUOSPS: |
| 4338 | case INTUOSP2_BT: |
| 4339 | case INTUOSP2S_BT: |
| 4340 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4341 | break; |
| 4342 | |
| 4343 | case INTUOS4WL: |
| 4344 | /* |
| 4345 | * For Bluetooth devices, the udev rule does not work correctly |
| 4346 | * for pads unless we add a stylus capability, which forces |
| 4347 | * ID_INPUT_TABLET to be set. |
| 4348 | */ |
| 4349 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 4350 | fallthrough; |
| 4351 | |
| 4352 | case INTUOS4: |
| 4353 | case INTUOS4L: |
| 4354 | case INTUOS4S: |
| 4355 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4356 | break; |
| 4357 | |
| 4358 | case INTUOSHT: |
| 4359 | case BAMBOO_PT: |
| 4360 | case BAMBOO_TOUCH: |
| 4361 | case INTUOSHT2: |
| 4362 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 4363 | |
| 4364 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 4365 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 4366 | __set_bit(BTN_BACK, input_dev->keybit); |
| 4367 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 4368 | |
| 4369 | break; |
| 4370 | |
| 4371 | case REMOTE: |
| 4372 | input_set_capability(dev: input_dev, EV_MSC, MSC_SERIAL); |
| 4373 | input_set_abs_params(dev: input_dev, ABS_WHEEL, min: 0, max: 71, fuzz: 0, flat: 0); |
| 4374 | break; |
| 4375 | |
| 4376 | case INTUOSHT3_BT: |
| 4377 | case HID_GENERIC: |
| 4378 | break; |
| 4379 | |
| 4380 | default: |
| 4381 | /* no pad supported */ |
| 4382 | return -ENODEV; |
| 4383 | } |
| 4384 | return 0; |
| 4385 | } |
| 4386 | |
| 4387 | static const struct wacom_features wacom_features_0x00 = |
| 4388 | { "Wacom Penpartner" , 5040, 3780, 255, 0, |
| 4389 | PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
| 4390 | static const struct wacom_features wacom_features_0x10 = |
| 4391 | { "Wacom Graphire" , 10206, 7422, 511, 63, |
| 4392 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4393 | static const struct wacom_features wacom_features_0x81 = |
| 4394 | { "Wacom Graphire BT" , 16704, 12064, 511, 32, |
| 4395 | GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 }; |
| 4396 | static const struct wacom_features wacom_features_0x11 = |
| 4397 | { "Wacom Graphire2 4x5" , 10206, 7422, 511, 63, |
| 4398 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4399 | static const struct wacom_features wacom_features_0x12 = |
| 4400 | { "Wacom Graphire2 5x7" , 13918, 10206, 511, 63, |
| 4401 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4402 | static const struct wacom_features wacom_features_0x13 = |
| 4403 | { "Wacom Graphire3" , 10208, 7424, 511, 63, |
| 4404 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4405 | static const struct wacom_features wacom_features_0x14 = |
| 4406 | { "Wacom Graphire3 6x8" , 16704, 12064, 511, 63, |
| 4407 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4408 | static const struct wacom_features wacom_features_0x15 = |
| 4409 | { "Wacom Graphire4 4x5" , 10208, 7424, 511, 63, |
| 4410 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4411 | static const struct wacom_features wacom_features_0x16 = |
| 4412 | { "Wacom Graphire4 6x8" , 16704, 12064, 511, 63, |
| 4413 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4414 | static const struct wacom_features wacom_features_0x17 = |
| 4415 | { "Wacom BambooFun 4x5" , 14760, 9225, 511, 63, |
| 4416 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4417 | static const struct wacom_features wacom_features_0x18 = |
| 4418 | { "Wacom BambooFun 6x8" , 21648, 13530, 511, 63, |
| 4419 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4420 | static const struct wacom_features wacom_features_0x19 = |
| 4421 | { "Wacom Bamboo1 Medium" , 16704, 12064, 511, 63, |
| 4422 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
| 4423 | static const struct wacom_features wacom_features_0x60 = |
| 4424 | { "Wacom Volito" , 5104, 3712, 511, 63, |
| 4425 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
| 4426 | static const struct wacom_features wacom_features_0x61 = |
| 4427 | { "Wacom PenStation2" , 3250, 2320, 255, 63, |
| 4428 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
| 4429 | static const struct wacom_features wacom_features_0x62 = |
| 4430 | { "Wacom Volito2 4x5" , 5104, 3712, 511, 63, |
| 4431 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
| 4432 | static const struct wacom_features wacom_features_0x63 = |
| 4433 | { "Wacom Volito2 2x3" , 3248, 2320, 511, 63, |
| 4434 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
| 4435 | static const struct wacom_features wacom_features_0x64 = |
| 4436 | { "Wacom PenPartner2" , 3250, 2320, 511, 63, |
| 4437 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
| 4438 | static const struct wacom_features wacom_features_0x65 = |
| 4439 | { "Wacom Bamboo" , 14760, 9225, 511, 63, |
| 4440 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4441 | static const struct wacom_features wacom_features_0x69 = |
| 4442 | { "Wacom Bamboo1" , 5104, 3712, 511, 63, |
| 4443 | GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
| 4444 | static const struct wacom_features wacom_features_0x6A = |
| 4445 | { "Wacom Bamboo1 4x6" , 14760, 9225, 1023, 63, |
| 4446 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4447 | static const struct wacom_features wacom_features_0x6B = |
| 4448 | { "Wacom Bamboo1 5x8" , 21648, 13530, 1023, 63, |
| 4449 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4450 | static const struct wacom_features wacom_features_0x20 = |
| 4451 | { "Wacom Intuos 4x5" , 12700, 10600, 1023, 31, |
| 4452 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4453 | static const struct wacom_features wacom_features_0x21 = |
| 4454 | { "Wacom Intuos 6x8" , 20320, 16240, 1023, 31, |
| 4455 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4456 | static const struct wacom_features wacom_features_0x22 = |
| 4457 | { "Wacom Intuos 9x12" , 30480, 24060, 1023, 31, |
| 4458 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4459 | static const struct wacom_features wacom_features_0x23 = |
| 4460 | { "Wacom Intuos 12x12" , 30480, 31680, 1023, 31, |
| 4461 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4462 | static const struct wacom_features wacom_features_0x24 = |
| 4463 | { "Wacom Intuos 12x18" , 45720, 31680, 1023, 31, |
| 4464 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4465 | static const struct wacom_features wacom_features_0x30 = |
| 4466 | { "Wacom PL400" , 5408, 4056, 255, 0, |
| 4467 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4468 | static const struct wacom_features wacom_features_0x31 = |
| 4469 | { "Wacom PL500" , 6144, 4608, 255, 0, |
| 4470 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4471 | static const struct wacom_features wacom_features_0x32 = |
| 4472 | { "Wacom PL600" , 6126, 4604, 255, 0, |
| 4473 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4474 | static const struct wacom_features wacom_features_0x33 = |
| 4475 | { "Wacom PL600SX" , 6260, 5016, 255, 0, |
| 4476 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4477 | static const struct wacom_features wacom_features_0x34 = |
| 4478 | { "Wacom PL550" , 6144, 4608, 511, 0, |
| 4479 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4480 | static const struct wacom_features wacom_features_0x35 = |
| 4481 | { "Wacom PL800" , 7220, 5780, 511, 0, |
| 4482 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4483 | static const struct wacom_features wacom_features_0x37 = |
| 4484 | { "Wacom PL700" , 6758, 5406, 511, 0, |
| 4485 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4486 | static const struct wacom_features wacom_features_0x38 = |
| 4487 | { "Wacom PL510" , 6282, 4762, 511, 0, |
| 4488 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4489 | static const struct wacom_features wacom_features_0x39 = |
| 4490 | { "Wacom DTU710" , 34080, 27660, 511, 0, |
| 4491 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4492 | static const struct wacom_features wacom_features_0xC4 = |
| 4493 | { "Wacom DTF521" , 6282, 4762, 511, 0, |
| 4494 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4495 | static const struct wacom_features wacom_features_0xC0 = |
| 4496 | { "Wacom DTF720" , 6858, 5506, 511, 0, |
| 4497 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4498 | static const struct wacom_features wacom_features_0xC2 = |
| 4499 | { "Wacom DTF720a" , 6858, 5506, 511, 0, |
| 4500 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
| 4501 | static const struct wacom_features wacom_features_0x03 = |
| 4502 | { "Wacom Cintiq Partner" , 20480, 15360, 511, 0, |
| 4503 | PTU, WACOM_PL_RES, WACOM_PL_RES }; |
| 4504 | static const struct wacom_features wacom_features_0x41 = |
| 4505 | { "Wacom Intuos2 4x5" , 12700, 10600, 1023, 31, |
| 4506 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4507 | static const struct wacom_features wacom_features_0x42 = |
| 4508 | { "Wacom Intuos2 6x8" , 20320, 16240, 1023, 31, |
| 4509 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4510 | static const struct wacom_features wacom_features_0x43 = |
| 4511 | { "Wacom Intuos2 9x12" , 30480, 24060, 1023, 31, |
| 4512 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4513 | static const struct wacom_features wacom_features_0x44 = |
| 4514 | { "Wacom Intuos2 12x12" , 30480, 31680, 1023, 31, |
| 4515 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4516 | static const struct wacom_features wacom_features_0x45 = |
| 4517 | { "Wacom Intuos2 12x18" , 45720, 31680, 1023, 31, |
| 4518 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4519 | static const struct wacom_features wacom_features_0xB0 = |
| 4520 | { "Wacom Intuos3 4x5" , 25400, 20320, 1023, 63, |
| 4521 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
| 4522 | static const struct wacom_features wacom_features_0xB1 = |
| 4523 | { "Wacom Intuos3 6x8" , 40640, 30480, 1023, 63, |
| 4524 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4525 | static const struct wacom_features wacom_features_0xB2 = |
| 4526 | { "Wacom Intuos3 9x12" , 60960, 45720, 1023, 63, |
| 4527 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4528 | static const struct wacom_features wacom_features_0xB3 = |
| 4529 | { "Wacom Intuos3 12x12" , 60960, 60960, 1023, 63, |
| 4530 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4531 | static const struct wacom_features wacom_features_0xB4 = |
| 4532 | { "Wacom Intuos3 12x19" , 97536, 60960, 1023, 63, |
| 4533 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4534 | static const struct wacom_features wacom_features_0xB5 = |
| 4535 | { "Wacom Intuos3 6x11" , 54204, 31750, 1023, 63, |
| 4536 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4537 | static const struct wacom_features wacom_features_0xB7 = |
| 4538 | { "Wacom Intuos3 4x6" , 31496, 19685, 1023, 63, |
| 4539 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
| 4540 | static const struct wacom_features wacom_features_0xB8 = |
| 4541 | { "Wacom Intuos4 4x6" , 31496, 19685, 2047, 63, |
| 4542 | INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
| 4543 | static const struct wacom_features wacom_features_0xB9 = |
| 4544 | { "Wacom Intuos4 6x9" , 44704, 27940, 2047, 63, |
| 4545 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4546 | static const struct wacom_features wacom_features_0xBA = |
| 4547 | { "Wacom Intuos4 8x13" , 65024, 40640, 2047, 63, |
| 4548 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4549 | static const struct wacom_features wacom_features_0xBB = |
| 4550 | { "Wacom Intuos4 12x19" , 97536, 60960, 2047, 63, |
| 4551 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4552 | static const struct wacom_features wacom_features_0xBC = |
| 4553 | { "Wacom Intuos4 WL" , 40640, 25400, 2047, 63, |
| 4554 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4555 | static const struct wacom_features wacom_features_0xBD = |
| 4556 | { "Wacom Intuos4 WL" , 40640, 25400, 2047, 63, |
| 4557 | INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4558 | static const struct wacom_features wacom_features_0x26 = |
| 4559 | { "Wacom Intuos5 touch S" , 31496, 19685, 2047, 63, |
| 4560 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 }; |
| 4561 | static const struct wacom_features wacom_features_0x27 = |
| 4562 | { "Wacom Intuos5 touch M" , 44704, 27940, 2047, 63, |
| 4563 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
| 4564 | static const struct wacom_features wacom_features_0x28 = |
| 4565 | { "Wacom Intuos5 touch L" , 65024, 40640, 2047, 63, |
| 4566 | INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
| 4567 | static const struct wacom_features wacom_features_0x29 = |
| 4568 | { "Wacom Intuos5 S" , 31496, 19685, 2047, 63, |
| 4569 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
| 4570 | static const struct wacom_features wacom_features_0x2A = |
| 4571 | { "Wacom Intuos5 M" , 44704, 27940, 2047, 63, |
| 4572 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
| 4573 | static const struct wacom_features wacom_features_0x314 = |
| 4574 | { "Wacom Intuos Pro S" , 31496, 19685, 2047, 63, |
| 4575 | INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16, |
| 4576 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4577 | static const struct wacom_features wacom_features_0x315 = |
| 4578 | { "Wacom Intuos Pro M" , 44704, 27940, 2047, 63, |
| 4579 | INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
| 4580 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4581 | static const struct wacom_features wacom_features_0x317 = |
| 4582 | { "Wacom Intuos Pro L" , 65024, 40640, 2047, 63, |
| 4583 | INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
| 4584 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4585 | static const struct wacom_features wacom_features_0xF4 = |
| 4586 | { "Wacom Cintiq 24HD" , 104480, 65600, 2047, 63, |
| 4587 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
| 4588 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4589 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4590 | static const struct wacom_features wacom_features_0xF8 = |
| 4591 | { "Wacom Cintiq 24HD touch" , 104480, 65600, 2047, 63, /* Pen */ |
| 4592 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
| 4593 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4594 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4595 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; |
| 4596 | static const struct wacom_features wacom_features_0xF6 = |
| 4597 | { "Wacom Cintiq 24HD touch" , .type = WACOM_24HDT, /* Touch */ |
| 4598 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, |
| 4599 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4600 | static const struct wacom_features wacom_features_0x32A = |
| 4601 | { "Wacom Cintiq 27QHD" , 120140, 67920, 2047, 63, |
| 4602 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
| 4603 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4604 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4605 | static const struct wacom_features wacom_features_0x32B = |
| 4606 | { "Wacom Cintiq 27QHD touch" , 120140, 67920, 2047, 63, |
| 4607 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
| 4608 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4609 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4610 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C }; |
| 4611 | static const struct wacom_features wacom_features_0x32C = |
| 4612 | { "Wacom Cintiq 27QHD touch" , .type = WACOM_27QHDT, |
| 4613 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 }; |
| 4614 | static const struct wacom_features wacom_features_0x3F = |
| 4615 | { "Wacom Cintiq 21UX" , 87200, 65600, 1023, 63, |
| 4616 | CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
| 4617 | static const struct wacom_features wacom_features_0xC5 = |
| 4618 | { "Wacom Cintiq 20WSX" , 86680, 54180, 1023, 63, |
| 4619 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
| 4620 | static const struct wacom_features wacom_features_0xC6 = |
| 4621 | { "Wacom Cintiq 12WX" , 53020, 33440, 1023, 63, |
| 4622 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
| 4623 | static const struct wacom_features wacom_features_0x304 = |
| 4624 | { "Wacom Cintiq 13HD" , 59552, 33848, 1023, 63, |
| 4625 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
| 4626 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4627 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4628 | static const struct wacom_features wacom_features_0x333 = |
| 4629 | { "Wacom Cintiq 13HD touch" , 59552, 33848, 2047, 63, |
| 4630 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
| 4631 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4632 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4633 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 }; |
| 4634 | static const struct wacom_features wacom_features_0x335 = |
| 4635 | { "Wacom Cintiq 13HD touch" , .type = WACOM_24HDT, /* Touch */ |
| 4636 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10, |
| 4637 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4638 | static const struct wacom_features wacom_features_0xC7 = |
| 4639 | { "Wacom DTU1931" , 37832, 30305, 511, 0, |
| 4640 | PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4641 | static const struct wacom_features wacom_features_0xCE = |
| 4642 | { "Wacom DTU2231" , 47864, 27011, 511, 0, |
| 4643 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4644 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE }; |
| 4645 | static const struct wacom_features wacom_features_0xF0 = |
| 4646 | { "Wacom DTU1631" , 34623, 19553, 511, 0, |
| 4647 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4648 | static const struct wacom_features wacom_features_0xFB = |
| 4649 | { "Wacom DTU1031" , 22096, 13960, 511, 0, |
| 4650 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
| 4651 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
| 4652 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
| 4653 | static const struct wacom_features wacom_features_0x32F = |
| 4654 | { "Wacom DTU1031X" , 22672, 12928, 511, 0, |
| 4655 | DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0, |
| 4656 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
| 4657 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
| 4658 | static const struct wacom_features wacom_features_0x336 = |
| 4659 | { "Wacom DTU1141" , 23672, 13403, 1023, 0, |
| 4660 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
| 4661 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
| 4662 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
| 4663 | static const struct wacom_features wacom_features_0x57 = |
| 4664 | { "Wacom DTK2241" , 95840, 54260, 2047, 63, |
| 4665 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
| 4666 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4667 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4668 | static const struct wacom_features wacom_features_0x59 = /* Pen */ |
| 4669 | { "Wacom DTH2242" , 95840, 54260, 2047, 63, |
| 4670 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
| 4671 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4672 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4673 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; |
| 4674 | static const struct wacom_features wacom_features_0x5D = /* Touch */ |
| 4675 | { "Wacom DTH2242" , .type = WACOM_24HDT, |
| 4676 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, |
| 4677 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4678 | static const struct wacom_features wacom_features_0xCC = |
| 4679 | { "Wacom Cintiq 21UX2" , 87200, 65600, 2047, 63, |
| 4680 | WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
| 4681 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4682 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4683 | static const struct wacom_features wacom_features_0xFA = |
| 4684 | { "Wacom Cintiq 22HD" , 95840, 54260, 2047, 63, |
| 4685 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
| 4686 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4687 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
| 4688 | static const struct wacom_features wacom_features_0x5B = |
| 4689 | { "Wacom Cintiq 22HDT" , 95840, 54260, 2047, 63, |
| 4690 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
| 4691 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4692 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4693 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; |
| 4694 | static const struct wacom_features wacom_features_0x5E = |
| 4695 | { "Wacom Cintiq 22HDT" , .type = WACOM_24HDT, |
| 4696 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10, |
| 4697 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4698 | static const struct wacom_features wacom_features_0x90 = |
| 4699 | { "Wacom ISDv4 90" , 26202, 16325, 255, 0, |
| 4700 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
| 4701 | static const struct wacom_features wacom_features_0x93 = |
| 4702 | { "Wacom ISDv4 93" , 26202, 16325, 255, 0, |
| 4703 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
| 4704 | static const struct wacom_features wacom_features_0x97 = |
| 4705 | { "Wacom ISDv4 97" , 26202, 16325, 511, 0, |
| 4706 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
| 4707 | static const struct wacom_features wacom_features_0x9A = |
| 4708 | { "Wacom ISDv4 9A" , 26202, 16325, 255, 0, |
| 4709 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
| 4710 | static const struct wacom_features wacom_features_0x9F = |
| 4711 | { "Wacom ISDv4 9F" , 26202, 16325, 255, 0, |
| 4712 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
| 4713 | static const struct wacom_features wacom_features_0xE2 = |
| 4714 | { "Wacom ISDv4 E2" , 26202, 16325, 255, 0, |
| 4715 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4716 | static const struct wacom_features wacom_features_0xE3 = |
| 4717 | { "Wacom ISDv4 E3" , 26202, 16325, 255, 0, |
| 4718 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4719 | static const struct wacom_features wacom_features_0xE5 = |
| 4720 | { "Wacom ISDv4 E5" , 26202, 16325, 255, 0, |
| 4721 | MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4722 | static const struct wacom_features wacom_features_0xE6 = |
| 4723 | { "Wacom ISDv4 E6" , 27760, 15694, 255, 0, |
| 4724 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4725 | static const struct wacom_features wacom_features_0xEC = |
| 4726 | { "Wacom ISDv4 EC" , 25710, 14500, 255, 0, |
| 4727 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
| 4728 | static const struct wacom_features wacom_features_0xED = |
| 4729 | { "Wacom ISDv4 ED" , 26202, 16325, 255, 0, |
| 4730 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
| 4731 | static const struct wacom_features wacom_features_0xEF = |
| 4732 | { "Wacom ISDv4 EF" , 26202, 16325, 255, 0, |
| 4733 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
| 4734 | static const struct wacom_features wacom_features_0x100 = |
| 4735 | { "Wacom ISDv4 100" , 26202, 16325, 255, 0, |
| 4736 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4737 | static const struct wacom_features wacom_features_0x101 = |
| 4738 | { "Wacom ISDv4 101" , 26202, 16325, 255, 0, |
| 4739 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4740 | static const struct wacom_features wacom_features_0x10D = |
| 4741 | { "Wacom ISDv4 10D" , 26202, 16325, 255, 0, |
| 4742 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4743 | static const struct wacom_features wacom_features_0x10E = |
| 4744 | { "Wacom ISDv4 10E" , 27760, 15694, 255, 0, |
| 4745 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4746 | static const struct wacom_features wacom_features_0x10F = |
| 4747 | { "Wacom ISDv4 10F" , 27760, 15694, 255, 0, |
| 4748 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4749 | static const struct wacom_features wacom_features_0x116 = |
| 4750 | { "Wacom ISDv4 116" , 26202, 16325, 255, 0, |
| 4751 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
| 4752 | static const struct wacom_features wacom_features_0x12C = |
| 4753 | { "Wacom ISDv4 12C" , 27848, 15752, 2047, 0, |
| 4754 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
| 4755 | static const struct wacom_features wacom_features_0x4001 = |
| 4756 | { "Wacom ISDv4 4001" , 26202, 16325, 255, 0, |
| 4757 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4758 | static const struct wacom_features wacom_features_0x4004 = |
| 4759 | { "Wacom ISDv4 4004" , 11060, 6220, 255, 0, |
| 4760 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4761 | static const struct wacom_features wacom_features_0x5000 = |
| 4762 | { "Wacom ISDv4 5000" , 27848, 15752, 1023, 0, |
| 4763 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4764 | static const struct wacom_features wacom_features_0x5002 = |
| 4765 | { "Wacom ISDv4 5002" , 29576, 16724, 1023, 0, |
| 4766 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4767 | static const struct wacom_features wacom_features_0x47 = |
| 4768 | { "Wacom Intuos2 6x8" , 20320, 16240, 1023, 31, |
| 4769 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4770 | static const struct wacom_features wacom_features_0x84 = |
| 4771 | { "Wacom Wireless Receiver" , .type = WIRELESS, .touch_max = 16 }; |
| 4772 | static const struct wacom_features wacom_features_0xD0 = |
| 4773 | { "Wacom Bamboo 2FG" , 14720, 9200, 1023, 31, |
| 4774 | BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4775 | static const struct wacom_features wacom_features_0xD1 = |
| 4776 | { "Wacom Bamboo 2FG 4x5" , 14720, 9200, 1023, 31, |
| 4777 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4778 | static const struct wacom_features wacom_features_0xD2 = |
| 4779 | { "Wacom Bamboo Craft" , 14720, 9200, 1023, 31, |
| 4780 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4781 | static const struct wacom_features wacom_features_0xD3 = |
| 4782 | { "Wacom Bamboo 2FG 6x8" , 21648, 13700, 1023, 31, |
| 4783 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4784 | static const struct wacom_features wacom_features_0xD4 = |
| 4785 | { "Wacom Bamboo Pen" , 14720, 9200, 1023, 31, |
| 4786 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4787 | static const struct wacom_features wacom_features_0xD5 = |
| 4788 | { "Wacom Bamboo Pen 6x8" , 21648, 13700, 1023, 31, |
| 4789 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4790 | static const struct wacom_features wacom_features_0xD6 = |
| 4791 | { "Wacom BambooPT 2FG 4x5" , 14720, 9200, 1023, 31, |
| 4792 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4793 | static const struct wacom_features wacom_features_0xD7 = |
| 4794 | { "Wacom BambooPT 2FG Small" , 14720, 9200, 1023, 31, |
| 4795 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4796 | static const struct wacom_features wacom_features_0xD8 = |
| 4797 | { "Wacom Bamboo Comic 2FG" , 21648, 13700, 1023, 31, |
| 4798 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4799 | static const struct wacom_features wacom_features_0xDA = |
| 4800 | { "Wacom Bamboo 2FG 4x5 SE" , 14720, 9200, 1023, 31, |
| 4801 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4802 | static const struct wacom_features wacom_features_0xDB = |
| 4803 | { "Wacom Bamboo 2FG 6x8 SE" , 21648, 13700, 1023, 31, |
| 4804 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
| 4805 | static const struct wacom_features wacom_features_0xDD = |
| 4806 | { "Wacom Bamboo Connect" , 14720, 9200, 1023, 31, |
| 4807 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4808 | static const struct wacom_features wacom_features_0xDE = |
| 4809 | { "Wacom Bamboo 16FG 4x5" , 14720, 9200, 1023, 31, |
| 4810 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
| 4811 | static const struct wacom_features wacom_features_0xDF = |
| 4812 | { "Wacom Bamboo 16FG 6x8" , 21648, 13700, 1023, 31, |
| 4813 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
| 4814 | static const struct wacom_features wacom_features_0x300 = |
| 4815 | { "Wacom Bamboo One S" , 14720, 9225, 1023, 31, |
| 4816 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4817 | static const struct wacom_features wacom_features_0x301 = |
| 4818 | { "Wacom Bamboo One M" , 21648, 13530, 1023, 31, |
| 4819 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4820 | static const struct wacom_features wacom_features_0x302 = |
| 4821 | { "Wacom Intuos PT S" , 15200, 9500, 1023, 31, |
| 4822 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4823 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4824 | static const struct wacom_features wacom_features_0x303 = |
| 4825 | { "Wacom Intuos PT M" , 21600, 13500, 1023, 31, |
| 4826 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4827 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4828 | static const struct wacom_features wacom_features_0x30E = |
| 4829 | { "Wacom Intuos S" , 15200, 9500, 1023, 31, |
| 4830 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4831 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4832 | static const struct wacom_features wacom_features_0x6004 = |
| 4833 | { "ISD-V4" , 12800, 8000, 255, 0, |
| 4834 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4835 | static const struct wacom_features wacom_features_0x307 = |
| 4836 | { "Wacom ISDv5 307" , 59552, 33848, 2047, 63, |
| 4837 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
| 4838 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4839 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4840 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; |
| 4841 | static const struct wacom_features wacom_features_0x309 = |
| 4842 | { "Wacom ISDv5 309" , .type = WACOM_24HDT, /* Touch */ |
| 4843 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, |
| 4844 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4845 | static const struct wacom_features wacom_features_0x30A = |
| 4846 | { "Wacom ISDv5 30A" , 59552, 33848, 2047, 63, |
| 4847 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
| 4848 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4849 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4850 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C }; |
| 4851 | static const struct wacom_features wacom_features_0x30C = |
| 4852 | { "Wacom ISDv5 30C" , .type = WACOM_24HDT, /* Touch */ |
| 4853 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10, |
| 4854 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4855 | static const struct wacom_features wacom_features_0x318 = |
| 4856 | { "Wacom USB Bamboo PAD" , 4095, 4095, /* Touch */ |
| 4857 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
| 4858 | static const struct wacom_features wacom_features_0x319 = |
| 4859 | { "Wacom Wireless Bamboo PAD" , 4095, 4095, /* Touch */ |
| 4860 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
| 4861 | static const struct wacom_features wacom_features_0x325 = |
| 4862 | { "Wacom ISDv5 325" , 59552, 33848, 2047, 63, |
| 4863 | CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11, |
| 4864 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4865 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
| 4866 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 }; |
| 4867 | static const struct wacom_features wacom_features_0x326 = /* Touch */ |
| 4868 | { "Wacom ISDv5 326" , .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM, |
| 4869 | .oPid = 0x325 }; |
| 4870 | static const struct wacom_features wacom_features_0x323 = |
| 4871 | { "Wacom Intuos P M" , 21600, 13500, 1023, 31, |
| 4872 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4873 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4874 | static const struct wacom_features wacom_features_0x331 = |
| 4875 | { "Wacom Express Key Remote" , .type = REMOTE, |
| 4876 | .numbered_buttons = 18, .check_for_hid_type = true, |
| 4877 | .hid_type = HID_TYPE_USBNONE }; |
| 4878 | static const struct wacom_features wacom_features_0x33B = |
| 4879 | { "Wacom Intuos S 2" , 15200, 9500, 2047, 63, |
| 4880 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4881 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4882 | static const struct wacom_features wacom_features_0x33C = |
| 4883 | { "Wacom Intuos PT S 2" , 15200, 9500, 2047, 63, |
| 4884 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4885 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4886 | static const struct wacom_features wacom_features_0x33D = |
| 4887 | { "Wacom Intuos P M 2" , 21600, 13500, 2047, 63, |
| 4888 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4889 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4890 | static const struct wacom_features wacom_features_0x33E = |
| 4891 | { "Wacom Intuos PT M 2" , 21600, 13500, 2047, 63, |
| 4892 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4893 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4894 | static const struct wacom_features wacom_features_0x343 = |
| 4895 | { "Wacom DTK1651" , 34816, 19759, 1023, 0, |
| 4896 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
| 4897 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
| 4898 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
| 4899 | static const struct wacom_features wacom_features_0x360 = |
| 4900 | { "Wacom Intuos Pro M" , 44800, 29600, 8191, 63, |
| 4901 | INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 }; |
| 4902 | static const struct wacom_features wacom_features_0x361 = |
| 4903 | { "Wacom Intuos Pro L" , 62200, 43200, 8191, 63, |
| 4904 | INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 }; |
| 4905 | static const struct wacom_features wacom_features_0x377 = |
| 4906 | { "Wacom Intuos BT S" , 15200, 9500, 4095, 63, |
| 4907 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
| 4908 | static const struct wacom_features wacom_features_0x379 = |
| 4909 | { "Wacom Intuos BT M" , 21600, 13500, 4095, 63, |
| 4910 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
| 4911 | static const struct wacom_features wacom_features_0x37A = |
| 4912 | { "Wacom One by Wacom S" , 15200, 9500, 2047, 63, |
| 4913 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4914 | static const struct wacom_features wacom_features_0x37B = |
| 4915 | { "Wacom One by Wacom M" , 21600, 13500, 2047, 63, |
| 4916 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4917 | static const struct wacom_features wacom_features_0x393 = |
| 4918 | { "Wacom Intuos Pro S" , 31920, 19950, 8191, 63, |
| 4919 | INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, |
| 4920 | .touch_max = 10 }; |
| 4921 | static const struct wacom_features wacom_features_0x3c6 = |
| 4922 | { "Wacom Intuos BT S" , 15200, 9500, 4095, 63, |
| 4923 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
| 4924 | static const struct wacom_features wacom_features_0x3c8 = |
| 4925 | { "Wacom Intuos BT M" , 21600, 13500, 4095, 63, |
| 4926 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
| 4927 | static const struct wacom_features wacom_features_0x3dd = |
| 4928 | { "Wacom Intuos Pro S" , 31920, 19950, 8191, 63, |
| 4929 | INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, |
| 4930 | .touch_max = 10 }; |
| 4931 | |
| 4932 | static const struct wacom_features wacom_features_HID_ANY_ID = |
| 4933 | { "Wacom HID" , .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID }; |
| 4934 | |
| 4935 | static const struct wacom_features wacom_features_0x94 = |
| 4936 | { "Wacom Bootloader" , .type = BOOTLOADER }; |
| 4937 | |
| 4938 | #define USB_DEVICE_WACOM(prod) \ |
| 4939 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4940 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4941 | |
| 4942 | #define BT_DEVICE_WACOM(prod) \ |
| 4943 | HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4944 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4945 | |
| 4946 | #define I2C_DEVICE_WACOM(prod) \ |
| 4947 | HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4948 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4949 | |
| 4950 | #define PCI_DEVICE_WACOM(prod) \ |
| 4951 | HID_DEVICE(BUS_PCI, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4952 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4953 | |
| 4954 | #define USB_DEVICE_LENOVO(prod) \ |
| 4955 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ |
| 4956 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4957 | |
| 4958 | const struct hid_device_id wacom_ids[] = { |
| 4959 | { USB_DEVICE_WACOM(0x00) }, |
| 4960 | { USB_DEVICE_WACOM(0x03) }, |
| 4961 | { USB_DEVICE_WACOM(0x10) }, |
| 4962 | { USB_DEVICE_WACOM(0x11) }, |
| 4963 | { USB_DEVICE_WACOM(0x12) }, |
| 4964 | { USB_DEVICE_WACOM(0x13) }, |
| 4965 | { USB_DEVICE_WACOM(0x14) }, |
| 4966 | { USB_DEVICE_WACOM(0x15) }, |
| 4967 | { USB_DEVICE_WACOM(0x16) }, |
| 4968 | { USB_DEVICE_WACOM(0x17) }, |
| 4969 | { USB_DEVICE_WACOM(0x18) }, |
| 4970 | { USB_DEVICE_WACOM(0x19) }, |
| 4971 | { USB_DEVICE_WACOM(0x20) }, |
| 4972 | { USB_DEVICE_WACOM(0x21) }, |
| 4973 | { USB_DEVICE_WACOM(0x22) }, |
| 4974 | { USB_DEVICE_WACOM(0x23) }, |
| 4975 | { USB_DEVICE_WACOM(0x24) }, |
| 4976 | { USB_DEVICE_WACOM(0x26) }, |
| 4977 | { USB_DEVICE_WACOM(0x27) }, |
| 4978 | { USB_DEVICE_WACOM(0x28) }, |
| 4979 | { USB_DEVICE_WACOM(0x29) }, |
| 4980 | { USB_DEVICE_WACOM(0x2A) }, |
| 4981 | { USB_DEVICE_WACOM(0x30) }, |
| 4982 | { USB_DEVICE_WACOM(0x31) }, |
| 4983 | { USB_DEVICE_WACOM(0x32) }, |
| 4984 | { USB_DEVICE_WACOM(0x33) }, |
| 4985 | { USB_DEVICE_WACOM(0x34) }, |
| 4986 | { USB_DEVICE_WACOM(0x35) }, |
| 4987 | { USB_DEVICE_WACOM(0x37) }, |
| 4988 | { USB_DEVICE_WACOM(0x38) }, |
| 4989 | { USB_DEVICE_WACOM(0x39) }, |
| 4990 | { USB_DEVICE_WACOM(0x3F) }, |
| 4991 | { USB_DEVICE_WACOM(0x41) }, |
| 4992 | { USB_DEVICE_WACOM(0x42) }, |
| 4993 | { USB_DEVICE_WACOM(0x43) }, |
| 4994 | { USB_DEVICE_WACOM(0x44) }, |
| 4995 | { USB_DEVICE_WACOM(0x45) }, |
| 4996 | { USB_DEVICE_WACOM(0x47) }, |
| 4997 | { USB_DEVICE_WACOM(0x57) }, |
| 4998 | { USB_DEVICE_WACOM(0x59) }, |
| 4999 | { USB_DEVICE_WACOM(0x5B) }, |
| 5000 | { USB_DEVICE_WACOM(0x5D) }, |
| 5001 | { USB_DEVICE_WACOM(0x5E) }, |
| 5002 | { USB_DEVICE_WACOM(0x60) }, |
| 5003 | { USB_DEVICE_WACOM(0x61) }, |
| 5004 | { USB_DEVICE_WACOM(0x62) }, |
| 5005 | { USB_DEVICE_WACOM(0x63) }, |
| 5006 | { USB_DEVICE_WACOM(0x64) }, |
| 5007 | { USB_DEVICE_WACOM(0x65) }, |
| 5008 | { USB_DEVICE_WACOM(0x69) }, |
| 5009 | { USB_DEVICE_WACOM(0x6A) }, |
| 5010 | { USB_DEVICE_WACOM(0x6B) }, |
| 5011 | { BT_DEVICE_WACOM(0x81) }, |
| 5012 | { USB_DEVICE_WACOM(0x84) }, |
| 5013 | { USB_DEVICE_WACOM(0x90) }, |
| 5014 | { USB_DEVICE_WACOM(0x93) }, |
| 5015 | { USB_DEVICE_WACOM(0x94) }, |
| 5016 | { USB_DEVICE_WACOM(0x97) }, |
| 5017 | { USB_DEVICE_WACOM(0x9A) }, |
| 5018 | { USB_DEVICE_WACOM(0x9F) }, |
| 5019 | { USB_DEVICE_WACOM(0xB0) }, |
| 5020 | { USB_DEVICE_WACOM(0xB1) }, |
| 5021 | { USB_DEVICE_WACOM(0xB2) }, |
| 5022 | { USB_DEVICE_WACOM(0xB3) }, |
| 5023 | { USB_DEVICE_WACOM(0xB4) }, |
| 5024 | { USB_DEVICE_WACOM(0xB5) }, |
| 5025 | { USB_DEVICE_WACOM(0xB7) }, |
| 5026 | { USB_DEVICE_WACOM(0xB8) }, |
| 5027 | { USB_DEVICE_WACOM(0xB9) }, |
| 5028 | { USB_DEVICE_WACOM(0xBA) }, |
| 5029 | { USB_DEVICE_WACOM(0xBB) }, |
| 5030 | { USB_DEVICE_WACOM(0xBC) }, |
| 5031 | { BT_DEVICE_WACOM(0xBD) }, |
| 5032 | { USB_DEVICE_WACOM(0xC0) }, |
| 5033 | { USB_DEVICE_WACOM(0xC2) }, |
| 5034 | { USB_DEVICE_WACOM(0xC4) }, |
| 5035 | { USB_DEVICE_WACOM(0xC5) }, |
| 5036 | { USB_DEVICE_WACOM(0xC6) }, |
| 5037 | { USB_DEVICE_WACOM(0xC7) }, |
| 5038 | { USB_DEVICE_WACOM(0xCC) }, |
| 5039 | { USB_DEVICE_WACOM(0xCE) }, |
| 5040 | { USB_DEVICE_WACOM(0xD0) }, |
| 5041 | { USB_DEVICE_WACOM(0xD1) }, |
| 5042 | { USB_DEVICE_WACOM(0xD2) }, |
| 5043 | { USB_DEVICE_WACOM(0xD3) }, |
| 5044 | { USB_DEVICE_WACOM(0xD4) }, |
| 5045 | { USB_DEVICE_WACOM(0xD5) }, |
| 5046 | { USB_DEVICE_WACOM(0xD6) }, |
| 5047 | { USB_DEVICE_WACOM(0xD7) }, |
| 5048 | { USB_DEVICE_WACOM(0xD8) }, |
| 5049 | { USB_DEVICE_WACOM(0xDA) }, |
| 5050 | { USB_DEVICE_WACOM(0xDB) }, |
| 5051 | { USB_DEVICE_WACOM(0xDD) }, |
| 5052 | { USB_DEVICE_WACOM(0xDE) }, |
| 5053 | { USB_DEVICE_WACOM(0xDF) }, |
| 5054 | { USB_DEVICE_WACOM(0xE2) }, |
| 5055 | { USB_DEVICE_WACOM(0xE3) }, |
| 5056 | { USB_DEVICE_WACOM(0xE5) }, |
| 5057 | { USB_DEVICE_WACOM(0xE6) }, |
| 5058 | { USB_DEVICE_WACOM(0xEC) }, |
| 5059 | { USB_DEVICE_WACOM(0xED) }, |
| 5060 | { USB_DEVICE_WACOM(0xEF) }, |
| 5061 | { USB_DEVICE_WACOM(0xF0) }, |
| 5062 | { USB_DEVICE_WACOM(0xF4) }, |
| 5063 | { USB_DEVICE_WACOM(0xF6) }, |
| 5064 | { USB_DEVICE_WACOM(0xF8) }, |
| 5065 | { USB_DEVICE_WACOM(0xFA) }, |
| 5066 | { USB_DEVICE_WACOM(0xFB) }, |
| 5067 | { USB_DEVICE_WACOM(0x100) }, |
| 5068 | { USB_DEVICE_WACOM(0x101) }, |
| 5069 | { USB_DEVICE_WACOM(0x10D) }, |
| 5070 | { USB_DEVICE_WACOM(0x10E) }, |
| 5071 | { USB_DEVICE_WACOM(0x10F) }, |
| 5072 | { USB_DEVICE_WACOM(0x116) }, |
| 5073 | { USB_DEVICE_WACOM(0x12C) }, |
| 5074 | { USB_DEVICE_WACOM(0x300) }, |
| 5075 | { USB_DEVICE_WACOM(0x301) }, |
| 5076 | { USB_DEVICE_WACOM(0x302) }, |
| 5077 | { USB_DEVICE_WACOM(0x303) }, |
| 5078 | { USB_DEVICE_WACOM(0x304) }, |
| 5079 | { USB_DEVICE_WACOM(0x307) }, |
| 5080 | { USB_DEVICE_WACOM(0x309) }, |
| 5081 | { USB_DEVICE_WACOM(0x30A) }, |
| 5082 | { USB_DEVICE_WACOM(0x30C) }, |
| 5083 | { USB_DEVICE_WACOM(0x30E) }, |
| 5084 | { USB_DEVICE_WACOM(0x314) }, |
| 5085 | { USB_DEVICE_WACOM(0x315) }, |
| 5086 | { USB_DEVICE_WACOM(0x317) }, |
| 5087 | { USB_DEVICE_WACOM(0x318) }, |
| 5088 | { USB_DEVICE_WACOM(0x319) }, |
| 5089 | { USB_DEVICE_WACOM(0x323) }, |
| 5090 | { USB_DEVICE_WACOM(0x325) }, |
| 5091 | { USB_DEVICE_WACOM(0x326) }, |
| 5092 | { USB_DEVICE_WACOM(0x32A) }, |
| 5093 | { USB_DEVICE_WACOM(0x32B) }, |
| 5094 | { USB_DEVICE_WACOM(0x32C) }, |
| 5095 | { USB_DEVICE_WACOM(0x32F) }, |
| 5096 | { USB_DEVICE_WACOM(0x331) }, |
| 5097 | { USB_DEVICE_WACOM(0x333) }, |
| 5098 | { USB_DEVICE_WACOM(0x335) }, |
| 5099 | { USB_DEVICE_WACOM(0x336) }, |
| 5100 | { USB_DEVICE_WACOM(0x33B) }, |
| 5101 | { USB_DEVICE_WACOM(0x33C) }, |
| 5102 | { USB_DEVICE_WACOM(0x33D) }, |
| 5103 | { USB_DEVICE_WACOM(0x33E) }, |
| 5104 | { USB_DEVICE_WACOM(0x343) }, |
| 5105 | { BT_DEVICE_WACOM(0x360) }, |
| 5106 | { BT_DEVICE_WACOM(0x361) }, |
| 5107 | { BT_DEVICE_WACOM(0x377) }, |
| 5108 | { BT_DEVICE_WACOM(0x379) }, |
| 5109 | { USB_DEVICE_WACOM(0x37A) }, |
| 5110 | { USB_DEVICE_WACOM(0x37B) }, |
| 5111 | { BT_DEVICE_WACOM(0x393) }, |
| 5112 | { BT_DEVICE_WACOM(0x3c6) }, |
| 5113 | { BT_DEVICE_WACOM(0x3c8) }, |
| 5114 | { BT_DEVICE_WACOM(0x3dd) }, |
| 5115 | { USB_DEVICE_WACOM(0x4001) }, |
| 5116 | { USB_DEVICE_WACOM(0x4004) }, |
| 5117 | { USB_DEVICE_WACOM(0x5000) }, |
| 5118 | { USB_DEVICE_WACOM(0x5002) }, |
| 5119 | { USB_DEVICE_LENOVO(0x6004) }, |
| 5120 | |
| 5121 | { USB_DEVICE_WACOM(HID_ANY_ID) }, |
| 5122 | { I2C_DEVICE_WACOM(HID_ANY_ID) }, |
| 5123 | { PCI_DEVICE_WACOM(HID_ANY_ID) }, |
| 5124 | { BT_DEVICE_WACOM(HID_ANY_ID) }, |
| 5125 | { } |
| 5126 | }; |
| 5127 | MODULE_DEVICE_TABLE(hid, wacom_ids); |
| 5128 | |