Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'wacom' into next

Merge large update to Wacom driver, converting it from USB to a HID
driver and unifying wired and bluetooth support, from Benjamin
Tissoires.

+2229 -2987
+9 -4
drivers/hid/Kconfig
··· 748 748 Rumble Force or Force Feedback Wheel. 749 749 750 750 config HID_WACOM 751 - tristate "Wacom Bluetooth devices support" 751 + tristate "Wacom Intuos/Graphire tablet support (USB)" 752 752 depends on HID 753 - depends on LEDS_CLASS 754 753 select POWER_SUPPLY 755 - ---help--- 756 - Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. 754 + select NEW_LEDS 755 + select LEDS_CLASS 756 + help 757 + Say Y here if you want to use the USB or BT version of the Wacom Intuos 758 + or Graphire tablet. 759 + 760 + To compile this driver as a module, choose M here: the 761 + module will be called wacom. 757 762 758 763 config HID_WIIMOTE 759 764 tristate "Nintendo Wii / Wii U peripherals"
+3 -1
drivers/hid/Makefile
··· 115 115 obj-$(CONFIG_HID_XINMO) += hid-xinmo.o 116 116 obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o 117 117 obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o 118 - obj-$(CONFIG_HID_WACOM) += hid-wacom.o 118 + 119 + wacom-objs := wacom_wac.o wacom_sys.o 120 + obj-$(CONFIG_HID_WACOM) += wacom.o 119 121 obj-$(CONFIG_HID_WALTOP) += hid-waltop.o 120 122 obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o 121 123 obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.o
+9 -3
drivers/hid/hid-core.c
··· 787 787 /* hid-rmi should take care of them, not hid-generic */ 788 788 hid->group = HID_GROUP_RMI; 789 789 790 + /* 791 + * Vendor specific handlings 792 + */ 793 + switch (hid->vendor) { 794 + case USB_VENDOR_ID_WACOM: 795 + hid->group = HID_GROUP_WACOM; 796 + break; 797 + } 798 + 790 799 vfree(parser); 791 800 return 0; 792 801 } ··· 1942 1933 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 1943 1934 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 1944 1935 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1945 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 1946 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 1947 1936 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 1948 1937 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 1949 1938 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, ··· 2346 2339 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 2347 2340 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 2348 2341 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 2349 - { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 2350 2342 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 2351 2343 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 2352 2344 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
-973
drivers/hid/hid-wacom.c
··· 1 - /* 2 - * Bluetooth Wacom Tablet support 3 - * 4 - * Copyright (c) 1999 Andreas Gal 5 - * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6 - * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 7 - * Copyright (c) 2006-2007 Jiri Kosina 8 - * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com> 9 - * Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru> 10 - * Copyright (c) 2009 Bastien Nocera <hadess@hadess.net> 11 - * Copyright (c) 2011 Przemysław Firszt <przemo@firszt.eu> 12 - */ 13 - 14 - /* 15 - * This program is free software; you can redistribute it and/or modify it 16 - * under the terms of the GNU General Public License as published by the Free 17 - * Software Foundation; either version 2 of the License, or (at your option) 18 - * any later version. 19 - */ 20 - 21 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 22 - 23 - #include <linux/device.h> 24 - #include <linux/hid.h> 25 - #include <linux/module.h> 26 - #include <linux/leds.h> 27 - #include <linux/slab.h> 28 - #include <linux/power_supply.h> 29 - 30 - #include "hid-ids.h" 31 - 32 - #define PAD_DEVICE_ID 0x0F 33 - 34 - #define WAC_CMD_LED_CONTROL 0x20 35 - #define WAC_CMD_ICON_START_STOP 0x21 36 - #define WAC_CMD_ICON_TRANSFER 0x26 37 - 38 - struct wacom_data { 39 - __u16 tool; 40 - __u16 butstate; 41 - __u8 whlstate; 42 - __u8 features; 43 - __u32 id; 44 - __u32 serial; 45 - unsigned char high_speed; 46 - __u8 battery_capacity; 47 - __u8 power_raw; 48 - __u8 ps_connected; 49 - __u8 bat_charging; 50 - struct power_supply battery; 51 - struct power_supply ac; 52 - __u8 led_selector; 53 - struct led_classdev *leds[4]; 54 - }; 55 - 56 - /*percent of battery capacity for Graphire 57 - 8th value means AC online and show 100% capacity */ 58 - static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; 59 - /*percent of battery capacity for Intuos4 WL, AC has a separate bit*/ 60 - static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; 61 - 62 - static enum power_supply_property wacom_battery_props[] = { 63 - POWER_SUPPLY_PROP_PRESENT, 64 - POWER_SUPPLY_PROP_CAPACITY, 65 - POWER_SUPPLY_PROP_SCOPE, 66 - POWER_SUPPLY_PROP_STATUS, 67 - }; 68 - 69 - static enum power_supply_property wacom_ac_props[] = { 70 - POWER_SUPPLY_PROP_PRESENT, 71 - POWER_SUPPLY_PROP_ONLINE, 72 - POWER_SUPPLY_PROP_SCOPE, 73 - }; 74 - 75 - static void wacom_scramble(__u8 *image) 76 - { 77 - __u16 mask; 78 - __u16 s1; 79 - __u16 s2; 80 - __u16 r1 ; 81 - __u16 r2 ; 82 - __u16 r; 83 - __u8 buf[256]; 84 - int i, w, x, y, z; 85 - 86 - for (x = 0; x < 32; x++) { 87 - for (y = 0; y < 8; y++) 88 - buf[(8 * x) + (7 - y)] = image[(8 * x) + y]; 89 - } 90 - 91 - /* Change 76543210 into GECA6420 as required by Intuos4 WL 92 - * HGFEDCBA HFDB7531 93 - */ 94 - for (x = 0; x < 4; x++) { 95 - for (y = 0; y < 4; y++) { 96 - for (z = 0; z < 8; z++) { 97 - mask = 0x0001; 98 - r1 = 0; 99 - r2 = 0; 100 - i = (x << 6) + (y << 4) + z; 101 - s1 = buf[i]; 102 - s2 = buf[i+8]; 103 - for (w = 0; w < 8; w++) { 104 - r1 |= (s1 & mask); 105 - r2 |= (s2 & mask); 106 - s1 <<= 1; 107 - s2 <<= 1; 108 - mask <<= 2; 109 - } 110 - r = r1 | (r2 << 1); 111 - i = (x << 6) + (y << 4) + (z << 1); 112 - image[i] = 0xFF & r; 113 - image[i+1] = (0xFF00 & r) >> 8; 114 - } 115 - } 116 - } 117 - } 118 - 119 - static void wacom_set_image(struct hid_device *hdev, const char *image, 120 - __u8 icon_no) 121 - { 122 - __u8 rep_data[68]; 123 - __u8 p[256]; 124 - int ret, i, j; 125 - 126 - for (i = 0; i < 256; i++) 127 - p[i] = image[i]; 128 - 129 - rep_data[0] = WAC_CMD_ICON_START_STOP; 130 - rep_data[1] = 0; 131 - ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2, 132 - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 133 - if (ret < 0) 134 - goto err; 135 - 136 - rep_data[0] = WAC_CMD_ICON_TRANSFER; 137 - rep_data[1] = icon_no & 0x07; 138 - 139 - wacom_scramble(p); 140 - 141 - for (i = 0; i < 4; i++) { 142 - for (j = 0; j < 64; j++) 143 - rep_data[j + 3] = p[(i << 6) + j]; 144 - 145 - rep_data[2] = i; 146 - ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 67, 147 - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 148 - } 149 - 150 - rep_data[0] = WAC_CMD_ICON_START_STOP; 151 - rep_data[1] = 0; 152 - 153 - ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2, 154 - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 155 - 156 - err: 157 - return; 158 - } 159 - 160 - static void wacom_leds_set_brightness(struct led_classdev *led_dev, 161 - enum led_brightness value) 162 - { 163 - struct device *dev = led_dev->dev->parent; 164 - struct hid_device *hdev; 165 - struct wacom_data *wdata; 166 - unsigned char *buf; 167 - __u8 led = 0; 168 - int i; 169 - 170 - hdev = container_of(dev, struct hid_device, dev); 171 - wdata = hid_get_drvdata(hdev); 172 - for (i = 0; i < 4; ++i) { 173 - if (wdata->leds[i] == led_dev) 174 - wdata->led_selector = i; 175 - } 176 - 177 - led = wdata->led_selector | 0x04; 178 - buf = kzalloc(9, GFP_KERNEL); 179 - if (buf) { 180 - buf[0] = WAC_CMD_LED_CONTROL; 181 - buf[1] = led; 182 - buf[2] = value >> 2; 183 - buf[3] = value; 184 - /* use fixed brightness for OLEDs */ 185 - buf[4] = 0x08; 186 - hid_hw_raw_request(hdev, buf[0], buf, 9, HID_FEATURE_REPORT, 187 - HID_REQ_SET_REPORT); 188 - kfree(buf); 189 - } 190 - 191 - return; 192 - } 193 - 194 - static enum led_brightness wacom_leds_get_brightness(struct led_classdev *led_dev) 195 - { 196 - struct wacom_data *wdata; 197 - struct device *dev = led_dev->dev->parent; 198 - int value = 0; 199 - int i; 200 - 201 - wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); 202 - 203 - for (i = 0; i < 4; ++i) { 204 - if (wdata->leds[i] == led_dev) { 205 - value = wdata->leds[i]->brightness; 206 - break; 207 - } 208 - } 209 - 210 - return value; 211 - } 212 - 213 - 214 - static int wacom_initialize_leds(struct hid_device *hdev) 215 - { 216 - struct wacom_data *wdata = hid_get_drvdata(hdev); 217 - struct led_classdev *led; 218 - struct device *dev = &hdev->dev; 219 - size_t namesz = strlen(dev_name(dev)) + 12; 220 - char *name; 221 - int i, ret; 222 - 223 - wdata->led_selector = 0; 224 - 225 - for (i = 0; i < 4; i++) { 226 - led = kzalloc(sizeof(struct led_classdev) + namesz, GFP_KERNEL); 227 - if (!led) { 228 - hid_warn(hdev, 229 - "can't allocate memory for LED selector\n"); 230 - ret = -ENOMEM; 231 - goto err; 232 - } 233 - 234 - name = (void *)&led[1]; 235 - snprintf(name, namesz, "%s:selector:%d", dev_name(dev), i); 236 - led->name = name; 237 - led->brightness = 0; 238 - led->max_brightness = 127; 239 - led->brightness_get = wacom_leds_get_brightness; 240 - led->brightness_set = wacom_leds_set_brightness; 241 - 242 - wdata->leds[i] = led; 243 - 244 - ret = led_classdev_register(dev, wdata->leds[i]); 245 - 246 - if (ret) { 247 - wdata->leds[i] = NULL; 248 - kfree(led); 249 - hid_warn(hdev, "can't register LED\n"); 250 - goto err; 251 - } 252 - } 253 - 254 - err: 255 - return ret; 256 - } 257 - 258 - static void wacom_destroy_leds(struct hid_device *hdev) 259 - { 260 - struct wacom_data *wdata = hid_get_drvdata(hdev); 261 - struct led_classdev *led; 262 - int i; 263 - 264 - for (i = 0; i < 4; ++i) { 265 - if (wdata->leds[i]) { 266 - led = wdata->leds[i]; 267 - wdata->leds[i] = NULL; 268 - led_classdev_unregister(led); 269 - kfree(led); 270 - } 271 - } 272 - 273 - } 274 - 275 - static int wacom_battery_get_property(struct power_supply *psy, 276 - enum power_supply_property psp, 277 - union power_supply_propval *val) 278 - { 279 - struct wacom_data *wdata = container_of(psy, 280 - struct wacom_data, battery); 281 - int ret = 0; 282 - 283 - switch (psp) { 284 - case POWER_SUPPLY_PROP_PRESENT: 285 - val->intval = 1; 286 - break; 287 - case POWER_SUPPLY_PROP_SCOPE: 288 - val->intval = POWER_SUPPLY_SCOPE_DEVICE; 289 - break; 290 - case POWER_SUPPLY_PROP_CAPACITY: 291 - val->intval = wdata->battery_capacity; 292 - break; 293 - case POWER_SUPPLY_PROP_STATUS: 294 - if (wdata->bat_charging) 295 - val->intval = POWER_SUPPLY_STATUS_CHARGING; 296 - else 297 - if (wdata->battery_capacity == 100 && wdata->ps_connected) 298 - val->intval = POWER_SUPPLY_STATUS_FULL; 299 - else 300 - val->intval = POWER_SUPPLY_STATUS_DISCHARGING; 301 - break; 302 - default: 303 - ret = -EINVAL; 304 - break; 305 - } 306 - return ret; 307 - } 308 - 309 - static int wacom_ac_get_property(struct power_supply *psy, 310 - enum power_supply_property psp, 311 - union power_supply_propval *val) 312 - { 313 - struct wacom_data *wdata = container_of(psy, struct wacom_data, ac); 314 - int ret = 0; 315 - 316 - switch (psp) { 317 - case POWER_SUPPLY_PROP_PRESENT: 318 - /* fall through */ 319 - case POWER_SUPPLY_PROP_ONLINE: 320 - val->intval = wdata->ps_connected; 321 - break; 322 - case POWER_SUPPLY_PROP_SCOPE: 323 - val->intval = POWER_SUPPLY_SCOPE_DEVICE; 324 - break; 325 - default: 326 - ret = -EINVAL; 327 - break; 328 - } 329 - return ret; 330 - } 331 - 332 - static void wacom_set_features(struct hid_device *hdev, u8 speed) 333 - { 334 - struct wacom_data *wdata = hid_get_drvdata(hdev); 335 - int limit, ret; 336 - __u8 rep_data[2]; 337 - 338 - switch (hdev->product) { 339 - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 340 - rep_data[0] = 0x03 ; rep_data[1] = 0x00; 341 - limit = 3; 342 - do { 343 - ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2, 344 - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 345 - } while (ret < 0 && limit-- > 0); 346 - 347 - if (ret >= 0) { 348 - if (speed == 0) 349 - rep_data[0] = 0x05; 350 - else 351 - rep_data[0] = 0x06; 352 - 353 - rep_data[1] = 0x00; 354 - limit = 3; 355 - do { 356 - ret = hid_hw_raw_request(hdev, rep_data[0], 357 - rep_data, 2, HID_FEATURE_REPORT, 358 - HID_REQ_SET_REPORT); 359 - } while (ret < 0 && limit-- > 0); 360 - 361 - if (ret >= 0) { 362 - wdata->high_speed = speed; 363 - return; 364 - } 365 - } 366 - 367 - /* 368 - * Note that if the raw queries fail, it's not a hard failure 369 - * and it is safe to continue 370 - */ 371 - hid_warn(hdev, "failed to poke device, command %d, err %d\n", 372 - rep_data[0], ret); 373 - break; 374 - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 375 - if (speed == 1) 376 - wdata->features &= ~0x20; 377 - else 378 - wdata->features |= 0x20; 379 - 380 - rep_data[0] = 0x03; 381 - rep_data[1] = wdata->features; 382 - 383 - ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2, 384 - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 385 - if (ret >= 0) 386 - wdata->high_speed = speed; 387 - break; 388 - } 389 - 390 - return; 391 - } 392 - 393 - static ssize_t wacom_show_speed(struct device *dev, 394 - struct device_attribute 395 - *attr, char *buf) 396 - { 397 - struct wacom_data *wdata = dev_get_drvdata(dev); 398 - 399 - return snprintf(buf, PAGE_SIZE, "%i\n", wdata->high_speed); 400 - } 401 - 402 - static ssize_t wacom_store_speed(struct device *dev, 403 - struct device_attribute *attr, 404 - const char *buf, size_t count) 405 - { 406 - struct hid_device *hdev = container_of(dev, struct hid_device, dev); 407 - int new_speed; 408 - 409 - if (sscanf(buf, "%1d", &new_speed ) != 1) 410 - return -EINVAL; 411 - 412 - if (new_speed == 0 || new_speed == 1) { 413 - wacom_set_features(hdev, new_speed); 414 - return strnlen(buf, PAGE_SIZE); 415 - } else 416 - return -EINVAL; 417 - } 418 - 419 - static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP, 420 - wacom_show_speed, wacom_store_speed); 421 - 422 - #define WACOM_STORE(OLED_ID) \ 423 - static ssize_t wacom_oled##OLED_ID##_store(struct device *dev, \ 424 - struct device_attribute *attr, \ 425 - const char *buf, size_t count) \ 426 - { \ 427 - struct hid_device *hdev = container_of(dev, struct hid_device, \ 428 - dev); \ 429 - \ 430 - if (count != 256) \ 431 - return -EINVAL; \ 432 - \ 433 - wacom_set_image(hdev, buf, OLED_ID); \ 434 - \ 435 - return count; \ 436 - } \ 437 - \ 438 - static DEVICE_ATTR(oled##OLED_ID##_img, S_IWUSR | S_IWGRP, NULL, \ 439 - wacom_oled##OLED_ID##_store) 440 - 441 - WACOM_STORE(0); 442 - WACOM_STORE(1); 443 - WACOM_STORE(2); 444 - WACOM_STORE(3); 445 - WACOM_STORE(4); 446 - WACOM_STORE(5); 447 - WACOM_STORE(6); 448 - WACOM_STORE(7); 449 - 450 - static int wacom_gr_parse_report(struct hid_device *hdev, 451 - struct wacom_data *wdata, 452 - struct input_dev *input, unsigned char *data) 453 - { 454 - int tool, x, y, rw; 455 - 456 - tool = 0; 457 - /* Get X & Y positions */ 458 - x = le16_to_cpu(*(__le16 *) &data[2]); 459 - y = le16_to_cpu(*(__le16 *) &data[4]); 460 - 461 - /* Get current tool identifier */ 462 - if (data[1] & 0x90) { /* If pen is in the in/active area */ 463 - switch ((data[1] >> 5) & 3) { 464 - case 0: /* Pen */ 465 - tool = BTN_TOOL_PEN; 466 - break; 467 - 468 - case 1: /* Rubber */ 469 - tool = BTN_TOOL_RUBBER; 470 - break; 471 - 472 - case 2: /* Mouse with wheel */ 473 - case 3: /* Mouse without wheel */ 474 - tool = BTN_TOOL_MOUSE; 475 - break; 476 - } 477 - 478 - /* Reset tool if out of active tablet area */ 479 - if (!(data[1] & 0x10)) 480 - tool = 0; 481 - } 482 - 483 - /* If tool changed, notify input subsystem */ 484 - if (wdata->tool != tool) { 485 - if (wdata->tool) { 486 - /* Completely reset old tool state */ 487 - if (wdata->tool == BTN_TOOL_MOUSE) { 488 - input_report_key(input, BTN_LEFT, 0); 489 - input_report_key(input, BTN_RIGHT, 0); 490 - input_report_key(input, BTN_MIDDLE, 0); 491 - input_report_abs(input, ABS_DISTANCE, 492 - input_abs_get_max(input, ABS_DISTANCE)); 493 - } else { 494 - input_report_key(input, BTN_TOUCH, 0); 495 - input_report_key(input, BTN_STYLUS, 0); 496 - input_report_key(input, BTN_STYLUS2, 0); 497 - input_report_abs(input, ABS_PRESSURE, 0); 498 - } 499 - input_report_key(input, wdata->tool, 0); 500 - input_sync(input); 501 - } 502 - wdata->tool = tool; 503 - if (tool) 504 - input_report_key(input, tool, 1); 505 - } 506 - 507 - if (tool) { 508 - input_report_abs(input, ABS_X, x); 509 - input_report_abs(input, ABS_Y, y); 510 - 511 - switch ((data[1] >> 5) & 3) { 512 - case 2: /* Mouse with wheel */ 513 - input_report_key(input, BTN_MIDDLE, data[1] & 0x04); 514 - rw = (data[6] & 0x01) ? -1 : 515 - (data[6] & 0x02) ? 1 : 0; 516 - input_report_rel(input, REL_WHEEL, rw); 517 - /* fall through */ 518 - 519 - case 3: /* Mouse without wheel */ 520 - input_report_key(input, BTN_LEFT, data[1] & 0x01); 521 - input_report_key(input, BTN_RIGHT, data[1] & 0x02); 522 - /* Compute distance between mouse and tablet */ 523 - rw = 44 - (data[6] >> 2); 524 - if (rw < 0) 525 - rw = 0; 526 - else if (rw > 31) 527 - rw = 31; 528 - input_report_abs(input, ABS_DISTANCE, rw); 529 - break; 530 - 531 - default: 532 - input_report_abs(input, ABS_PRESSURE, 533 - data[6] | (((__u16) (data[1] & 0x08)) << 5)); 534 - input_report_key(input, BTN_TOUCH, data[1] & 0x01); 535 - input_report_key(input, BTN_STYLUS, data[1] & 0x02); 536 - input_report_key(input, BTN_STYLUS2, (tool == BTN_TOOL_PEN) && data[1] & 0x04); 537 - break; 538 - } 539 - 540 - input_sync(input); 541 - } 542 - 543 - /* Report the state of the two buttons at the top of the tablet 544 - * as two extra fingerpad keys (buttons 4 & 5). */ 545 - rw = data[7] & 0x03; 546 - if (rw != wdata->butstate) { 547 - wdata->butstate = rw; 548 - input_report_key(input, BTN_0, rw & 0x02); 549 - input_report_key(input, BTN_1, rw & 0x01); 550 - input_report_key(input, BTN_TOOL_FINGER, 0xf0); 551 - input_event(input, EV_MSC, MSC_SERIAL, 0xf0); 552 - input_sync(input); 553 - } 554 - 555 - /* Store current battery capacity and power supply state*/ 556 - rw = (data[7] >> 2 & 0x07); 557 - if (rw != wdata->power_raw) { 558 - wdata->power_raw = rw; 559 - wdata->battery_capacity = batcap_gr[rw]; 560 - if (rw == 7) 561 - wdata->ps_connected = 1; 562 - else 563 - wdata->ps_connected = 0; 564 - } 565 - return 1; 566 - } 567 - 568 - static void wacom_i4_parse_button_report(struct wacom_data *wdata, 569 - struct input_dev *input, unsigned char *data) 570 - { 571 - __u16 new_butstate; 572 - __u8 new_whlstate; 573 - __u8 sync = 0; 574 - 575 - new_whlstate = data[1]; 576 - if (new_whlstate != wdata->whlstate) { 577 - wdata->whlstate = new_whlstate; 578 - if (new_whlstate & 0x80) { 579 - input_report_key(input, BTN_TOUCH, 1); 580 - input_report_abs(input, ABS_WHEEL, (new_whlstate & 0x7f)); 581 - input_report_key(input, BTN_TOOL_FINGER, 1); 582 - } else { 583 - input_report_key(input, BTN_TOUCH, 0); 584 - input_report_abs(input, ABS_WHEEL, 0); 585 - input_report_key(input, BTN_TOOL_FINGER, 0); 586 - } 587 - sync = 1; 588 - } 589 - 590 - new_butstate = (data[3] << 1) | (data[2] & 0x01); 591 - if (new_butstate != wdata->butstate) { 592 - wdata->butstate = new_butstate; 593 - input_report_key(input, BTN_0, new_butstate & 0x001); 594 - input_report_key(input, BTN_1, new_butstate & 0x002); 595 - input_report_key(input, BTN_2, new_butstate & 0x004); 596 - input_report_key(input, BTN_3, new_butstate & 0x008); 597 - input_report_key(input, BTN_4, new_butstate & 0x010); 598 - input_report_key(input, BTN_5, new_butstate & 0x020); 599 - input_report_key(input, BTN_6, new_butstate & 0x040); 600 - input_report_key(input, BTN_7, new_butstate & 0x080); 601 - input_report_key(input, BTN_8, new_butstate & 0x100); 602 - input_report_key(input, BTN_TOOL_FINGER, 1); 603 - sync = 1; 604 - } 605 - 606 - if (sync) { 607 - input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); 608 - input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); 609 - input_sync(input); 610 - } 611 - } 612 - 613 - static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 614 - struct input_dev *input, unsigned char *data) 615 - { 616 - __u16 x, y, pressure; 617 - __u8 distance; 618 - __u8 tilt_x, tilt_y; 619 - 620 - switch (data[1]) { 621 - case 0x80: /* Out of proximity report */ 622 - input_report_key(input, BTN_TOUCH, 0); 623 - input_report_abs(input, ABS_PRESSURE, 0); 624 - input_report_key(input, BTN_STYLUS, 0); 625 - input_report_key(input, BTN_STYLUS2, 0); 626 - input_report_key(input, wdata->tool, 0); 627 - input_report_abs(input, ABS_MISC, 0); 628 - input_event(input, EV_MSC, MSC_SERIAL, wdata->serial); 629 - wdata->tool = 0; 630 - input_sync(input); 631 - break; 632 - case 0xC2: /* Tool report */ 633 - wdata->id = ((data[2] << 4) | (data[3] >> 4) | 634 - ((data[7] & 0x0f) << 20) | 635 - ((data[8] & 0xf0) << 12)); 636 - wdata->serial = ((data[3] & 0x0f) << 28) + 637 - (data[4] << 20) + (data[5] << 12) + 638 - (data[6] << 4) + (data[7] >> 4); 639 - 640 - switch (wdata->id) { 641 - case 0x100802: 642 - wdata->tool = BTN_TOOL_PEN; 643 - break; 644 - case 0x10080A: 645 - wdata->tool = BTN_TOOL_RUBBER; 646 - break; 647 - } 648 - break; 649 - default: /* Position/pressure report */ 650 - x = data[2] << 9 | data[3] << 1 | ((data[9] & 0x02) >> 1); 651 - y = data[4] << 9 | data[5] << 1 | (data[9] & 0x01); 652 - pressure = (data[6] << 3) | ((data[7] & 0xC0) >> 5) 653 - | (data[1] & 0x01); 654 - distance = (data[9] >> 2) & 0x3f; 655 - tilt_x = ((data[7] << 1) & 0x7e) | (data[8] >> 7); 656 - tilt_y = data[8] & 0x7f; 657 - 658 - input_report_key(input, BTN_TOUCH, pressure > 1); 659 - 660 - input_report_key(input, BTN_STYLUS, data[1] & 0x02); 661 - input_report_key(input, BTN_STYLUS2, data[1] & 0x04); 662 - input_report_key(input, wdata->tool, 1); 663 - input_report_abs(input, ABS_X, x); 664 - input_report_abs(input, ABS_Y, y); 665 - input_report_abs(input, ABS_PRESSURE, pressure); 666 - input_report_abs(input, ABS_DISTANCE, distance); 667 - input_report_abs(input, ABS_TILT_X, tilt_x); 668 - input_report_abs(input, ABS_TILT_Y, tilt_y); 669 - input_report_abs(input, ABS_MISC, wdata->id); 670 - input_event(input, EV_MSC, MSC_SERIAL, wdata->serial); 671 - input_report_key(input, wdata->tool, 1); 672 - input_sync(input); 673 - break; 674 - } 675 - 676 - return; 677 - } 678 - 679 - static void wacom_i4_parse_report(struct hid_device *hdev, 680 - struct wacom_data *wdata, 681 - struct input_dev *input, unsigned char *data) 682 - { 683 - switch (data[0]) { 684 - case 0x00: /* Empty report */ 685 - break; 686 - case 0x02: /* Pen report */ 687 - wacom_i4_parse_pen_report(wdata, input, data); 688 - break; 689 - case 0x03: /* Features Report */ 690 - wdata->features = data[2]; 691 - break; 692 - case 0x0C: /* Button report */ 693 - wacom_i4_parse_button_report(wdata, input, data); 694 - break; 695 - default: 696 - hid_err(hdev, "Unknown report: %d,%d\n", data[0], data[1]); 697 - break; 698 - } 699 - } 700 - 701 - static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, 702 - u8 *raw_data, int size) 703 - { 704 - struct wacom_data *wdata = hid_get_drvdata(hdev); 705 - struct hid_input *hidinput; 706 - struct input_dev *input; 707 - unsigned char *data = (unsigned char *) raw_data; 708 - int i; 709 - __u8 power_raw; 710 - 711 - if (!(hdev->claimed & HID_CLAIMED_INPUT)) 712 - return 0; 713 - 714 - hidinput = list_entry(hdev->inputs.next, struct hid_input, list); 715 - input = hidinput->input; 716 - 717 - switch (hdev->product) { 718 - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 719 - if (data[0] == 0x03) { 720 - return wacom_gr_parse_report(hdev, wdata, input, data); 721 - } else { 722 - hid_err(hdev, "Unknown report: %d,%d size:%d\n", 723 - data[0], data[1], size); 724 - return 0; 725 - } 726 - break; 727 - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 728 - i = 1; 729 - 730 - switch (data[0]) { 731 - case 0x04: 732 - wacom_i4_parse_report(hdev, wdata, input, data + i); 733 - i += 10; 734 - /* fall through */ 735 - case 0x03: 736 - wacom_i4_parse_report(hdev, wdata, input, data + i); 737 - i += 10; 738 - wacom_i4_parse_report(hdev, wdata, input, data + i); 739 - power_raw = data[i+10]; 740 - if (power_raw != wdata->power_raw) { 741 - wdata->power_raw = power_raw; 742 - wdata->battery_capacity = batcap_i4[power_raw & 0x07]; 743 - wdata->bat_charging = (power_raw & 0x08) ? 1 : 0; 744 - wdata->ps_connected = (power_raw & 0x10) ? 1 : 0; 745 - } 746 - 747 - break; 748 - default: 749 - hid_err(hdev, "Unknown report: %d,%d size:%d\n", 750 - data[0], data[1], size); 751 - return 0; 752 - } 753 - } 754 - return 1; 755 - } 756 - 757 - static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, 758 - struct hid_field *field, struct hid_usage *usage, unsigned long **bit, 759 - int *max) 760 - { 761 - struct input_dev *input = hi->input; 762 - 763 - __set_bit(INPUT_PROP_POINTER, input->propbit); 764 - 765 - /* Basics */ 766 - input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL); 767 - 768 - __set_bit(REL_WHEEL, input->relbit); 769 - 770 - __set_bit(BTN_TOOL_PEN, input->keybit); 771 - __set_bit(BTN_TOUCH, input->keybit); 772 - __set_bit(BTN_STYLUS, input->keybit); 773 - __set_bit(BTN_STYLUS2, input->keybit); 774 - __set_bit(BTN_LEFT, input->keybit); 775 - __set_bit(BTN_RIGHT, input->keybit); 776 - __set_bit(BTN_MIDDLE, input->keybit); 777 - 778 - /* Pad */ 779 - input_set_capability(input, EV_MSC, MSC_SERIAL); 780 - 781 - __set_bit(BTN_0, input->keybit); 782 - __set_bit(BTN_1, input->keybit); 783 - __set_bit(BTN_TOOL_FINGER, input->keybit); 784 - 785 - /* Distance, rubber and mouse */ 786 - __set_bit(BTN_TOOL_RUBBER, input->keybit); 787 - __set_bit(BTN_TOOL_MOUSE, input->keybit); 788 - 789 - switch (hdev->product) { 790 - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 791 - input_set_abs_params(input, ABS_X, 0, 16704, 4, 0); 792 - input_set_abs_params(input, ABS_Y, 0, 12064, 4, 0); 793 - input_set_abs_params(input, ABS_PRESSURE, 0, 511, 0, 0); 794 - input_set_abs_params(input, ABS_DISTANCE, 0, 32, 0, 0); 795 - break; 796 - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 797 - __set_bit(ABS_WHEEL, input->absbit); 798 - __set_bit(ABS_MISC, input->absbit); 799 - __set_bit(BTN_2, input->keybit); 800 - __set_bit(BTN_3, input->keybit); 801 - __set_bit(BTN_4, input->keybit); 802 - __set_bit(BTN_5, input->keybit); 803 - __set_bit(BTN_6, input->keybit); 804 - __set_bit(BTN_7, input->keybit); 805 - __set_bit(BTN_8, input->keybit); 806 - input_set_abs_params(input, ABS_WHEEL, 0, 71, 0, 0); 807 - input_set_abs_params(input, ABS_X, 0, 40640, 4, 0); 808 - input_set_abs_params(input, ABS_Y, 0, 25400, 4, 0); 809 - input_set_abs_params(input, ABS_PRESSURE, 0, 2047, 0, 0); 810 - input_set_abs_params(input, ABS_DISTANCE, 0, 63, 0, 0); 811 - input_set_abs_params(input, ABS_TILT_X, 0, 127, 0, 0); 812 - input_set_abs_params(input, ABS_TILT_Y, 0, 127, 0, 0); 813 - break; 814 - } 815 - 816 - return 0; 817 - } 818 - 819 - static int wacom_probe(struct hid_device *hdev, 820 - const struct hid_device_id *id) 821 - { 822 - struct wacom_data *wdata; 823 - int ret; 824 - 825 - wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); 826 - if (wdata == NULL) { 827 - hid_err(hdev, "can't alloc wacom descriptor\n"); 828 - return -ENOMEM; 829 - } 830 - 831 - hid_set_drvdata(hdev, wdata); 832 - 833 - /* Parse the HID report now */ 834 - ret = hid_parse(hdev); 835 - if (ret) { 836 - hid_err(hdev, "parse failed\n"); 837 - goto err_free; 838 - } 839 - 840 - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 841 - if (ret) { 842 - hid_err(hdev, "hw start failed\n"); 843 - goto err_free; 844 - } 845 - 846 - ret = device_create_file(&hdev->dev, &dev_attr_speed); 847 - if (ret) 848 - hid_warn(hdev, 849 - "can't create sysfs speed attribute err: %d\n", ret); 850 - 851 - #define OLED_INIT(OLED_ID) \ 852 - do { \ 853 - ret = device_create_file(&hdev->dev, \ 854 - &dev_attr_oled##OLED_ID##_img); \ 855 - if (ret) \ 856 - hid_warn(hdev, \ 857 - "can't create sysfs oled attribute, err: %d\n", ret);\ 858 - } while (0) 859 - 860 - OLED_INIT(0); 861 - OLED_INIT(1); 862 - OLED_INIT(2); 863 - OLED_INIT(3); 864 - OLED_INIT(4); 865 - OLED_INIT(5); 866 - OLED_INIT(6); 867 - OLED_INIT(7); 868 - 869 - wdata->features = 0; 870 - wacom_set_features(hdev, 1); 871 - 872 - if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) { 873 - sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); 874 - ret = wacom_initialize_leds(hdev); 875 - if (ret) 876 - hid_warn(hdev, 877 - "can't create led attribute, err: %d\n", ret); 878 - } 879 - 880 - wdata->battery.properties = wacom_battery_props; 881 - wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props); 882 - wdata->battery.get_property = wacom_battery_get_property; 883 - wdata->battery.name = "wacom_battery"; 884 - wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; 885 - wdata->battery.use_for_apm = 0; 886 - 887 - 888 - ret = power_supply_register(&hdev->dev, &wdata->battery); 889 - if (ret) { 890 - hid_err(hdev, "can't create sysfs battery attribute, err: %d\n", 891 - ret); 892 - goto err_battery; 893 - } 894 - 895 - power_supply_powers(&wdata->battery, &hdev->dev); 896 - 897 - wdata->ac.properties = wacom_ac_props; 898 - wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props); 899 - wdata->ac.get_property = wacom_ac_get_property; 900 - wdata->ac.name = "wacom_ac"; 901 - wdata->ac.type = POWER_SUPPLY_TYPE_MAINS; 902 - wdata->ac.use_for_apm = 0; 903 - 904 - ret = power_supply_register(&hdev->dev, &wdata->ac); 905 - if (ret) { 906 - hid_err(hdev, 907 - "can't create ac battery attribute, err: %d\n", ret); 908 - goto err_ac; 909 - } 910 - 911 - power_supply_powers(&wdata->ac, &hdev->dev); 912 - return 0; 913 - 914 - err_ac: 915 - power_supply_unregister(&wdata->battery); 916 - err_battery: 917 - wacom_destroy_leds(hdev); 918 - device_remove_file(&hdev->dev, &dev_attr_oled0_img); 919 - device_remove_file(&hdev->dev, &dev_attr_oled1_img); 920 - device_remove_file(&hdev->dev, &dev_attr_oled2_img); 921 - device_remove_file(&hdev->dev, &dev_attr_oled3_img); 922 - device_remove_file(&hdev->dev, &dev_attr_oled4_img); 923 - device_remove_file(&hdev->dev, &dev_attr_oled5_img); 924 - device_remove_file(&hdev->dev, &dev_attr_oled6_img); 925 - device_remove_file(&hdev->dev, &dev_attr_oled7_img); 926 - device_remove_file(&hdev->dev, &dev_attr_speed); 927 - hid_hw_stop(hdev); 928 - err_free: 929 - kfree(wdata); 930 - return ret; 931 - } 932 - 933 - static void wacom_remove(struct hid_device *hdev) 934 - { 935 - struct wacom_data *wdata = hid_get_drvdata(hdev); 936 - 937 - wacom_destroy_leds(hdev); 938 - device_remove_file(&hdev->dev, &dev_attr_oled0_img); 939 - device_remove_file(&hdev->dev, &dev_attr_oled1_img); 940 - device_remove_file(&hdev->dev, &dev_attr_oled2_img); 941 - device_remove_file(&hdev->dev, &dev_attr_oled3_img); 942 - device_remove_file(&hdev->dev, &dev_attr_oled4_img); 943 - device_remove_file(&hdev->dev, &dev_attr_oled5_img); 944 - device_remove_file(&hdev->dev, &dev_attr_oled6_img); 945 - device_remove_file(&hdev->dev, &dev_attr_oled7_img); 946 - device_remove_file(&hdev->dev, &dev_attr_speed); 947 - hid_hw_stop(hdev); 948 - 949 - power_supply_unregister(&wdata->battery); 950 - power_supply_unregister(&wdata->ac); 951 - kfree(hid_get_drvdata(hdev)); 952 - } 953 - 954 - static const struct hid_device_id wacom_devices[] = { 955 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 956 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 957 - 958 - { } 959 - }; 960 - MODULE_DEVICE_TABLE(hid, wacom_devices); 961 - 962 - static struct hid_driver wacom_driver = { 963 - .name = "wacom", 964 - .id_table = wacom_devices, 965 - .probe = wacom_probe, 966 - .remove = wacom_remove, 967 - .raw_event = wacom_raw_event, 968 - .input_mapped = wacom_input_mapped, 969 - }; 970 - module_hid_driver(wacom_driver); 971 - 972 - MODULE_DESCRIPTION("Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL"); 973 - MODULE_LICENSE("GPL");
+1456
drivers/hid/wacom_sys.c
··· 1 + /* 2 + * drivers/input/tablet/wacom_sys.c 3 + * 4 + * USB Wacom tablet support - system specific code 5 + */ 6 + 7 + /* 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; either version 2 of the License, or 11 + * (at your option) any later version. 12 + */ 13 + 14 + #include "wacom_wac.h" 15 + #include "wacom.h" 16 + #include <linux/hid.h> 17 + 18 + #define WAC_MSG_RETRIES 5 19 + 20 + #define WAC_CMD_LED_CONTROL 0x20 21 + #define WAC_CMD_ICON_START 0x21 22 + #define WAC_CMD_ICON_XFER 0x23 23 + #define WAC_CMD_ICON_BT_XFER 0x26 24 + #define WAC_CMD_RETRIES 10 25 + 26 + static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id, 27 + void *buf, size_t size, unsigned int retries) 28 + { 29 + int retval; 30 + 31 + do { 32 + retval = hid_hw_raw_request(hdev, id, buf, size, type, 33 + HID_REQ_GET_REPORT); 34 + } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 35 + 36 + return retval; 37 + } 38 + 39 + static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf, 40 + size_t size, unsigned int retries) 41 + { 42 + int retval; 43 + 44 + do { 45 + retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, 46 + HID_REQ_SET_REPORT); 47 + } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 48 + 49 + return retval; 50 + } 51 + 52 + static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, 53 + u8 *raw_data, int size) 54 + { 55 + struct wacom *wacom = hid_get_drvdata(hdev); 56 + 57 + if (size > WACOM_PKGLEN_MAX) 58 + return 1; 59 + 60 + memcpy(wacom->wacom_wac.data, raw_data, size); 61 + 62 + wacom_wac_irq(&wacom->wacom_wac, size); 63 + 64 + return 0; 65 + } 66 + 67 + static int wacom_open(struct input_dev *dev) 68 + { 69 + struct wacom *wacom = input_get_drvdata(dev); 70 + int retval; 71 + 72 + mutex_lock(&wacom->lock); 73 + retval = hid_hw_open(wacom->hdev); 74 + mutex_unlock(&wacom->lock); 75 + 76 + return retval; 77 + } 78 + 79 + static void wacom_close(struct input_dev *dev) 80 + { 81 + struct wacom *wacom = input_get_drvdata(dev); 82 + 83 + mutex_lock(&wacom->lock); 84 + hid_hw_close(wacom->hdev); 85 + mutex_unlock(&wacom->lock); 86 + } 87 + 88 + /* 89 + * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res. 90 + */ 91 + static int wacom_calc_hid_res(int logical_extents, int physical_extents, 92 + unsigned unit, int exponent) 93 + { 94 + struct hid_field field = { 95 + .logical_maximum = logical_extents, 96 + .physical_maximum = physical_extents, 97 + .unit = unit, 98 + .unit_exponent = exponent, 99 + }; 100 + 101 + return hidinput_calc_abs_res(&field, ABS_X); 102 + } 103 + 104 + static void wacom_feature_mapping(struct hid_device *hdev, 105 + struct hid_field *field, struct hid_usage *usage) 106 + { 107 + struct wacom *wacom = hid_get_drvdata(hdev); 108 + struct wacom_features *features = &wacom->wacom_wac.features; 109 + 110 + switch (usage->hid) { 111 + case HID_DG_CONTACTMAX: 112 + /* leave touch_max as is if predefined */ 113 + if (!features->touch_max) 114 + features->touch_max = field->value[0]; 115 + break; 116 + } 117 + } 118 + 119 + /* 120 + * Interface Descriptor of wacom devices can be incomplete and 121 + * inconsistent so wacom_features table is used to store stylus 122 + * device's packet lengths, various maximum values, and tablet 123 + * resolution based on product ID's. 124 + * 125 + * For devices that contain 2 interfaces, wacom_features table is 126 + * inaccurate for the touch interface. Since the Interface Descriptor 127 + * for touch interfaces has pretty complete data, this function exists 128 + * to query tablet for this missing information instead of hard coding in 129 + * an additional table. 130 + * 131 + * A typical Interface Descriptor for a stylus will contain a 132 + * boot mouse application collection that is not of interest and this 133 + * function will ignore it. 134 + * 135 + * It also contains a digitizer application collection that also is not 136 + * of interest since any information it contains would be duplicate 137 + * of what is in wacom_features. Usually it defines a report of an array 138 + * of bytes that could be used as max length of the stylus packet returned. 139 + * If it happens to define a Digitizer-Stylus Physical Collection then 140 + * the X and Y logical values contain valid data but it is ignored. 141 + * 142 + * A typical Interface Descriptor for a touch interface will contain a 143 + * Digitizer-Finger Physical Collection which will define both logical 144 + * X/Y maximum as well as the physical size of tablet. Since touch 145 + * interfaces haven't supported pressure or distance, this is enough 146 + * information to override invalid values in the wacom_features table. 147 + * 148 + * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful 149 + * data. We deal with them after returning from this function. 150 + */ 151 + static void wacom_usage_mapping(struct hid_device *hdev, 152 + struct hid_field *field, struct hid_usage *usage) 153 + { 154 + struct wacom *wacom = hid_get_drvdata(hdev); 155 + struct wacom_features *features = &wacom->wacom_wac.features; 156 + bool finger = (field->logical == HID_DG_FINGER) || 157 + (field->physical == HID_DG_FINGER); 158 + bool pen = (field->logical == HID_DG_STYLUS) || 159 + (field->physical == HID_DG_STYLUS); 160 + 161 + /* 162 + * Requiring Stylus Usage will ignore boot mouse 163 + * X/Y values and some cases of invalid Digitizer X/Y 164 + * values commonly reported. 165 + */ 166 + if (!pen && !finger) 167 + return; 168 + 169 + if (finger && !features->touch_max) 170 + /* touch device at least supports one touch point */ 171 + features->touch_max = 1; 172 + 173 + switch (usage->hid) { 174 + case HID_GD_X: 175 + features->x_max = field->logical_maximum; 176 + if (finger) { 177 + features->device_type = BTN_TOOL_FINGER; 178 + features->x_phy = field->physical_maximum; 179 + if (features->type != BAMBOO_PT) { 180 + features->unit = field->unit; 181 + features->unitExpo = field->unit_exponent; 182 + } 183 + } else { 184 + features->device_type = BTN_TOOL_PEN; 185 + } 186 + break; 187 + case HID_GD_Y: 188 + features->y_max = field->logical_maximum; 189 + if (finger) { 190 + features->y_phy = field->physical_maximum; 191 + if (features->type != BAMBOO_PT) { 192 + features->unit = field->unit; 193 + features->unitExpo = field->unit_exponent; 194 + } 195 + } 196 + break; 197 + case HID_DG_TIPPRESSURE: 198 + if (pen) 199 + features->pressure_max = field->logical_maximum; 200 + break; 201 + } 202 + } 203 + 204 + static void wacom_parse_hid(struct hid_device *hdev, 205 + struct wacom_features *features) 206 + { 207 + struct hid_report_enum *rep_enum; 208 + struct hid_report *hreport; 209 + int i, j; 210 + 211 + /* check features first */ 212 + rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; 213 + list_for_each_entry(hreport, &rep_enum->report_list, list) { 214 + for (i = 0; i < hreport->maxfield; i++) { 215 + /* Ignore if report count is out of bounds. */ 216 + if (hreport->field[i]->report_count < 1) 217 + continue; 218 + 219 + for (j = 0; j < hreport->field[i]->maxusage; j++) { 220 + wacom_feature_mapping(hdev, hreport->field[i], 221 + hreport->field[i]->usage + j); 222 + } 223 + } 224 + } 225 + 226 + /* now check the input usages */ 227 + rep_enum = &hdev->report_enum[HID_INPUT_REPORT]; 228 + list_for_each_entry(hreport, &rep_enum->report_list, list) { 229 + 230 + if (!hreport->maxfield) 231 + continue; 232 + 233 + for (i = 0; i < hreport->maxfield; i++) 234 + for (j = 0; j < hreport->field[i]->maxusage; j++) 235 + wacom_usage_mapping(hdev, hreport->field[i], 236 + hreport->field[i]->usage + j); 237 + } 238 + } 239 + 240 + static int wacom_set_device_mode(struct hid_device *hdev, int report_id, 241 + int length, int mode) 242 + { 243 + unsigned char *rep_data; 244 + int error = -ENOMEM, limit = 0; 245 + 246 + rep_data = kzalloc(length, GFP_KERNEL); 247 + if (!rep_data) 248 + return error; 249 + 250 + do { 251 + rep_data[0] = report_id; 252 + rep_data[1] = mode; 253 + 254 + error = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 255 + length, 1); 256 + if (error >= 0) 257 + error = wacom_get_report(hdev, HID_FEATURE_REPORT, 258 + report_id, rep_data, length, 1); 259 + } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES); 260 + 261 + kfree(rep_data); 262 + 263 + return error < 0 ? error : 0; 264 + } 265 + 266 + static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed, 267 + struct wacom_features *features) 268 + { 269 + struct wacom *wacom = hid_get_drvdata(hdev); 270 + int ret; 271 + u8 rep_data[2]; 272 + 273 + switch (features->type) { 274 + case GRAPHIRE_BT: 275 + rep_data[0] = 0x03; 276 + rep_data[1] = 0x00; 277 + ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2, 278 + 3); 279 + 280 + if (ret >= 0) { 281 + rep_data[0] = speed == 0 ? 0x05 : 0x06; 282 + rep_data[1] = 0x00; 283 + 284 + ret = wacom_set_report(hdev, HID_FEATURE_REPORT, 285 + rep_data, 2, 3); 286 + 287 + if (ret >= 0) { 288 + wacom->wacom_wac.bt_high_speed = speed; 289 + return 0; 290 + } 291 + } 292 + 293 + /* 294 + * Note that if the raw queries fail, it's not a hard failure 295 + * and it is safe to continue 296 + */ 297 + hid_warn(hdev, "failed to poke device, command %d, err %d\n", 298 + rep_data[0], ret); 299 + break; 300 + case INTUOS4WL: 301 + if (speed == 1) 302 + wacom->wacom_wac.bt_features &= ~0x20; 303 + else 304 + wacom->wacom_wac.bt_features |= 0x20; 305 + 306 + rep_data[0] = 0x03; 307 + rep_data[1] = wacom->wacom_wac.bt_features; 308 + 309 + ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2, 310 + 1); 311 + if (ret >= 0) 312 + wacom->wacom_wac.bt_high_speed = speed; 313 + break; 314 + } 315 + 316 + return 0; 317 + } 318 + 319 + /* 320 + * Switch the tablet into its most-capable mode. Wacom tablets are 321 + * typically configured to power-up in a mode which sends mouse-like 322 + * reports to the OS. To get absolute position, pressure data, etc. 323 + * from the tablet, it is necessary to switch the tablet out of this 324 + * mode and into one which sends the full range of tablet data. 325 + */ 326 + static int wacom_query_tablet_data(struct hid_device *hdev, 327 + struct wacom_features *features) 328 + { 329 + if (hdev->bus == BUS_BLUETOOTH) 330 + return wacom_bt_query_tablet_data(hdev, 1, features); 331 + 332 + if (features->device_type == BTN_TOOL_FINGER) { 333 + if (features->type > TABLETPC) { 334 + /* MT Tablet PC touch */ 335 + return wacom_set_device_mode(hdev, 3, 4, 4); 336 + } 337 + else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) { 338 + return wacom_set_device_mode(hdev, 18, 3, 2); 339 + } 340 + } else if (features->device_type == BTN_TOOL_PEN) { 341 + if (features->type <= BAMBOO_PT && features->type != WIRELESS) { 342 + return wacom_set_device_mode(hdev, 2, 2, 2); 343 + } 344 + } 345 + 346 + return 0; 347 + } 348 + 349 + static void wacom_retrieve_hid_descriptor(struct hid_device *hdev, 350 + struct wacom_features *features) 351 + { 352 + struct wacom *wacom = hid_get_drvdata(hdev); 353 + struct usb_interface *intf = wacom->intf; 354 + 355 + /* default features */ 356 + features->device_type = BTN_TOOL_PEN; 357 + features->x_fuzz = 4; 358 + features->y_fuzz = 4; 359 + features->pressure_fuzz = 0; 360 + features->distance_fuzz = 0; 361 + 362 + /* 363 + * The wireless device HID is basic and layout conflicts with 364 + * other tablets (monitor and touch interface can look like pen). 365 + * Skip the query for this type and modify defaults based on 366 + * interface number. 367 + */ 368 + if (features->type == WIRELESS) { 369 + if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 370 + features->device_type = 0; 371 + } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { 372 + features->device_type = BTN_TOOL_FINGER; 373 + features->pktlen = WACOM_PKGLEN_BBTOUCH3; 374 + } 375 + } 376 + 377 + /* only devices that support touch need to retrieve the info */ 378 + if (features->type < BAMBOO_PT) 379 + return; 380 + 381 + wacom_parse_hid(hdev, features); 382 + } 383 + 384 + struct wacom_hdev_data { 385 + struct list_head list; 386 + struct kref kref; 387 + struct hid_device *dev; 388 + struct wacom_shared shared; 389 + }; 390 + 391 + static LIST_HEAD(wacom_udev_list); 392 + static DEFINE_MUTEX(wacom_udev_list_lock); 393 + 394 + static bool wacom_are_sibling(struct hid_device *hdev, 395 + struct hid_device *sibling) 396 + { 397 + struct wacom *wacom = hid_get_drvdata(hdev); 398 + struct wacom_features *features = &wacom->wacom_wac.features; 399 + int vid = features->oVid; 400 + int pid = features->oPid; 401 + int n1,n2; 402 + 403 + if (vid == 0 && pid == 0) { 404 + vid = hdev->vendor; 405 + pid = hdev->product; 406 + } 407 + 408 + if (vid != sibling->vendor || pid != sibling->product) 409 + return false; 410 + 411 + /* Compare the physical path. */ 412 + n1 = strrchr(hdev->phys, '.') - hdev->phys; 413 + n2 = strrchr(sibling->phys, '.') - sibling->phys; 414 + if (n1 != n2 || n1 <= 0 || n2 <= 0) 415 + return false; 416 + 417 + return !strncmp(hdev->phys, sibling->phys, n1); 418 + } 419 + 420 + static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev) 421 + { 422 + struct wacom_hdev_data *data; 423 + 424 + list_for_each_entry(data, &wacom_udev_list, list) { 425 + if (wacom_are_sibling(hdev, data->dev)) { 426 + kref_get(&data->kref); 427 + return data; 428 + } 429 + } 430 + 431 + return NULL; 432 + } 433 + 434 + static int wacom_add_shared_data(struct hid_device *hdev) 435 + { 436 + struct wacom *wacom = hid_get_drvdata(hdev); 437 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 438 + struct wacom_hdev_data *data; 439 + int retval = 0; 440 + 441 + mutex_lock(&wacom_udev_list_lock); 442 + 443 + data = wacom_get_hdev_data(hdev); 444 + if (!data) { 445 + data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL); 446 + if (!data) { 447 + retval = -ENOMEM; 448 + goto out; 449 + } 450 + 451 + kref_init(&data->kref); 452 + data->dev = hdev; 453 + list_add_tail(&data->list, &wacom_udev_list); 454 + } 455 + 456 + wacom_wac->shared = &data->shared; 457 + 458 + out: 459 + mutex_unlock(&wacom_udev_list_lock); 460 + return retval; 461 + } 462 + 463 + static void wacom_release_shared_data(struct kref *kref) 464 + { 465 + struct wacom_hdev_data *data = 466 + container_of(kref, struct wacom_hdev_data, kref); 467 + 468 + mutex_lock(&wacom_udev_list_lock); 469 + list_del(&data->list); 470 + mutex_unlock(&wacom_udev_list_lock); 471 + 472 + kfree(data); 473 + } 474 + 475 + static void wacom_remove_shared_data(struct wacom_wac *wacom) 476 + { 477 + struct wacom_hdev_data *data; 478 + 479 + if (wacom->shared) { 480 + data = container_of(wacom->shared, struct wacom_hdev_data, shared); 481 + kref_put(&data->kref, wacom_release_shared_data); 482 + wacom->shared = NULL; 483 + } 484 + } 485 + 486 + static int wacom_led_control(struct wacom *wacom) 487 + { 488 + unsigned char *buf; 489 + int retval; 490 + 491 + buf = kzalloc(9, GFP_KERNEL); 492 + if (!buf) 493 + return -ENOMEM; 494 + 495 + if (wacom->wacom_wac.features.type >= INTUOS5S && 496 + wacom->wacom_wac.features.type <= INTUOSPL) { 497 + /* 498 + * Touch Ring and crop mark LED luminance may take on 499 + * one of four values: 500 + * 0 = Low; 1 = Medium; 2 = High; 3 = Off 501 + */ 502 + int ring_led = wacom->led.select[0] & 0x03; 503 + int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; 504 + int crop_lum = 0; 505 + 506 + buf[0] = WAC_CMD_LED_CONTROL; 507 + buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); 508 + } 509 + else { 510 + int led = wacom->led.select[0] | 0x4; 511 + 512 + if (wacom->wacom_wac.features.type == WACOM_21UX2 || 513 + wacom->wacom_wac.features.type == WACOM_24HD) 514 + led |= (wacom->led.select[1] << 4) | 0x40; 515 + 516 + buf[0] = WAC_CMD_LED_CONTROL; 517 + buf[1] = led; 518 + buf[2] = wacom->led.llv; 519 + buf[3] = wacom->led.hlv; 520 + buf[4] = wacom->led.img_lum; 521 + } 522 + 523 + retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 9, 524 + WAC_CMD_RETRIES); 525 + kfree(buf); 526 + 527 + return retval; 528 + } 529 + 530 + static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id, 531 + const unsigned len, const void *img) 532 + { 533 + unsigned char *buf; 534 + int i, retval; 535 + const unsigned chunk_len = len / 4; /* 4 chunks are needed to be sent */ 536 + 537 + buf = kzalloc(chunk_len + 3 , GFP_KERNEL); 538 + if (!buf) 539 + return -ENOMEM; 540 + 541 + /* Send 'start' command */ 542 + buf[0] = WAC_CMD_ICON_START; 543 + buf[1] = 1; 544 + retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, 545 + WAC_CMD_RETRIES); 546 + if (retval < 0) 547 + goto out; 548 + 549 + buf[0] = xfer_id; 550 + buf[1] = button_id & 0x07; 551 + for (i = 0; i < 4; i++) { 552 + buf[2] = i; 553 + memcpy(buf + 3, img + i * chunk_len, chunk_len); 554 + 555 + retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, 556 + buf, chunk_len + 3, WAC_CMD_RETRIES); 557 + if (retval < 0) 558 + break; 559 + } 560 + 561 + /* Send 'stop' */ 562 + buf[0] = WAC_CMD_ICON_START; 563 + buf[1] = 0; 564 + wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, 565 + WAC_CMD_RETRIES); 566 + 567 + out: 568 + kfree(buf); 569 + return retval; 570 + } 571 + 572 + static ssize_t wacom_led_select_store(struct device *dev, int set_id, 573 + const char *buf, size_t count) 574 + { 575 + struct hid_device *hdev = container_of(dev, struct hid_device, dev); 576 + struct wacom *wacom = hid_get_drvdata(hdev); 577 + unsigned int id; 578 + int err; 579 + 580 + err = kstrtouint(buf, 10, &id); 581 + if (err) 582 + return err; 583 + 584 + mutex_lock(&wacom->lock); 585 + 586 + wacom->led.select[set_id] = id & 0x3; 587 + err = wacom_led_control(wacom); 588 + 589 + mutex_unlock(&wacom->lock); 590 + 591 + return err < 0 ? err : count; 592 + } 593 + 594 + #define DEVICE_LED_SELECT_ATTR(SET_ID) \ 595 + static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \ 596 + struct device_attribute *attr, const char *buf, size_t count) \ 597 + { \ 598 + return wacom_led_select_store(dev, SET_ID, buf, count); \ 599 + } \ 600 + static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ 601 + struct device_attribute *attr, char *buf) \ 602 + { \ 603 + struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ 604 + struct wacom *wacom = hid_get_drvdata(hdev); \ 605 + return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \ 606 + } \ 607 + static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \ 608 + wacom_led##SET_ID##_select_show, \ 609 + wacom_led##SET_ID##_select_store) 610 + 611 + DEVICE_LED_SELECT_ATTR(0); 612 + DEVICE_LED_SELECT_ATTR(1); 613 + 614 + static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, 615 + const char *buf, size_t count) 616 + { 617 + unsigned int value; 618 + int err; 619 + 620 + err = kstrtouint(buf, 10, &value); 621 + if (err) 622 + return err; 623 + 624 + mutex_lock(&wacom->lock); 625 + 626 + *dest = value & 0x7f; 627 + err = wacom_led_control(wacom); 628 + 629 + mutex_unlock(&wacom->lock); 630 + 631 + return err < 0 ? err : count; 632 + } 633 + 634 + #define DEVICE_LUMINANCE_ATTR(name, field) \ 635 + static ssize_t wacom_##name##_luminance_store(struct device *dev, \ 636 + struct device_attribute *attr, const char *buf, size_t count) \ 637 + { \ 638 + struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ 639 + struct wacom *wacom = hid_get_drvdata(hdev); \ 640 + \ 641 + return wacom_luminance_store(wacom, &wacom->led.field, \ 642 + buf, count); \ 643 + } \ 644 + static DEVICE_ATTR(name##_luminance, S_IWUSR, \ 645 + NULL, wacom_##name##_luminance_store) 646 + 647 + DEVICE_LUMINANCE_ATTR(status0, llv); 648 + DEVICE_LUMINANCE_ATTR(status1, hlv); 649 + DEVICE_LUMINANCE_ATTR(buttons, img_lum); 650 + 651 + static ssize_t wacom_button_image_store(struct device *dev, int button_id, 652 + const char *buf, size_t count) 653 + { 654 + struct hid_device *hdev = container_of(dev, struct hid_device, dev); 655 + struct wacom *wacom = hid_get_drvdata(hdev); 656 + int err; 657 + unsigned len; 658 + u8 xfer_id; 659 + 660 + if (hdev->bus == BUS_BLUETOOTH) { 661 + len = 256; 662 + xfer_id = WAC_CMD_ICON_BT_XFER; 663 + } else { 664 + len = 1024; 665 + xfer_id = WAC_CMD_ICON_XFER; 666 + } 667 + 668 + if (count != len) 669 + return -EINVAL; 670 + 671 + mutex_lock(&wacom->lock); 672 + 673 + err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf); 674 + 675 + mutex_unlock(&wacom->lock); 676 + 677 + return err < 0 ? err : count; 678 + } 679 + 680 + #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \ 681 + static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \ 682 + struct device_attribute *attr, const char *buf, size_t count) \ 683 + { \ 684 + return wacom_button_image_store(dev, BUTTON_ID, buf, count); \ 685 + } \ 686 + static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \ 687 + NULL, wacom_btnimg##BUTTON_ID##_store) 688 + 689 + DEVICE_BTNIMG_ATTR(0); 690 + DEVICE_BTNIMG_ATTR(1); 691 + DEVICE_BTNIMG_ATTR(2); 692 + DEVICE_BTNIMG_ATTR(3); 693 + DEVICE_BTNIMG_ATTR(4); 694 + DEVICE_BTNIMG_ATTR(5); 695 + DEVICE_BTNIMG_ATTR(6); 696 + DEVICE_BTNIMG_ATTR(7); 697 + 698 + static struct attribute *cintiq_led_attrs[] = { 699 + &dev_attr_status_led0_select.attr, 700 + &dev_attr_status_led1_select.attr, 701 + NULL 702 + }; 703 + 704 + static struct attribute_group cintiq_led_attr_group = { 705 + .name = "wacom_led", 706 + .attrs = cintiq_led_attrs, 707 + }; 708 + 709 + static struct attribute *intuos4_led_attrs[] = { 710 + &dev_attr_status0_luminance.attr, 711 + &dev_attr_status1_luminance.attr, 712 + &dev_attr_status_led0_select.attr, 713 + &dev_attr_buttons_luminance.attr, 714 + &dev_attr_button0_rawimg.attr, 715 + &dev_attr_button1_rawimg.attr, 716 + &dev_attr_button2_rawimg.attr, 717 + &dev_attr_button3_rawimg.attr, 718 + &dev_attr_button4_rawimg.attr, 719 + &dev_attr_button5_rawimg.attr, 720 + &dev_attr_button6_rawimg.attr, 721 + &dev_attr_button7_rawimg.attr, 722 + NULL 723 + }; 724 + 725 + static struct attribute_group intuos4_led_attr_group = { 726 + .name = "wacom_led", 727 + .attrs = intuos4_led_attrs, 728 + }; 729 + 730 + static struct attribute *intuos5_led_attrs[] = { 731 + &dev_attr_status0_luminance.attr, 732 + &dev_attr_status_led0_select.attr, 733 + NULL 734 + }; 735 + 736 + static struct attribute_group intuos5_led_attr_group = { 737 + .name = "wacom_led", 738 + .attrs = intuos5_led_attrs, 739 + }; 740 + 741 + static int wacom_initialize_leds(struct wacom *wacom) 742 + { 743 + int error; 744 + 745 + /* Initialize default values */ 746 + switch (wacom->wacom_wac.features.type) { 747 + case INTUOS4S: 748 + case INTUOS4: 749 + case INTUOS4WL: 750 + case INTUOS4L: 751 + wacom->led.select[0] = 0; 752 + wacom->led.select[1] = 0; 753 + wacom->led.llv = 10; 754 + wacom->led.hlv = 20; 755 + wacom->led.img_lum = 10; 756 + error = sysfs_create_group(&wacom->hdev->dev.kobj, 757 + &intuos4_led_attr_group); 758 + break; 759 + 760 + case WACOM_24HD: 761 + case WACOM_21UX2: 762 + wacom->led.select[0] = 0; 763 + wacom->led.select[1] = 0; 764 + wacom->led.llv = 0; 765 + wacom->led.hlv = 0; 766 + wacom->led.img_lum = 0; 767 + 768 + error = sysfs_create_group(&wacom->hdev->dev.kobj, 769 + &cintiq_led_attr_group); 770 + break; 771 + 772 + case INTUOS5S: 773 + case INTUOS5: 774 + case INTUOS5L: 775 + case INTUOSPS: 776 + case INTUOSPM: 777 + case INTUOSPL: 778 + if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { 779 + wacom->led.select[0] = 0; 780 + wacom->led.select[1] = 0; 781 + wacom->led.llv = 32; 782 + wacom->led.hlv = 0; 783 + wacom->led.img_lum = 0; 784 + 785 + error = sysfs_create_group(&wacom->hdev->dev.kobj, 786 + &intuos5_led_attr_group); 787 + } else 788 + return 0; 789 + break; 790 + 791 + default: 792 + return 0; 793 + } 794 + 795 + if (error) { 796 + hid_err(wacom->hdev, 797 + "cannot create sysfs group err: %d\n", error); 798 + return error; 799 + } 800 + wacom_led_control(wacom); 801 + wacom->led_initialized = true; 802 + 803 + return 0; 804 + } 805 + 806 + static void wacom_destroy_leds(struct wacom *wacom) 807 + { 808 + if (!wacom->led_initialized) 809 + return; 810 + 811 + wacom->led_initialized = false; 812 + 813 + switch (wacom->wacom_wac.features.type) { 814 + case INTUOS4S: 815 + case INTUOS4: 816 + case INTUOS4WL: 817 + case INTUOS4L: 818 + sysfs_remove_group(&wacom->hdev->dev.kobj, 819 + &intuos4_led_attr_group); 820 + break; 821 + 822 + case WACOM_24HD: 823 + case WACOM_21UX2: 824 + sysfs_remove_group(&wacom->hdev->dev.kobj, 825 + &cintiq_led_attr_group); 826 + break; 827 + 828 + case INTUOS5S: 829 + case INTUOS5: 830 + case INTUOS5L: 831 + case INTUOSPS: 832 + case INTUOSPM: 833 + case INTUOSPL: 834 + if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) 835 + sysfs_remove_group(&wacom->hdev->dev.kobj, 836 + &intuos5_led_attr_group); 837 + break; 838 + } 839 + } 840 + 841 + static enum power_supply_property wacom_battery_props[] = { 842 + POWER_SUPPLY_PROP_STATUS, 843 + POWER_SUPPLY_PROP_SCOPE, 844 + POWER_SUPPLY_PROP_CAPACITY 845 + }; 846 + 847 + static enum power_supply_property wacom_ac_props[] = { 848 + POWER_SUPPLY_PROP_PRESENT, 849 + POWER_SUPPLY_PROP_ONLINE, 850 + POWER_SUPPLY_PROP_SCOPE, 851 + }; 852 + 853 + static int wacom_battery_get_property(struct power_supply *psy, 854 + enum power_supply_property psp, 855 + union power_supply_propval *val) 856 + { 857 + struct wacom *wacom = container_of(psy, struct wacom, battery); 858 + int ret = 0; 859 + 860 + switch (psp) { 861 + case POWER_SUPPLY_PROP_SCOPE: 862 + val->intval = POWER_SUPPLY_SCOPE_DEVICE; 863 + break; 864 + case POWER_SUPPLY_PROP_CAPACITY: 865 + val->intval = 866 + wacom->wacom_wac.battery_capacity; 867 + break; 868 + case POWER_SUPPLY_PROP_STATUS: 869 + if (wacom->wacom_wac.bat_charging) 870 + val->intval = POWER_SUPPLY_STATUS_CHARGING; 871 + else if (wacom->wacom_wac.battery_capacity == 100 && 872 + wacom->wacom_wac.ps_connected) 873 + val->intval = POWER_SUPPLY_STATUS_FULL; 874 + else 875 + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; 876 + break; 877 + default: 878 + ret = -EINVAL; 879 + break; 880 + } 881 + 882 + return ret; 883 + } 884 + 885 + static int wacom_ac_get_property(struct power_supply *psy, 886 + enum power_supply_property psp, 887 + union power_supply_propval *val) 888 + { 889 + struct wacom *wacom = container_of(psy, struct wacom, ac); 890 + int ret = 0; 891 + 892 + switch (psp) { 893 + case POWER_SUPPLY_PROP_PRESENT: 894 + /* fall through */ 895 + case POWER_SUPPLY_PROP_ONLINE: 896 + val->intval = wacom->wacom_wac.ps_connected; 897 + break; 898 + case POWER_SUPPLY_PROP_SCOPE: 899 + val->intval = POWER_SUPPLY_SCOPE_DEVICE; 900 + break; 901 + default: 902 + ret = -EINVAL; 903 + break; 904 + } 905 + return ret; 906 + } 907 + 908 + static int wacom_initialize_battery(struct wacom *wacom) 909 + { 910 + static atomic_t battery_no = ATOMIC_INIT(0); 911 + int error; 912 + unsigned long n; 913 + 914 + if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) { 915 + n = atomic_inc_return(&battery_no) - 1; 916 + 917 + wacom->battery.properties = wacom_battery_props; 918 + wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); 919 + wacom->battery.get_property = wacom_battery_get_property; 920 + sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n); 921 + wacom->battery.name = wacom->wacom_wac.bat_name; 922 + wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; 923 + wacom->battery.use_for_apm = 0; 924 + 925 + wacom->ac.properties = wacom_ac_props; 926 + wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props); 927 + wacom->ac.get_property = wacom_ac_get_property; 928 + sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n); 929 + wacom->ac.name = wacom->wacom_wac.ac_name; 930 + wacom->ac.type = POWER_SUPPLY_TYPE_MAINS; 931 + wacom->ac.use_for_apm = 0; 932 + 933 + error = power_supply_register(&wacom->hdev->dev, 934 + &wacom->battery); 935 + if (error) 936 + return error; 937 + 938 + power_supply_powers(&wacom->battery, &wacom->hdev->dev); 939 + 940 + error = power_supply_register(&wacom->hdev->dev, &wacom->ac); 941 + if (error) { 942 + power_supply_unregister(&wacom->battery); 943 + return error; 944 + } 945 + 946 + power_supply_powers(&wacom->ac, &wacom->hdev->dev); 947 + } 948 + 949 + return 0; 950 + } 951 + 952 + static void wacom_destroy_battery(struct wacom *wacom) 953 + { 954 + if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && 955 + wacom->battery.dev) { 956 + power_supply_unregister(&wacom->battery); 957 + wacom->battery.dev = NULL; 958 + power_supply_unregister(&wacom->ac); 959 + wacom->ac.dev = NULL; 960 + } 961 + } 962 + 963 + static ssize_t wacom_show_speed(struct device *dev, 964 + struct device_attribute 965 + *attr, char *buf) 966 + { 967 + struct hid_device *hdev = container_of(dev, struct hid_device, dev); 968 + struct wacom *wacom = hid_get_drvdata(hdev); 969 + 970 + return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); 971 + } 972 + 973 + static ssize_t wacom_store_speed(struct device *dev, 974 + struct device_attribute *attr, 975 + const char *buf, size_t count) 976 + { 977 + struct hid_device *hdev = container_of(dev, struct hid_device, dev); 978 + struct wacom *wacom = hid_get_drvdata(hdev); 979 + u8 new_speed; 980 + 981 + if (kstrtou8(buf, 0, &new_speed)) 982 + return -EINVAL; 983 + 984 + if (new_speed != 0 && new_speed != 1) 985 + return -EINVAL; 986 + 987 + wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features); 988 + 989 + return count; 990 + } 991 + 992 + static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP, 993 + wacom_show_speed, wacom_store_speed); 994 + 995 + static struct input_dev *wacom_allocate_input(struct wacom *wacom) 996 + { 997 + struct input_dev *input_dev; 998 + struct hid_device *hdev = wacom->hdev; 999 + struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1000 + 1001 + input_dev = input_allocate_device(); 1002 + if (!input_dev) 1003 + return NULL; 1004 + 1005 + input_dev->name = wacom_wac->name; 1006 + input_dev->phys = hdev->phys; 1007 + input_dev->dev.parent = &hdev->dev; 1008 + input_dev->open = wacom_open; 1009 + input_dev->close = wacom_close; 1010 + input_dev->uniq = hdev->uniq; 1011 + input_dev->id.bustype = hdev->bus; 1012 + input_dev->id.vendor = hdev->vendor; 1013 + input_dev->id.product = hdev->product; 1014 + input_dev->id.version = hdev->version; 1015 + input_set_drvdata(input_dev, wacom); 1016 + 1017 + return input_dev; 1018 + } 1019 + 1020 + static void wacom_unregister_inputs(struct wacom *wacom) 1021 + { 1022 + if (wacom->wacom_wac.input) 1023 + input_unregister_device(wacom->wacom_wac.input); 1024 + if (wacom->wacom_wac.pad_input) 1025 + input_unregister_device(wacom->wacom_wac.pad_input); 1026 + wacom->wacom_wac.input = NULL; 1027 + wacom->wacom_wac.pad_input = NULL; 1028 + } 1029 + 1030 + static int wacom_register_inputs(struct wacom *wacom) 1031 + { 1032 + struct input_dev *input_dev, *pad_input_dev; 1033 + struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1034 + int error; 1035 + 1036 + input_dev = wacom_allocate_input(wacom); 1037 + pad_input_dev = wacom_allocate_input(wacom); 1038 + if (!input_dev || !pad_input_dev) { 1039 + error = -ENOMEM; 1040 + goto fail1; 1041 + } 1042 + 1043 + wacom_wac->input = input_dev; 1044 + wacom_wac->pad_input = pad_input_dev; 1045 + wacom_wac->pad_input->name = wacom_wac->pad_name; 1046 + 1047 + error = wacom_setup_input_capabilities(input_dev, wacom_wac); 1048 + if (error) 1049 + goto fail2; 1050 + 1051 + error = input_register_device(input_dev); 1052 + if (error) 1053 + goto fail2; 1054 + 1055 + error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); 1056 + if (error) { 1057 + /* no pad in use on this interface */ 1058 + input_free_device(pad_input_dev); 1059 + wacom_wac->pad_input = NULL; 1060 + pad_input_dev = NULL; 1061 + } else { 1062 + error = input_register_device(pad_input_dev); 1063 + if (error) 1064 + goto fail3; 1065 + } 1066 + 1067 + return 0; 1068 + 1069 + fail3: 1070 + input_unregister_device(input_dev); 1071 + input_dev = NULL; 1072 + fail2: 1073 + wacom_wac->input = NULL; 1074 + wacom_wac->pad_input = NULL; 1075 + fail1: 1076 + if (input_dev) 1077 + input_free_device(input_dev); 1078 + if (pad_input_dev) 1079 + input_free_device(pad_input_dev); 1080 + return error; 1081 + } 1082 + 1083 + static void wacom_wireless_work(struct work_struct *work) 1084 + { 1085 + struct wacom *wacom = container_of(work, struct wacom, work); 1086 + struct usb_device *usbdev = wacom->usbdev; 1087 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1088 + struct hid_device *hdev1, *hdev2; 1089 + struct wacom *wacom1, *wacom2; 1090 + struct wacom_wac *wacom_wac1, *wacom_wac2; 1091 + int error; 1092 + 1093 + /* 1094 + * Regardless if this is a disconnect or a new tablet, 1095 + * remove any existing input and battery devices. 1096 + */ 1097 + 1098 + wacom_destroy_battery(wacom); 1099 + 1100 + /* Stylus interface */ 1101 + hdev1 = usb_get_intfdata(usbdev->config->interface[1]); 1102 + wacom1 = hid_get_drvdata(hdev1); 1103 + wacom_wac1 = &(wacom1->wacom_wac); 1104 + wacom_unregister_inputs(wacom1); 1105 + 1106 + /* Touch interface */ 1107 + hdev2 = usb_get_intfdata(usbdev->config->interface[2]); 1108 + wacom2 = hid_get_drvdata(hdev2); 1109 + wacom_wac2 = &(wacom2->wacom_wac); 1110 + wacom_unregister_inputs(wacom2); 1111 + 1112 + if (wacom_wac->pid == 0) { 1113 + hid_info(wacom->hdev, "wireless tablet disconnected\n"); 1114 + wacom_wac1->shared->type = 0; 1115 + } else { 1116 + const struct hid_device_id *id = wacom_ids; 1117 + 1118 + hid_info(wacom->hdev, "wireless tablet connected with PID %x\n", 1119 + wacom_wac->pid); 1120 + 1121 + while (id->bus) { 1122 + if (id->vendor == USB_VENDOR_ID_WACOM && 1123 + id->product == wacom_wac->pid) 1124 + break; 1125 + id++; 1126 + } 1127 + 1128 + if (!id->bus) { 1129 + hid_info(wacom->hdev, "ignoring unknown PID.\n"); 1130 + return; 1131 + } 1132 + 1133 + /* Stylus interface */ 1134 + wacom_wac1->features = 1135 + *((struct wacom_features *)id->driver_data); 1136 + wacom_wac1->features.device_type = BTN_TOOL_PEN; 1137 + snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1138 + wacom_wac1->features.name); 1139 + snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", 1140 + wacom_wac1->features.name); 1141 + wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; 1142 + wacom_wac1->shared->type = wacom_wac1->features.type; 1143 + error = wacom_register_inputs(wacom1); 1144 + if (error) 1145 + goto fail; 1146 + 1147 + /* Touch interface */ 1148 + if (wacom_wac1->features.touch_max || 1149 + wacom_wac1->features.type == INTUOSHT) { 1150 + wacom_wac2->features = 1151 + *((struct wacom_features *)id->driver_data); 1152 + wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1153 + wacom_wac2->features.device_type = BTN_TOOL_FINGER; 1154 + wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1155 + if (wacom_wac2->features.touch_max) 1156 + snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1157 + "%s (WL) Finger",wacom_wac2->features.name); 1158 + else 1159 + snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1160 + "%s (WL) Pad",wacom_wac2->features.name); 1161 + snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, 1162 + "%s (WL) Pad", wacom_wac2->features.name); 1163 + error = wacom_register_inputs(wacom2); 1164 + if (error) 1165 + goto fail; 1166 + 1167 + if (wacom_wac1->features.type == INTUOSHT && 1168 + wacom_wac1->features.touch_max) 1169 + wacom_wac->shared->touch_input = wacom_wac2->input; 1170 + } 1171 + 1172 + error = wacom_initialize_battery(wacom); 1173 + if (error) 1174 + goto fail; 1175 + } 1176 + 1177 + return; 1178 + 1179 + fail: 1180 + wacom_unregister_inputs(wacom1); 1181 + wacom_unregister_inputs(wacom2); 1182 + return; 1183 + } 1184 + 1185 + /* 1186 + * Not all devices report physical dimensions from HID. 1187 + * Compute the default from hardcoded logical dimension 1188 + * and resolution before driver overwrites them. 1189 + */ 1190 + static void wacom_set_default_phy(struct wacom_features *features) 1191 + { 1192 + if (features->x_resolution) { 1193 + features->x_phy = (features->x_max * 100) / 1194 + features->x_resolution; 1195 + features->y_phy = (features->y_max * 100) / 1196 + features->y_resolution; 1197 + } 1198 + } 1199 + 1200 + static void wacom_calculate_res(struct wacom_features *features) 1201 + { 1202 + features->x_resolution = wacom_calc_hid_res(features->x_max, 1203 + features->x_phy, 1204 + features->unit, 1205 + features->unitExpo); 1206 + features->y_resolution = wacom_calc_hid_res(features->y_max, 1207 + features->y_phy, 1208 + features->unit, 1209 + features->unitExpo); 1210 + } 1211 + 1212 + static int wacom_hid_report_len(struct hid_report *report) 1213 + { 1214 + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ 1215 + return ((report->size - 1) >> 3) + 1 + (report->id > 0); 1216 + } 1217 + 1218 + static size_t wacom_compute_pktlen(struct hid_device *hdev) 1219 + { 1220 + struct hid_report_enum *report_enum; 1221 + struct hid_report *report; 1222 + size_t size = 0; 1223 + 1224 + report_enum = hdev->report_enum + HID_INPUT_REPORT; 1225 + 1226 + list_for_each_entry(report, &report_enum->report_list, list) { 1227 + size_t report_size = wacom_hid_report_len(report); 1228 + if (report_size > size) 1229 + size = report_size; 1230 + } 1231 + 1232 + return size; 1233 + } 1234 + 1235 + static int wacom_probe(struct hid_device *hdev, 1236 + const struct hid_device_id *id) 1237 + { 1238 + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); 1239 + struct usb_device *dev = interface_to_usbdev(intf); 1240 + struct wacom *wacom; 1241 + struct wacom_wac *wacom_wac; 1242 + struct wacom_features *features; 1243 + int error; 1244 + 1245 + if (!id->driver_data) 1246 + return -EINVAL; 1247 + 1248 + wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 1249 + if (!wacom) 1250 + return -ENOMEM; 1251 + 1252 + hid_set_drvdata(hdev, wacom); 1253 + wacom->hdev = hdev; 1254 + 1255 + /* ask for the report descriptor to be loaded by HID */ 1256 + error = hid_parse(hdev); 1257 + if (error) { 1258 + hid_err(hdev, "parse failed\n"); 1259 + goto fail1; 1260 + } 1261 + 1262 + wacom_wac = &wacom->wacom_wac; 1263 + wacom_wac->features = *((struct wacom_features *)id->driver_data); 1264 + features = &wacom_wac->features; 1265 + features->pktlen = wacom_compute_pktlen(hdev); 1266 + if (features->pktlen > WACOM_PKGLEN_MAX) { 1267 + error = -EINVAL; 1268 + goto fail1; 1269 + } 1270 + 1271 + if (features->check_for_hid_type && features->hid_type != hdev->type) { 1272 + error = -ENODEV; 1273 + goto fail1; 1274 + } 1275 + 1276 + wacom->usbdev = dev; 1277 + wacom->intf = intf; 1278 + mutex_init(&wacom->lock); 1279 + INIT_WORK(&wacom->work, wacom_wireless_work); 1280 + 1281 + /* set the default size in case we do not get them from hid */ 1282 + wacom_set_default_phy(features); 1283 + 1284 + /* Retrieve the physical and logical size for touch devices */ 1285 + wacom_retrieve_hid_descriptor(hdev, features); 1286 + 1287 + /* 1288 + * Intuos5 has no useful data about its touch interface in its 1289 + * HID descriptor. If this is the touch interface (PacketSize 1290 + * of WACOM_PKGLEN_BBTOUCH3), override the table values. 1291 + */ 1292 + if (features->type >= INTUOS5S && features->type <= INTUOSHT) { 1293 + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 1294 + features->device_type = BTN_TOOL_FINGER; 1295 + 1296 + features->x_max = 4096; 1297 + features->y_max = 4096; 1298 + } else { 1299 + features->device_type = BTN_TOOL_PEN; 1300 + } 1301 + } 1302 + 1303 + /* 1304 + * Same thing for Bamboo 3rd gen. 1305 + */ 1306 + if ((features->type == BAMBOO_PT) && 1307 + (features->pktlen == WACOM_PKGLEN_BBTOUCH3) && 1308 + (features->device_type == BTN_TOOL_PEN)) { 1309 + features->device_type = BTN_TOOL_FINGER; 1310 + 1311 + features->x_max = 4096; 1312 + features->y_max = 4096; 1313 + } 1314 + 1315 + if (hdev->bus == BUS_BLUETOOTH) 1316 + features->quirks |= WACOM_QUIRK_BATTERY; 1317 + 1318 + wacom_setup_device_quirks(features); 1319 + 1320 + /* set unit to "100th of a mm" for devices not reported by HID */ 1321 + if (!features->unit) { 1322 + features->unit = 0x11; 1323 + features->unitExpo = -3; 1324 + } 1325 + wacom_calculate_res(features); 1326 + 1327 + strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 1328 + snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), 1329 + "%s Pad", features->name); 1330 + 1331 + if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { 1332 + /* Append the device type to the name */ 1333 + if (features->device_type != BTN_TOOL_FINGER) 1334 + strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); 1335 + else if (features->touch_max) 1336 + strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); 1337 + else 1338 + strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); 1339 + 1340 + error = wacom_add_shared_data(hdev); 1341 + if (error) 1342 + goto fail1; 1343 + } 1344 + 1345 + error = wacom_initialize_leds(wacom); 1346 + if (error) 1347 + goto fail2; 1348 + 1349 + if (!(features->quirks & WACOM_QUIRK_MONITOR) && 1350 + (features->quirks & WACOM_QUIRK_BATTERY)) { 1351 + error = wacom_initialize_battery(wacom); 1352 + if (error) 1353 + goto fail3; 1354 + } 1355 + 1356 + if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 1357 + error = wacom_register_inputs(wacom); 1358 + if (error) 1359 + goto fail4; 1360 + } 1361 + 1362 + if (hdev->bus == BUS_BLUETOOTH) { 1363 + error = device_create_file(&hdev->dev, &dev_attr_speed); 1364 + if (error) 1365 + hid_warn(hdev, 1366 + "can't create sysfs speed attribute err: %d\n", 1367 + error); 1368 + } 1369 + 1370 + /* Note that if query fails it is not a hard failure */ 1371 + wacom_query_tablet_data(hdev, features); 1372 + 1373 + /* Regular HID work starts now */ 1374 + error = hid_hw_start(hdev, HID_CONNECT_HIDRAW); 1375 + if (error) { 1376 + hid_err(hdev, "hw start failed\n"); 1377 + goto fail5; 1378 + } 1379 + 1380 + if (features->quirks & WACOM_QUIRK_MONITOR) 1381 + error = hid_hw_open(hdev); 1382 + 1383 + if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { 1384 + if (wacom_wac->features.device_type == BTN_TOOL_FINGER) 1385 + wacom_wac->shared->touch_input = wacom_wac->input; 1386 + } 1387 + 1388 + return 0; 1389 + 1390 + fail5: if (hdev->bus == BUS_BLUETOOTH) 1391 + device_remove_file(&hdev->dev, &dev_attr_speed); 1392 + wacom_unregister_inputs(wacom); 1393 + fail4: wacom_destroy_battery(wacom); 1394 + fail3: wacom_destroy_leds(wacom); 1395 + fail2: wacom_remove_shared_data(wacom_wac); 1396 + fail1: kfree(wacom); 1397 + hid_set_drvdata(hdev, NULL); 1398 + return error; 1399 + } 1400 + 1401 + static void wacom_remove(struct hid_device *hdev) 1402 + { 1403 + struct wacom *wacom = hid_get_drvdata(hdev); 1404 + 1405 + hid_hw_stop(hdev); 1406 + 1407 + cancel_work_sync(&wacom->work); 1408 + wacom_unregister_inputs(wacom); 1409 + if (hdev->bus == BUS_BLUETOOTH) 1410 + device_remove_file(&hdev->dev, &dev_attr_speed); 1411 + wacom_destroy_battery(wacom); 1412 + wacom_destroy_leds(wacom); 1413 + wacom_remove_shared_data(&wacom->wacom_wac); 1414 + 1415 + hid_set_drvdata(hdev, NULL); 1416 + kfree(wacom); 1417 + } 1418 + 1419 + static int wacom_resume(struct hid_device *hdev) 1420 + { 1421 + struct wacom *wacom = hid_get_drvdata(hdev); 1422 + struct wacom_features *features = &wacom->wacom_wac.features; 1423 + 1424 + mutex_lock(&wacom->lock); 1425 + 1426 + /* switch to wacom mode first */ 1427 + wacom_query_tablet_data(hdev, features); 1428 + wacom_led_control(wacom); 1429 + 1430 + mutex_unlock(&wacom->lock); 1431 + 1432 + return 0; 1433 + } 1434 + 1435 + static int wacom_reset_resume(struct hid_device *hdev) 1436 + { 1437 + return wacom_resume(hdev); 1438 + } 1439 + 1440 + static struct hid_driver wacom_driver = { 1441 + .name = "wacom", 1442 + .id_table = wacom_ids, 1443 + .probe = wacom_probe, 1444 + .remove = wacom_remove, 1445 + #ifdef CONFIG_PM 1446 + .resume = wacom_resume, 1447 + .reset_resume = wacom_reset_resume, 1448 + #endif 1449 + .raw_event = wacom_raw_event, 1450 + }; 1451 + module_hid_driver(wacom_driver); 1452 + 1453 + MODULE_VERSION(DRIVER_VERSION); 1454 + MODULE_AUTHOR(DRIVER_AUTHOR); 1455 + MODULE_DESCRIPTION(DRIVER_DESC); 1456 + MODULE_LICENSE(DRIVER_LICENSE);
-16
drivers/input/tablet/Kconfig
··· 73 73 To compile this driver as a module, choose M here: the 74 74 module will be called kbtab. 75 75 76 - config TABLET_USB_WACOM 77 - tristate "Wacom Intuos/Graphire tablet support (USB)" 78 - depends on USB_ARCH_HAS_HCD 79 - select POWER_SUPPLY 80 - select USB 81 - select NEW_LEDS 82 - select LEDS_CLASS 83 - help 84 - Say Y here if you want to use the USB version of the Wacom Intuos 85 - or Graphire tablet. Make sure to say Y to "Mouse support" 86 - (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support" 87 - (CONFIG_INPUT_EVDEV) as well. 88 - 89 - To compile this driver as a module, choose M here: the 90 - module will be called wacom. 91 - 92 76 config TABLET_SERIAL_WACOM4 93 77 tristate "Wacom protocol 4 serial tablet support" 94 78 select SERIO
-3
drivers/input/tablet/Makefile
··· 2 2 # Makefile for the tablet drivers 3 3 # 4 4 5 - # Multipart objects. 6 - wacom-objs := wacom_wac.o wacom_sys.o 7 5 8 6 obj-$(CONFIG_TABLET_USB_ACECAD) += acecad.o 9 7 obj-$(CONFIG_TABLET_USB_AIPTEK) += aiptek.o 10 8 obj-$(CONFIG_TABLET_USB_GTCO) += gtco.o 11 9 obj-$(CONFIG_TABLET_USB_HANWANG) += hanwang.o 12 10 obj-$(CONFIG_TABLET_USB_KBTAB) += kbtab.o 13 - obj-$(CONFIG_TABLET_USB_WACOM) += wacom.o 14 11 obj-$(CONFIG_TABLET_SERIAL_WACOM4) += wacom_serial4.o
+17 -10
drivers/input/tablet/wacom.h drivers/hid/wacom.h
··· 12 12 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> 13 13 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> 14 14 * Copyright (c) 2002-2011 Ping Cheng <pingc@wacom.com> 15 + * Copyright (c) 2014 Benjamin Tissoires <benjamin.tissoires@redhat.com> 15 16 * 16 17 * ChangeLog: 17 18 * v0.1 (vp) - Initial release ··· 73 72 * v1.52 (pc) - Query Wacom data upon system resume 74 73 * - add defines for features->type 75 74 * - add new devices (0x9F, 0xE2, and 0XE3) 75 + * v2.00 (bt) - conversion to a HID driver 76 + * - integration of the Bluetooth devices 76 77 */ 77 78 78 79 /* ··· 96 93 /* 97 94 * Version Information 98 95 */ 99 - #define DRIVER_VERSION "v1.53" 96 + #define DRIVER_VERSION "v2.00" 100 97 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 101 98 #define DRIVER_DESC "USB Wacom tablet driver" 102 99 #define DRIVER_LICENSE "GPL" 103 - 104 - MODULE_AUTHOR(DRIVER_AUTHOR); 105 - MODULE_DESCRIPTION(DRIVER_DESC); 106 - MODULE_LICENSE(DRIVER_LICENSE); 107 100 108 101 #define USB_VENDOR_ID_WACOM 0x056a 109 102 #define USB_VENDOR_ID_LENOVO 0x17ef 110 103 111 104 struct wacom { 112 - dma_addr_t data_dma; 113 105 struct usb_device *usbdev; 114 106 struct usb_interface *intf; 115 - struct urb *irq; 116 107 struct wacom_wac wacom_wac; 108 + struct hid_device *hdev; 117 109 struct mutex lock; 118 110 struct work_struct work; 119 - bool open; 120 - char phys[32]; 121 111 struct wacom_led { 122 112 u8 select[2]; /* status led selector (0..3) */ 123 113 u8 llv; /* status led brightness no button (1..127) */ 124 114 u8 hlv; /* status led brightness button pressed (1..127) */ 125 115 u8 img_lum; /* OLED matrix display brightness */ 126 116 } led; 117 + bool led_initialized; 127 118 struct power_supply battery; 119 + struct power_supply ac; 128 120 }; 129 121 130 122 static inline void wacom_schedule_work(struct wacom_wac *wacom_wac) ··· 128 130 schedule_work(&wacom->work); 129 131 } 130 132 131 - extern const struct usb_device_id wacom_ids[]; 133 + static inline void wacom_notify_battery(struct wacom_wac *wacom_wac) 134 + { 135 + struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); 136 + 137 + power_supply_changed(&wacom->battery); 138 + } 139 + 140 + extern const struct hid_device_id wacom_ids[]; 132 141 133 142 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 134 143 void wacom_setup_device_quirks(struct wacom_features *features); 135 144 int wacom_setup_input_capabilities(struct input_dev *input_dev, 136 145 struct wacom_wac *wacom_wac); 146 + int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, 147 + struct wacom_wac *wacom_wac); 137 148 #endif
-1497
drivers/input/tablet/wacom_sys.c
··· 1 - /* 2 - * drivers/input/tablet/wacom_sys.c 3 - * 4 - * USB Wacom tablet support - system specific code 5 - */ 6 - 7 - /* 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License as published by 10 - * the Free Software Foundation; either version 2 of the License, or 11 - * (at your option) any later version. 12 - */ 13 - 14 - #include "wacom_wac.h" 15 - #include "wacom.h" 16 - 17 - /* defines to get HID report descriptor */ 18 - #define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01) 19 - #define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02) 20 - #define HID_USAGE_UNDEFINED 0x00 21 - #define HID_USAGE_PAGE 0x05 22 - #define HID_USAGE_PAGE_DIGITIZER 0x0d 23 - #define HID_USAGE_PAGE_DESKTOP 0x01 24 - #define HID_USAGE 0x09 25 - #define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30) 26 - #define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31) 27 - #define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30) 28 - #define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d) 29 - #define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e) 30 - #define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22) 31 - #define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20) 32 - #define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55) 33 - #define HID_COLLECTION 0xa1 34 - #define HID_COLLECTION_LOGICAL 0x02 35 - #define HID_COLLECTION_END 0xc0 36 - 37 - struct hid_descriptor { 38 - struct usb_descriptor_header header; 39 - __le16 bcdHID; 40 - u8 bCountryCode; 41 - u8 bNumDescriptors; 42 - u8 bDescriptorType; 43 - __le16 wDescriptorLength; 44 - } __attribute__ ((packed)); 45 - 46 - /* defines to get/set USB message */ 47 - #define USB_REQ_GET_REPORT 0x01 48 - #define USB_REQ_SET_REPORT 0x09 49 - 50 - #define WAC_HID_FEATURE_REPORT 0x03 51 - #define WAC_MSG_RETRIES 5 52 - 53 - #define WAC_CMD_LED_CONTROL 0x20 54 - #define WAC_CMD_ICON_START 0x21 55 - #define WAC_CMD_ICON_XFER 0x23 56 - #define WAC_CMD_RETRIES 10 57 - 58 - static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id, 59 - void *buf, size_t size, unsigned int retries) 60 - { 61 - struct usb_device *dev = interface_to_usbdev(intf); 62 - int retval; 63 - 64 - do { 65 - retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 66 - USB_REQ_GET_REPORT, 67 - USB_DIR_IN | USB_TYPE_CLASS | 68 - USB_RECIP_INTERFACE, 69 - (type << 8) + id, 70 - intf->altsetting[0].desc.bInterfaceNumber, 71 - buf, size, 100); 72 - } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 73 - 74 - return retval; 75 - } 76 - 77 - static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id, 78 - void *buf, size_t size, unsigned int retries) 79 - { 80 - struct usb_device *dev = interface_to_usbdev(intf); 81 - int retval; 82 - 83 - do { 84 - retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 85 - USB_REQ_SET_REPORT, 86 - USB_TYPE_CLASS | USB_RECIP_INTERFACE, 87 - (type << 8) + id, 88 - intf->altsetting[0].desc.bInterfaceNumber, 89 - buf, size, 1000); 90 - } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 91 - 92 - return retval; 93 - } 94 - 95 - static void wacom_sys_irq(struct urb *urb) 96 - { 97 - struct wacom *wacom = urb->context; 98 - struct device *dev = &wacom->intf->dev; 99 - int retval; 100 - 101 - switch (urb->status) { 102 - case 0: 103 - /* success */ 104 - break; 105 - case -ECONNRESET: 106 - case -ENOENT: 107 - case -ESHUTDOWN: 108 - /* this urb is terminated, clean up */ 109 - dev_dbg(dev, "%s - urb shutting down with status: %d\n", 110 - __func__, urb->status); 111 - return; 112 - default: 113 - dev_dbg(dev, "%s - nonzero urb status received: %d\n", 114 - __func__, urb->status); 115 - goto exit; 116 - } 117 - 118 - wacom_wac_irq(&wacom->wacom_wac, urb->actual_length); 119 - 120 - exit: 121 - usb_mark_last_busy(wacom->usbdev); 122 - retval = usb_submit_urb(urb, GFP_ATOMIC); 123 - if (retval) 124 - dev_err(dev, "%s - usb_submit_urb failed with result %d\n", 125 - __func__, retval); 126 - } 127 - 128 - static int wacom_open(struct input_dev *dev) 129 - { 130 - struct wacom *wacom = input_get_drvdata(dev); 131 - int retval = 0; 132 - 133 - if (usb_autopm_get_interface(wacom->intf) < 0) 134 - return -EIO; 135 - 136 - mutex_lock(&wacom->lock); 137 - 138 - if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { 139 - retval = -EIO; 140 - goto out; 141 - } 142 - 143 - wacom->open = true; 144 - wacom->intf->needs_remote_wakeup = 1; 145 - 146 - out: 147 - mutex_unlock(&wacom->lock); 148 - usb_autopm_put_interface(wacom->intf); 149 - return retval; 150 - } 151 - 152 - static void wacom_close(struct input_dev *dev) 153 - { 154 - struct wacom *wacom = input_get_drvdata(dev); 155 - int autopm_error; 156 - 157 - autopm_error = usb_autopm_get_interface(wacom->intf); 158 - 159 - mutex_lock(&wacom->lock); 160 - usb_kill_urb(wacom->irq); 161 - wacom->open = false; 162 - wacom->intf->needs_remote_wakeup = 0; 163 - mutex_unlock(&wacom->lock); 164 - 165 - if (!autopm_error) 166 - usb_autopm_put_interface(wacom->intf); 167 - } 168 - 169 - /* 170 - * Calculate the resolution of the X or Y axis, given appropriate HID data. 171 - * This function is little more than hidinput_calc_abs_res stripped down. 172 - */ 173 - static int wacom_calc_hid_res(int logical_extents, int physical_extents, 174 - unsigned char unit, unsigned char exponent) 175 - { 176 - int prev, unit_exponent; 177 - 178 - /* Check if the extents are sane */ 179 - if (logical_extents <= 0 || physical_extents <= 0) 180 - return 0; 181 - 182 - /* Get signed value of nybble-sized twos-compliment exponent */ 183 - unit_exponent = exponent; 184 - if (unit_exponent > 7) 185 - unit_exponent -= 16; 186 - 187 - /* Convert physical_extents to millimeters */ 188 - if (unit == 0x11) { /* If centimeters */ 189 - unit_exponent += 1; 190 - } else if (unit == 0x13) { /* If inches */ 191 - prev = physical_extents; 192 - physical_extents *= 254; 193 - if (physical_extents < prev) 194 - return 0; 195 - unit_exponent -= 1; 196 - } else { 197 - return 0; 198 - } 199 - 200 - /* Apply negative unit exponent */ 201 - for (; unit_exponent < 0; unit_exponent++) { 202 - prev = logical_extents; 203 - logical_extents *= 10; 204 - if (logical_extents < prev) 205 - return 0; 206 - } 207 - /* Apply positive unit exponent */ 208 - for (; unit_exponent > 0; unit_exponent--) { 209 - prev = physical_extents; 210 - physical_extents *= 10; 211 - if (physical_extents < prev) 212 - return 0; 213 - } 214 - 215 - /* Calculate resolution */ 216 - return logical_extents / physical_extents; 217 - } 218 - 219 - static int wacom_parse_logical_collection(unsigned char *report, 220 - struct wacom_features *features) 221 - { 222 - int length = 0; 223 - 224 - if (features->type == BAMBOO_PT) { 225 - 226 - /* Logical collection is only used by 3rd gen Bamboo Touch */ 227 - features->pktlen = WACOM_PKGLEN_BBTOUCH3; 228 - features->device_type = BTN_TOOL_FINGER; 229 - 230 - features->x_max = features->y_max = 231 - get_unaligned_le16(&report[10]); 232 - 233 - length = 11; 234 - } 235 - return length; 236 - } 237 - 238 - static void wacom_retrieve_report_data(struct usb_interface *intf, 239 - struct wacom_features *features) 240 - { 241 - int result = 0; 242 - unsigned char *rep_data; 243 - 244 - rep_data = kmalloc(2, GFP_KERNEL); 245 - if (rep_data) { 246 - 247 - rep_data[0] = 12; 248 - result = wacom_get_report(intf, WAC_HID_FEATURE_REPORT, 249 - rep_data[0], rep_data, 2, 250 - WAC_MSG_RETRIES); 251 - 252 - if (result >= 0 && rep_data[1] > 2) 253 - features->touch_max = rep_data[1]; 254 - 255 - kfree(rep_data); 256 - } 257 - } 258 - 259 - /* 260 - * Interface Descriptor of wacom devices can be incomplete and 261 - * inconsistent so wacom_features table is used to store stylus 262 - * device's packet lengths, various maximum values, and tablet 263 - * resolution based on product ID's. 264 - * 265 - * For devices that contain 2 interfaces, wacom_features table is 266 - * inaccurate for the touch interface. Since the Interface Descriptor 267 - * for touch interfaces has pretty complete data, this function exists 268 - * to query tablet for this missing information instead of hard coding in 269 - * an additional table. 270 - * 271 - * A typical Interface Descriptor for a stylus will contain a 272 - * boot mouse application collection that is not of interest and this 273 - * function will ignore it. 274 - * 275 - * It also contains a digitizer application collection that also is not 276 - * of interest since any information it contains would be duplicate 277 - * of what is in wacom_features. Usually it defines a report of an array 278 - * of bytes that could be used as max length of the stylus packet returned. 279 - * If it happens to define a Digitizer-Stylus Physical Collection then 280 - * the X and Y logical values contain valid data but it is ignored. 281 - * 282 - * A typical Interface Descriptor for a touch interface will contain a 283 - * Digitizer-Finger Physical Collection which will define both logical 284 - * X/Y maximum as well as the physical size of tablet. Since touch 285 - * interfaces haven't supported pressure or distance, this is enough 286 - * information to override invalid values in the wacom_features table. 287 - * 288 - * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical 289 - * Collection. Instead they define a Logical Collection with a single 290 - * Logical Maximum for both X and Y. 291 - * 292 - * Intuos5 touch interface does not contain useful data. We deal with 293 - * this after returning from this function. 294 - */ 295 - static int wacom_parse_hid(struct usb_interface *intf, 296 - struct hid_descriptor *hid_desc, 297 - struct wacom_features *features) 298 - { 299 - struct usb_device *dev = interface_to_usbdev(intf); 300 - char limit = 0; 301 - /* result has to be defined as int for some devices */ 302 - int result = 0, touch_max = 0; 303 - int i = 0, page = 0, finger = 0, pen = 0; 304 - unsigned char *report; 305 - 306 - report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); 307 - if (!report) 308 - return -ENOMEM; 309 - 310 - /* retrive report descriptors */ 311 - do { 312 - result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 313 - USB_REQ_GET_DESCRIPTOR, 314 - USB_RECIP_INTERFACE | USB_DIR_IN, 315 - HID_DEVICET_REPORT << 8, 316 - intf->altsetting[0].desc.bInterfaceNumber, /* interface */ 317 - report, 318 - hid_desc->wDescriptorLength, 319 - 5000); /* 5 secs */ 320 - } while (result < 0 && limit++ < WAC_MSG_RETRIES); 321 - 322 - /* No need to parse the Descriptor. It isn't an error though */ 323 - if (result < 0) 324 - goto out; 325 - 326 - for (i = 0; i < hid_desc->wDescriptorLength; i++) { 327 - 328 - switch (report[i]) { 329 - case HID_USAGE_PAGE: 330 - page = report[i + 1]; 331 - i++; 332 - break; 333 - 334 - case HID_USAGE: 335 - switch (page << 16 | report[i + 1]) { 336 - case HID_USAGE_X: 337 - if (finger) { 338 - features->device_type = BTN_TOOL_FINGER; 339 - /* touch device at least supports one touch point */ 340 - touch_max = 1; 341 - switch (features->type) { 342 - case TABLETPC2FG: 343 - features->pktlen = WACOM_PKGLEN_TPC2FG; 344 - break; 345 - 346 - case MTSCREEN: 347 - case WACOM_24HDT: 348 - features->pktlen = WACOM_PKGLEN_MTOUCH; 349 - break; 350 - 351 - case MTTPC: 352 - case MTTPC_B: 353 - features->pktlen = WACOM_PKGLEN_MTTPC; 354 - break; 355 - 356 - case BAMBOO_PT: 357 - features->pktlen = WACOM_PKGLEN_BBTOUCH; 358 - break; 359 - 360 - default: 361 - features->pktlen = WACOM_PKGLEN_GRAPHIRE; 362 - break; 363 - } 364 - 365 - switch (features->type) { 366 - case BAMBOO_PT: 367 - features->x_phy = 368 - get_unaligned_le16(&report[i + 5]); 369 - features->x_max = 370 - get_unaligned_le16(&report[i + 8]); 371 - i += 15; 372 - break; 373 - 374 - case WACOM_24HDT: 375 - features->x_max = 376 - get_unaligned_le16(&report[i + 3]); 377 - features->x_phy = 378 - get_unaligned_le16(&report[i + 8]); 379 - features->unit = report[i - 1]; 380 - features->unitExpo = report[i - 3]; 381 - i += 12; 382 - break; 383 - 384 - case MTTPC_B: 385 - features->x_max = 386 - get_unaligned_le16(&report[i + 3]); 387 - features->x_phy = 388 - get_unaligned_le16(&report[i + 6]); 389 - features->unit = report[i - 5]; 390 - features->unitExpo = report[i - 3]; 391 - i += 9; 392 - break; 393 - 394 - default: 395 - features->x_max = 396 - get_unaligned_le16(&report[i + 3]); 397 - features->x_phy = 398 - get_unaligned_le16(&report[i + 6]); 399 - features->unit = report[i + 9]; 400 - features->unitExpo = report[i + 11]; 401 - i += 12; 402 - break; 403 - } 404 - } else if (pen) { 405 - /* penabled only accepts exact bytes of data */ 406 - if (features->type >= TABLETPC) 407 - features->pktlen = WACOM_PKGLEN_GRAPHIRE; 408 - features->device_type = BTN_TOOL_PEN; 409 - features->x_max = 410 - get_unaligned_le16(&report[i + 3]); 411 - i += 4; 412 - } 413 - break; 414 - 415 - case HID_USAGE_Y: 416 - if (finger) { 417 - switch (features->type) { 418 - case TABLETPC2FG: 419 - case MTSCREEN: 420 - case MTTPC: 421 - features->y_max = 422 - get_unaligned_le16(&report[i + 3]); 423 - features->y_phy = 424 - get_unaligned_le16(&report[i + 6]); 425 - i += 7; 426 - break; 427 - 428 - case WACOM_24HDT: 429 - features->y_max = 430 - get_unaligned_le16(&report[i + 3]); 431 - features->y_phy = 432 - get_unaligned_le16(&report[i - 2]); 433 - i += 7; 434 - break; 435 - 436 - case BAMBOO_PT: 437 - features->y_phy = 438 - get_unaligned_le16(&report[i + 3]); 439 - features->y_max = 440 - get_unaligned_le16(&report[i + 6]); 441 - i += 12; 442 - break; 443 - 444 - case MTTPC_B: 445 - features->y_max = 446 - get_unaligned_le16(&report[i + 3]); 447 - features->y_phy = 448 - get_unaligned_le16(&report[i + 6]); 449 - i += 9; 450 - break; 451 - 452 - default: 453 - features->y_max = 454 - features->x_max; 455 - features->y_phy = 456 - get_unaligned_le16(&report[i + 3]); 457 - i += 4; 458 - break; 459 - } 460 - } else if (pen) { 461 - features->y_max = 462 - get_unaligned_le16(&report[i + 3]); 463 - i += 4; 464 - } 465 - break; 466 - 467 - case HID_USAGE_FINGER: 468 - finger = 1; 469 - i++; 470 - break; 471 - 472 - /* 473 - * Requiring Stylus Usage will ignore boot mouse 474 - * X/Y values and some cases of invalid Digitizer X/Y 475 - * values commonly reported. 476 - */ 477 - case HID_USAGE_STYLUS: 478 - pen = 1; 479 - i++; 480 - break; 481 - 482 - case HID_USAGE_CONTACTMAX: 483 - /* leave touch_max as is if predefined */ 484 - if (!features->touch_max) 485 - wacom_retrieve_report_data(intf, features); 486 - i++; 487 - break; 488 - 489 - case HID_USAGE_PRESSURE: 490 - if (pen) { 491 - features->pressure_max = 492 - get_unaligned_le16(&report[i + 3]); 493 - i += 4; 494 - } 495 - break; 496 - } 497 - break; 498 - 499 - case HID_COLLECTION_END: 500 - /* reset UsagePage and Finger */ 501 - finger = page = 0; 502 - break; 503 - 504 - case HID_COLLECTION: 505 - i++; 506 - switch (report[i]) { 507 - case HID_COLLECTION_LOGICAL: 508 - i += wacom_parse_logical_collection(&report[i], 509 - features); 510 - break; 511 - } 512 - break; 513 - } 514 - } 515 - 516 - out: 517 - if (!features->touch_max && touch_max) 518 - features->touch_max = touch_max; 519 - result = 0; 520 - kfree(report); 521 - return result; 522 - } 523 - 524 - static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int length, int mode) 525 - { 526 - unsigned char *rep_data; 527 - int error = -ENOMEM, limit = 0; 528 - 529 - rep_data = kzalloc(length, GFP_KERNEL); 530 - if (!rep_data) 531 - return error; 532 - 533 - do { 534 - rep_data[0] = report_id; 535 - rep_data[1] = mode; 536 - 537 - error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT, 538 - report_id, rep_data, length, 1); 539 - } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES); 540 - 541 - kfree(rep_data); 542 - 543 - return error < 0 ? error : 0; 544 - } 545 - 546 - /* 547 - * Switch the tablet into its most-capable mode. Wacom tablets are 548 - * typically configured to power-up in a mode which sends mouse-like 549 - * reports to the OS. To get absolute position, pressure data, etc. 550 - * from the tablet, it is necessary to switch the tablet out of this 551 - * mode and into one which sends the full range of tablet data. 552 - */ 553 - static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features) 554 - { 555 - if (features->device_type == BTN_TOOL_FINGER) { 556 - if (features->type > TABLETPC) { 557 - /* MT Tablet PC touch */ 558 - return wacom_set_device_mode(intf, 3, 4, 4); 559 - } 560 - else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) { 561 - return wacom_set_device_mode(intf, 18, 3, 2); 562 - } 563 - } else if (features->device_type == BTN_TOOL_PEN) { 564 - if (features->type <= BAMBOO_PT && features->type != WIRELESS) { 565 - return wacom_set_device_mode(intf, 2, 2, 2); 566 - } 567 - } 568 - 569 - return 0; 570 - } 571 - 572 - static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, 573 - struct wacom_features *features) 574 - { 575 - int error = 0; 576 - struct usb_host_interface *interface = intf->cur_altsetting; 577 - struct hid_descriptor *hid_desc; 578 - 579 - /* default features */ 580 - features->device_type = BTN_TOOL_PEN; 581 - features->x_fuzz = 4; 582 - features->y_fuzz = 4; 583 - features->pressure_fuzz = 0; 584 - features->distance_fuzz = 0; 585 - 586 - /* 587 - * The wireless device HID is basic and layout conflicts with 588 - * other tablets (monitor and touch interface can look like pen). 589 - * Skip the query for this type and modify defaults based on 590 - * interface number. 591 - */ 592 - if (features->type == WIRELESS) { 593 - if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 594 - features->device_type = 0; 595 - } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { 596 - features->device_type = BTN_TOOL_FINGER; 597 - features->pktlen = WACOM_PKGLEN_BBTOUCH3; 598 - } 599 - } 600 - 601 - /* only devices that support touch need to retrieve the info */ 602 - if (features->type < BAMBOO_PT) { 603 - goto out; 604 - } 605 - 606 - error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc); 607 - if (error) { 608 - error = usb_get_extra_descriptor(&interface->endpoint[0], 609 - HID_DEVICET_REPORT, &hid_desc); 610 - if (error) { 611 - dev_err(&intf->dev, 612 - "can not retrieve extra class descriptor\n"); 613 - goto out; 614 - } 615 - } 616 - error = wacom_parse_hid(intf, hid_desc, features); 617 - 618 - out: 619 - return error; 620 - } 621 - 622 - struct wacom_usbdev_data { 623 - struct list_head list; 624 - struct kref kref; 625 - struct usb_device *dev; 626 - struct wacom_shared shared; 627 - }; 628 - 629 - static LIST_HEAD(wacom_udev_list); 630 - static DEFINE_MUTEX(wacom_udev_list_lock); 631 - 632 - static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product) 633 - { 634 - int port1; 635 - struct usb_device *sibling; 636 - 637 - if (vendor == 0 && product == 0) 638 - return dev; 639 - 640 - if (dev->parent == NULL) 641 - return NULL; 642 - 643 - usb_hub_for_each_child(dev->parent, port1, sibling) { 644 - struct usb_device_descriptor *d; 645 - if (sibling == NULL) 646 - continue; 647 - 648 - d = &sibling->descriptor; 649 - if (d->idVendor == vendor && d->idProduct == product) 650 - return sibling; 651 - } 652 - 653 - return NULL; 654 - } 655 - 656 - static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev) 657 - { 658 - struct wacom_usbdev_data *data; 659 - 660 - list_for_each_entry(data, &wacom_udev_list, list) { 661 - if (data->dev == dev) { 662 - kref_get(&data->kref); 663 - return data; 664 - } 665 - } 666 - 667 - return NULL; 668 - } 669 - 670 - static int wacom_add_shared_data(struct wacom_wac *wacom, 671 - struct usb_device *dev) 672 - { 673 - struct wacom_usbdev_data *data; 674 - int retval = 0; 675 - 676 - mutex_lock(&wacom_udev_list_lock); 677 - 678 - data = wacom_get_usbdev_data(dev); 679 - if (!data) { 680 - data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL); 681 - if (!data) { 682 - retval = -ENOMEM; 683 - goto out; 684 - } 685 - 686 - kref_init(&data->kref); 687 - data->dev = dev; 688 - list_add_tail(&data->list, &wacom_udev_list); 689 - } 690 - 691 - wacom->shared = &data->shared; 692 - 693 - out: 694 - mutex_unlock(&wacom_udev_list_lock); 695 - return retval; 696 - } 697 - 698 - static void wacom_release_shared_data(struct kref *kref) 699 - { 700 - struct wacom_usbdev_data *data = 701 - container_of(kref, struct wacom_usbdev_data, kref); 702 - 703 - mutex_lock(&wacom_udev_list_lock); 704 - list_del(&data->list); 705 - mutex_unlock(&wacom_udev_list_lock); 706 - 707 - kfree(data); 708 - } 709 - 710 - static void wacom_remove_shared_data(struct wacom_wac *wacom) 711 - { 712 - struct wacom_usbdev_data *data; 713 - 714 - if (wacom->shared) { 715 - data = container_of(wacom->shared, struct wacom_usbdev_data, shared); 716 - kref_put(&data->kref, wacom_release_shared_data); 717 - wacom->shared = NULL; 718 - } 719 - } 720 - 721 - static int wacom_led_control(struct wacom *wacom) 722 - { 723 - unsigned char *buf; 724 - int retval; 725 - 726 - buf = kzalloc(9, GFP_KERNEL); 727 - if (!buf) 728 - return -ENOMEM; 729 - 730 - if (wacom->wacom_wac.features.type >= INTUOS5S && 731 - wacom->wacom_wac.features.type <= INTUOSPL) { 732 - /* 733 - * Touch Ring and crop mark LED luminance may take on 734 - * one of four values: 735 - * 0 = Low; 1 = Medium; 2 = High; 3 = Off 736 - */ 737 - int ring_led = wacom->led.select[0] & 0x03; 738 - int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; 739 - int crop_lum = 0; 740 - 741 - buf[0] = WAC_CMD_LED_CONTROL; 742 - buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); 743 - } 744 - else { 745 - int led = wacom->led.select[0] | 0x4; 746 - 747 - if (wacom->wacom_wac.features.type == WACOM_21UX2 || 748 - wacom->wacom_wac.features.type == WACOM_24HD) 749 - led |= (wacom->led.select[1] << 4) | 0x40; 750 - 751 - buf[0] = WAC_CMD_LED_CONTROL; 752 - buf[1] = led; 753 - buf[2] = wacom->led.llv; 754 - buf[3] = wacom->led.hlv; 755 - buf[4] = wacom->led.img_lum; 756 - } 757 - 758 - retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL, 759 - buf, 9, WAC_CMD_RETRIES); 760 - kfree(buf); 761 - 762 - return retval; 763 - } 764 - 765 - static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *img) 766 - { 767 - unsigned char *buf; 768 - int i, retval; 769 - 770 - buf = kzalloc(259, GFP_KERNEL); 771 - if (!buf) 772 - return -ENOMEM; 773 - 774 - /* Send 'start' command */ 775 - buf[0] = WAC_CMD_ICON_START; 776 - buf[1] = 1; 777 - retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START, 778 - buf, 2, WAC_CMD_RETRIES); 779 - if (retval < 0) 780 - goto out; 781 - 782 - buf[0] = WAC_CMD_ICON_XFER; 783 - buf[1] = button_id & 0x07; 784 - for (i = 0; i < 4; i++) { 785 - buf[2] = i; 786 - memcpy(buf + 3, img + i * 256, 256); 787 - 788 - retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_XFER, 789 - buf, 259, WAC_CMD_RETRIES); 790 - if (retval < 0) 791 - break; 792 - } 793 - 794 - /* Send 'stop' */ 795 - buf[0] = WAC_CMD_ICON_START; 796 - buf[1] = 0; 797 - wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START, 798 - buf, 2, WAC_CMD_RETRIES); 799 - 800 - out: 801 - kfree(buf); 802 - return retval; 803 - } 804 - 805 - static ssize_t wacom_led_select_store(struct device *dev, int set_id, 806 - const char *buf, size_t count) 807 - { 808 - struct wacom *wacom = dev_get_drvdata(dev); 809 - unsigned int id; 810 - int err; 811 - 812 - err = kstrtouint(buf, 10, &id); 813 - if (err) 814 - return err; 815 - 816 - mutex_lock(&wacom->lock); 817 - 818 - wacom->led.select[set_id] = id & 0x3; 819 - err = wacom_led_control(wacom); 820 - 821 - mutex_unlock(&wacom->lock); 822 - 823 - return err < 0 ? err : count; 824 - } 825 - 826 - #define DEVICE_LED_SELECT_ATTR(SET_ID) \ 827 - static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \ 828 - struct device_attribute *attr, const char *buf, size_t count) \ 829 - { \ 830 - return wacom_led_select_store(dev, SET_ID, buf, count); \ 831 - } \ 832 - static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ 833 - struct device_attribute *attr, char *buf) \ 834 - { \ 835 - struct wacom *wacom = dev_get_drvdata(dev); \ 836 - return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \ 837 - } \ 838 - static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \ 839 - wacom_led##SET_ID##_select_show, \ 840 - wacom_led##SET_ID##_select_store) 841 - 842 - DEVICE_LED_SELECT_ATTR(0); 843 - DEVICE_LED_SELECT_ATTR(1); 844 - 845 - static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, 846 - const char *buf, size_t count) 847 - { 848 - unsigned int value; 849 - int err; 850 - 851 - err = kstrtouint(buf, 10, &value); 852 - if (err) 853 - return err; 854 - 855 - mutex_lock(&wacom->lock); 856 - 857 - *dest = value & 0x7f; 858 - err = wacom_led_control(wacom); 859 - 860 - mutex_unlock(&wacom->lock); 861 - 862 - return err < 0 ? err : count; 863 - } 864 - 865 - #define DEVICE_LUMINANCE_ATTR(name, field) \ 866 - static ssize_t wacom_##name##_luminance_store(struct device *dev, \ 867 - struct device_attribute *attr, const char *buf, size_t count) \ 868 - { \ 869 - struct wacom *wacom = dev_get_drvdata(dev); \ 870 - \ 871 - return wacom_luminance_store(wacom, &wacom->led.field, \ 872 - buf, count); \ 873 - } \ 874 - static DEVICE_ATTR(name##_luminance, S_IWUSR, \ 875 - NULL, wacom_##name##_luminance_store) 876 - 877 - DEVICE_LUMINANCE_ATTR(status0, llv); 878 - DEVICE_LUMINANCE_ATTR(status1, hlv); 879 - DEVICE_LUMINANCE_ATTR(buttons, img_lum); 880 - 881 - static ssize_t wacom_button_image_store(struct device *dev, int button_id, 882 - const char *buf, size_t count) 883 - { 884 - struct wacom *wacom = dev_get_drvdata(dev); 885 - int err; 886 - 887 - if (count != 1024) 888 - return -EINVAL; 889 - 890 - mutex_lock(&wacom->lock); 891 - 892 - err = wacom_led_putimage(wacom, button_id, buf); 893 - 894 - mutex_unlock(&wacom->lock); 895 - 896 - return err < 0 ? err : count; 897 - } 898 - 899 - #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \ 900 - static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \ 901 - struct device_attribute *attr, const char *buf, size_t count) \ 902 - { \ 903 - return wacom_button_image_store(dev, BUTTON_ID, buf, count); \ 904 - } \ 905 - static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \ 906 - NULL, wacom_btnimg##BUTTON_ID##_store) 907 - 908 - DEVICE_BTNIMG_ATTR(0); 909 - DEVICE_BTNIMG_ATTR(1); 910 - DEVICE_BTNIMG_ATTR(2); 911 - DEVICE_BTNIMG_ATTR(3); 912 - DEVICE_BTNIMG_ATTR(4); 913 - DEVICE_BTNIMG_ATTR(5); 914 - DEVICE_BTNIMG_ATTR(6); 915 - DEVICE_BTNIMG_ATTR(7); 916 - 917 - static struct attribute *cintiq_led_attrs[] = { 918 - &dev_attr_status_led0_select.attr, 919 - &dev_attr_status_led1_select.attr, 920 - NULL 921 - }; 922 - 923 - static struct attribute_group cintiq_led_attr_group = { 924 - .name = "wacom_led", 925 - .attrs = cintiq_led_attrs, 926 - }; 927 - 928 - static struct attribute *intuos4_led_attrs[] = { 929 - &dev_attr_status0_luminance.attr, 930 - &dev_attr_status1_luminance.attr, 931 - &dev_attr_status_led0_select.attr, 932 - &dev_attr_buttons_luminance.attr, 933 - &dev_attr_button0_rawimg.attr, 934 - &dev_attr_button1_rawimg.attr, 935 - &dev_attr_button2_rawimg.attr, 936 - &dev_attr_button3_rawimg.attr, 937 - &dev_attr_button4_rawimg.attr, 938 - &dev_attr_button5_rawimg.attr, 939 - &dev_attr_button6_rawimg.attr, 940 - &dev_attr_button7_rawimg.attr, 941 - NULL 942 - }; 943 - 944 - static struct attribute_group intuos4_led_attr_group = { 945 - .name = "wacom_led", 946 - .attrs = intuos4_led_attrs, 947 - }; 948 - 949 - static struct attribute *intuos5_led_attrs[] = { 950 - &dev_attr_status0_luminance.attr, 951 - &dev_attr_status_led0_select.attr, 952 - NULL 953 - }; 954 - 955 - static struct attribute_group intuos5_led_attr_group = { 956 - .name = "wacom_led", 957 - .attrs = intuos5_led_attrs, 958 - }; 959 - 960 - static int wacom_initialize_leds(struct wacom *wacom) 961 - { 962 - int error; 963 - 964 - /* Initialize default values */ 965 - switch (wacom->wacom_wac.features.type) { 966 - case INTUOS4S: 967 - case INTUOS4: 968 - case INTUOS4L: 969 - wacom->led.select[0] = 0; 970 - wacom->led.select[1] = 0; 971 - wacom->led.llv = 10; 972 - wacom->led.hlv = 20; 973 - wacom->led.img_lum = 10; 974 - error = sysfs_create_group(&wacom->intf->dev.kobj, 975 - &intuos4_led_attr_group); 976 - break; 977 - 978 - case WACOM_24HD: 979 - case WACOM_21UX2: 980 - wacom->led.select[0] = 0; 981 - wacom->led.select[1] = 0; 982 - wacom->led.llv = 0; 983 - wacom->led.hlv = 0; 984 - wacom->led.img_lum = 0; 985 - 986 - error = sysfs_create_group(&wacom->intf->dev.kobj, 987 - &cintiq_led_attr_group); 988 - break; 989 - 990 - case INTUOS5S: 991 - case INTUOS5: 992 - case INTUOS5L: 993 - case INTUOSPS: 994 - case INTUOSPM: 995 - case INTUOSPL: 996 - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { 997 - wacom->led.select[0] = 0; 998 - wacom->led.select[1] = 0; 999 - wacom->led.llv = 32; 1000 - wacom->led.hlv = 0; 1001 - wacom->led.img_lum = 0; 1002 - 1003 - error = sysfs_create_group(&wacom->intf->dev.kobj, 1004 - &intuos5_led_attr_group); 1005 - } else 1006 - return 0; 1007 - break; 1008 - 1009 - default: 1010 - return 0; 1011 - } 1012 - 1013 - if (error) { 1014 - dev_err(&wacom->intf->dev, 1015 - "cannot create sysfs group err: %d\n", error); 1016 - return error; 1017 - } 1018 - wacom_led_control(wacom); 1019 - 1020 - return 0; 1021 - } 1022 - 1023 - static void wacom_destroy_leds(struct wacom *wacom) 1024 - { 1025 - switch (wacom->wacom_wac.features.type) { 1026 - case INTUOS4S: 1027 - case INTUOS4: 1028 - case INTUOS4L: 1029 - sysfs_remove_group(&wacom->intf->dev.kobj, 1030 - &intuos4_led_attr_group); 1031 - break; 1032 - 1033 - case WACOM_24HD: 1034 - case WACOM_21UX2: 1035 - sysfs_remove_group(&wacom->intf->dev.kobj, 1036 - &cintiq_led_attr_group); 1037 - break; 1038 - 1039 - case INTUOS5S: 1040 - case INTUOS5: 1041 - case INTUOS5L: 1042 - case INTUOSPS: 1043 - case INTUOSPM: 1044 - case INTUOSPL: 1045 - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) 1046 - sysfs_remove_group(&wacom->intf->dev.kobj, 1047 - &intuos5_led_attr_group); 1048 - break; 1049 - } 1050 - } 1051 - 1052 - static enum power_supply_property wacom_battery_props[] = { 1053 - POWER_SUPPLY_PROP_SCOPE, 1054 - POWER_SUPPLY_PROP_CAPACITY 1055 - }; 1056 - 1057 - static int wacom_battery_get_property(struct power_supply *psy, 1058 - enum power_supply_property psp, 1059 - union power_supply_propval *val) 1060 - { 1061 - struct wacom *wacom = container_of(psy, struct wacom, battery); 1062 - int ret = 0; 1063 - 1064 - switch (psp) { 1065 - case POWER_SUPPLY_PROP_SCOPE: 1066 - val->intval = POWER_SUPPLY_SCOPE_DEVICE; 1067 - break; 1068 - case POWER_SUPPLY_PROP_CAPACITY: 1069 - val->intval = 1070 - wacom->wacom_wac.battery_capacity * 100 / 31; 1071 - break; 1072 - default: 1073 - ret = -EINVAL; 1074 - break; 1075 - } 1076 - 1077 - return ret; 1078 - } 1079 - 1080 - static int wacom_initialize_battery(struct wacom *wacom) 1081 - { 1082 - int error = 0; 1083 - 1084 - if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) { 1085 - wacom->battery.properties = wacom_battery_props; 1086 - wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); 1087 - wacom->battery.get_property = wacom_battery_get_property; 1088 - wacom->battery.name = "wacom_battery"; 1089 - wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; 1090 - wacom->battery.use_for_apm = 0; 1091 - 1092 - error = power_supply_register(&wacom->usbdev->dev, 1093 - &wacom->battery); 1094 - 1095 - if (!error) 1096 - power_supply_powers(&wacom->battery, 1097 - &wacom->usbdev->dev); 1098 - } 1099 - 1100 - return error; 1101 - } 1102 - 1103 - static void wacom_destroy_battery(struct wacom *wacom) 1104 - { 1105 - if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR && 1106 - wacom->battery.dev) { 1107 - power_supply_unregister(&wacom->battery); 1108 - wacom->battery.dev = NULL; 1109 - } 1110 - } 1111 - 1112 - static int wacom_register_input(struct wacom *wacom) 1113 - { 1114 - struct input_dev *input_dev; 1115 - struct usb_interface *intf = wacom->intf; 1116 - struct usb_device *dev = interface_to_usbdev(intf); 1117 - struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1118 - int error; 1119 - 1120 - input_dev = input_allocate_device(); 1121 - if (!input_dev) { 1122 - error = -ENOMEM; 1123 - goto fail1; 1124 - } 1125 - 1126 - input_dev->name = wacom_wac->name; 1127 - input_dev->dev.parent = &intf->dev; 1128 - input_dev->open = wacom_open; 1129 - input_dev->close = wacom_close; 1130 - usb_to_input_id(dev, &input_dev->id); 1131 - input_set_drvdata(input_dev, wacom); 1132 - 1133 - wacom_wac->input = input_dev; 1134 - error = wacom_setup_input_capabilities(input_dev, wacom_wac); 1135 - if (error) 1136 - goto fail1; 1137 - 1138 - error = input_register_device(input_dev); 1139 - if (error) 1140 - goto fail2; 1141 - 1142 - return 0; 1143 - 1144 - fail2: 1145 - input_free_device(input_dev); 1146 - wacom_wac->input = NULL; 1147 - fail1: 1148 - return error; 1149 - } 1150 - 1151 - static void wacom_wireless_work(struct work_struct *work) 1152 - { 1153 - struct wacom *wacom = container_of(work, struct wacom, work); 1154 - struct usb_device *usbdev = wacom->usbdev; 1155 - struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1156 - struct wacom *wacom1, *wacom2; 1157 - struct wacom_wac *wacom_wac1, *wacom_wac2; 1158 - int error; 1159 - 1160 - /* 1161 - * Regardless if this is a disconnect or a new tablet, 1162 - * remove any existing input and battery devices. 1163 - */ 1164 - 1165 - wacom_destroy_battery(wacom); 1166 - 1167 - /* Stylus interface */ 1168 - wacom1 = usb_get_intfdata(usbdev->config->interface[1]); 1169 - wacom_wac1 = &(wacom1->wacom_wac); 1170 - if (wacom_wac1->input) 1171 - input_unregister_device(wacom_wac1->input); 1172 - wacom_wac1->input = NULL; 1173 - 1174 - /* Touch interface */ 1175 - wacom2 = usb_get_intfdata(usbdev->config->interface[2]); 1176 - wacom_wac2 = &(wacom2->wacom_wac); 1177 - if (wacom_wac2->input) 1178 - input_unregister_device(wacom_wac2->input); 1179 - wacom_wac2->input = NULL; 1180 - 1181 - if (wacom_wac->pid == 0) { 1182 - dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); 1183 - } else { 1184 - const struct usb_device_id *id = wacom_ids; 1185 - 1186 - dev_info(&wacom->intf->dev, 1187 - "wireless tablet connected with PID %x\n", 1188 - wacom_wac->pid); 1189 - 1190 - while (id->match_flags) { 1191 - if (id->idVendor == USB_VENDOR_ID_WACOM && 1192 - id->idProduct == wacom_wac->pid) 1193 - break; 1194 - id++; 1195 - } 1196 - 1197 - if (!id->match_flags) { 1198 - dev_info(&wacom->intf->dev, 1199 - "ignoring unknown PID.\n"); 1200 - return; 1201 - } 1202 - 1203 - /* Stylus interface */ 1204 - wacom_wac1->features = 1205 - *((struct wacom_features *)id->driver_info); 1206 - wacom_wac1->features.device_type = BTN_TOOL_PEN; 1207 - snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1208 - wacom_wac1->features.name); 1209 - wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; 1210 - wacom_wac1->shared->type = wacom_wac1->features.type; 1211 - error = wacom_register_input(wacom1); 1212 - if (error) 1213 - goto fail; 1214 - 1215 - /* Touch interface */ 1216 - if (wacom_wac1->features.touch_max || 1217 - wacom_wac1->features.type == INTUOSHT) { 1218 - wacom_wac2->features = 1219 - *((struct wacom_features *)id->driver_info); 1220 - wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1221 - wacom_wac2->features.device_type = BTN_TOOL_FINGER; 1222 - wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1223 - if (wacom_wac2->features.touch_max) 1224 - snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1225 - "%s (WL) Finger",wacom_wac2->features.name); 1226 - else 1227 - snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1228 - "%s (WL) Pad",wacom_wac2->features.name); 1229 - error = wacom_register_input(wacom2); 1230 - if (error) 1231 - goto fail; 1232 - 1233 - if (wacom_wac1->features.type == INTUOSHT && 1234 - wacom_wac1->features.touch_max) 1235 - wacom_wac->shared->touch_input = wacom_wac2->input; 1236 - } 1237 - 1238 - error = wacom_initialize_battery(wacom); 1239 - if (error) 1240 - goto fail; 1241 - } 1242 - 1243 - return; 1244 - 1245 - fail: 1246 - if (wacom_wac2->input) { 1247 - input_unregister_device(wacom_wac2->input); 1248 - wacom_wac2->input = NULL; 1249 - } 1250 - 1251 - if (wacom_wac1->input) { 1252 - input_unregister_device(wacom_wac1->input); 1253 - wacom_wac1->input = NULL; 1254 - } 1255 - return; 1256 - } 1257 - 1258 - /* 1259 - * Not all devices report physical dimensions from HID. 1260 - * Compute the default from hardcoded logical dimension 1261 - * and resolution before driver overwrites them. 1262 - */ 1263 - static void wacom_set_default_phy(struct wacom_features *features) 1264 - { 1265 - if (features->x_resolution) { 1266 - features->x_phy = (features->x_max * 100) / 1267 - features->x_resolution; 1268 - features->y_phy = (features->y_max * 100) / 1269 - features->y_resolution; 1270 - } 1271 - } 1272 - 1273 - static void wacom_calculate_res(struct wacom_features *features) 1274 - { 1275 - features->x_resolution = wacom_calc_hid_res(features->x_max, 1276 - features->x_phy, 1277 - features->unit, 1278 - features->unitExpo); 1279 - features->y_resolution = wacom_calc_hid_res(features->y_max, 1280 - features->y_phy, 1281 - features->unit, 1282 - features->unitExpo); 1283 - } 1284 - 1285 - static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 1286 - { 1287 - struct usb_device *dev = interface_to_usbdev(intf); 1288 - struct usb_endpoint_descriptor *endpoint; 1289 - struct wacom *wacom; 1290 - struct wacom_wac *wacom_wac; 1291 - struct wacom_features *features; 1292 - int error; 1293 - 1294 - if (!id->driver_info) 1295 - return -EINVAL; 1296 - 1297 - wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 1298 - if (!wacom) 1299 - return -ENOMEM; 1300 - 1301 - wacom_wac = &wacom->wacom_wac; 1302 - wacom_wac->features = *((struct wacom_features *)id->driver_info); 1303 - features = &wacom_wac->features; 1304 - if (features->pktlen > WACOM_PKGLEN_MAX) { 1305 - error = -EINVAL; 1306 - goto fail1; 1307 - } 1308 - 1309 - wacom_wac->data = usb_alloc_coherent(dev, WACOM_PKGLEN_MAX, 1310 - GFP_KERNEL, &wacom->data_dma); 1311 - if (!wacom_wac->data) { 1312 - error = -ENOMEM; 1313 - goto fail1; 1314 - } 1315 - 1316 - wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 1317 - if (!wacom->irq) { 1318 - error = -ENOMEM; 1319 - goto fail2; 1320 - } 1321 - 1322 - wacom->usbdev = dev; 1323 - wacom->intf = intf; 1324 - mutex_init(&wacom->lock); 1325 - INIT_WORK(&wacom->work, wacom_wireless_work); 1326 - usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 1327 - strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 1328 - 1329 - endpoint = &intf->cur_altsetting->endpoint[0].desc; 1330 - 1331 - /* set the default size in case we do not get them from hid */ 1332 - wacom_set_default_phy(features); 1333 - 1334 - /* Retrieve the physical and logical size for touch devices */ 1335 - error = wacom_retrieve_hid_descriptor(intf, features); 1336 - if (error) 1337 - goto fail3; 1338 - 1339 - /* 1340 - * Intuos5 has no useful data about its touch interface in its 1341 - * HID descriptor. If this is the touch interface (wMaxPacketSize 1342 - * of WACOM_PKGLEN_BBTOUCH3), override the table values. 1343 - */ 1344 - if (features->type >= INTUOS5S && features->type <= INTUOSHT) { 1345 - if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) { 1346 - features->device_type = BTN_TOOL_FINGER; 1347 - features->pktlen = WACOM_PKGLEN_BBTOUCH3; 1348 - 1349 - features->x_max = 4096; 1350 - features->y_max = 4096; 1351 - } else { 1352 - features->device_type = BTN_TOOL_PEN; 1353 - } 1354 - } 1355 - 1356 - wacom_setup_device_quirks(features); 1357 - 1358 - /* set unit to "100th of a mm" for devices not reported by HID */ 1359 - if (!features->unit) { 1360 - features->unit = 0x11; 1361 - features->unitExpo = 16 - 3; 1362 - } 1363 - wacom_calculate_res(features); 1364 - 1365 - strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 1366 - 1367 - if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { 1368 - struct usb_device *other_dev; 1369 - 1370 - /* Append the device type to the name */ 1371 - if (features->device_type != BTN_TOOL_FINGER) 1372 - strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); 1373 - else if (features->touch_max) 1374 - strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); 1375 - else 1376 - strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); 1377 - 1378 - other_dev = wacom_get_sibling(dev, features->oVid, features->oPid); 1379 - if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL) 1380 - other_dev = dev; 1381 - error = wacom_add_shared_data(wacom_wac, other_dev); 1382 - if (error) 1383 - goto fail3; 1384 - } 1385 - 1386 - usb_fill_int_urb(wacom->irq, dev, 1387 - usb_rcvintpipe(dev, endpoint->bEndpointAddress), 1388 - wacom_wac->data, features->pktlen, 1389 - wacom_sys_irq, wacom, endpoint->bInterval); 1390 - wacom->irq->transfer_dma = wacom->data_dma; 1391 - wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1392 - 1393 - error = wacom_initialize_leds(wacom); 1394 - if (error) 1395 - goto fail4; 1396 - 1397 - if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 1398 - error = wacom_register_input(wacom); 1399 - if (error) 1400 - goto fail5; 1401 - } 1402 - 1403 - /* Note that if query fails it is not a hard failure */ 1404 - wacom_query_tablet_data(intf, features); 1405 - 1406 - usb_set_intfdata(intf, wacom); 1407 - 1408 - if (features->quirks & WACOM_QUIRK_MONITOR) { 1409 - if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { 1410 - error = -EIO; 1411 - goto fail5; 1412 - } 1413 - } 1414 - 1415 - if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { 1416 - if (wacom_wac->features.device_type == BTN_TOOL_FINGER) 1417 - wacom_wac->shared->touch_input = wacom_wac->input; 1418 - } 1419 - 1420 - return 0; 1421 - 1422 - fail5: wacom_destroy_leds(wacom); 1423 - fail4: wacom_remove_shared_data(wacom_wac); 1424 - fail3: usb_free_urb(wacom->irq); 1425 - fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); 1426 - fail1: kfree(wacom); 1427 - return error; 1428 - } 1429 - 1430 - static void wacom_disconnect(struct usb_interface *intf) 1431 - { 1432 - struct wacom *wacom = usb_get_intfdata(intf); 1433 - 1434 - usb_set_intfdata(intf, NULL); 1435 - 1436 - usb_kill_urb(wacom->irq); 1437 - cancel_work_sync(&wacom->work); 1438 - if (wacom->wacom_wac.input) 1439 - input_unregister_device(wacom->wacom_wac.input); 1440 - wacom_destroy_battery(wacom); 1441 - wacom_destroy_leds(wacom); 1442 - usb_free_urb(wacom->irq); 1443 - usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, 1444 - wacom->wacom_wac.data, wacom->data_dma); 1445 - wacom_remove_shared_data(&wacom->wacom_wac); 1446 - kfree(wacom); 1447 - } 1448 - 1449 - static int wacom_suspend(struct usb_interface *intf, pm_message_t message) 1450 - { 1451 - struct wacom *wacom = usb_get_intfdata(intf); 1452 - 1453 - mutex_lock(&wacom->lock); 1454 - usb_kill_urb(wacom->irq); 1455 - mutex_unlock(&wacom->lock); 1456 - 1457 - return 0; 1458 - } 1459 - 1460 - static int wacom_resume(struct usb_interface *intf) 1461 - { 1462 - struct wacom *wacom = usb_get_intfdata(intf); 1463 - struct wacom_features *features = &wacom->wacom_wac.features; 1464 - int rv = 0; 1465 - 1466 - mutex_lock(&wacom->lock); 1467 - 1468 - /* switch to wacom mode first */ 1469 - wacom_query_tablet_data(intf, features); 1470 - wacom_led_control(wacom); 1471 - 1472 - if ((wacom->open || (features->quirks & WACOM_QUIRK_MONITOR)) && 1473 - usb_submit_urb(wacom->irq, GFP_NOIO) < 0) 1474 - rv = -EIO; 1475 - 1476 - mutex_unlock(&wacom->lock); 1477 - 1478 - return rv; 1479 - } 1480 - 1481 - static int wacom_reset_resume(struct usb_interface *intf) 1482 - { 1483 - return wacom_resume(intf); 1484 - } 1485 - 1486 - static struct usb_driver wacom_driver = { 1487 - .name = "wacom", 1488 - .id_table = wacom_ids, 1489 - .probe = wacom_probe, 1490 - .disconnect = wacom_disconnect, 1491 - .suspend = wacom_suspend, 1492 - .resume = wacom_resume, 1493 - .reset_resume = wacom_reset_resume, 1494 - .supports_autosuspend = 1, 1495 - }; 1496 - 1497 - module_usb_driver(wacom_driver);
+712 -476
drivers/input/tablet/wacom_wac.c drivers/hid/wacom_wac.c
··· 25 25 #define WACOM_INTUOS_RES 100 26 26 #define WACOM_INTUOS3_RES 200 27 27 28 - /* Scale factor relating reported contact size to logical contact area. 28 + /* 29 + * Scale factor relating reported contact size to logical contact area. 29 30 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo 30 31 */ 31 32 #define WACOM_CONTACT_AREA_SCALE 2607 33 + 34 + /* 35 + * Percent of battery capacity for Graphire. 36 + * 8th value means AC online and show 100% capacity. 37 + */ 38 + static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; 39 + 40 + /* 41 + * Percent of battery capacity for Intuos4 WL, AC has a separate bit. 42 + */ 43 + static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; 32 44 33 45 static int wacom_penpartner_irq(struct wacom_wac *wacom) 34 46 { ··· 229 217 "%s: received unknown report #%d", __func__, data[0]); 230 218 return 0; 231 219 } else if (data[0] == WACOM_REPORT_DTUSPAD) { 220 + input = wacom->pad_input; 232 221 input_report_key(input, BTN_0, (data[1] & 0x01)); 233 222 input_report_key(input, BTN_1, (data[1] & 0x02)); 234 223 input_report_key(input, BTN_2, (data[1] & 0x04)); 235 224 input_report_key(input, BTN_3, (data[1] & 0x08)); 236 225 input_report_abs(input, ABS_MISC, 237 226 data[1] & 0x0f ? PAD_DEVICE_ID : 0); 238 - /* 239 - * Serial number is required when expresskeys are 240 - * reported through pen interface. 241 - */ 242 - input_event(input, EV_MSC, MSC_SERIAL, 0xf0); 243 227 return 1; 244 228 } else { 245 229 prox = data[1] & 0x80; ··· 265 257 wacom->id[0] = 0; 266 258 input_report_key(input, wacom->tool[0], prox); 267 259 input_report_abs(input, ABS_MISC, wacom->id[0]); 268 - input_event(input, EV_MSC, MSC_SERIAL, 1); 269 260 return 1; 270 261 } 271 262 } ··· 274 267 struct wacom_features *features = &wacom->features; 275 268 unsigned char *data = wacom->data; 276 269 struct input_dev *input = wacom->input; 270 + struct input_dev *pad_input = wacom->pad_input; 271 + int battery_capacity, ps_connected; 277 272 int prox; 278 273 int rw = 0; 279 274 int retval = 0; 280 275 281 - if (data[0] != WACOM_REPORT_PENABLED) { 276 + if (features->type == GRAPHIRE_BT) { 277 + if (data[0] != WACOM_REPORT_PENABLED_BT) { 278 + dev_dbg(input->dev.parent, 279 + "%s: received unknown report #%d\n", __func__, 280 + data[0]); 281 + goto exit; 282 + } 283 + } else if (data[0] != WACOM_REPORT_PENABLED) { 282 284 dev_dbg(input->dev.parent, 283 285 "%s: received unknown report #%d\n", __func__, data[0]); 284 286 goto exit; ··· 321 305 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 322 306 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 323 307 if (wacom->tool[0] != BTN_TOOL_MOUSE) { 324 - input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8)); 308 + if (features->type == GRAPHIRE_BT) 309 + input_report_abs(input, ABS_PRESSURE, data[6] | 310 + (((__u16) (data[1] & 0x08)) << 5)); 311 + else 312 + input_report_abs(input, ABS_PRESSURE, data[6] | 313 + ((data[7] & 0x03) << 8)); 325 314 input_report_key(input, BTN_TOUCH, data[1] & 0x01); 326 315 input_report_key(input, BTN_STYLUS, data[1] & 0x02); 327 316 input_report_key(input, BTN_STYLUS2, data[1] & 0x04); ··· 337 316 features->type == WACOM_MO) { 338 317 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); 339 318 rw = (data[7] & 0x04) - (data[7] & 0x03); 319 + } else if (features->type == GRAPHIRE_BT) { 320 + /* Compute distance between mouse and tablet */ 321 + rw = 44 - (data[6] >> 2); 322 + rw = clamp_val(rw, 0, 31); 323 + input_report_abs(input, ABS_DISTANCE, rw); 324 + if (((data[1] >> 5) & 3) == 2) { 325 + /* Mouse with wheel */ 326 + input_report_key(input, BTN_MIDDLE, 327 + data[1] & 0x04); 328 + rw = (data[6] & 0x01) ? -1 : 329 + (data[6] & 0x02) ? 1 : 0; 330 + } else { 331 + rw = 0; 332 + } 340 333 } else { 341 334 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); 342 335 rw = -(signed char)data[6]; ··· 362 327 wacom->id[0] = 0; 363 328 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ 364 329 input_report_key(input, wacom->tool[0], prox); 365 - input_event(input, EV_MSC, MSC_SERIAL, 1); 366 330 input_sync(input); /* sync last event */ 367 331 } 368 332 ··· 371 337 prox = data[7] & 0xf8; 372 338 if (prox || wacom->id[1]) { 373 339 wacom->id[1] = PAD_DEVICE_ID; 374 - input_report_key(input, BTN_BACK, (data[7] & 0x40)); 375 - input_report_key(input, BTN_FORWARD, (data[7] & 0x80)); 340 + input_report_key(pad_input, BTN_BACK, (data[7] & 0x40)); 341 + input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80)); 376 342 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); 377 - input_report_rel(input, REL_WHEEL, rw); 343 + input_report_rel(pad_input, REL_WHEEL, rw); 378 344 if (!prox) 379 345 wacom->id[1] = 0; 380 - input_report_abs(input, ABS_MISC, wacom->id[1]); 381 - input_event(input, EV_MSC, MSC_SERIAL, 0xf0); 346 + input_report_abs(pad_input, ABS_MISC, wacom->id[1]); 382 347 retval = 1; 383 348 } 384 349 break; ··· 386 353 prox = (data[7] & 0xf8) || data[8]; 387 354 if (prox || wacom->id[1]) { 388 355 wacom->id[1] = PAD_DEVICE_ID; 389 - input_report_key(input, BTN_BACK, (data[7] & 0x08)); 390 - input_report_key(input, BTN_LEFT, (data[7] & 0x20)); 391 - input_report_key(input, BTN_FORWARD, (data[7] & 0x10)); 392 - input_report_key(input, BTN_RIGHT, (data[7] & 0x40)); 393 - input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f)); 356 + input_report_key(pad_input, BTN_BACK, (data[7] & 0x08)); 357 + input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20)); 358 + input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10)); 359 + input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40)); 360 + input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f)); 394 361 if (!prox) 395 362 wacom->id[1] = 0; 396 - input_report_abs(input, ABS_MISC, wacom->id[1]); 397 - input_event(input, EV_MSC, MSC_SERIAL, 0xf0); 363 + input_report_abs(pad_input, ABS_MISC, wacom->id[1]); 398 364 retval = 1; 399 365 } 400 366 break; 367 + case GRAPHIRE_BT: 368 + prox = data[7] & 0x03; 369 + if (prox || wacom->id[1]) { 370 + wacom->id[1] = PAD_DEVICE_ID; 371 + input_report_key(pad_input, BTN_0, (data[7] & 0x02)); 372 + input_report_key(pad_input, BTN_1, (data[7] & 0x01)); 373 + if (!prox) 374 + wacom->id[1] = 0; 375 + input_report_abs(pad_input, ABS_MISC, wacom->id[1]); 376 + retval = 1; 377 + } 378 + break; 379 + } 380 + 381 + /* Store current battery capacity and power supply state */ 382 + if (features->type == GRAPHIRE_BT) { 383 + rw = (data[7] >> 2 & 0x07); 384 + battery_capacity = batcap_gr[rw]; 385 + ps_connected = rw == 7; 386 + if ((wacom->battery_capacity != battery_capacity) || 387 + (wacom->ps_connected != ps_connected)) { 388 + wacom->battery_capacity = battery_capacity; 389 + wacom->ps_connected = ps_connected; 390 + wacom_notify_battery(wacom); 391 + } 401 392 } 402 393 exit: 403 394 return retval; ··· 641 584 642 585 /* pad packets. Works as a second tool and is always in prox */ 643 586 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) { 587 + input = wacom->pad_input; 644 588 if (features->type >= INTUOS4S && features->type <= INTUOS4L) { 645 589 input_report_key(input, BTN_0, (data[2] & 0x01)); 646 590 input_report_key(input, BTN_1, (data[3] & 0x01)); ··· 831 773 input_report_abs(input, ABS_MISC, 0); 832 774 } 833 775 } 834 - input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); 835 776 return 1; 836 777 } 837 778 ··· 956 899 int y = y2 - y1; 957 900 958 901 return int_sqrt(x*x + y*y); 902 + } 903 + 904 + static void wacom_intuos_bt_process_data(struct wacom_wac *wacom, 905 + unsigned char *data) 906 + { 907 + memcpy(wacom->data, data, 10); 908 + wacom_intuos_irq(wacom); 909 + 910 + input_sync(wacom->input); 911 + if (wacom->pad_input) 912 + input_sync(wacom->pad_input); 913 + } 914 + 915 + static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) 916 + { 917 + unsigned char data[WACOM_PKGLEN_MAX]; 918 + int i = 1; 919 + unsigned power_raw, battery_capacity, bat_charging, ps_connected; 920 + 921 + memcpy(data, wacom->data, len); 922 + 923 + switch (data[0]) { 924 + case 0x04: 925 + wacom_intuos_bt_process_data(wacom, data + i); 926 + i += 10; 927 + /* fall through */ 928 + case 0x03: 929 + wacom_intuos_bt_process_data(wacom, data + i); 930 + i += 10; 931 + wacom_intuos_bt_process_data(wacom, data + i); 932 + i += 10; 933 + power_raw = data[i]; 934 + bat_charging = (power_raw & 0x08) ? 1 : 0; 935 + ps_connected = (power_raw & 0x10) ? 1 : 0; 936 + battery_capacity = batcap_i4[power_raw & 0x07]; 937 + if ((wacom->battery_capacity != battery_capacity) || 938 + (wacom->bat_charging != bat_charging) || 939 + (wacom->ps_connected != ps_connected)) { 940 + wacom->battery_capacity = battery_capacity; 941 + wacom->bat_charging = bat_charging; 942 + wacom->ps_connected = ps_connected; 943 + wacom_notify_battery(wacom); 944 + } 945 + 946 + break; 947 + default: 948 + dev_dbg(wacom->input->dev.parent, 949 + "Unknown report: %d,%d size:%zu\n", 950 + data[0], data[1], len); 951 + return 0; 952 + } 953 + return 0; 959 954 } 960 955 961 956 static int wacom_24hdt_irq(struct wacom_wac *wacom) ··· 1202 1093 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 1203 1094 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 1204 1095 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 1205 - input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x03) << 8) | data[6]); 1096 + input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]); 1206 1097 input_report_key(input, BTN_TOUCH, data[1] & 0x05); 1207 1098 input_report_key(input, wacom->tool[0], prox); 1208 1099 return 1; ··· 1252 1143 { 1253 1144 struct wacom_features *features = &wacom->features; 1254 1145 struct input_dev *input = wacom->input; 1146 + struct input_dev *pad_input = wacom->pad_input; 1255 1147 unsigned char *data = wacom->data; 1256 1148 int i; 1257 1149 ··· 1287 1177 1288 1178 input_mt_report_pointer_emulation(input, true); 1289 1179 1290 - input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); 1291 - input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); 1292 - input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); 1293 - input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); 1180 + input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0); 1181 + input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0); 1182 + input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0); 1183 + input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0); 1294 1184 1295 - input_sync(input); 1296 - 1297 - return 0; 1185 + return 1; 1298 1186 } 1299 1187 1300 1188 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) ··· 1340 1232 1341 1233 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) 1342 1234 { 1343 - struct input_dev *input = wacom->input; 1235 + struct input_dev *input = wacom->pad_input; 1344 1236 struct wacom_features *features = &wacom->features; 1345 1237 1346 1238 if (features->type == INTUOSHT) { ··· 1377 1269 } 1378 1270 input_mt_report_pointer_emulation(input, true); 1379 1271 1380 - input_sync(input); 1381 - 1382 - return 0; 1272 + return 1; 1383 1273 } 1384 1274 1385 1275 static int wacom_bpt_pen(struct wacom_wac *wacom) ··· 1481 1375 1482 1376 connected = data[1] & 0x01; 1483 1377 if (connected) { 1484 - int pid, battery; 1378 + int pid, battery, ps_connected; 1485 1379 1486 1380 if ((wacom->shared->type == INTUOSHT) && 1487 1381 wacom->shared->touch_max) { ··· 1491 1385 } 1492 1386 1493 1387 pid = get_unaligned_be16(&data[6]); 1494 - battery = data[5] & 0x3f; 1388 + battery = (data[5] & 0x3f) * 100 / 31; 1389 + ps_connected = !!(data[5] & 0x80); 1495 1390 if (wacom->pid != pid) { 1496 1391 wacom->pid = pid; 1497 1392 wacom_schedule_work(wacom); 1498 1393 } 1499 - wacom->battery_capacity = battery; 1394 + 1395 + if (wacom->shared->type && 1396 + (battery != wacom->battery_capacity || 1397 + ps_connected != wacom->ps_connected)) { 1398 + wacom->battery_capacity = battery; 1399 + wacom->ps_connected = ps_connected; 1400 + wacom->bat_charging = ps_connected && 1401 + wacom->battery_capacity < 100; 1402 + wacom_notify_battery(wacom); 1403 + } 1500 1404 } else if (wacom->pid != 0) { 1501 1405 /* disconnected while previously connected */ 1502 1406 wacom->pid = 0; 1503 1407 wacom_schedule_work(wacom); 1504 1408 wacom->battery_capacity = 0; 1409 + wacom->bat_charging = 0; 1410 + wacom->ps_connected = 0; 1505 1411 } 1506 1412 1507 1413 return 0; ··· 1534 1416 1535 1417 case WACOM_G4: 1536 1418 case GRAPHIRE: 1419 + case GRAPHIRE_BT: 1537 1420 case WACOM_MO: 1538 1421 sync = wacom_graphire_irq(wacom_wac); 1539 1422 break; ··· 1567 1448 case DTK: 1568 1449 case CINTIQ_HYBRID: 1569 1450 sync = wacom_intuos_irq(wacom_wac); 1451 + break; 1452 + 1453 + case INTUOS4WL: 1454 + sync = wacom_intuos_bt_irq(wacom_wac, len); 1570 1455 break; 1571 1456 1572 1457 case WACOM_24HDT: ··· 1612 1489 break; 1613 1490 } 1614 1491 1615 - if (sync) 1492 + if (sync) { 1616 1493 input_sync(wacom_wac->input); 1494 + if (wacom_wac->pad_input) 1495 + input_sync(wacom_wac->pad_input); 1496 + } 1617 1497 } 1618 1498 1619 1499 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) ··· 1691 1565 features->quirks |= WACOM_QUIRK_NO_INPUT; 1692 1566 1693 1567 /* must be monitor interface if no device_type set */ 1694 - if (!features->device_type) 1568 + if (!features->device_type) { 1695 1569 features->quirks |= WACOM_QUIRK_MONITOR; 1570 + features->quirks |= WACOM_QUIRK_BATTERY; 1571 + } 1696 1572 } 1697 1573 } 1698 1574 ··· 1743 1615 struct wacom_wac *wacom_wac) 1744 1616 { 1745 1617 struct wacom_features *features = &wacom_wac->features; 1746 - int i; 1747 1618 1748 1619 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 1749 1620 ··· 1757 1630 /* fall through */ 1758 1631 1759 1632 case WACOM_G4: 1760 - input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1761 - 1762 - __set_bit(BTN_BACK, input_dev->keybit); 1763 - __set_bit(BTN_FORWARD, input_dev->keybit); 1764 1633 /* fall through */ 1765 1634 1766 1635 case GRAPHIRE: ··· 1775 1652 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1776 1653 break; 1777 1654 1655 + case GRAPHIRE_BT: 1656 + __clear_bit(ABS_MISC, input_dev->absbit); 1657 + input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1658 + features->distance_max, 1659 + 0, 0); 1660 + 1661 + input_set_capability(input_dev, EV_REL, REL_WHEEL); 1662 + 1663 + __set_bit(BTN_LEFT, input_dev->keybit); 1664 + __set_bit(BTN_RIGHT, input_dev->keybit); 1665 + __set_bit(BTN_MIDDLE, input_dev->keybit); 1666 + 1667 + __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1668 + __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1669 + __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); 1670 + __set_bit(BTN_STYLUS, input_dev->keybit); 1671 + __set_bit(BTN_STYLUS2, input_dev->keybit); 1672 + 1673 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1674 + break; 1675 + 1778 1676 case WACOM_24HD: 1779 - __set_bit(BTN_A, input_dev->keybit); 1780 - __set_bit(BTN_B, input_dev->keybit); 1781 - __set_bit(BTN_C, input_dev->keybit); 1782 - __set_bit(BTN_X, input_dev->keybit); 1783 - __set_bit(BTN_Y, input_dev->keybit); 1784 - __set_bit(BTN_Z, input_dev->keybit); 1785 - 1786 - for (i = 6; i < 10; i++) 1787 - __set_bit(BTN_0 + i, input_dev->keybit); 1788 - 1789 - __set_bit(KEY_PROG1, input_dev->keybit); 1790 - __set_bit(KEY_PROG2, input_dev->keybit); 1791 - __set_bit(KEY_PROG3, input_dev->keybit); 1792 - 1793 1677 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1794 1678 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); 1795 1679 /* fall through */ 1796 1680 1797 1681 case DTK: 1798 - for (i = 0; i < 6; i++) 1799 - __set_bit(BTN_0 + i, input_dev->keybit); 1800 - 1801 1682 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 1802 1683 1803 1684 wacom_setup_cintiq(wacom_wac); 1804 1685 break; 1805 1686 1806 1687 case WACOM_22HD: 1807 - __set_bit(KEY_PROG1, input_dev->keybit); 1808 - __set_bit(KEY_PROG2, input_dev->keybit); 1809 - __set_bit(KEY_PROG3, input_dev->keybit); 1810 - /* fall through */ 1811 - 1812 1688 case WACOM_21UX2: 1813 - __set_bit(BTN_A, input_dev->keybit); 1814 - __set_bit(BTN_B, input_dev->keybit); 1815 - __set_bit(BTN_C, input_dev->keybit); 1816 - __set_bit(BTN_X, input_dev->keybit); 1817 - __set_bit(BTN_Y, input_dev->keybit); 1818 - __set_bit(BTN_Z, input_dev->keybit); 1819 - __set_bit(BTN_BASE, input_dev->keybit); 1820 - __set_bit(BTN_BASE2, input_dev->keybit); 1821 - /* fall through */ 1822 - 1823 1689 case WACOM_BEE: 1824 - __set_bit(BTN_8, input_dev->keybit); 1825 - __set_bit(BTN_9, input_dev->keybit); 1826 - /* fall through */ 1827 - 1828 1690 case CINTIQ: 1829 - for (i = 0; i < 8; i++) 1830 - __set_bit(BTN_0 + i, input_dev->keybit); 1831 - 1832 - input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 1833 - input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 1834 1691 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1835 1692 1836 1693 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); ··· 1819 1716 break; 1820 1717 1821 1718 case WACOM_13HD: 1822 - for (i = 0; i < 9; i++) 1823 - __set_bit(BTN_0 + i, input_dev->keybit); 1824 - 1825 1719 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1826 1720 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 1827 1721 wacom_setup_cintiq(wacom_wac); ··· 1826 1726 1827 1727 case INTUOS3: 1828 1728 case INTUOS3L: 1829 - __set_bit(BTN_4, input_dev->keybit); 1830 - __set_bit(BTN_5, input_dev->keybit); 1831 - __set_bit(BTN_6, input_dev->keybit); 1832 - __set_bit(BTN_7, input_dev->keybit); 1833 - 1834 - input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 1835 - /* fall through */ 1836 - 1837 1729 case INTUOS3S: 1838 - __set_bit(BTN_0, input_dev->keybit); 1839 - __set_bit(BTN_1, input_dev->keybit); 1840 - __set_bit(BTN_2, input_dev->keybit); 1841 - __set_bit(BTN_3, input_dev->keybit); 1842 - 1843 - input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 1844 1730 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1845 1731 /* fall through */ 1846 1732 ··· 1840 1754 case INTUOS5L: 1841 1755 case INTUOSPM: 1842 1756 case INTUOSPL: 1843 - if (features->device_type == BTN_TOOL_PEN) { 1844 - __set_bit(BTN_7, input_dev->keybit); 1845 - __set_bit(BTN_8, input_dev->keybit); 1846 - } 1847 - /* fall through */ 1848 - 1849 1757 case INTUOS5S: 1850 1758 case INTUOSPS: 1851 1759 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1852 1760 1853 1761 if (features->device_type == BTN_TOOL_PEN) { 1854 - for (i = 0; i < 7; i++) 1855 - __set_bit(BTN_0 + i, input_dev->keybit); 1856 - 1857 1762 input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1858 1763 features->distance_max, 1859 1764 0, 0); ··· 1864 1787 break; 1865 1788 1866 1789 case INTUOS4: 1790 + case INTUOS4WL: 1867 1791 case INTUOS4L: 1868 - __set_bit(BTN_7, input_dev->keybit); 1869 - __set_bit(BTN_8, input_dev->keybit); 1870 - /* fall through */ 1871 - 1872 1792 case INTUOS4S: 1873 - for (i = 0; i < 7; i++) 1874 - __set_bit(BTN_0 + i, input_dev->keybit); 1875 - 1876 1793 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1877 1794 wacom_setup_intuos(wacom_wac); 1878 1795 ··· 1910 1839 case DTUS: 1911 1840 case PL: 1912 1841 case DTU: 1913 - if (features->type == DTUS) { 1914 - input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1915 - for (i = 0; i < 4; i++) 1916 - __set_bit(BTN_0 + i, input_dev->keybit); 1917 - } 1918 1842 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1919 1843 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1920 1844 __set_bit(BTN_STYLUS, input_dev->keybit); ··· 1942 1876 __clear_bit(ABS_MISC, input_dev->absbit); 1943 1877 1944 1878 if (features->device_type == BTN_TOOL_FINGER) { 1945 - 1946 - __set_bit(BTN_LEFT, input_dev->keybit); 1947 - __set_bit(BTN_FORWARD, input_dev->keybit); 1948 - __set_bit(BTN_BACK, input_dev->keybit); 1949 - __set_bit(BTN_RIGHT, input_dev->keybit); 1950 1879 1951 1880 if (features->touch_max) { 1952 1881 /* touch interface */ ··· 1980 1919 break; 1981 1920 1982 1921 case CINTIQ_HYBRID: 1983 - __set_bit(BTN_1, input_dev->keybit); 1984 - __set_bit(BTN_2, input_dev->keybit); 1985 - __set_bit(BTN_3, input_dev->keybit); 1986 - __set_bit(BTN_4, input_dev->keybit); 1987 - 1988 - __set_bit(BTN_5, input_dev->keybit); 1989 - __set_bit(BTN_6, input_dev->keybit); 1990 - __set_bit(BTN_7, input_dev->keybit); 1991 - __set_bit(BTN_8, input_dev->keybit); 1992 - __set_bit(BTN_0, input_dev->keybit); 1993 - 1994 1922 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1995 1923 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 1996 1924 ··· 1989 1939 return 0; 1990 1940 } 1991 1941 1942 + int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, 1943 + struct wacom_wac *wacom_wac) 1944 + { 1945 + struct wacom_features *features = &wacom_wac->features; 1946 + int i; 1947 + 1948 + input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 1949 + 1950 + /* kept for making legacy xf86-input-wacom working with the wheels */ 1951 + __set_bit(ABS_MISC, input_dev->absbit); 1952 + 1953 + /* kept for making legacy xf86-input-wacom accepting the pad */ 1954 + input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0); 1955 + input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); 1956 + 1957 + switch (features->type) { 1958 + case GRAPHIRE_BT: 1959 + __set_bit(BTN_0, input_dev->keybit); 1960 + __set_bit(BTN_1, input_dev->keybit); 1961 + break; 1962 + 1963 + case WACOM_MO: 1964 + __set_bit(BTN_BACK, input_dev->keybit); 1965 + __set_bit(BTN_LEFT, input_dev->keybit); 1966 + __set_bit(BTN_FORWARD, input_dev->keybit); 1967 + __set_bit(BTN_RIGHT, input_dev->keybit); 1968 + input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 1969 + break; 1970 + 1971 + case WACOM_G4: 1972 + __set_bit(BTN_BACK, input_dev->keybit); 1973 + __set_bit(BTN_LEFT, input_dev->keybit); 1974 + __set_bit(BTN_FORWARD, input_dev->keybit); 1975 + __set_bit(BTN_RIGHT, input_dev->keybit); 1976 + input_set_capability(input_dev, EV_REL, REL_WHEEL); 1977 + break; 1978 + 1979 + case WACOM_24HD: 1980 + __set_bit(BTN_A, input_dev->keybit); 1981 + __set_bit(BTN_B, input_dev->keybit); 1982 + __set_bit(BTN_C, input_dev->keybit); 1983 + __set_bit(BTN_X, input_dev->keybit); 1984 + __set_bit(BTN_Y, input_dev->keybit); 1985 + __set_bit(BTN_Z, input_dev->keybit); 1986 + 1987 + for (i = 0; i < 10; i++) 1988 + __set_bit(BTN_0 + i, input_dev->keybit); 1989 + 1990 + __set_bit(KEY_PROG1, input_dev->keybit); 1991 + __set_bit(KEY_PROG2, input_dev->keybit); 1992 + __set_bit(KEY_PROG3, input_dev->keybit); 1993 + 1994 + input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 1995 + input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); 1996 + break; 1997 + 1998 + case DTK: 1999 + for (i = 0; i < 6; i++) 2000 + __set_bit(BTN_0 + i, input_dev->keybit); 2001 + 2002 + break; 2003 + 2004 + case WACOM_22HD: 2005 + __set_bit(KEY_PROG1, input_dev->keybit); 2006 + __set_bit(KEY_PROG2, input_dev->keybit); 2007 + __set_bit(KEY_PROG3, input_dev->keybit); 2008 + /* fall through */ 2009 + 2010 + case WACOM_21UX2: 2011 + __set_bit(BTN_A, input_dev->keybit); 2012 + __set_bit(BTN_B, input_dev->keybit); 2013 + __set_bit(BTN_C, input_dev->keybit); 2014 + __set_bit(BTN_X, input_dev->keybit); 2015 + __set_bit(BTN_Y, input_dev->keybit); 2016 + __set_bit(BTN_Z, input_dev->keybit); 2017 + __set_bit(BTN_BASE, input_dev->keybit); 2018 + __set_bit(BTN_BASE2, input_dev->keybit); 2019 + /* fall through */ 2020 + 2021 + case WACOM_BEE: 2022 + __set_bit(BTN_8, input_dev->keybit); 2023 + __set_bit(BTN_9, input_dev->keybit); 2024 + /* fall through */ 2025 + 2026 + case CINTIQ: 2027 + for (i = 0; i < 8; i++) 2028 + __set_bit(BTN_0 + i, input_dev->keybit); 2029 + 2030 + input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 2031 + input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 2032 + break; 2033 + 2034 + case WACOM_13HD: 2035 + for (i = 0; i < 9; i++) 2036 + __set_bit(BTN_0 + i, input_dev->keybit); 2037 + 2038 + input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 2039 + break; 2040 + 2041 + case INTUOS3: 2042 + case INTUOS3L: 2043 + __set_bit(BTN_4, input_dev->keybit); 2044 + __set_bit(BTN_5, input_dev->keybit); 2045 + __set_bit(BTN_6, input_dev->keybit); 2046 + __set_bit(BTN_7, input_dev->keybit); 2047 + 2048 + input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 2049 + /* fall through */ 2050 + 2051 + case INTUOS3S: 2052 + __set_bit(BTN_0, input_dev->keybit); 2053 + __set_bit(BTN_1, input_dev->keybit); 2054 + __set_bit(BTN_2, input_dev->keybit); 2055 + __set_bit(BTN_3, input_dev->keybit); 2056 + 2057 + input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 2058 + break; 2059 + 2060 + case INTUOS5: 2061 + case INTUOS5L: 2062 + case INTUOSPM: 2063 + case INTUOSPL: 2064 + __set_bit(BTN_7, input_dev->keybit); 2065 + __set_bit(BTN_8, input_dev->keybit); 2066 + /* fall through */ 2067 + 2068 + case INTUOS5S: 2069 + case INTUOSPS: 2070 + /* touch interface does not have the pad device */ 2071 + if (features->device_type != BTN_TOOL_PEN) 2072 + return 1; 2073 + 2074 + for (i = 0; i < 7; i++) 2075 + __set_bit(BTN_0 + i, input_dev->keybit); 2076 + 2077 + input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 2078 + break; 2079 + 2080 + case INTUOS4WL: 2081 + /* 2082 + * For Bluetooth devices, the udev rule does not work correctly 2083 + * for pads unless we add a stylus capability, which forces 2084 + * ID_INPUT_TABLET to be set. 2085 + */ 2086 + __set_bit(BTN_STYLUS, input_dev->keybit); 2087 + /* fall through */ 2088 + 2089 + case INTUOS4: 2090 + case INTUOS4L: 2091 + __set_bit(BTN_7, input_dev->keybit); 2092 + __set_bit(BTN_8, input_dev->keybit); 2093 + /* fall through */ 2094 + 2095 + case INTUOS4S: 2096 + for (i = 0; i < 7; i++) 2097 + __set_bit(BTN_0 + i, input_dev->keybit); 2098 + 2099 + input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 2100 + break; 2101 + 2102 + case CINTIQ_HYBRID: 2103 + for (i = 0; i < 9; i++) 2104 + __set_bit(BTN_0 + i, input_dev->keybit); 2105 + 2106 + break; 2107 + 2108 + case DTUS: 2109 + for (i = 0; i < 4; i++) 2110 + __set_bit(BTN_0 + i, input_dev->keybit); 2111 + break; 2112 + 2113 + case INTUOSHT: 2114 + case BAMBOO_PT: 2115 + /* pad device is on the touch interface */ 2116 + if (features->device_type != BTN_TOOL_FINGER) 2117 + return 1; 2118 + 2119 + __clear_bit(ABS_MISC, input_dev->absbit); 2120 + 2121 + __set_bit(BTN_LEFT, input_dev->keybit); 2122 + __set_bit(BTN_FORWARD, input_dev->keybit); 2123 + __set_bit(BTN_BACK, input_dev->keybit); 2124 + __set_bit(BTN_RIGHT, input_dev->keybit); 2125 + 2126 + break; 2127 + 2128 + default: 2129 + /* no pad supported */ 2130 + return 1; 2131 + } 2132 + return 0; 2133 + } 2134 + 1992 2135 static const struct wacom_features wacom_features_0x00 = 1993 - { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 1994 - 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; 2136 + { "Wacom Penpartner", 5040, 3780, 255, 0, 2137 + PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; 1995 2138 static const struct wacom_features wacom_features_0x10 = 1996 - { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 1997 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2139 + { "Wacom Graphire", 10206, 7422, 511, 63, 2140 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2141 + static const struct wacom_features wacom_features_0x81 = 2142 + { "Wacom Graphire BT", 16704, 12064, 511, 32, 2143 + GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 1998 2144 static const struct wacom_features wacom_features_0x11 = 1999 - { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 2000 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2145 + { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, 2146 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2001 2147 static const struct wacom_features wacom_features_0x12 = 2002 - { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 2003 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2148 + { "Wacom Graphire2 5x7", 13918, 10206, 511, 63, 2149 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2004 2150 static const struct wacom_features wacom_features_0x13 = 2005 - { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 2006 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2151 + { "Wacom Graphire3", 10208, 7424, 511, 63, 2152 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2007 2153 static const struct wacom_features wacom_features_0x14 = 2008 - { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 2009 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2154 + { "Wacom Graphire3 6x8", 16704, 12064, 511, 63, 2155 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2010 2156 static const struct wacom_features wacom_features_0x15 = 2011 - { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 2012 - 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2157 + { "Wacom Graphire4 4x5", 10208, 7424, 511, 63, 2158 + WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2013 2159 static const struct wacom_features wacom_features_0x16 = 2014 - { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 2015 - 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2160 + { "Wacom Graphire4 6x8", 16704, 12064, 511, 63, 2161 + WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2016 2162 static const struct wacom_features wacom_features_0x17 = 2017 - { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 2018 - 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2163 + { "Wacom BambooFun 4x5", 14760, 9225, 511, 63, 2164 + WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2019 2165 static const struct wacom_features wacom_features_0x18 = 2020 - { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 2021 - 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2166 + { "Wacom BambooFun 6x8", 21648, 13530, 511, 63, 2167 + WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2022 2168 static const struct wacom_features wacom_features_0x19 = 2023 - { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 2024 - 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2169 + { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63, 2170 + GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; 2025 2171 static const struct wacom_features wacom_features_0x60 = 2026 - { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 2027 - 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2172 + { "Wacom Volito", 5104, 3712, 511, 63, 2173 + GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2028 2174 static const struct wacom_features wacom_features_0x61 = 2029 - { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 2030 - 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2175 + { "Wacom PenStation2", 3250, 2320, 255, 63, 2176 + GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2031 2177 static const struct wacom_features wacom_features_0x62 = 2032 - { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 2033 - 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2178 + { "Wacom Volito2 4x5", 5104, 3712, 511, 63, 2179 + GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2034 2180 static const struct wacom_features wacom_features_0x63 = 2035 - { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 2036 - 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2181 + { "Wacom Volito2 2x3", 3248, 2320, 511, 63, 2182 + GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2037 2183 static const struct wacom_features wacom_features_0x64 = 2038 - { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 2039 - 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2184 + { "Wacom PenPartner2", 3250, 2320, 511, 63, 2185 + GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; 2040 2186 static const struct wacom_features wacom_features_0x65 = 2041 - { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 2042 - 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2187 + { "Wacom Bamboo", 14760, 9225, 511, 63, 2188 + WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2043 2189 static const struct wacom_features wacom_features_0x69 = 2044 - { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 2045 - 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; 2190 + { "Wacom Bamboo1", 5104, 3712, 511, 63, 2191 + GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; 2046 2192 static const struct wacom_features wacom_features_0x6A = 2047 - { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023, 2048 - 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2193 + { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63, 2194 + GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2049 2195 static const struct wacom_features wacom_features_0x6B = 2050 - { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023, 2051 - 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2196 + { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63, 2197 + GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2052 2198 static const struct wacom_features wacom_features_0x20 = 2053 - { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 2054 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2199 + { "Wacom Intuos 4x5", 12700, 10600, 1023, 31, 2200 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2055 2201 static const struct wacom_features wacom_features_0x21 = 2056 - { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 2057 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2202 + { "Wacom Intuos 6x8", 20320, 16240, 1023, 31, 2203 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2058 2204 static const struct wacom_features wacom_features_0x22 = 2059 - { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 2060 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2205 + { "Wacom Intuos 9x12", 30480, 24060, 1023, 31, 2206 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2061 2207 static const struct wacom_features wacom_features_0x23 = 2062 - { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 2063 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2208 + { "Wacom Intuos 12x12", 30480, 31680, 1023, 31, 2209 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2064 2210 static const struct wacom_features wacom_features_0x24 = 2065 - { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 2066 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2211 + { "Wacom Intuos 12x18", 45720, 31680, 1023, 31, 2212 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2067 2213 static const struct wacom_features wacom_features_0x30 = 2068 - { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 2069 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2214 + { "Wacom PL400", 5408, 4056, 255, 0, 2215 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2070 2216 static const struct wacom_features wacom_features_0x31 = 2071 - { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 2072 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2217 + { "Wacom PL500", 6144, 4608, 255, 0, 2218 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2073 2219 static const struct wacom_features wacom_features_0x32 = 2074 - { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 2075 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2220 + { "Wacom PL600", 6126, 4604, 255, 0, 2221 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2076 2222 static const struct wacom_features wacom_features_0x33 = 2077 - { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 2078 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2223 + { "Wacom PL600SX", 6260, 5016, 255, 0, 2224 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2079 2225 static const struct wacom_features wacom_features_0x34 = 2080 - { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 2081 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2226 + { "Wacom PL550", 6144, 4608, 511, 0, 2227 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2082 2228 static const struct wacom_features wacom_features_0x35 = 2083 - { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 2084 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2229 + { "Wacom PL800", 7220, 5780, 511, 0, 2230 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2085 2231 static const struct wacom_features wacom_features_0x37 = 2086 - { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 2087 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2232 + { "Wacom PL700", 6758, 5406, 511, 0, 2233 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2088 2234 static const struct wacom_features wacom_features_0x38 = 2089 - { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 2090 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2235 + { "Wacom PL510", 6282, 4762, 511, 0, 2236 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2091 2237 static const struct wacom_features wacom_features_0x39 = 2092 - { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 2093 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2238 + { "Wacom DTU710", 34080, 27660, 511, 0, 2239 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2094 2240 static const struct wacom_features wacom_features_0xC4 = 2095 - { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 2096 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2241 + { "Wacom DTF521", 6282, 4762, 511, 0, 2242 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2097 2243 static const struct wacom_features wacom_features_0xC0 = 2098 - { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 2099 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2244 + { "Wacom DTF720", 6858, 5506, 511, 0, 2245 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2100 2246 static const struct wacom_features wacom_features_0xC2 = 2101 - { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 2102 - 0, PL, WACOM_PL_RES, WACOM_PL_RES }; 2247 + { "Wacom DTF720a", 6858, 5506, 511, 0, 2248 + PL, WACOM_PL_RES, WACOM_PL_RES }; 2103 2249 static const struct wacom_features wacom_features_0x03 = 2104 - { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 2105 - 0, PTU, WACOM_PL_RES, WACOM_PL_RES }; 2250 + { "Wacom Cintiq Partner", 20480, 15360, 511, 0, 2251 + PTU, WACOM_PL_RES, WACOM_PL_RES }; 2106 2252 static const struct wacom_features wacom_features_0x41 = 2107 - { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 2108 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2253 + { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31, 2254 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2109 2255 static const struct wacom_features wacom_features_0x42 = 2110 - { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 2111 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2256 + { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, 2257 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2112 2258 static const struct wacom_features wacom_features_0x43 = 2113 - { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 2114 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2259 + { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31, 2260 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2115 2261 static const struct wacom_features wacom_features_0x44 = 2116 - { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 2117 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2262 + { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31, 2263 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2118 2264 static const struct wacom_features wacom_features_0x45 = 2119 - { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 2120 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2265 + { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31, 2266 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2121 2267 static const struct wacom_features wacom_features_0xB0 = 2122 - { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 2123 - 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2268 + { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63, 2269 + INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2124 2270 static const struct wacom_features wacom_features_0xB1 = 2125 - { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 2126 - 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2271 + { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63, 2272 + INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2127 2273 static const struct wacom_features wacom_features_0xB2 = 2128 - { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 2129 - 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2274 + { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63, 2275 + INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2130 2276 static const struct wacom_features wacom_features_0xB3 = 2131 - { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 2132 - 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2277 + { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63, 2278 + INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2133 2279 static const struct wacom_features wacom_features_0xB4 = 2134 - { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 2135 - 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2280 + { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63, 2281 + INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2136 2282 static const struct wacom_features wacom_features_0xB5 = 2137 - { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 2138 - 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2283 + { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63, 2284 + INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2139 2285 static const struct wacom_features wacom_features_0xB7 = 2140 - { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 2141 - 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2286 + { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63, 2287 + INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2142 2288 static const struct wacom_features wacom_features_0xB8 = 2143 - { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 2144 - 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2289 + { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63, 2290 + INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2145 2291 static const struct wacom_features wacom_features_0xB9 = 2146 - { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 2147 - 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2292 + { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63, 2293 + INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2148 2294 static const struct wacom_features wacom_features_0xBA = 2149 - { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 2150 - 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2295 + { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63, 2296 + INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2151 2297 static const struct wacom_features wacom_features_0xBB = 2152 - { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 2153 - 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2298 + { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63, 2299 + INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2154 2300 static const struct wacom_features wacom_features_0xBC = 2155 - { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40640, 25400, 2047, 2156 - 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2301 + { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, 2302 + INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2303 + static const struct wacom_features wacom_features_0xBD = 2304 + { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, 2305 + INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2157 2306 static const struct wacom_features wacom_features_0x26 = 2158 - { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 2159 - 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2160 - .touch_max = 16 }; 2307 + { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63, 2308 + INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 }; 2161 2309 static const struct wacom_features wacom_features_0x27 = 2162 - { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 2163 - 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2164 - .touch_max = 16 }; 2310 + { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63, 2311 + INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 }; 2165 2312 static const struct wacom_features wacom_features_0x28 = 2166 - { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 2167 - 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2168 - .touch_max = 16 }; 2313 + { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63, 2314 + INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 }; 2169 2315 static const struct wacom_features wacom_features_0x29 = 2170 - { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 2171 - 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2316 + { "Wacom Intuos5 S", 31496, 19685, 2047, 63, 2317 + INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2172 2318 static const struct wacom_features wacom_features_0x2A = 2173 - { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 2174 - 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2319 + { "Wacom Intuos5 M", 44704, 27940, 2047, 63, 2320 + INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2175 2321 static const struct wacom_features wacom_features_0x314 = 2176 - { "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 2177 - 63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2178 - .touch_max = 16 }; 2322 + { "Wacom Intuos Pro S", 31496, 19685, 2047, 63, 2323 + INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16, 2324 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2179 2325 static const struct wacom_features wacom_features_0x315 = 2180 - { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 2181 - 63, INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2182 - .touch_max = 16 }; 2326 + { "Wacom Intuos Pro M", 44704, 27940, 2047, 63, 2327 + INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16, 2328 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2183 2329 static const struct wacom_features wacom_features_0x317 = 2184 - { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 2185 - 63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2186 - .touch_max = 16 }; 2330 + { "Wacom Intuos Pro L", 65024, 40640, 2047, 63, 2331 + INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16, 2332 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2187 2333 static const struct wacom_features wacom_features_0xF4 = 2188 - { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104280, 65400, 2047, 2189 - 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2334 + { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63, 2335 + WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2190 2336 static const struct wacom_features wacom_features_0xF8 = 2191 - { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104280, 65400, 2047, /* Pen */ 2192 - 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2337 + { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */ 2338 + WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2193 2339 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; 2194 2340 static const struct wacom_features wacom_features_0xF6 = 2195 2341 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */ 2196 - .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10 }; 2342 + .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, 2343 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2197 2344 static const struct wacom_features wacom_features_0x3F = 2198 - { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 2199 - 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2345 + { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63, 2346 + CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2200 2347 static const struct wacom_features wacom_features_0xC5 = 2201 - { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 2202 - 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2348 + { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63, 2349 + WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2203 2350 static const struct wacom_features wacom_features_0xC6 = 2204 - { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 2205 - 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2351 + { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63, 2352 + WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2206 2353 static const struct wacom_features wacom_features_0x304 = 2207 - { "Wacom Cintiq 13HD", WACOM_PKGLEN_INTUOS, 59352, 33648, 1023, 2208 - 63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2354 + { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63, 2355 + WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2209 2356 static const struct wacom_features wacom_features_0xC7 = 2210 - { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 2211 - 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2357 + { "Wacom DTU1931", 37832, 30305, 511, 0, 2358 + PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2212 2359 static const struct wacom_features wacom_features_0xCE = 2213 - { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511, 2214 - 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2360 + { "Wacom DTU2231", 47864, 27011, 511, 0, 2361 + DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2362 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE }; 2215 2363 static const struct wacom_features wacom_features_0xF0 = 2216 - { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511, 2217 - 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2364 + { "Wacom DTU1631", 34623, 19553, 511, 0, 2365 + DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2218 2366 static const struct wacom_features wacom_features_0xFB = 2219 - { "Wacom DTU1031", WACOM_PKGLEN_DTUS, 22096, 13960, 511, 2220 - 0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2367 + { "Wacom DTU1031", 22096, 13960, 511, 0, 2368 + DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2221 2369 static const struct wacom_features wacom_features_0x57 = 2222 - { "Wacom DTK2241", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047, 2223 - 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2370 + { "Wacom DTK2241", 95640, 54060, 2047, 63, 2371 + DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2224 2372 static const struct wacom_features wacom_features_0x59 = /* Pen */ 2225 - { "Wacom DTH2242", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047, 2226 - 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2373 + { "Wacom DTH2242", 95640, 54060, 2047, 63, 2374 + DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2227 2375 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; 2228 2376 static const struct wacom_features wacom_features_0x5D = /* Touch */ 2229 2377 { "Wacom DTH2242", .type = WACOM_24HDT, 2230 - .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10 }; 2378 + .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, 2379 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2231 2380 static const struct wacom_features wacom_features_0xCC = 2232 - { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87000, 65400, 2047, 2233 - 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2381 + { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63, 2382 + WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2234 2383 static const struct wacom_features wacom_features_0xFA = 2235 - { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047, 2236 - 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2384 + { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63, 2385 + WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2237 2386 static const struct wacom_features wacom_features_0x5B = 2238 - { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047, 2239 - 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2387 + { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63, 2388 + WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2240 2389 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; 2241 2390 static const struct wacom_features wacom_features_0x5E = 2242 2391 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT, 2243 - .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10 }; 2392 + .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10, 2393 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2244 2394 static const struct wacom_features wacom_features_0x90 = 2245 - { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2246 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2395 + { "Wacom ISDv4 90", 26202, 16325, 255, 0, 2396 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2247 2397 static const struct wacom_features wacom_features_0x93 = 2248 - { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2249 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2398 + { "Wacom ISDv4 93", 26202, 16325, 255, 0, 2399 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2250 2400 static const struct wacom_features wacom_features_0x97 = 2251 - { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511, 2252 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2401 + { "Wacom ISDv4 97", 26202, 16325, 511, 0, 2402 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2253 2403 static const struct wacom_features wacom_features_0x9A = 2254 - { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2255 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2404 + { "Wacom ISDv4 9A", 26202, 16325, 255, 0, 2405 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2256 2406 static const struct wacom_features wacom_features_0x9F = 2257 - { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2258 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2407 + { "Wacom ISDv4 9F", 26202, 16325, 255, 0, 2408 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2259 2409 static const struct wacom_features wacom_features_0xE2 = 2260 - { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 2261 - 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2262 - .touch_max = 2 }; 2410 + { "Wacom ISDv4 E2", 26202, 16325, 255, 0, 2411 + TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2263 2412 static const struct wacom_features wacom_features_0xE3 = 2264 - { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 2265 - 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2266 - .touch_max = 2 }; 2413 + { "Wacom ISDv4 E3", 26202, 16325, 255, 0, 2414 + TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2267 2415 static const struct wacom_features wacom_features_0xE5 = 2268 - { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255, 2269 - 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2416 + { "Wacom ISDv4 E5", 26202, 16325, 255, 0, 2417 + MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2270 2418 static const struct wacom_features wacom_features_0xE6 = 2271 - { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255, 2272 - 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2273 - .touch_max = 2 }; 2419 + { "Wacom ISDv4 E6", 27760, 15694, 255, 0, 2420 + TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2274 2421 static const struct wacom_features wacom_features_0xEC = 2275 - { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255, 2276 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2422 + { "Wacom ISDv4 EC", 25710, 14500, 255, 0, 2423 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2277 2424 static const struct wacom_features wacom_features_0xED = 2278 - { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2279 - 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2425 + { "Wacom ISDv4 ED", 26202, 16325, 255, 0, 2426 + TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2280 2427 static const struct wacom_features wacom_features_0xEF = 2281 - { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2282 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2428 + { "Wacom ISDv4 EF", 26202, 16325, 255, 0, 2429 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2283 2430 static const struct wacom_features wacom_features_0x100 = 2284 - { "Wacom ISDv4 100", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2285 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2431 + { "Wacom ISDv4 100", 26202, 16325, 255, 0, 2432 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2286 2433 static const struct wacom_features wacom_features_0x101 = 2287 - { "Wacom ISDv4 101", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2288 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2434 + { "Wacom ISDv4 101", 26202, 16325, 255, 0, 2435 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2289 2436 static const struct wacom_features wacom_features_0x10D = 2290 - { "Wacom ISDv4 10D", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2291 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2437 + { "Wacom ISDv4 10D", 26202, 16325, 255, 0, 2438 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2292 2439 static const struct wacom_features wacom_features_0x10E = 2293 - { "Wacom ISDv4 10E", WACOM_PKGLEN_MTTPC, 27760, 15694, 255, 2294 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2440 + { "Wacom ISDv4 10E", 27760, 15694, 255, 0, 2441 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2295 2442 static const struct wacom_features wacom_features_0x10F = 2296 - { "Wacom ISDv4 10F", WACOM_PKGLEN_MTTPC, 27760, 15694, 255, 2297 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2443 + { "Wacom ISDv4 10F", 27760, 15694, 255, 0, 2444 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2298 2445 static const struct wacom_features wacom_features_0x116 = 2299 - { "Wacom ISDv4 116", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 2300 - 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2446 + { "Wacom ISDv4 116", 26202, 16325, 255, 0, 2447 + TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2448 + static const struct wacom_features wacom_features_0x12C = 2449 + { "Wacom ISDv4 12C", 27848, 15752, 2047, 0, 2450 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2301 2451 static const struct wacom_features wacom_features_0x4001 = 2302 - { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2303 - 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2452 + { "Wacom ISDv4 4001", 26202, 16325, 255, 0, 2453 + MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2304 2454 static const struct wacom_features wacom_features_0x4004 = 2305 - { "Wacom ISDv4 4004", WACOM_PKGLEN_MTTPC, 11060, 6220, 255, 2306 - 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2455 + { "Wacom ISDv4 4004", 11060, 6220, 255, 0, 2456 + MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2307 2457 static const struct wacom_features wacom_features_0x5000 = 2308 - { "Wacom ISDv4 5000", WACOM_PKGLEN_MTTPC, 27848, 15752, 1023, 2309 - 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2458 + { "Wacom ISDv4 5000", 27848, 15752, 1023, 0, 2459 + MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2310 2460 static const struct wacom_features wacom_features_0x5002 = 2311 - { "Wacom ISDv4 5002", WACOM_PKGLEN_MTTPC, 29576, 16724, 1023, 2312 - 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2461 + { "Wacom ISDv4 5002", 29576, 16724, 1023, 0, 2462 + MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2313 2463 static const struct wacom_features wacom_features_0x47 = 2314 - { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 2315 - 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2464 + { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, 2465 + INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2316 2466 static const struct wacom_features wacom_features_0x84 = 2317 - { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0, 2318 - 0, WIRELESS, 0, 0, .touch_max = 16 }; 2467 + { "Wacom Wireless Receiver", 0, 0, 0, 0, 2468 + WIRELESS, 0, 0, .touch_max = 16 }; 2319 2469 static const struct wacom_features wacom_features_0xD0 = 2320 - { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2321 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2322 - .touch_max = 2 }; 2470 + { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31, 2471 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2323 2472 static const struct wacom_features wacom_features_0xD1 = 2324 - { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2325 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2326 - .touch_max = 2 }; 2473 + { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31, 2474 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2327 2475 static const struct wacom_features wacom_features_0xD2 = 2328 - { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2329 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2330 - .touch_max = 2 }; 2476 + { "Wacom Bamboo Craft", 14720, 9200, 1023, 31, 2477 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2331 2478 static const struct wacom_features wacom_features_0xD3 = 2332 - { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, 2333 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2334 - .touch_max = 2 }; 2479 + { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31, 2480 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2335 2481 static const struct wacom_features wacom_features_0xD4 = 2336 - { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2337 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2482 + { "Wacom Bamboo Pen", 14720, 9200, 1023, 31, 2483 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2338 2484 static const struct wacom_features wacom_features_0xD5 = 2339 - { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, 2340 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2485 + { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31, 2486 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2341 2487 static const struct wacom_features wacom_features_0xD6 = 2342 - { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2343 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2344 - .touch_max = 2 }; 2488 + { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31, 2489 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2345 2490 static const struct wacom_features wacom_features_0xD7 = 2346 - { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2347 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2348 - .touch_max = 2 }; 2491 + { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31, 2492 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2349 2493 static const struct wacom_features wacom_features_0xD8 = 2350 - { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, 2351 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2352 - .touch_max = 2 }; 2494 + { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31, 2495 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2353 2496 static const struct wacom_features wacom_features_0xDA = 2354 - { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 2355 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2356 - .touch_max = 2 }; 2497 + { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31, 2498 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2357 2499 static const struct wacom_features wacom_features_0xDB = 2358 - { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, 2359 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2360 - .touch_max = 2 }; 2500 + { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31, 2501 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 2361 2502 static const struct wacom_features wacom_features_0xDD = 2362 - { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, 2363 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2503 + { "Wacom Bamboo Connect", 14720, 9200, 1023, 31, 2504 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2364 2505 static const struct wacom_features wacom_features_0xDE = 2365 - { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, 2366 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2367 - .touch_max = 16 }; 2506 + { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31, 2507 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; 2368 2508 static const struct wacom_features wacom_features_0xDF = 2369 - { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023, 2370 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2371 - .touch_max = 16 }; 2509 + { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31, 2510 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; 2372 2511 static const struct wacom_features wacom_features_0x300 = 2373 - { "Wacom Bamboo One S", WACOM_PKGLEN_BBPEN, 14720, 9225, 1023, 2374 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2512 + { "Wacom Bamboo One S", 14720, 9225, 1023, 31, 2513 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2375 2514 static const struct wacom_features wacom_features_0x301 = 2376 - { "Wacom Bamboo One M", WACOM_PKGLEN_BBPEN, 21648, 13530, 1023, 2377 - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2515 + { "Wacom Bamboo One M", 21648, 13530, 1023, 31, 2516 + BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2378 2517 static const struct wacom_features wacom_features_0x302 = 2379 - { "Wacom Intuos PT S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023, 2380 - 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2381 - .touch_max = 16 }; 2518 + { "Wacom Intuos PT S", 15200, 9500, 1023, 31, 2519 + INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, 2520 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2382 2521 static const struct wacom_features wacom_features_0x303 = 2383 - { "Wacom Intuos PT M", WACOM_PKGLEN_BBPEN, 21600, 13500, 1023, 2384 - 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2385 - .touch_max = 16 }; 2522 + { "Wacom Intuos PT M", 21600, 13500, 1023, 31, 2523 + INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, 2524 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2386 2525 static const struct wacom_features wacom_features_0x30E = 2387 - { "Wacom Intuos S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023, 2388 - 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2526 + { "Wacom Intuos S", 15200, 9500, 1023, 31, 2527 + INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2528 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2389 2529 static const struct wacom_features wacom_features_0x6004 = 2390 - { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 2391 - 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2392 - static const struct wacom_features wacom_features_0x0307 = 2393 - { "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS, 59352, 33648, 2047, 2394 - 63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2530 + { "ISD-V4", 12800, 8000, 255, 0, 2531 + TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2532 + static const struct wacom_features wacom_features_0x307 = 2533 + { "Wacom ISDv5 307", 59352, 33648, 2047, 63, 2534 + CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2395 2535 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; 2396 - static const struct wacom_features wacom_features_0x0309 = 2536 + static const struct wacom_features wacom_features_0x309 = 2397 2537 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */ 2398 - .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10 }; 2538 + .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, 2539 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2399 2540 2400 - #define USB_DEVICE_WACOM(prod) \ 2401 - USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 2402 - .driver_info = (kernel_ulong_t)&wacom_features_##prod 2541 + #define USB_DEVICE_WACOM(prod) \ 2542 + HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ 2543 + .driver_data = (kernel_ulong_t)&wacom_features_##prod 2403 2544 2404 - #define USB_DEVICE_DETAILED(prod, class, sub, proto) \ 2405 - USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \ 2406 - sub, proto), \ 2407 - .driver_info = (kernel_ulong_t)&wacom_features_##prod 2545 + #define BT_DEVICE_WACOM(prod) \ 2546 + HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ 2547 + .driver_data = (kernel_ulong_t)&wacom_features_##prod 2408 2548 2409 2549 #define USB_DEVICE_LENOVO(prod) \ 2410 - USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ 2411 - .driver_info = (kernel_ulong_t)&wacom_features_##prod 2550 + HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ 2551 + .driver_data = (kernel_ulong_t)&wacom_features_##prod 2412 2552 2413 - const struct usb_device_id wacom_ids[] = { 2553 + const struct hid_device_id wacom_ids[] = { 2414 2554 { USB_DEVICE_WACOM(0x00) }, 2555 + { USB_DEVICE_WACOM(0x03) }, 2415 2556 { USB_DEVICE_WACOM(0x10) }, 2416 2557 { USB_DEVICE_WACOM(0x11) }, 2417 2558 { USB_DEVICE_WACOM(0x12) }, ··· 2613 2372 { USB_DEVICE_WACOM(0x17) }, 2614 2373 { USB_DEVICE_WACOM(0x18) }, 2615 2374 { USB_DEVICE_WACOM(0x19) }, 2616 - { USB_DEVICE_WACOM(0x60) }, 2617 - { USB_DEVICE_WACOM(0x61) }, 2618 - { USB_DEVICE_WACOM(0x62) }, 2619 - { USB_DEVICE_WACOM(0x63) }, 2620 - { USB_DEVICE_WACOM(0x64) }, 2621 - { USB_DEVICE_WACOM(0x65) }, 2622 - { USB_DEVICE_WACOM(0x69) }, 2623 - { USB_DEVICE_WACOM(0x6A) }, 2624 - { USB_DEVICE_WACOM(0x6B) }, 2625 2375 { USB_DEVICE_WACOM(0x20) }, 2626 2376 { USB_DEVICE_WACOM(0x21) }, 2627 2377 { USB_DEVICE_WACOM(0x22) }, 2628 2378 { USB_DEVICE_WACOM(0x23) }, 2629 2379 { USB_DEVICE_WACOM(0x24) }, 2380 + { USB_DEVICE_WACOM(0x26) }, 2381 + { USB_DEVICE_WACOM(0x27) }, 2382 + { USB_DEVICE_WACOM(0x28) }, 2383 + { USB_DEVICE_WACOM(0x29) }, 2384 + { USB_DEVICE_WACOM(0x2A) }, 2630 2385 { USB_DEVICE_WACOM(0x30) }, 2631 2386 { USB_DEVICE_WACOM(0x31) }, 2632 2387 { USB_DEVICE_WACOM(0x32) }, ··· 2632 2395 { USB_DEVICE_WACOM(0x37) }, 2633 2396 { USB_DEVICE_WACOM(0x38) }, 2634 2397 { USB_DEVICE_WACOM(0x39) }, 2635 - { USB_DEVICE_WACOM(0xC4) }, 2636 - { USB_DEVICE_WACOM(0xC0) }, 2637 - { USB_DEVICE_WACOM(0xC2) }, 2638 - { USB_DEVICE_WACOM(0x03) }, 2398 + { USB_DEVICE_WACOM(0x3F) }, 2639 2399 { USB_DEVICE_WACOM(0x41) }, 2640 2400 { USB_DEVICE_WACOM(0x42) }, 2641 2401 { USB_DEVICE_WACOM(0x43) }, 2642 2402 { USB_DEVICE_WACOM(0x44) }, 2643 2403 { USB_DEVICE_WACOM(0x45) }, 2404 + { USB_DEVICE_WACOM(0x47) }, 2644 2405 { USB_DEVICE_WACOM(0x57) }, 2645 2406 { USB_DEVICE_WACOM(0x59) }, 2646 - { USB_DEVICE_DETAILED(0x5D, USB_CLASS_HID, 0, 0) }, 2647 2407 { USB_DEVICE_WACOM(0x5B) }, 2648 - { USB_DEVICE_DETAILED(0x5E, USB_CLASS_HID, 0, 0) }, 2408 + { USB_DEVICE_WACOM(0x5D) }, 2409 + { USB_DEVICE_WACOM(0x5E) }, 2410 + { USB_DEVICE_WACOM(0x60) }, 2411 + { USB_DEVICE_WACOM(0x61) }, 2412 + { USB_DEVICE_WACOM(0x62) }, 2413 + { USB_DEVICE_WACOM(0x63) }, 2414 + { USB_DEVICE_WACOM(0x64) }, 2415 + { USB_DEVICE_WACOM(0x65) }, 2416 + { USB_DEVICE_WACOM(0x69) }, 2417 + { USB_DEVICE_WACOM(0x6A) }, 2418 + { USB_DEVICE_WACOM(0x6B) }, 2419 + { BT_DEVICE_WACOM(0x81) }, 2420 + { USB_DEVICE_WACOM(0x84) }, 2421 + { USB_DEVICE_WACOM(0x90) }, 2422 + { USB_DEVICE_WACOM(0x93) }, 2423 + { USB_DEVICE_WACOM(0x97) }, 2424 + { USB_DEVICE_WACOM(0x9A) }, 2425 + { USB_DEVICE_WACOM(0x9F) }, 2649 2426 { USB_DEVICE_WACOM(0xB0) }, 2650 2427 { USB_DEVICE_WACOM(0xB1) }, 2651 2428 { USB_DEVICE_WACOM(0xB2) }, ··· 2672 2421 { USB_DEVICE_WACOM(0xBA) }, 2673 2422 { USB_DEVICE_WACOM(0xBB) }, 2674 2423 { USB_DEVICE_WACOM(0xBC) }, 2675 - { USB_DEVICE_WACOM(0x26) }, 2676 - { USB_DEVICE_WACOM(0x27) }, 2677 - { USB_DEVICE_WACOM(0x28) }, 2678 - { USB_DEVICE_WACOM(0x29) }, 2679 - { USB_DEVICE_WACOM(0x2A) }, 2680 - { USB_DEVICE_WACOM(0x3F) }, 2424 + { BT_DEVICE_WACOM(0xBD) }, 2425 + { USB_DEVICE_WACOM(0xC0) }, 2426 + { USB_DEVICE_WACOM(0xC2) }, 2427 + { USB_DEVICE_WACOM(0xC4) }, 2681 2428 { USB_DEVICE_WACOM(0xC5) }, 2682 2429 { USB_DEVICE_WACOM(0xC6) }, 2683 2430 { USB_DEVICE_WACOM(0xC7) }, 2684 - /* 2685 - * DTU-2231 has two interfaces on the same configuration, 2686 - * only one is used. 2687 - */ 2688 - { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID, 2689 - USB_INTERFACE_SUBCLASS_BOOT, 2690 - USB_INTERFACE_PROTOCOL_MOUSE) }, 2691 - { USB_DEVICE_WACOM(0x84) }, 2431 + { USB_DEVICE_WACOM(0xCC) }, 2432 + { USB_DEVICE_WACOM(0xCE) }, 2692 2433 { USB_DEVICE_WACOM(0xD0) }, 2693 2434 { USB_DEVICE_WACOM(0xD1) }, 2694 2435 { USB_DEVICE_WACOM(0xD2) }, ··· 2695 2452 { USB_DEVICE_WACOM(0xDD) }, 2696 2453 { USB_DEVICE_WACOM(0xDE) }, 2697 2454 { USB_DEVICE_WACOM(0xDF) }, 2698 - { USB_DEVICE_WACOM(0xF0) }, 2699 - { USB_DEVICE_WACOM(0xCC) }, 2700 - { USB_DEVICE_WACOM(0x90) }, 2701 - { USB_DEVICE_WACOM(0x93) }, 2702 - { USB_DEVICE_WACOM(0x97) }, 2703 - { USB_DEVICE_WACOM(0x9A) }, 2704 - { USB_DEVICE_WACOM(0x9F) }, 2705 2455 { USB_DEVICE_WACOM(0xE2) }, 2706 2456 { USB_DEVICE_WACOM(0xE3) }, 2707 2457 { USB_DEVICE_WACOM(0xE5) }, ··· 2702 2466 { USB_DEVICE_WACOM(0xEC) }, 2703 2467 { USB_DEVICE_WACOM(0xED) }, 2704 2468 { USB_DEVICE_WACOM(0xEF) }, 2469 + { USB_DEVICE_WACOM(0xF0) }, 2470 + { USB_DEVICE_WACOM(0xF4) }, 2471 + { USB_DEVICE_WACOM(0xF6) }, 2472 + { USB_DEVICE_WACOM(0xF8) }, 2473 + { USB_DEVICE_WACOM(0xFA) }, 2474 + { USB_DEVICE_WACOM(0xFB) }, 2705 2475 { USB_DEVICE_WACOM(0x100) }, 2706 2476 { USB_DEVICE_WACOM(0x101) }, 2707 2477 { USB_DEVICE_WACOM(0x10D) }, 2708 2478 { USB_DEVICE_WACOM(0x10E) }, 2709 2479 { USB_DEVICE_WACOM(0x10F) }, 2710 2480 { USB_DEVICE_WACOM(0x116) }, 2481 + { USB_DEVICE_WACOM(0x12C) }, 2711 2482 { USB_DEVICE_WACOM(0x300) }, 2712 2483 { USB_DEVICE_WACOM(0x301) }, 2713 - { USB_DEVICE_DETAILED(0x302, USB_CLASS_HID, 0, 0) }, 2714 - { USB_DEVICE_DETAILED(0x303, USB_CLASS_HID, 0, 0) }, 2715 - { USB_DEVICE_DETAILED(0x30E, USB_CLASS_HID, 0, 0) }, 2484 + { USB_DEVICE_WACOM(0x302) }, 2485 + { USB_DEVICE_WACOM(0x303) }, 2716 2486 { USB_DEVICE_WACOM(0x304) }, 2717 - { USB_DEVICE_DETAILED(0x314, USB_CLASS_HID, 0, 0) }, 2718 - { USB_DEVICE_DETAILED(0x315, USB_CLASS_HID, 0, 0) }, 2719 - { USB_DEVICE_DETAILED(0x317, USB_CLASS_HID, 0, 0) }, 2487 + { USB_DEVICE_WACOM(0x307) }, 2488 + { USB_DEVICE_WACOM(0x309) }, 2489 + { USB_DEVICE_WACOM(0x30E) }, 2490 + { USB_DEVICE_WACOM(0x314) }, 2491 + { USB_DEVICE_WACOM(0x315) }, 2492 + { USB_DEVICE_WACOM(0x317) }, 2720 2493 { USB_DEVICE_WACOM(0x4001) }, 2721 2494 { USB_DEVICE_WACOM(0x4004) }, 2722 2495 { USB_DEVICE_WACOM(0x5000) }, 2723 2496 { USB_DEVICE_WACOM(0x5002) }, 2724 - { USB_DEVICE_WACOM(0x47) }, 2725 - { USB_DEVICE_WACOM(0xF4) }, 2726 - { USB_DEVICE_WACOM(0xF8) }, 2727 - { USB_DEVICE_DETAILED(0xF6, USB_CLASS_HID, 0, 0) }, 2728 - { USB_DEVICE_WACOM(0xFA) }, 2729 - { USB_DEVICE_WACOM(0xFB) }, 2730 - { USB_DEVICE_WACOM(0x0307) }, 2731 - { USB_DEVICE_DETAILED(0x0309, USB_CLASS_HID, 0, 0) }, 2732 - { USB_DEVICE_LENOVO(0x6004) }, 2733 2497 { } 2734 2498 }; 2735 - MODULE_DEVICE_TABLE(usb, wacom_ids); 2499 + MODULE_DEVICE_TABLE(hid, wacom_ids);
+18 -4
drivers/input/tablet/wacom_wac.h drivers/hid/wacom_wac.h
··· 46 46 47 47 /* wacom data packet report IDs */ 48 48 #define WACOM_REPORT_PENABLED 2 49 + #define WACOM_REPORT_PENABLED_BT 3 49 50 #define WACOM_REPORT_INTUOSREAD 5 50 51 #define WACOM_REPORT_INTUOSWRITE 6 51 52 #define WACOM_REPORT_INTUOSPAD 12 ··· 69 68 #define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002 70 69 #define WACOM_QUIRK_NO_INPUT 0x0004 71 70 #define WACOM_QUIRK_MONITOR 0x0008 71 + #define WACOM_QUIRK_BATTERY 0x0010 72 72 73 73 enum { 74 74 PENPARTNER = 0, 75 75 GRAPHIRE, 76 + GRAPHIRE_BT, 76 77 WACOM_G4, 77 78 PTU, 78 79 PL, ··· 86 83 INTUOS3L, 87 84 INTUOS4S, 88 85 INTUOS4, 86 + INTUOS4WL, 89 87 INTUOS4L, 90 88 INTUOS5S, 91 89 INTUOS5, ··· 118 114 119 115 struct wacom_features { 120 116 const char *name; 121 - int pktlen; 122 117 int x_max; 123 118 int y_max; 124 119 int pressure_max; ··· 130 127 int device_type; 131 128 int x_phy; 132 129 int y_phy; 133 - unsigned char unit; 134 - unsigned char unitExpo; 130 + unsigned unit; 131 + int unitExpo; 135 132 int x_fuzz; 136 133 int y_fuzz; 137 134 int pressure_fuzz; ··· 140 137 unsigned touch_max; 141 138 int oVid; 142 139 int oPid; 140 + int pktlen; 141 + bool check_for_hid_type; 142 + int hid_type; 143 143 }; 144 144 145 145 struct wacom_shared { ··· 156 150 157 151 struct wacom_wac { 158 152 char name[WACOM_NAME_MAX]; 159 - unsigned char *data; 153 + char pad_name[WACOM_NAME_MAX]; 154 + char bat_name[WACOM_NAME_MAX]; 155 + char ac_name[WACOM_NAME_MAX]; 156 + unsigned char data[WACOM_PKGLEN_MAX]; 160 157 int tool[2]; 161 158 int id[2]; 162 159 __u32 serial[2]; 163 160 struct wacom_features features; 164 161 struct wacom_shared *shared; 165 162 struct input_dev *input; 163 + struct input_dev *pad_input; 166 164 int pid; 167 165 int battery_capacity; 168 166 int num_contacts_left; 167 + int bat_charging; 168 + int ps_connected; 169 + u8 bt_features; 170 + u8 bt_high_speed; 169 171 }; 170 172 171 173 #endif
+5
include/linux/hid.h
··· 311 311 #define HID_GROUP_RMI 0x0100 312 312 313 313 /* 314 + * Vendor specific HID device groups 315 + */ 316 + #define HID_GROUP_WACOM 0x0101 317 + 318 + /* 314 319 * This is the global environment of the parser. This information is 315 320 * persistent for main-items. The global environment can be saved and 316 321 * restored with PUSH/POP statements.