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

Merge branches 'upstream-fixes', 'wacom' and 'waltop' into for-linus

Conflicts:
drivers/hid/hid-core.c

+461 -148
+8
Documentation/ABI/testing/sysfs-driver-wacom
··· 9 9 or 0 otherwise. Writing to this file one of these values 10 10 switches reporting speed. 11 11 12 + What: /sys/class/leds/0005\:056A\:00BD.0001\:selector\:*/ 13 + Date: May 2012 14 + Kernel Version: 3.5 15 + Contact: linux-bluetooth@vger.kernel.org 16 + Description: 17 + LED selector for Intuos4 WL. There are 4 leds, but only one LED 18 + can be lit at a time. Max brightness is 127. 19 + 12 20 What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/led 13 21 Date: August 2011 14 22 Contact: linux-input@vger.kernel.org
+7 -9
drivers/hid/Kconfig
··· 32 32 If unsure, say Y. 33 33 34 34 config HID_BATTERY_STRENGTH 35 - bool 35 + bool "Battery level reporting for HID devices" 36 36 depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY 37 37 default n 38 + ---help--- 39 + This option adds support of reporting battery strength (for HID devices 40 + that support this feature) through power_supply class so that userspace 41 + tools, such as upower, can display it. 38 42 39 43 config HIDRAW 40 44 bool "/dev/hidraw raw HID device support" ··· 617 613 config HID_WACOM 618 614 tristate "Wacom Bluetooth devices support" 619 615 depends on BT_HIDP 620 - ---help--- 621 - Support for Wacom Graphire Bluetooth tablet. 622 - 623 - config HID_WACOM_POWER_SUPPLY 624 - bool "Wacom Bluetooth devices power supply status support" 625 - depends on HID_WACOM 616 + depends on LEDS_CLASS 626 617 select POWER_SUPPLY 627 618 ---help--- 628 - Say Y here if you want to enable power supply status monitoring for 629 - Wacom Bluetooth devices. 619 + Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. 630 620 631 621 config HID_WIIMOTE 632 622 tristate "Nintendo Wii Remote support"
+3
drivers/hid/hid-apple.c
··· 458 458 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), 459 459 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | 460 460 APPLE_ISO_KEYBOARD }, 461 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 462 + USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), 463 + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 461 464 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), 462 465 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 463 466 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
+1 -1
drivers/hid/hid-core.c
··· 1511 1511 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1512 1512 { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, 1513 1513 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1514 - { HID_USB_DEVICE(USB_VENDOR_ID_BAANTO, USB_DEVICE_ID_BAANTO_MT_190W2), }, 1515 1514 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1516 1515 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 1517 1516 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, ··· 1659 1660 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, 1660 1661 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 1661 1662 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1663 + { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, 1662 1664 { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1663 1665 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1664 1666 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
+1
drivers/hid/hid-ids.h
··· 756 756 #define USB_DEVICE_ID_WALTOP_PID_0038 0x0038 757 757 #define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH 0x0501 758 758 #define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH 0x0500 759 + #define USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET 0x0502 759 760 760 761 #define USB_VENDOR_ID_WISEGROUP 0x0925 761 762 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
+22 -3
drivers/hid/hid-input.c
··· 225 225 * Verify and convert units. 226 226 * See HID specification v1.11 6.2.2.7 Global Items for unit decoding 227 227 */ 228 - if (code == ABS_X || code == ABS_Y || code == ABS_Z) { 228 + switch (code) { 229 + case ABS_X: 230 + case ABS_Y: 231 + case ABS_Z: 229 232 if (field->unit == 0x11) { /* If centimeters */ 230 233 /* Convert to millimeters */ 231 234 unit_exponent += 1; ··· 242 239 } else { 243 240 return 0; 244 241 } 245 - } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { 242 + break; 243 + 244 + case ABS_RX: 245 + case ABS_RY: 246 + case ABS_RZ: 247 + case ABS_TILT_X: 248 + case ABS_TILT_Y: 246 249 if (field->unit == 0x14) { /* If degrees */ 247 250 /* Convert to radians */ 248 251 prev = logical_extents; ··· 259 250 } else if (field->unit != 0x12) { /* If not radians */ 260 251 return 0; 261 252 } 262 - } else { 253 + break; 254 + 255 + default: 263 256 return 0; 264 257 } 265 258 ··· 632 621 633 622 case 0x3c: /* Invert */ 634 623 map_key_clear(BTN_TOOL_RUBBER); 624 + break; 625 + 626 + case 0x3d: /* X Tilt */ 627 + map_abs_clear(ABS_TILT_X); 628 + break; 629 + 630 + case 0x3e: /* Y Tilt */ 631 + map_abs_clear(ABS_TILT_Y); 635 632 break; 636 633 637 634 case 0x33: /* Touch */
+3 -2
drivers/hid/hid-logitech-dj.c
··· 26 26 #include <linux/hid.h> 27 27 #include <linux/module.h> 28 28 #include <linux/usb.h> 29 + #include <asm/unaligned.h> 29 30 #include "usbhid/usbhid.h" 30 31 #include "hid-ids.h" 31 32 #include "hid-logitech-dj.h" ··· 274 273 goto dj_device_allocate_fail; 275 274 } 276 275 277 - dj_dev->reports_supported = le32_to_cpu( 278 - dj_report->report_params[DEVICE_PAIRED_RF_REPORT_TYPE]); 276 + dj_dev->reports_supported = get_unaligned_le32( 277 + dj_report->report_params + DEVICE_PAIRED_RF_REPORT_TYPE); 279 278 dj_dev->hdev = dj_hiddev; 280 279 dj_dev->dj_receiver_dev = djrcv_dev; 281 280 dj_dev->device_index = dj_report->device_index;
+216 -86
drivers/hid/hid-wacom.c
··· 24 24 #include <linux/device.h> 25 25 #include <linux/hid.h> 26 26 #include <linux/module.h> 27 + #include <linux/leds.h> 27 28 #include <linux/slab.h> 28 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 29 29 #include <linux/power_supply.h> 30 - #endif 31 30 32 31 #include "hid-ids.h" 33 32 34 33 #define PAD_DEVICE_ID 0x0F 34 + 35 + #define WAC_CMD_LED_CONTROL 0x20 35 36 36 37 struct wacom_data { 37 38 __u16 tool; ··· 42 41 __u32 id; 43 42 __u32 serial; 44 43 unsigned char high_speed; 45 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 46 - int battery_capacity; 44 + __u8 battery_capacity; 45 + __u8 power_raw; 46 + __u8 ps_connected; 47 47 struct power_supply battery; 48 48 struct power_supply ac; 49 - #endif 49 + __u8 led_selector; 50 + struct led_classdev *leds[4]; 50 51 }; 51 52 52 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 53 - /*percent of battery capacity, 0 means AC online*/ 54 - static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 }; 53 + /*percent of battery capacity for Graphire 54 + 8th value means AC online and show 100% capacity */ 55 + static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; 56 + /*percent of battery capacity for Intuos4 WL, AC has a separate bit*/ 57 + static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; 55 58 56 59 static enum power_supply_property wacom_battery_props[] = { 57 60 POWER_SUPPLY_PROP_PRESENT, ··· 69 64 POWER_SUPPLY_PROP_SCOPE, 70 65 }; 71 66 67 + static void wacom_leds_set_brightness(struct led_classdev *led_dev, 68 + enum led_brightness value) 69 + { 70 + struct device *dev = led_dev->dev->parent; 71 + struct hid_device *hdev; 72 + struct wacom_data *wdata; 73 + unsigned char *buf; 74 + __u8 led = 0; 75 + int i; 76 + 77 + hdev = container_of(dev, struct hid_device, dev); 78 + wdata = hid_get_drvdata(hdev); 79 + for (i = 0; i < 4; ++i) { 80 + if (wdata->leds[i] == led_dev) 81 + wdata->led_selector = i; 82 + } 83 + 84 + led = wdata->led_selector | 0x04; 85 + buf = kzalloc(9, GFP_KERNEL); 86 + if (buf) { 87 + buf[0] = WAC_CMD_LED_CONTROL; 88 + buf[1] = led; 89 + buf[2] = value; 90 + hdev->hid_output_raw_report(hdev, buf, 9, HID_FEATURE_REPORT); 91 + kfree(buf); 92 + } 93 + 94 + return; 95 + } 96 + 97 + static enum led_brightness wacom_leds_get_brightness(struct led_classdev *led_dev) 98 + { 99 + struct wacom_data *wdata; 100 + struct device *dev = led_dev->dev->parent; 101 + int value = 0; 102 + int i; 103 + 104 + wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); 105 + 106 + for (i = 0; i < 4; ++i) { 107 + if (wdata->leds[i] == led_dev) { 108 + value = wdata->leds[i]->brightness; 109 + break; 110 + } 111 + } 112 + 113 + return value; 114 + } 115 + 116 + 117 + static int wacom_initialize_leds(struct hid_device *hdev) 118 + { 119 + struct wacom_data *wdata = hid_get_drvdata(hdev); 120 + struct led_classdev *led; 121 + struct device *dev = &hdev->dev; 122 + size_t namesz = strlen(dev_name(dev)) + 12; 123 + char *name; 124 + int i, ret; 125 + 126 + wdata->led_selector = 0; 127 + 128 + for (i = 0; i < 4; i++) { 129 + led = kzalloc(sizeof(struct led_classdev) + namesz, GFP_KERNEL); 130 + if (!led) { 131 + hid_warn(hdev, 132 + "can't allocate memory for LED selector\n"); 133 + ret = -ENOMEM; 134 + goto err; 135 + } 136 + 137 + name = (void *)&led[1]; 138 + snprintf(name, namesz, "%s:selector:%d", dev_name(dev), i); 139 + led->name = name; 140 + led->brightness = 0; 141 + led->max_brightness = 127; 142 + led->brightness_get = wacom_leds_get_brightness; 143 + led->brightness_set = wacom_leds_set_brightness; 144 + 145 + wdata->leds[i] = led; 146 + 147 + ret = led_classdev_register(dev, wdata->leds[i]); 148 + 149 + if (ret) { 150 + wdata->leds[i] = NULL; 151 + kfree(led); 152 + hid_warn(hdev, "can't register LED\n"); 153 + goto err; 154 + } 155 + } 156 + 157 + err: 158 + return ret; 159 + } 160 + 161 + static void wacom_destroy_leds(struct hid_device *hdev) 162 + { 163 + struct wacom_data *wdata = hid_get_drvdata(hdev); 164 + struct led_classdev *led; 165 + int i; 166 + 167 + for (i = 0; i < 4; ++i) { 168 + if (wdata->leds[i]) { 169 + led = wdata->leds[i]; 170 + wdata->leds[i] = NULL; 171 + led_classdev_unregister(led); 172 + kfree(led); 173 + } 174 + } 175 + 176 + } 177 + 72 178 static int wacom_battery_get_property(struct power_supply *psy, 73 179 enum power_supply_property psp, 74 180 union power_supply_propval *val) 75 181 { 76 182 struct wacom_data *wdata = container_of(psy, 77 183 struct wacom_data, battery); 78 - int power_state = batcap[wdata->battery_capacity]; 79 184 int ret = 0; 80 185 81 186 switch (psp) { ··· 196 81 val->intval = POWER_SUPPLY_SCOPE_DEVICE; 197 82 break; 198 83 case POWER_SUPPLY_PROP_CAPACITY: 199 - /* show 100% battery capacity when charging */ 200 - if (power_state == 0) 201 - val->intval = 100; 202 - else 203 - val->intval = power_state; 84 + val->intval = wdata->battery_capacity; 204 85 break; 205 86 default: 206 87 ret = -EINVAL; ··· 210 99 union power_supply_propval *val) 211 100 { 212 101 struct wacom_data *wdata = container_of(psy, struct wacom_data, ac); 213 - int power_state = batcap[wdata->battery_capacity]; 214 102 int ret = 0; 215 103 216 104 switch (psp) { 217 105 case POWER_SUPPLY_PROP_PRESENT: 218 106 /* fall through */ 219 107 case POWER_SUPPLY_PROP_ONLINE: 220 - if (power_state == 0) 221 - val->intval = 1; 222 - else 223 - val->intval = 0; 108 + val->intval = wdata->ps_connected; 224 109 break; 225 110 case POWER_SUPPLY_PROP_SCOPE: 226 111 val->intval = POWER_SUPPLY_SCOPE_DEVICE; ··· 227 120 } 228 121 return ret; 229 122 } 230 - #endif 231 123 232 - static void wacom_set_features(struct hid_device *hdev) 233 - { 234 - int ret; 235 - __u8 rep_data[2]; 236 - 237 - /*set high speed, tablet mode*/ 238 - rep_data[0] = 0x03; 239 - rep_data[1] = 0x20; 240 - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, 241 - HID_FEATURE_REPORT); 242 - return; 243 - } 244 - 245 - static void wacom_poke(struct hid_device *hdev, u8 speed) 124 + static void wacom_set_features(struct hid_device *hdev, u8 speed) 246 125 { 247 126 struct wacom_data *wdata = hid_get_drvdata(hdev); 248 127 int limit, ret; 249 - char rep_data[2]; 128 + __u8 rep_data[2]; 250 129 251 - rep_data[0] = 0x03 ; rep_data[1] = 0x00; 252 - limit = 3; 253 - do { 254 - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, 255 - HID_FEATURE_REPORT); 256 - } while (ret < 0 && limit-- > 0); 257 - 258 - if (ret >= 0) { 259 - if (speed == 0) 260 - rep_data[0] = 0x05; 261 - else 262 - rep_data[0] = 0x06; 263 - 264 - rep_data[1] = 0x00; 130 + switch (hdev->product) { 131 + case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 132 + rep_data[0] = 0x03 ; rep_data[1] = 0x00; 265 133 limit = 3; 266 134 do { 267 135 ret = hdev->hid_output_raw_report(hdev, rep_data, 2, ··· 244 162 } while (ret < 0 && limit-- > 0); 245 163 246 164 if (ret >= 0) { 247 - wdata->high_speed = speed; 248 - return; 165 + if (speed == 0) 166 + rep_data[0] = 0x05; 167 + else 168 + rep_data[0] = 0x06; 169 + 170 + rep_data[1] = 0x00; 171 + limit = 3; 172 + do { 173 + ret = hdev->hid_output_raw_report(hdev, 174 + rep_data, 2, HID_FEATURE_REPORT); 175 + } while (ret < 0 && limit-- > 0); 176 + 177 + if (ret >= 0) { 178 + wdata->high_speed = speed; 179 + return; 180 + } 249 181 } 182 + 183 + /* 184 + * Note that if the raw queries fail, it's not a hard failure 185 + * and it is safe to continue 186 + */ 187 + hid_warn(hdev, "failed to poke device, command %d, err %d\n", 188 + rep_data[0], ret); 189 + break; 190 + case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 191 + if (speed == 1) 192 + wdata->features &= ~0x20; 193 + else 194 + wdata->features |= 0x20; 195 + 196 + rep_data[0] = 0x03; 197 + rep_data[1] = wdata->features; 198 + 199 + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, 200 + HID_FEATURE_REPORT); 201 + if (ret >= 0) 202 + wdata->high_speed = speed; 203 + break; 250 204 } 251 205 252 - /* 253 - * Note that if the raw queries fail, it's not a hard failure and it 254 - * is safe to continue 255 - */ 256 - hid_warn(hdev, "failed to poke device, command %d, err %d\n", 257 - rep_data[0], ret); 258 206 return; 259 207 } 260 208 ··· 308 196 return -EINVAL; 309 197 310 198 if (new_speed == 0 || new_speed == 1) { 311 - wacom_poke(hdev, new_speed); 199 + wacom_set_features(hdev, new_speed); 312 200 return strnlen(buf, PAGE_SIZE); 313 201 } else 314 202 return -EINVAL; ··· 422 310 input_sync(input); 423 311 } 424 312 425 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 426 - /* Store current battery capacity */ 313 + /* Store current battery capacity and power supply state*/ 427 314 rw = (data[7] >> 2 & 0x07); 428 - if (rw != wdata->battery_capacity) 429 - wdata->battery_capacity = rw; 430 - #endif 315 + if (rw != wdata->power_raw) { 316 + wdata->power_raw = rw; 317 + wdata->battery_capacity = batcap_gr[rw]; 318 + if (rw == 7) 319 + wdata->ps_connected = 1; 320 + else 321 + wdata->ps_connected = 0; 322 + } 431 323 return 1; 432 324 } 433 325 ··· 485 369 { 486 370 __u16 x, y, pressure; 487 371 __u8 distance; 372 + __u8 tilt_x, tilt_y; 488 373 489 374 switch (data[1]) { 490 375 case 0x80: /* Out of proximity report */ ··· 522 405 pressure = (data[6] << 3) | ((data[7] & 0xC0) >> 5) 523 406 | (data[1] & 0x01); 524 407 distance = (data[9] >> 2) & 0x3f; 408 + tilt_x = ((data[7] << 1) & 0x7e) | (data[8] >> 7); 409 + tilt_y = data[8] & 0x7f; 525 410 526 411 input_report_key(input, BTN_TOUCH, pressure > 1); 527 412 ··· 534 415 input_report_abs(input, ABS_Y, y); 535 416 input_report_abs(input, ABS_PRESSURE, pressure); 536 417 input_report_abs(input, ABS_DISTANCE, distance); 418 + input_report_abs(input, ABS_TILT_X, tilt_x); 419 + input_report_abs(input, ABS_TILT_Y, tilt_y); 537 420 input_report_abs(input, ABS_MISC, wdata->id); 538 421 input_event(input, EV_MSC, MSC_SERIAL, wdata->serial); 539 422 input_report_key(input, wdata->tool, 1); ··· 576 455 struct input_dev *input; 577 456 unsigned char *data = (unsigned char *) raw_data; 578 457 int i; 458 + __u8 power_raw; 579 459 580 460 if (!(hdev->claimed & HID_CLAIMED_INPUT)) 581 461 return 0; ··· 584 462 hidinput = list_entry(hdev->inputs.next, struct hid_input, list); 585 463 input = hidinput->input; 586 464 587 - /* Check if this is a tablet report */ 588 - if (data[0] != 0x03) 589 - return 0; 590 - 591 465 switch (hdev->product) { 592 466 case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 593 - return wacom_gr_parse_report(hdev, wdata, input, data); 467 + if (data[0] == 0x03) { 468 + return wacom_gr_parse_report(hdev, wdata, input, data); 469 + } else { 470 + hid_err(hdev, "Unknown report: %d,%d size:%d\n", 471 + data[0], data[1], size); 472 + return 0; 473 + } 594 474 break; 595 475 case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 596 476 i = 1; ··· 606 482 wacom_i4_parse_report(hdev, wdata, input, data + i); 607 483 i += 10; 608 484 wacom_i4_parse_report(hdev, wdata, input, data + i); 485 + power_raw = data[i+10]; 486 + if (power_raw != wdata->power_raw) { 487 + wdata->power_raw = power_raw; 488 + wdata->battery_capacity = batcap_i4[power_raw & 0x07]; 489 + wdata->ps_connected = power_raw & 0x08; 490 + } 491 + 609 492 break; 610 493 default: 611 494 hid_err(hdev, "Unknown report: %d,%d size:%d\n", ··· 677 546 input_set_abs_params(input, ABS_Y, 0, 25400, 4, 0); 678 547 input_set_abs_params(input, ABS_PRESSURE, 0, 2047, 0, 0); 679 548 input_set_abs_params(input, ABS_DISTANCE, 0, 63, 0, 0); 549 + input_set_abs_params(input, ABS_TILT_X, 0, 127, 0, 0); 550 + input_set_abs_params(input, ABS_TILT_Y, 0, 127, 0, 0); 680 551 break; 681 552 } 682 553 ··· 717 584 hid_warn(hdev, 718 585 "can't create sysfs speed attribute err: %d\n", ret); 719 586 720 - switch (hdev->product) { 721 - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: 722 - /* Set Wacom mode 2 with high reporting speed */ 723 - wacom_poke(hdev, 1); 724 - break; 725 - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: 587 + wdata->features = 0; 588 + wacom_set_features(hdev, 1); 589 + 590 + if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) { 726 591 sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); 727 - wdata->features = 0; 728 - wacom_set_features(hdev); 729 - break; 592 + ret = wacom_initialize_leds(hdev); 593 + if (ret) { 594 + hid_warn(hdev, 595 + "can't create led attribute, err: %d\n", ret); 596 + goto destroy_leds; 597 + } 730 598 } 731 599 732 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 733 600 wdata->battery.properties = wacom_battery_props; 734 601 wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props); 735 602 wdata->battery.get_property = wacom_battery_get_property; ··· 762 629 } 763 630 764 631 power_supply_powers(&wdata->ac, &hdev->dev); 765 - #endif 766 632 return 0; 767 633 768 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 769 634 err_ac: 770 635 power_supply_unregister(&wdata->battery); 771 636 err_battery: 772 637 device_remove_file(&hdev->dev, &dev_attr_speed); 773 638 hid_hw_stop(hdev); 774 - #endif 639 + destroy_leds: 640 + wacom_destroy_leds(hdev); 775 641 err_free: 776 642 kfree(wdata); 777 643 return ret; ··· 778 646 779 647 static void wacom_remove(struct hid_device *hdev) 780 648 { 781 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 782 649 struct wacom_data *wdata = hid_get_drvdata(hdev); 783 - #endif 650 + 651 + wacom_destroy_leds(hdev); 784 652 device_remove_file(&hdev->dev, &dev_attr_speed); 785 653 hid_hw_stop(hdev); 786 654 787 - #ifdef CONFIG_HID_WACOM_POWER_SUPPLY 788 655 power_supply_unregister(&wdata->battery); 789 656 power_supply_unregister(&wdata->ac); 790 - #endif 791 657 kfree(hid_get_drvdata(hdev)); 792 658 } 793 659 ··· 823 693 824 694 module_init(wacom_init); 825 695 module_exit(wacom_exit); 696 + MODULE_DESCRIPTION("Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL"); 826 697 MODULE_LICENSE("GPL"); 827 -
+194 -36
drivers/hid/hid-waltop.c
··· 502 502 0xC0 /* End Collection */ 503 503 }; 504 504 505 - struct waltop_state { 506 - u8 pressure0; 507 - u8 pressure1; 505 + /* 506 + * See Sirius Battery Free Tablet description, device and HID report descriptors 507 + * at 508 + * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Sirius_Battery_Free_Tablet 509 + */ 510 + 511 + /* Size of the original report descriptor of Sirius Battery Free Tablet */ 512 + #define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE 335 513 + 514 + /* Fixed Sirius Battery Free Tablet descriptor */ 515 + static __u8 sirius_battery_free_tablet_rdesc_fixed[] = { 516 + 0x05, 0x0D, /* Usage Page (Digitizer), */ 517 + 0x09, 0x02, /* Usage (Pen), */ 518 + 0xA1, 0x01, /* Collection (Application), */ 519 + 0x85, 0x10, /* Report ID (16), */ 520 + 0x09, 0x20, /* Usage (Stylus), */ 521 + 0xA0, /* Collection (Physical), */ 522 + 0x95, 0x01, /* Report Count (1), */ 523 + 0x15, 0x01, /* Logical Minimum (1), */ 524 + 0x25, 0x03, /* Logical Maximum (3), */ 525 + 0x75, 0x02, /* Report Size (2), */ 526 + 0x09, 0x42, /* Usage (Tip Switch), */ 527 + 0x09, 0x44, /* Usage (Barrel Switch), */ 528 + 0x09, 0x46, /* Usage (Tablet Pick), */ 529 + 0x80, /* Input, */ 530 + 0x14, /* Logical Minimum (0), */ 531 + 0x25, 0x01, /* Logical Maximum (1), */ 532 + 0x75, 0x01, /* Report Size (1), */ 533 + 0x09, 0x3C, /* Usage (Invert), */ 534 + 0x81, 0x02, /* Input (Variable), */ 535 + 0x81, 0x03, /* Input (Constant, Variable), */ 536 + 0x09, 0x32, /* Usage (In Range), */ 537 + 0x81, 0x02, /* Input (Variable), */ 538 + 0x95, 0x03, /* Report Count (3), */ 539 + 0x81, 0x03, /* Input (Constant, Variable), */ 540 + 0xA4, /* Push, */ 541 + 0x05, 0x01, /* Usage Page (Desktop), */ 542 + 0x55, 0xFD, /* Unit Exponent (-3), */ 543 + 0x65, 0x13, /* Unit (Inch), */ 544 + 0x34, /* Physical Minimum (0), */ 545 + 0x14, /* Logical Minimum (0), */ 546 + 0x75, 0x10, /* Report Size (16), */ 547 + 0x95, 0x01, /* Report Count (1), */ 548 + 0x46, 0x10, 0x27, /* Physical Maximum (10000), */ 549 + 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */ 550 + 0x09, 0x30, /* Usage (X), */ 551 + 0x81, 0x02, /* Input (Variable), */ 552 + 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 553 + 0x26, 0xE0, 0x2E, /* Logical Maximum (12000), */ 554 + 0x09, 0x31, /* Usage (Y), */ 555 + 0x81, 0x02, /* Input (Variable), */ 556 + 0xB4, /* Pop, */ 557 + 0x75, 0x10, /* Report Size (16), */ 558 + 0x95, 0x01, /* Report Count (1), */ 559 + 0x14, /* Logical Minimum (0), */ 560 + 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ 561 + 0x09, 0x30, /* Usage (Tip Pressure), */ 562 + 0x81, 0x02, /* Input (Variable), */ 563 + 0xA4, /* Push, */ 564 + 0x55, 0xFE, /* Unit Exponent (-2), */ 565 + 0x65, 0x12, /* Unit (Radians), */ 566 + 0x35, 0x97, /* Physical Minimum (-105), */ 567 + 0x45, 0x69, /* Physical Maximum (105), */ 568 + 0x15, 0x97, /* Logical Minimum (-105), */ 569 + 0x25, 0x69, /* Logical Maximum (105), */ 570 + 0x75, 0x08, /* Report Size (8), */ 571 + 0x95, 0x02, /* Report Count (2), */ 572 + 0x09, 0x3D, /* Usage (X Tilt), */ 573 + 0x09, 0x3E, /* Usage (Y Tilt), */ 574 + 0x81, 0x02, /* Input (Variable), */ 575 + 0xB4, /* Pop, */ 576 + 0xC0, /* End Collection, */ 577 + 0xC0, /* End Collection, */ 578 + 0x05, 0x01, /* Usage Page (Desktop), */ 579 + 0x09, 0x02, /* Usage (Mouse), */ 580 + 0xA1, 0x01, /* Collection (Application), */ 581 + 0x85, 0x01, /* Report ID (1), */ 582 + 0x09, 0x01, /* Usage (Pointer), */ 583 + 0xA0, /* Collection (Physical), */ 584 + 0x75, 0x08, /* Report Size (8), */ 585 + 0x95, 0x03, /* Report Count (3), */ 586 + 0x81, 0x03, /* Input (Constant, Variable), */ 587 + 0x09, 0x38, /* Usage (Wheel), */ 588 + 0x15, 0xFF, /* Logical Minimum (-1), */ 589 + 0x25, 0x01, /* Logical Maximum (1), */ 590 + 0x75, 0x08, /* Report Size (8), */ 591 + 0x95, 0x01, /* Report Count (1), */ 592 + 0x81, 0x06, /* Input (Variable, Relative), */ 593 + 0x75, 0x08, /* Report Size (8), */ 594 + 0x95, 0x03, /* Report Count (3), */ 595 + 0x81, 0x03, /* Input (Constant, Variable), */ 596 + 0xC0, /* End Collection, */ 597 + 0xC0, /* End Collection, */ 598 + 0x05, 0x01, /* Usage Page (Desktop), */ 599 + 0x09, 0x06, /* Usage (Keyboard), */ 600 + 0xA1, 0x01, /* Collection (Application), */ 601 + 0x85, 0x0D, /* Report ID (13), */ 602 + 0x05, 0x07, /* Usage Page (Keyboard), */ 603 + 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */ 604 + 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */ 605 + 0x14, /* Logical Minimum (0), */ 606 + 0x25, 0x01, /* Logical Maximum (1), */ 607 + 0x75, 0x01, /* Report Size (1), */ 608 + 0x95, 0x08, /* Report Count (8), */ 609 + 0x81, 0x02, /* Input (Variable), */ 610 + 0x75, 0x08, /* Report Size (8), */ 611 + 0x95, 0x01, /* Report Count (1), */ 612 + 0x81, 0x01, /* Input (Constant), */ 613 + 0x18, /* Usage Minimum (None), */ 614 + 0x29, 0x65, /* Usage Maximum (KB Application), */ 615 + 0x14, /* Logical Minimum (0), */ 616 + 0x25, 0x65, /* Logical Maximum (101), */ 617 + 0x75, 0x08, /* Report Size (8), */ 618 + 0x95, 0x05, /* Report Count (5), */ 619 + 0x80, /* Input, */ 620 + 0xC0, /* End Collection, */ 621 + 0x05, 0x0C, /* Usage Page (Consumer), */ 622 + 0x09, 0x01, /* Usage (Consumer Control), */ 623 + 0xA1, 0x01, /* Collection (Application), */ 624 + 0x85, 0x0C, /* Report ID (12), */ 625 + 0x09, 0xE9, /* Usage (Volume Inc), */ 626 + 0x09, 0xEA, /* Usage (Volume Dec), */ 627 + 0x14, /* Logical Minimum (0), */ 628 + 0x25, 0x01, /* Logical Maximum (1), */ 629 + 0x75, 0x01, /* Report Size (1), */ 630 + 0x95, 0x02, /* Report Count (2), */ 631 + 0x81, 0x02, /* Input (Variable), */ 632 + 0x75, 0x06, /* Report Size (6), */ 633 + 0x95, 0x01, /* Report Count (1), */ 634 + 0x81, 0x03, /* Input (Constant, Variable), */ 635 + 0x75, 0x10, /* Report Size (16), */ 636 + 0x95, 0x03, /* Report Count (3), */ 637 + 0x81, 0x03, /* Input (Constant, Variable), */ 638 + 0xC0 /* End Collection */ 508 639 }; 509 640 510 641 static int waltop_probe(struct hid_device *hdev, 511 642 const struct hid_device_id *id) 512 643 { 513 644 int ret; 514 - struct waltop_state *s; 515 - 516 - s = kzalloc(sizeof(*s), GFP_KERNEL); 517 - if (s == NULL) { 518 - hid_err(hdev, "can't allocate device state\n"); 519 - ret = -ENOMEM; 520 - goto err; 521 - } 522 - 523 - s->pressure0 = 0; 524 - s->pressure1 = 0; 525 - 526 - hid_set_drvdata(hdev, s); 527 645 528 646 ret = hid_parse(hdev); 529 647 if (ret) { ··· 657 539 658 540 return 0; 659 541 err: 660 - kfree(s); 661 542 return ret; 662 543 } 663 544 ··· 700 583 *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed); 701 584 } 702 585 break; 586 + case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET: 587 + if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) { 588 + rdesc = sirius_battery_free_tablet_rdesc_fixed; 589 + *rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed); 590 + } 591 + break; 703 592 } 704 593 return rdesc; 705 594 } ··· 713 590 static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, 714 591 u8 *data, int size) 715 592 { 716 - /* If this is a pen input report of a tablet with PID 0038 */ 717 - if (hdev->product == USB_DEVICE_ID_WALTOP_PID_0038 && 718 - report->type == HID_INPUT_REPORT && 719 - report->id == 16 && 720 - size == 8) { 721 - struct waltop_state *s = hid_get_drvdata(hdev); 722 - 593 + /* If this is a pen input report */ 594 + if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) { 723 595 /* 724 - * Ignore maximum pressure reported when a barrel button is 725 - * pressed. 596 + * Ignore reported pressure when a barrel button is pressed, 597 + * because it is rarely correct. 726 598 */ 727 599 728 600 /* If a barrel button is pressed */ 729 601 if ((data[1] & 0xF) > 1) { 730 - /* Use the last known pressure */ 731 - data[6] = s->pressure0; 732 - data[7] = s->pressure1; 733 - } else { 734 - /* Remember reported pressure */ 735 - s->pressure0 = data[6]; 736 - s->pressure1 = data[7]; 602 + /* Report zero pressure */ 603 + data[6] = 0; 604 + data[7] = 0; 737 605 } 606 + } 607 + 608 + /* If this is a pen input report of Sirius Battery Free Tablet */ 609 + if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET && 610 + report->type == HID_INPUT_REPORT && 611 + report->id == 16 && 612 + size == 10) { 613 + /* 614 + * The tablet reports tilt as roughly sin(a)*21 (18 means 60 615 + * degrees). 616 + * 617 + * This array stores angles as radians * 100, corresponding to 618 + * reported values up to 60 degrees, as expected by userspace. 619 + */ 620 + static const s8 tilt_to_radians[] = { 621 + 0, 5, 10, 14, 19, 24, 29, 34, 40, 45, 622 + 50, 56, 62, 68, 74, 81, 88, 96, 105 623 + }; 624 + 625 + s8 tilt_x = (s8)data[8]; 626 + s8 tilt_y = (s8)data[9]; 627 + s8 sign_x = tilt_x >= 0 ? 1 : -1; 628 + s8 sign_y = tilt_y >= 0 ? 1 : -1; 629 + 630 + tilt_x *= sign_x; 631 + tilt_y *= sign_y; 632 + 633 + /* 634 + * Reverse the Y Tilt direction to match the HID standard and 635 + * userspace expectations. See HID Usage Tables v1.12 16.3.2 636 + * Tilt Orientation. 637 + */ 638 + sign_y *= -1; 639 + 640 + /* 641 + * This effectively clamps reported tilt to 60 degrees - the 642 + * range expected by userspace 643 + */ 644 + if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1) 645 + tilt_x = ARRAY_SIZE(tilt_to_radians) - 1; 646 + if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1) 647 + tilt_y = ARRAY_SIZE(tilt_to_radians) - 1; 648 + 649 + data[8] = tilt_to_radians[tilt_x] * sign_x; 650 + data[9] = tilt_to_radians[tilt_y] * sign_y; 738 651 } 739 652 740 653 return 0; ··· 778 619 779 620 static void waltop_remove(struct hid_device *hdev) 780 621 { 781 - struct waltop_state *s = hid_get_drvdata(hdev); 782 - 783 622 hid_hw_stop(hdev); 784 - kfree(s); 785 623 } 786 624 787 625 static const struct hid_device_id waltop_devices[] = { ··· 794 638 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 795 639 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 796 640 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 641 + { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 642 + USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, 797 643 { } 798 644 }; 799 645 MODULE_DEVICE_TABLE(hid, waltop_devices);
+5 -11
drivers/hid/hid-wiimote-core.c
··· 769 769 770 770 /* 771 771 * Basic IR data is encoded into 3 bytes. The first two bytes are the 772 - * upper 8 bit of the X/Y data, the 3rd byte contains the lower 2 bits 772 + * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits 773 773 * of both. 774 774 * If data is packed, then the 3rd byte is put first and slightly 775 775 * reordered. This allows to interleave packed and non-packed data to ··· 778 778 */ 779 779 780 780 if (packed) { 781 - x = ir[1] << 2; 782 - y = ir[2] << 2; 783 - 784 - x |= ir[0] & 0x3; 785 - y |= (ir[0] >> 2) & 0x3; 781 + x = ir[1] | ((ir[0] & 0x03) << 8); 782 + y = ir[2] | ((ir[0] & 0x0c) << 6); 786 783 } else { 787 - x = ir[0] << 2; 788 - y = ir[1] << 2; 789 - 790 - x |= (ir[2] >> 4) & 0x3; 791 - y |= (ir[2] >> 6) & 0x3; 784 + x = ir[0] | ((ir[2] & 0x30) << 4); 785 + y = ir[1] | ((ir[2] & 0xc0) << 2); 792 786 } 793 787 794 788 input_report_abs(wdata->ir, xid, x);
+1
drivers/hid/usbhid/hid-quirks.c
··· 88 88 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U, HID_QUIRK_MULTI_INPUT }, 89 89 { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH, HID_QUIRK_MULTI_INPUT }, 90 90 { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH, HID_QUIRK_MULTI_INPUT }, 91 + { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET, HID_QUIRK_MULTI_INPUT }, 91 92 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 92 93 93 94 { USB_VENDOR_ID_WISEGROUP_LTD2, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },