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

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid

Pull HID updates from Jiri Kosina:

- 3rd generation Wacom Intuos BT device support from Aaron Armstrong
Skomra

- support for NSG-MR5U and NSG-MR7U devices from Todd Kelner

- multitouch Razer Blade Stealth support from Benjamin Tissoires

- Elantech touchpad support from Alexandrov Stansilav

- a few other scattered-around fixes and cleanups to drivers and
generic code

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (31 commits)
HID: google: Enable PM Full On mode when adjusting backlight
HID: google: add google hammer HID driver
HID: core: reset the quirks before calling probe again
HID: multitouch: do not set HID_QUIRK_NO_INIT_REPORTS
HID: core: remove the need for HID_QUIRK_NO_EMPTY_INPUT
HID: use BIT() macro for quirks too
HID: use BIT macro instead of plain integers for flags
HID: multitouch: remove dead zones of Razer Blade Stealth
HID: multitouch: export a quirk for the button handling of touchpads
HID: usbhid: extend the polling interval configuration to keyboards
HID: ntrig: document sysfs interface
HID: wacom: wacom_wac_collection() is local to wacom_wac.c
HID: wacom: generic: add the "Report Valid" usage
HID: wacom: generic: Support multiple tools per report
HID: wacom: Add support for 3rd generation Intuos BT
HID: core: rewrite the hid-generic automatic unbind
HID: sony: Add touchpad support for NSG-MR5U and NSG-MR7U remotes
HID: hid-multitouch: Use true and false for boolean values
HID: hid-ntrig: use true and false for boolean values
HID: logitech-hidpp: document sysfs interface
...

+1182 -255
+19
Documentation/ABI/testing/sysfs-driver-hid-logitech-hidpp
··· 1 + What: /sys/bus/hid/drivers/logitech-hidpp-device/<dev>/range 2 + Date: Jan, 2016 3 + KernelVersion: 4.6 4 + Contact: linux-input@vger.kernel.org 5 + Description: 6 + (RW) This attribute controls the amount of 'turn' permitted in 7 + Logitech G920 wheel. Reading from the file shows the current 8 + range of the steering wheel. Writing a value within the min and 9 + max boundary sets the range of the wheel. 10 + 11 + What: /sys/bus/hid/drivers/logitech-hidpp-device/<dev>/builtin_power_supply 12 + Date: Apr, 2017 13 + KernelVersion: 4.12 14 + Contact: linux-input@vger.kernel.org 15 + Description: 16 + Presence of this file indicates that HID++ driver is capable of 17 + handling battery properties in the kernel. This way, upower can 18 + add a udev rule to decide whether or not it should use the 19 + internal unifying support or the generic kernel one.
+70
Documentation/ABI/testing/sysfs-driver-hid-ntrig
··· 1 + What: /sys/bus/hid/drivers/ntrig/<dev>/activate_slack 2 + Date: May, 2010 3 + KernelVersion: 2.6.35 4 + Contact: linux-input@vger.kernel.org 5 + Description: 6 + (RW) Number of contact frames ignored before acknowledging the 7 + start of activity (activating touch). 8 + 9 + 10 + What: /sys/bus/hid/drivers/ntrig/<dev>/decativate_slack 11 + Date: May, 2010 12 + KernelVersion: 2.6.35 13 + Contact: linux-input@vger.kernel.org 14 + Description: 15 + (RW) Number of empty (no contact) frames ignored before 16 + acknowledging the end of activity (deactivating touch). 17 + 18 + When the last finger is removed from the device, it sends a 19 + number of empty frames. By holding off on deactivation for a few 20 + frames false erroneous disconnects can be tolerated, where the 21 + sensor may mistakenly not detect a finger that is still present. 22 + 23 + 24 + What: /sys/bus/hid/drivers/ntrig/<dev>/activation_width 25 + What: /sys/bus/hid/drivers/ntrig/<dev>/activation_height 26 + Date: May, 2010 27 + KernelVersion: 2.6.35 28 + Contact: linux-input@vger.kernel.org 29 + Description: 30 + Threholds to override activation slack. 31 + 32 + activation_width: (RW) Width threshold to immediately 33 + start processing touch events. 34 + 35 + activation_height: (RW) Height threshold to immediately 36 + start processing touch events. 37 + 38 + 39 + What: /sys/bus/hid/drivers/ntrig/<dev>/min_width 40 + What: /sys/bus/hid/drivers/ntrig/<dev>/min_height 41 + Date: May, 2010 42 + KernelVersion: 2.6.35 43 + Contact: linux-input@vger.kernel.org 44 + Description: 45 + Minimum size contact accepted. 46 + 47 + min_width: (RW) Minimum touch contact width to decide 48 + activation and activity. 49 + 50 + min_height: (RW) Minimum touch contact height to decide 51 + activation and activity. 52 + 53 + 54 + What: /sys/bus/hid/drivers/ntrig/<dev>/sensor_physical_width 55 + What: /sys/bus/hid/drivers/ntrig/<dev>/sensor_physical_height 56 + Date: May, 2010 57 + KernelVersion: 2.6.35 58 + Contact: linux-input@vger.kernel.org 59 + Description: 60 + (RO) These are internal ranges not used for normal events but 61 + useful for tuning. 62 + 63 + 64 + What: /sys/bus/hid/drivers/ntrig/<dev>/sensor_logical_width 65 + What: /sys/bus/hid/drivers/ntrig/<dev>/sensor_logical_height 66 + Date: May, 2010 67 + KernelVersion: 2.6.35 68 + Contact: linux-input@vger.kernel.org 69 + Description: 70 + (RO) The range for positions reported during activity.
+3
Documentation/admin-guide/kernel-parameters.txt
··· 4456 4456 usbhid.jspoll= 4457 4457 [USBHID] The interval which joysticks are to be polled at. 4458 4458 4459 + usbhid.kbpoll= 4460 + [USBHID] The interval which keyboards are to be polled at. 4461 + 4459 4462 usb-storage.delay_use= 4460 4463 [UMS] The delay in seconds before a new device is 4461 4464 scanned for Logical Units (default 1).
+17 -3
drivers/hid/Kconfig
··· 274 274 Currently the following devices are known to be supported: 275 275 - Trio Linker Plus II 276 276 277 + config HID_ELAN 278 + tristate "ELAN USB Touchpad Support" 279 + depends on LEDS_CLASS && USB_HID 280 + ---help--- 281 + Say Y to enable support for the USB ELAN touchpad 282 + Currently the following devices are known to be supported: 283 + - HP Pavilion X2 10-p0XX. 284 + 277 285 config HID_ELECOM 278 286 tristate "ELECOM HID devices" 279 287 depends on HID 280 288 ---help--- 281 289 Support for ELECOM devices: 282 290 - BM084 Bluetooth Mouse 283 - - EX-G Trackball (Wired and wireless) 284 - - DEFT Trackball (Wired and wireless) 285 - - HUGE Trackball (Wired and wireless) 291 + - EX-G Trackballs (M-XT3DRBK, M-XT3URBK) 292 + - DEFT Trackballs (M-DT1DRBK, M-DT1URBK, M-DT2DRBK, M-DT2URBK) 293 + - HUGE Trackballs (M-HT1DRBK, M-HT1URBK) 286 294 287 295 config HID_ELO 288 296 tristate "ELO USB 4000/4500 touchscreen" ··· 338 330 ---help--- 339 331 Say Y here if you have a Holtek On Line Grip based game controller 340 332 and want to have force feedback support for it. 333 + 334 + config HID_GOOGLE_HAMMER 335 + tristate "Google Hammer Keyboard" 336 + depends on USB_HID && LEDS_CLASS 337 + ---help--- 338 + Say Y here if you have a Google Hammer device. 341 339 342 340 config HID_GT683R 343 341 tristate "MSI GT68xR LED support"
+2
drivers/hid/Makefile
··· 39 39 obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 40 40 obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o 41 41 obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o 42 + obj-$(CONFIG_HID_ELAN) += hid-elan.o 42 43 obj-$(CONFIG_HID_ELECOM) += hid-elecom.o 43 44 obj-$(CONFIG_HID_ELO) += hid-elo.o 44 45 obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 45 46 obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o 46 47 obj-$(CONFIG_HID_GFRM) += hid-gfrm.o 48 + obj-$(CONFIG_HID_GOOGLE_HAMMER) += hid-google-hammer.o 47 49 obj-$(CONFIG_HID_GT683R) += hid-gt683r.o 48 50 obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 49 51 obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o
+4 -3
drivers/hid/hid-asus.c
··· 570 570 static int asus_start_multitouch(struct hid_device *hdev) 571 571 { 572 572 int ret; 573 - const unsigned char buf[] = { FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00 }; 573 + static const unsigned char buf[] = { 574 + FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00 575 + }; 574 576 unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL); 575 577 576 578 if (!dmabuf) { ··· 646 644 * All functionality is on a single HID interface and for 647 645 * userspace the touchpad must be a separate input_dev. 648 646 */ 649 - hdev->quirks |= HID_QUIRK_MULTI_INPUT | 650 - HID_QUIRK_NO_EMPTY_INPUT; 647 + hdev->quirks |= HID_QUIRK_MULTI_INPUT; 651 648 drvdata->tp = &asus_t100chi_tp; 652 649 } 653 650
+33 -18
drivers/hid/hid-core.c
··· 1365 1365 * of implement() working on 8 byte chunks 1366 1366 */ 1367 1367 1368 - int len = hid_report_len(report) + 7; 1368 + u32 len = hid_report_len(report) + 7; 1369 1369 1370 1370 return kmalloc(len, flags); 1371 1371 } ··· 1430 1430 { 1431 1431 char *buf; 1432 1432 int ret; 1433 - int len; 1433 + u32 len; 1434 1434 1435 1435 buf = hid_alloc_report_buf(report, GFP_KERNEL); 1436 1436 if (!buf) ··· 1456 1456 } 1457 1457 EXPORT_SYMBOL_GPL(__hid_request); 1458 1458 1459 - int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 1459 + int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, 1460 1460 int interrupt) 1461 1461 { 1462 1462 struct hid_report_enum *report_enum = hid->report_enum + type; 1463 1463 struct hid_report *report; 1464 1464 struct hid_driver *hdrv; 1465 1465 unsigned int a; 1466 - int rsize, csize = size; 1466 + u32 rsize, csize = size; 1467 1467 u8 *cdata = data; 1468 1468 int ret = 0; 1469 1469 ··· 1521 1521 * 1522 1522 * This is data entry for lower layers. 1523 1523 */ 1524 - int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 1524 + int hid_input_report(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt) 1525 1525 { 1526 1526 struct hid_report_enum *report_enum; 1527 1527 struct hid_driver *hdrv; ··· 1966 1966 } 1967 1967 } 1968 1968 1969 + /* reset the quirks that has been previously set */ 1970 + hdev->quirks = hid_lookup_quirk(hdev); 1969 1971 hdev->driver = hdrv; 1970 1972 if (hdrv->probe) { 1971 1973 ret = hdrv->probe(hdev, id); ··· 2199 2197 EXPORT_SYMBOL_GPL(hid_destroy_device); 2200 2198 2201 2199 2202 - static int __bus_add_driver(struct device_driver *drv, void *data) 2200 + static int __hid_bus_reprobe_drivers(struct device *dev, void *data) 2203 2201 { 2204 - struct hid_driver *added_hdrv = data; 2202 + struct hid_driver *hdrv = data; 2203 + struct hid_device *hdev = to_hid_device(dev); 2204 + 2205 + if (hdev->driver == hdrv && 2206 + !hdrv->match(hdev, hid_ignore_special_drivers)) 2207 + return device_reprobe(dev); 2208 + 2209 + return 0; 2210 + } 2211 + 2212 + static int __hid_bus_driver_added(struct device_driver *drv, void *data) 2213 + { 2205 2214 struct hid_driver *hdrv = to_hid_driver(drv); 2206 2215 2207 - if (hdrv->bus_add_driver) 2208 - hdrv->bus_add_driver(added_hdrv); 2216 + if (hdrv->match) { 2217 + bus_for_each_dev(&hid_bus_type, NULL, hdrv, 2218 + __hid_bus_reprobe_drivers); 2219 + } 2209 2220 2210 2221 return 0; 2211 2222 } 2212 2223 2213 2224 static int __bus_removed_driver(struct device_driver *drv, void *data) 2214 2225 { 2215 - struct hid_driver *removed_hdrv = data; 2216 - struct hid_driver *hdrv = to_hid_driver(drv); 2217 - 2218 - if (hdrv->bus_removed_driver) 2219 - hdrv->bus_removed_driver(removed_hdrv); 2220 - 2221 - return 0; 2226 + return bus_rescan_devices(&hid_bus_type); 2222 2227 } 2223 2228 2224 2229 int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 2225 2230 const char *mod_name) 2226 2231 { 2232 + int ret; 2233 + 2227 2234 hdrv->driver.name = hdrv->name; 2228 2235 hdrv->driver.bus = &hid_bus_type; 2229 2236 hdrv->driver.owner = owner; ··· 2241 2230 INIT_LIST_HEAD(&hdrv->dyn_list); 2242 2231 spin_lock_init(&hdrv->dyn_lock); 2243 2232 2244 - bus_for_each_drv(&hid_bus_type, NULL, hdrv, __bus_add_driver); 2233 + ret = driver_register(&hdrv->driver); 2245 2234 2246 - return driver_register(&hdrv->driver); 2235 + if (ret == 0) 2236 + bus_for_each_drv(&hid_bus_type, NULL, NULL, 2237 + __hid_bus_driver_added); 2238 + 2239 + return ret; 2247 2240 } 2248 2241 EXPORT_SYMBOL_GPL(__hid_register_driver); 2249 2242
+18 -6
drivers/hid/hid-corsair.c
··· 2 2 * HID driver for Corsair devices 3 3 * 4 4 * Supported devices: 5 + * - Vengeance K70 Keyboard 6 + * - K70 RAPIDFIRE Keyboard 5 7 * - Vengeance K90 Keyboard 6 8 * - Scimitar PRO RGB Gaming Mouse 7 9 * 8 10 * Copyright (c) 2015 Clement Vuchener 9 11 * Copyright (c) 2017 Oscar Campos 12 + * Copyright (c) 2017 Aaron Bottegal 10 13 */ 11 14 12 15 /* ··· 676 673 } 677 674 678 675 /* 679 - * The report descriptor of Corsair Scimitar RGB Pro gaming mouse is 676 + * The report descriptor of some of the Corsair gaming mice is 680 677 * non parseable as they define two consecutive Logical Minimum for 681 678 * the Usage Page (Consumer) in rdescs bytes 75 and 77 being 77 0x16 682 679 * that should be obviousy 0x26 for Logical Magimum of 16 bits. This ··· 684 681 * Minimum being larger than Logical Maximum. 685 682 * 686 683 * This driver fixes the report descriptor for: 687 - * - USB ID b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse 684 + * - USB ID 1b1c:1b34, sold as GLAIVE RGB Gaming mouse 685 + * - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse 688 686 */ 689 687 690 688 static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc, ··· 695 691 696 692 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { 697 693 /* 698 - * Corsair Scimitar RGB Pro report descriptor is broken and 699 - * defines two different Logical Minimum for the Consumer 700 - * Application. The byte 77 should be a 0x26 defining a 16 701 - * bits integer for the Logical Maximum but it is a 0x16 694 + * Corsair GLAIVE RGB and Scimitar RGB Pro report descriptor is 695 + * broken and defines two different Logical Minimum for the 696 + * Consumer Application. The byte 77 should be a 0x26 defining 697 + * a 16 bits integer for the Logical Maximum but it is a 0x16 702 698 * instead (Logical Minimum) 703 699 */ 704 700 switch (hdev->product) { 701 + case USB_DEVICE_ID_CORSAIR_GLAIVE_RGB: 705 702 case USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB: 706 703 if (*rsize >= 172 && rdesc[75] == 0x15 && rdesc[77] == 0x16 707 704 && rdesc[78] == 0xff && rdesc[79] == 0x0f) { ··· 721 716 .driver_data = CORSAIR_USE_K90_MACRO | 722 717 CORSAIR_USE_K90_BACKLIGHT }, 723 718 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, 719 + USB_DEVICE_ID_CORSAIR_GLAIVE_RGB) }, 720 + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, 724 721 USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) }, 722 + /* 723 + * Vengeance K70 and K70 RAPIDFIRE share product IDs. 724 + */ 725 + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, 726 + USB_DEVICE_ID_CORSAIR_K70R) }, 725 727 {} 726 728 }; 727 729
+421
drivers/hid/hid-elan.c
··· 1 + /* 2 + * HID Driver for ELAN Touchpad 3 + * 4 + * Currently only supports touchpad found on HP Pavilion X2 10 5 + * 6 + * Copyright (c) 2016 Alexandrov Stanislav <neko@nya.ai> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the Free 10 + * Software Foundation; either version 2 of the License, or (at your option) 11 + * any later version. 12 + */ 13 + 14 + #include <linux/hid.h> 15 + #include <linux/input/mt.h> 16 + #include <linux/leds.h> 17 + #include <linux/module.h> 18 + #include <linux/usb.h> 19 + 20 + #include "hid-ids.h" 21 + 22 + #define ELAN_SINGLE_FINGER 0x81 23 + #define ELAN_MT_FIRST_FINGER 0x82 24 + #define ELAN_MT_SECOND_FINGER 0x83 25 + #define ELAN_INPUT_REPORT_SIZE 8 26 + 27 + #define ELAN_MUTE_LED_REPORT 0xBC 28 + #define ELAN_LED_REPORT_SIZE 8 29 + 30 + struct elan_touchpad_settings { 31 + u8 max_fingers; 32 + u16 max_x; 33 + u16 max_y; 34 + u8 max_area_x; 35 + u8 max_area_y; 36 + u8 max_w; 37 + int usb_bInterfaceNumber; 38 + }; 39 + 40 + struct elan_drvdata { 41 + struct input_dev *input; 42 + u8 prev_report[ELAN_INPUT_REPORT_SIZE]; 43 + struct led_classdev mute_led; 44 + u8 mute_led_state; 45 + struct elan_touchpad_settings *settings; 46 + }; 47 + 48 + static int is_not_elan_touchpad(struct hid_device *hdev) 49 + { 50 + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); 51 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 52 + 53 + return (intf->altsetting->desc.bInterfaceNumber != drvdata->settings->usb_bInterfaceNumber); 54 + } 55 + 56 + static int elan_input_mapping(struct hid_device *hdev, struct hid_input *hi, 57 + struct hid_field *field, struct hid_usage *usage, 58 + unsigned long **bit, int *max) 59 + { 60 + if (is_not_elan_touchpad(hdev)) 61 + return 0; 62 + 63 + if (field->report->id == ELAN_SINGLE_FINGER || 64 + field->report->id == ELAN_MT_FIRST_FINGER || 65 + field->report->id == ELAN_MT_SECOND_FINGER) 66 + return -1; 67 + 68 + return 0; 69 + } 70 + 71 + static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) 72 + { 73 + int ret; 74 + struct input_dev *input; 75 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 76 + 77 + if (is_not_elan_touchpad(hdev)) 78 + return 0; 79 + 80 + input = devm_input_allocate_device(&hdev->dev); 81 + if (!input) 82 + return -ENOMEM; 83 + 84 + input->name = "Elan Touchpad"; 85 + input->phys = hdev->phys; 86 + input->uniq = hdev->uniq; 87 + input->id.bustype = hdev->bus; 88 + input->id.vendor = hdev->vendor; 89 + input->id.product = hdev->product; 90 + input->id.version = hdev->version; 91 + input->dev.parent = &hdev->dev; 92 + 93 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 94 + drvdata->settings->max_x, 0, 0); 95 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 96 + drvdata->settings->max_y, 0, 0); 97 + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 98 + drvdata->settings->max_fingers, 0, 0); 99 + input_set_abs_params(input, ABS_TOOL_WIDTH, 0, 100 + drvdata->settings->max_w, 0, 0); 101 + 102 + __set_bit(BTN_LEFT, input->keybit); 103 + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 104 + 105 + ret = input_mt_init_slots(input, drvdata->settings->max_fingers, 106 + INPUT_MT_POINTER); 107 + if (ret) { 108 + hid_err(hdev, "Failed to init elan MT slots: %d\n", ret); 109 + return ret; 110 + } 111 + 112 + ret = input_register_device(input); 113 + if (ret) { 114 + hid_err(hdev, "Failed to register elan input device: %d\n", 115 + ret); 116 + input_free_device(input); 117 + return ret; 118 + } 119 + 120 + drvdata->input = input; 121 + 122 + return 0; 123 + } 124 + 125 + static void elan_report_mt_slot(struct elan_drvdata *drvdata, u8 *data, 126 + unsigned int slot_num) 127 + { 128 + struct input_dev *input = drvdata->input; 129 + int x, y, w; 130 + 131 + bool active = !!data; 132 + 133 + input_mt_slot(input, slot_num); 134 + input_mt_report_slot_state(input, MT_TOOL_FINGER, active); 135 + if (active) { 136 + x = ((data[0] & 0xF0) << 4) | data[1]; 137 + y = drvdata->settings->max_y - 138 + (((data[0] & 0x07) << 8) | data[2]); 139 + w = data[4]; 140 + 141 + input_report_abs(input, ABS_MT_POSITION_X, x); 142 + input_report_abs(input, ABS_MT_POSITION_Y, y); 143 + input_report_abs(input, ABS_TOOL_WIDTH, w); 144 + } 145 + } 146 + 147 + static void elan_report_input(struct elan_drvdata *drvdata, u8 *data) 148 + { 149 + int i; 150 + struct input_dev *input = drvdata->input; 151 + 152 + /* 153 + * There is 3 types of reports: for single touch, 154 + * for multitouch - first finger and for multitouch - second finger 155 + * 156 + * packet structure for ELAN_SINGLE_FINGER and ELAN_MT_FIRST_FINGER: 157 + * 158 + * byte 1: 1 0 0 0 0 0 0 1 // 0x81 or 0x82 159 + * byte 2: 0 0 0 0 0 0 0 0 // looks like unused 160 + * byte 3: f5 f4 f3 f2 f1 0 0 L 161 + * byte 4: x12 x11 x10 x9 0? y11 y10 y9 162 + * byte 5: x8 x7 x6 x5 x4 x3 x2 x1 163 + * byte 6: y8 y7 y6 y5 y4 y3 y2 y1 164 + * byte 7: sy4 sy3 sy2 sy1 sx4 sx3 sx2 sx1 165 + * byte 8: w8 w7 w6 w5 w4 w3 w2 w1 166 + * 167 + * packet structure for ELAN_MT_SECOND_FINGER: 168 + * 169 + * byte 1: 1 0 0 0 0 0 1 1 // 0x83 170 + * byte 2: x12 x11 x10 x9 0 y11 y10 y9 171 + * byte 3: x8 x7 x6 x5 x4 x3 x2 x1 172 + * byte 4: y8 y7 y6 y5 y4 y3 y2 y1 173 + * byte 5: sy4 sy3 sy2 sy1 sx4 sx3 sx2 sx1 174 + * byte 6: w8 w7 w6 w5 w4 w3 w2 w1 175 + * byte 7: 0 0 0 0 0 0 0 0 176 + * byte 8: 0 0 0 0 0 0 0 0 177 + * 178 + * f5-f1: finger touch bits 179 + * L: clickpad button 180 + * sy / sx: not sure yet, but this looks like rectangular 181 + * area for finger 182 + * w: looks like finger width 183 + */ 184 + 185 + if (data[0] == ELAN_SINGLE_FINGER) { 186 + for (i = 0; i < drvdata->settings->max_fingers; i++) { 187 + if (data[2] & BIT(i + 3)) 188 + elan_report_mt_slot(drvdata, data + 3, i); 189 + else 190 + elan_report_mt_slot(drvdata, NULL, i); 191 + } 192 + input_report_key(input, BTN_LEFT, data[2] & 0x01); 193 + } 194 + /* 195 + * When touched with two fingers Elan touchpad will emit two HID reports 196 + * first is ELAN_MT_FIRST_FINGER and second is ELAN_MT_SECOND_FINGER 197 + * we will save ELAN_MT_FIRST_FINGER report and wait for 198 + * ELAN_MT_SECOND_FINGER to finish multitouch 199 + */ 200 + if (data[0] == ELAN_MT_FIRST_FINGER) { 201 + memcpy(drvdata->prev_report, data, 202 + sizeof(drvdata->prev_report)); 203 + return; 204 + } 205 + 206 + if (data[0] == ELAN_MT_SECOND_FINGER) { 207 + int first = 0; 208 + u8 *prev_report = drvdata->prev_report; 209 + 210 + if (prev_report[0] != ELAN_MT_FIRST_FINGER) 211 + return; 212 + 213 + for (i = 0; i < drvdata->settings->max_fingers; i++) { 214 + if (prev_report[2] & BIT(i + 3)) { 215 + if (!first) { 216 + first = 1; 217 + elan_report_mt_slot(drvdata, prev_report + 3, i); 218 + } else { 219 + elan_report_mt_slot(drvdata, data + 1, i); 220 + } 221 + } else { 222 + elan_report_mt_slot(drvdata, NULL, i); 223 + } 224 + } 225 + input_report_key(input, BTN_LEFT, prev_report[2] & 0x01); 226 + } 227 + 228 + input_mt_sync_frame(input); 229 + input_sync(input); 230 + } 231 + 232 + static int elan_raw_event(struct hid_device *hdev, 233 + struct hid_report *report, u8 *data, int size) 234 + { 235 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 236 + 237 + if (is_not_elan_touchpad(hdev)) 238 + return 0; 239 + 240 + if (data[0] == ELAN_SINGLE_FINGER || 241 + data[0] == ELAN_MT_FIRST_FINGER || 242 + data[0] == ELAN_MT_SECOND_FINGER) { 243 + if (size == ELAN_INPUT_REPORT_SIZE) { 244 + elan_report_input(drvdata, data); 245 + return 1; 246 + } 247 + } 248 + 249 + return 0; 250 + } 251 + 252 + static int elan_start_multitouch(struct hid_device *hdev) 253 + { 254 + int ret; 255 + 256 + /* 257 + * This byte sequence will enable multitouch mode and disable 258 + * mouse emulation 259 + */ 260 + const unsigned char buf[] = { 0x0D, 0x00, 0x03, 0x21, 0x00 }; 261 + unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL); 262 + 263 + if (!dmabuf) 264 + return -ENOMEM; 265 + 266 + ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, sizeof(buf), 267 + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 268 + 269 + kfree(dmabuf); 270 + 271 + if (ret != sizeof(buf)) { 272 + hid_err(hdev, "Failed to start multitouch: %d\n", ret); 273 + return ret; 274 + } 275 + 276 + return 0; 277 + } 278 + 279 + static enum led_brightness elan_mute_led_get_brigtness(struct led_classdev *led_cdev) 280 + { 281 + struct device *dev = led_cdev->dev->parent; 282 + struct hid_device *hdev = to_hid_device(dev); 283 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 284 + 285 + return drvdata->mute_led_state; 286 + } 287 + 288 + static int elan_mute_led_set_brigtness(struct led_classdev *led_cdev, 289 + enum led_brightness value) 290 + { 291 + int ret; 292 + u8 led_state; 293 + struct device *dev = led_cdev->dev->parent; 294 + struct hid_device *hdev = to_hid_device(dev); 295 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 296 + 297 + unsigned char *dmabuf = kzalloc(ELAN_LED_REPORT_SIZE, GFP_KERNEL); 298 + 299 + if (!dmabuf) 300 + return -ENOMEM; 301 + 302 + led_state = !!value; 303 + 304 + dmabuf[0] = ELAN_MUTE_LED_REPORT; 305 + dmabuf[1] = 0x02; 306 + dmabuf[2] = led_state; 307 + 308 + ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, ELAN_LED_REPORT_SIZE, 309 + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 310 + 311 + kfree(dmabuf); 312 + 313 + if (ret != ELAN_LED_REPORT_SIZE) { 314 + hid_err(hdev, "Failed to set mute led brightness: %d\n", ret); 315 + return ret; 316 + } 317 + 318 + drvdata->mute_led_state = led_state; 319 + return 0; 320 + } 321 + 322 + static int elan_init_mute_led(struct hid_device *hdev) 323 + { 324 + struct elan_drvdata *drvdata = hid_get_drvdata(hdev); 325 + struct led_classdev *mute_led = &drvdata->mute_led; 326 + 327 + mute_led->name = "elan:red:mute"; 328 + mute_led->brightness_get = elan_mute_led_get_brigtness; 329 + mute_led->brightness_set_blocking = elan_mute_led_set_brigtness; 330 + mute_led->max_brightness = LED_ON; 331 + mute_led->dev = &hdev->dev; 332 + 333 + return devm_led_classdev_register(&hdev->dev, mute_led); 334 + } 335 + 336 + static int elan_probe(struct hid_device *hdev, const struct hid_device_id *id) 337 + { 338 + int ret; 339 + struct elan_drvdata *drvdata; 340 + 341 + drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL); 342 + 343 + if (!drvdata) 344 + return -ENOMEM; 345 + 346 + drvdata->settings = (struct elan_touchpad_settings *)id->driver_data; 347 + hid_set_drvdata(hdev, drvdata); 348 + 349 + ret = hid_parse(hdev); 350 + if (ret) { 351 + hid_err(hdev, "Hid Parse failed\n"); 352 + return ret; 353 + } 354 + 355 + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 356 + if (ret) { 357 + hid_err(hdev, "Hid hw start failed\n"); 358 + return ret; 359 + } 360 + 361 + if (is_not_elan_touchpad(hdev)) 362 + return 0; 363 + 364 + if (!drvdata->input) { 365 + hid_err(hdev, "Input device is not registred\n"); 366 + ret = -ENAVAIL; 367 + goto err; 368 + } 369 + 370 + ret = elan_start_multitouch(hdev); 371 + if (ret) 372 + goto err; 373 + 374 + ret = elan_init_mute_led(hdev); 375 + if (ret) 376 + goto err; 377 + 378 + return 0; 379 + err: 380 + hid_hw_stop(hdev); 381 + return ret; 382 + } 383 + 384 + static void elan_remove(struct hid_device *hdev) 385 + { 386 + hid_hw_stop(hdev); 387 + } 388 + 389 + static const struct elan_touchpad_settings hp_x2_10_touchpad_data = { 390 + .max_fingers = 5, 391 + .max_x = 2930, 392 + .max_y = 1250, 393 + .max_area_x = 15, 394 + .max_area_y = 15, 395 + .max_w = 255, 396 + .usb_bInterfaceNumber = 1, 397 + }; 398 + 399 + static const struct hid_device_id elan_devices[] = { 400 + { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2_10_COVER), 401 + (kernel_ulong_t)&hp_x2_10_touchpad_data}, 402 + { } 403 + }; 404 + 405 + MODULE_DEVICE_TABLE(hid, elan_devices); 406 + 407 + static struct hid_driver elan_driver = { 408 + .name = "elan", 409 + .id_table = elan_devices, 410 + .input_mapping = elan_input_mapping, 411 + .input_configured = elan_input_configured, 412 + .raw_event = elan_raw_event, 413 + .probe = elan_probe, 414 + .remove = elan_remove, 415 + }; 416 + 417 + module_hid_driver(elan_driver); 418 + 419 + MODULE_LICENSE("GPL"); 420 + MODULE_AUTHOR("Alexandrov Stanislav"); 421 + MODULE_DESCRIPTION("Driver for HID ELAN Touchpads");
+17 -15
drivers/hid/hid-elecom.c
··· 1 1 /* 2 2 * HID driver for ELECOM devices: 3 3 * - BM084 Bluetooth Mouse 4 - * - EX-G Trackball (Wired and wireless) 5 - * - DEFT Trackball (Wired and wireless) 6 - * - HUGE Trackball (Wired and wireless) 4 + * - EX-G Trackballs (M-XT3DRBK, M-XT3URBK, M-XT4DRBK) 5 + * - DEFT Trackballs (M-DT1DRBK, M-DT1URBK, M-DT2DRBK, M-DT2URBK) 6 + * - HUGE Trackballs (M-HT1DRBK, M-HT1URBK) 7 7 * 8 8 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com> 9 9 * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com> ··· 65 65 rdesc[47] = 0x00; 66 66 } 67 67 break; 68 - case USB_DEVICE_ID_ELECOM_EX_G_WIRED: 69 - case USB_DEVICE_ID_ELECOM_EX_G_WIRELESS: 68 + case USB_DEVICE_ID_ELECOM_M_XT3URBK: 69 + case USB_DEVICE_ID_ELECOM_M_XT3DRBK: 70 + case USB_DEVICE_ID_ELECOM_M_XT4DRBK: 70 71 mouse_button_fixup(hdev, rdesc, *rsize, 6); 71 72 break; 72 - case USB_DEVICE_ID_ELECOM_DEFT_WIRED: 73 - case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS: 74 - case USB_DEVICE_ID_ELECOM_HUGE_WIRED: 75 - case USB_DEVICE_ID_ELECOM_HUGE_WIRELESS: 73 + case USB_DEVICE_ID_ELECOM_M_DT1URBK: 74 + case USB_DEVICE_ID_ELECOM_M_DT1DRBK: 75 + case USB_DEVICE_ID_ELECOM_M_HT1URBK: 76 + case USB_DEVICE_ID_ELECOM_M_HT1DRBK: 76 77 mouse_button_fixup(hdev, rdesc, *rsize, 8); 77 78 break; 78 79 } ··· 82 81 83 82 static const struct hid_device_id elecom_devices[] = { 84 83 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 85 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRED) }, 86 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRELESS) }, 87 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 88 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 89 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) }, 90 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRELESS) }, 84 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK) }, 85 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK) }, 86 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, 87 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, 88 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, 89 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1URBK) }, 90 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK) }, 91 91 { } 92 92 }; 93 93 MODULE_DEVICE_TABLE(hid, elecom_devices);
-33
drivers/hid/hid-generic.c
··· 26 26 27 27 static struct hid_driver hid_generic; 28 28 29 - static int __unmap_hid_generic(struct device *dev, void *data) 30 - { 31 - struct hid_driver *hdrv = data; 32 - struct hid_device *hdev = to_hid_device(dev); 33 - 34 - /* only unbind matching devices already bound to hid-generic */ 35 - if (hdev->driver != &hid_generic || 36 - hid_match_device(hdev, hdrv) == NULL) 37 - return 0; 38 - 39 - if (dev->parent) /* Needed for USB */ 40 - device_lock(dev->parent); 41 - device_release_driver(dev); 42 - if (dev->parent) 43 - device_unlock(dev->parent); 44 - 45 - return 0; 46 - } 47 - 48 - static void hid_generic_add_driver(struct hid_driver *hdrv) 49 - { 50 - bus_for_each_dev(&hid_bus_type, NULL, hdrv, __unmap_hid_generic); 51 - } 52 - 53 - static void hid_generic_removed_driver(struct hid_driver *hdrv) 54 - { 55 - int ret; 56 - 57 - ret = driver_attach(&hid_generic.driver); 58 - } 59 - 60 29 static int __check_hid_generic(struct device_driver *drv, void *data) 61 30 { 62 31 struct hid_driver *hdrv = to_hid_driver(drv); ··· 66 97 .name = "hid-generic", 67 98 .id_table = hid_table, 68 99 .match = hid_generic_match, 69 - .bus_add_driver = hid_generic_add_driver, 70 - .bus_removed_driver = hid_generic_removed_driver, 71 100 }; 72 101 module_hid_driver(hid_generic); 73 102
+138
drivers/hid/hid-google-hammer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * HID driver for Google Hammer device. 4 + * 5 + * Copyright (c) 2017 Google Inc. 6 + * Author: Wei-Ning Huang <wnhuang@google.com> 7 + */ 8 + 9 + /* 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms of the GNU General Public License as published by the Free 12 + * Software Foundation; either version 2 of the License, or (at your option) 13 + * any later version. 14 + */ 15 + 16 + #include <linux/hid.h> 17 + #include <linux/leds.h> 18 + #include <linux/module.h> 19 + 20 + #include "hid-ids.h" 21 + 22 + #define MAX_BRIGHTNESS 100 23 + 24 + /* HID usage for keyboard backlight (Alphanumeric display brightness) */ 25 + #define HID_AD_BRIGHTNESS 0x00140046 26 + 27 + struct hammer_kbd_leds { 28 + struct led_classdev cdev; 29 + struct hid_device *hdev; 30 + u8 buf[2] ____cacheline_aligned; 31 + }; 32 + 33 + static int hammer_kbd_brightness_set_blocking(struct led_classdev *cdev, 34 + enum led_brightness br) 35 + { 36 + struct hammer_kbd_leds *led = container_of(cdev, 37 + struct hammer_kbd_leds, 38 + cdev); 39 + int ret; 40 + 41 + led->buf[0] = 0; 42 + led->buf[1] = br; 43 + 44 + /* 45 + * Request USB HID device to be in Full On mode, so that sending 46 + * hardware output report and hardware raw request won't fail. 47 + */ 48 + ret = hid_hw_power(led->hdev, PM_HINT_FULLON); 49 + if (ret < 0) { 50 + hid_err(led->hdev, "failed: device not resumed %d\n", ret); 51 + return ret; 52 + } 53 + 54 + ret = hid_hw_output_report(led->hdev, led->buf, sizeof(led->buf)); 55 + if (ret == -ENOSYS) 56 + ret = hid_hw_raw_request(led->hdev, 0, led->buf, 57 + sizeof(led->buf), 58 + HID_OUTPUT_REPORT, 59 + HID_REQ_SET_REPORT); 60 + if (ret < 0) 61 + hid_err(led->hdev, "failed to set keyboard backlight: %d\n", 62 + ret); 63 + 64 + /* Request USB HID device back to Normal Mode. */ 65 + hid_hw_power(led->hdev, PM_HINT_NORMAL); 66 + 67 + return ret; 68 + } 69 + 70 + static int hammer_register_leds(struct hid_device *hdev) 71 + { 72 + struct hammer_kbd_leds *kbd_backlight; 73 + 74 + kbd_backlight = devm_kzalloc(&hdev->dev, 75 + sizeof(*kbd_backlight), 76 + GFP_KERNEL); 77 + if (!kbd_backlight) 78 + return -ENOMEM; 79 + 80 + kbd_backlight->hdev = hdev; 81 + kbd_backlight->cdev.name = "hammer::kbd_backlight"; 82 + kbd_backlight->cdev.max_brightness = MAX_BRIGHTNESS; 83 + kbd_backlight->cdev.brightness_set_blocking = 84 + hammer_kbd_brightness_set_blocking; 85 + kbd_backlight->cdev.flags = LED_HW_PLUGGABLE; 86 + 87 + /* Set backlight to 0% initially. */ 88 + hammer_kbd_brightness_set_blocking(&kbd_backlight->cdev, 0); 89 + 90 + return devm_led_classdev_register(&hdev->dev, &kbd_backlight->cdev); 91 + } 92 + 93 + static int hammer_input_configured(struct hid_device *hdev, 94 + struct hid_input *hi) 95 + { 96 + struct list_head *report_list = 97 + &hdev->report_enum[HID_OUTPUT_REPORT].report_list; 98 + struct hid_report *report; 99 + 100 + if (list_empty(report_list)) 101 + return 0; 102 + 103 + report = list_first_entry(report_list, struct hid_report, list); 104 + 105 + if (report->maxfield == 1 && 106 + report->field[0]->application == HID_GD_KEYBOARD && 107 + report->field[0]->maxusage == 1 && 108 + report->field[0]->usage[0].hid == HID_AD_BRIGHTNESS) { 109 + int err = hammer_register_leds(hdev); 110 + 111 + if (err) 112 + hid_warn(hdev, 113 + "Failed to register keyboard backlight: %d\n", 114 + err); 115 + } 116 + 117 + return 0; 118 + } 119 + 120 + static const struct hid_device_id hammer_devices[] = { 121 + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 122 + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, 123 + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 124 + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) }, 125 + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 126 + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) }, 127 + { } 128 + }; 129 + MODULE_DEVICE_TABLE(hid, hammer_devices); 130 + 131 + static struct hid_driver hammer_driver = { 132 + .name = "hammer", 133 + .id_table = hammer_devices, 134 + .input_configured = hammer_input_configured, 135 + }; 136 + module_hid_driver(hammer_driver); 137 + 138 + MODULE_LICENSE("GPL");
+15 -6
drivers/hid/hid-ids.h
··· 291 291 #define USB_DEVICE_ID_CORSAIR_K70RGB 0x1b13 292 292 #define USB_DEVICE_ID_CORSAIR_STRAFE 0x1b15 293 293 #define USB_DEVICE_ID_CORSAIR_K65RGB 0x1b17 294 + #define USB_DEVICE_ID_CORSAIR_GLAIVE_RGB 0x1b34 294 295 #define USB_DEVICE_ID_CORSAIR_K70RGB_RAPIDFIRE 0x1b38 295 296 #define USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE 0x1b39 296 297 #define USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB 0x1b3e ··· 369 368 #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001 370 369 371 370 #define USB_VENDOR_ID_ELAN 0x04f3 371 + #define USB_DEVICE_ID_HP_X2_10_COVER 0x0755 372 372 373 373 #define USB_VENDOR_ID_ELECOM 0x056e 374 374 #define USB_DEVICE_ID_ELECOM_BM084 0x0061 375 - #define USB_DEVICE_ID_ELECOM_EX_G_WIRED 0x00fb 376 - #define USB_DEVICE_ID_ELECOM_EX_G_WIRELESS 0x00fc 377 - #define USB_DEVICE_ID_ELECOM_DEFT_WIRED 0x00fe 378 - #define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS 0x00ff 379 - #define USB_DEVICE_ID_ELECOM_HUGE_WIRED 0x010c 380 - #define USB_DEVICE_ID_ELECOM_HUGE_WIRELESS 0x010d 375 + #define USB_DEVICE_ID_ELECOM_M_XT3URBK 0x00fb 376 + #define USB_DEVICE_ID_ELECOM_M_XT3DRBK 0x00fc 377 + #define USB_DEVICE_ID_ELECOM_M_XT4DRBK 0x00fd 378 + #define USB_DEVICE_ID_ELECOM_M_DT1URBK 0x00fe 379 + #define USB_DEVICE_ID_ELECOM_M_DT1DRBK 0x00ff 380 + #define USB_DEVICE_ID_ELECOM_M_HT1URBK 0x010c 381 + #define USB_DEVICE_ID_ELECOM_M_HT1DRBK 0x010d 381 382 382 383 #define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34 383 384 #define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004 ··· 448 445 #define USB_DEVICE_ID_GOODTOUCH_000f 0x000f 449 446 450 447 #define USB_VENDOR_ID_GOOGLE 0x18d1 448 + #define USB_DEVICE_ID_GOOGLE_HAMMER 0x5022 451 449 #define USB_DEVICE_ID_GOOGLE_TOUCH_ROSE 0x5028 450 + #define USB_DEVICE_ID_GOOGLE_STAFF 0x502b 451 + #define USB_DEVICE_ID_GOOGLE_WAND 0x502d 452 452 453 453 #define USB_VENDOR_ID_GOTOP 0x08f2 454 454 #define USB_DEVICE_ID_SUPER_Q2 0x007f ··· 967 961 968 962 #define USB_VENDOR_ID_SMK 0x0609 969 963 #define USB_DEVICE_ID_SMK_PS3_BDREMOTE 0x0306 964 + #define USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE 0x0368 965 + #define USB_DEVICE_ID_SMK_NSG_MR7U_REMOTE 0x0369 966 + 970 967 971 968 #define USB_VENDOR_ID_SONY 0x054c 972 969 #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
+7 -6
drivers/hid/hid-input.c
··· 1368 1368 led_work); 1369 1369 struct hid_field *field; 1370 1370 struct hid_report *report; 1371 - int len, ret; 1371 + int ret; 1372 + u32 len; 1372 1373 __u8 *buf; 1373 1374 1374 1375 field = hidinput_get_led_field(hid); ··· 1657 1656 } 1658 1657 1659 1658 list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { 1660 - if ((hid->quirks & HID_QUIRK_NO_EMPTY_INPUT) && 1661 - !hidinput_has_been_populated(hidinput)) { 1659 + if (drv->input_configured && 1660 + drv->input_configured(hid, hidinput)) 1661 + goto out_unwind; 1662 + 1663 + if (!hidinput_has_been_populated(hidinput)) { 1662 1664 /* no need to register an input device not populated */ 1663 1665 hidinput_cleanup_hidinput(hid, hidinput); 1664 1666 continue; 1665 1667 } 1666 1668 1667 - if (drv->input_configured && 1668 - drv->input_configured(hid, hidinput)) 1669 - goto out_unwind; 1670 1669 if (input_register_device(hidinput->input)) 1671 1670 goto out_unwind; 1672 1671 hidinput->registered = true;
+28 -40
drivers/hid/hid-multitouch.c
··· 74 74 #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) 75 75 #define MT_QUIRK_STICKY_FINGERS BIT(16) 76 76 #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) 77 + #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) 77 78 78 79 #define MT_INPUTMODE_TOUCHSCREEN 0x02 79 80 #define MT_INPUTMODE_TOUCHPAD 0x03 ··· 127 126 int left_button_state; /* left button state */ 128 127 unsigned last_slot_field; /* the last field of a slot */ 129 128 unsigned mt_report_id; /* the report ID of the multitouch device */ 130 - unsigned long initial_quirks; /* initial quirks state */ 131 129 __s16 inputmode; /* InputMode HID feature, -1 if non-existent */ 132 130 __s16 inputmode_index; /* InputMode HID feature index in the report */ 133 131 __s16 maxcontact_report_id; /* Maximum Contact Number HID feature, ··· 183 183 #define MT_CLS_ASUS 0x010b 184 184 #define MT_CLS_VTL 0x0110 185 185 #define MT_CLS_GOOGLE 0x0111 186 + #define MT_CLS_RAZER_BLADE_STEALTH 0x0112 186 187 187 188 #define MT_DEFAULT_MAXCONTACT 10 188 189 #define MT_MAX_MAXCONTACT 250 ··· 242 241 MT_QUIRK_IGNORE_DUPLICATES | 243 242 MT_QUIRK_HOVERING | 244 243 MT_QUIRK_CONTACT_CNT_ACCURATE | 245 - MT_QUIRK_STICKY_FINGERS }, 244 + MT_QUIRK_STICKY_FINGERS | 245 + MT_QUIRK_WIN8_PTP_BUTTONS }, 246 246 { .name = MT_CLS_EXPORT_ALL_INPUTS, 247 247 .quirks = MT_QUIRK_ALWAYS_VALID | 248 248 MT_QUIRK_CONTACT_CNT_ACCURATE, ··· 252 250 .quirks = MT_QUIRK_ALWAYS_VALID | 253 251 MT_QUIRK_IGNORE_DUPLICATES | 254 252 MT_QUIRK_HOVERING | 255 - MT_QUIRK_CONTACT_CNT_ACCURATE, 253 + MT_QUIRK_CONTACT_CNT_ACCURATE | 254 + MT_QUIRK_WIN8_PTP_BUTTONS, 256 255 .export_all_inputs = true }, 257 256 258 257 /* ··· 326 323 MT_QUIRK_SLOT_IS_CONTACTID | 327 324 MT_QUIRK_HOVERING 328 325 }, 326 + { .name = MT_CLS_RAZER_BLADE_STEALTH, 327 + .quirks = MT_QUIRK_ALWAYS_VALID | 328 + MT_QUIRK_IGNORE_DUPLICATES | 329 + MT_QUIRK_HOVERING | 330 + MT_QUIRK_CONTACT_CNT_ACCURATE | 331 + MT_QUIRK_WIN8_PTP_BUTTONS, 332 + }, 329 333 { } 330 334 }; 331 335 ··· 379 369 380 370 static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) 381 371 { 382 - struct mt_device *td = hid_get_drvdata(hdev); 383 - int ret, size = hid_report_len(report); 372 + int ret; 373 + u32 size = hid_report_len(report); 384 374 u8 *buf; 385 375 386 376 /* 387 377 * Do not fetch the feature report if the device has been explicitly 388 378 * marked as non-capable. 389 379 */ 390 - if (td->initial_quirks & HID_QUIRK_NO_INIT_REPORTS) 380 + if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) 391 381 return; 392 382 393 383 buf = hid_alloc_report_buf(report, GFP_KERNEL); ··· 669 659 * MS PTP spec says that external buttons left and right have 670 660 * usages 2 and 3. 671 661 */ 672 - if ((cls->name == MT_CLS_WIN_8 || 673 - cls->name == MT_CLS_WIN_8_DUAL) && 662 + if ((cls->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && 674 663 field->application == HID_DG_TOUCHPAD && 675 664 (usage->hid & HID_USAGE) > 1) 676 665 code--; ··· 731 722 } 732 723 733 724 if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE)) 734 - s->confidence_state = 1; 725 + s->confidence_state = true; 735 726 active = (s->touch_state || s->inrange_state) && 736 727 s->confidence_state; 737 728 ··· 781 772 */ 782 773 static void mt_sync_frame(struct mt_device *td, struct input_dev *input) 783 774 { 784 - __s32 cls = td->mtclass.name; 785 - 786 - if (cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) 775 + if (td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) 787 776 input_event(input, EV_KEY, BTN_LEFT, td->left_button_state); 788 777 789 778 input_mt_sync_frame(input); ··· 833 826 bool first_packet) 834 827 { 835 828 struct mt_device *td = hid_get_drvdata(hid); 836 - __s32 cls = td->mtclass.name; 837 829 __s32 quirks = td->mtclass.quirks; 838 830 struct input_dev *input = field->hidinput->input; 839 831 ··· 910 904 * non finger/touch events in the first_packet of 911 905 * a (possible) multi-packet frame. 912 906 */ 913 - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && 907 + if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && 914 908 !first_packet) 915 909 return; 916 910 ··· 921 915 * BTN_LEFT if either is pressed, so we or all values 922 916 * together and report the result in mt_sync_frame(). 923 917 */ 924 - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && 918 + if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && 925 919 usage->type == EV_KEY && usage->code == BTN_LEFT) { 926 920 td->left_button_state |= value; 927 921 return; ··· 945 939 static void mt_touch_report(struct hid_device *hid, struct hid_report *report) 946 940 { 947 941 struct mt_device *td = hid_get_drvdata(hid); 948 - __s32 cls = td->mtclass.name; 949 942 struct hid_field *field; 950 943 bool first_packet; 951 944 unsigned count; ··· 973 968 * of a possible multi-packet frame be checking that the 974 969 * timestamp has changed. 975 970 */ 976 - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && 971 + if ((td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && 977 972 td->num_received == 0 && td->prev_scantime != scantime) 978 973 td->num_expected = value; 979 974 /* A non 0 contact count always indicates a first packet */ ··· 1188 1183 struct hid_report_enum *re; 1189 1184 struct mt_class *cls = &td->mtclass; 1190 1185 char *buf; 1191 - int report_len; 1186 + u32 report_len; 1192 1187 1193 1188 if (td->inputmode < 0) 1194 1189 return; ··· 1452 1447 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) 1453 1448 td->serial_maybe = true; 1454 1449 1455 - /* 1456 - * Store the initial quirk state 1457 - */ 1458 - td->initial_quirks = hdev->quirks; 1459 - 1460 1450 /* This allows the driver to correctly support devices 1461 1451 * that emit events over several HID messages. 1462 1452 */ ··· 1463 1463 * device. 1464 1464 */ 1465 1465 hdev->quirks |= HID_QUIRK_MULTI_INPUT; 1466 - hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; 1467 - 1468 - /* 1469 - * Some multitouch screens do not like to be polled for input 1470 - * reports. Fortunately, the Win8 spec says that all touches 1471 - * should be sent during each report, making the initialization 1472 - * of input reports unnecessary. For Win7 devices, well, let's hope 1473 - * they will still be happy (this is only be a problem if a touch 1474 - * was already there while probing the device). 1475 - * 1476 - * In addition some touchpads do not behave well if we read 1477 - * all feature reports from them. Instead we prevent 1478 - * initial report fetching and then selectively fetch each 1479 - * report we are interested in. 1480 - */ 1481 - hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; 1482 1466 1483 1467 timer_setup(&td->release_timer, mt_expired_timeout, 0); 1484 1468 ··· 1521 1537 1522 1538 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); 1523 1539 hid_hw_stop(hdev); 1524 - hdev->quirks = td->initial_quirks; 1525 1540 } 1526 1541 1527 1542 /* ··· 1775 1792 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID, 1776 1793 MT_USB_DEVICE(USB_VENDOR_ID_QUANTA, 1777 1794 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) }, 1795 + 1796 + /* Razer touchpads */ 1797 + { .driver_data = MT_CLS_RAZER_BLADE_STEALTH, 1798 + HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 1799 + USB_VENDOR_ID_SYNAPTICS, 0x8323) }, 1778 1800 1779 1801 /* Stantum panels */ 1780 1802 { .driver_data = MT_CLS_CONFIDENCE,
+6 -6
drivers/hid/hid-ntrig.c
··· 591 591 switch (usage->hid) { 592 592 case 0xff000001: 593 593 /* Tag indicating the start of a multitouch group */ 594 - nd->reading_mt = 1; 595 - nd->first_contact_touch = 0; 594 + nd->reading_mt = true; 595 + nd->first_contact_touch = false; 596 596 break; 597 597 case HID_DG_TIPSWITCH: 598 598 nd->tipswitch = value; ··· 663 663 * even if deactivation slack is turned off. 664 664 */ 665 665 nd->act_state = deactivate_slack - 1; 666 - nd->confidence = 0; 666 + nd->confidence = false; 667 667 break; 668 668 } 669 669 ··· 679 679 */ 680 680 if (nd->w < nd->min_width || 681 681 nd->h < nd->min_height) 682 - nd->confidence = 0; 682 + nd->confidence = false; 683 683 } else 684 684 break; 685 685 ··· 758 758 if (!nd->reading_mt) /* Just to be sure */ 759 759 break; 760 760 761 - nd->reading_mt = 0; 761 + nd->reading_mt = false; 762 762 763 763 764 764 /* ··· 910 910 return -ENOMEM; 911 911 } 912 912 913 - nd->reading_mt = 0; 913 + nd->reading_mt = false; 914 914 nd->min_width = 0; 915 915 nd->min_height = 0; 916 916 nd->activate_slack = activate_slack;
+14 -6
drivers/hid/hid-quirks.c
··· 62 62 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70R), HID_QUIRK_NO_INIT_REPORTS }, 63 63 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K95RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, 64 64 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_M65RGB), HID_QUIRK_NO_INIT_REPORTS }, 65 + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_GLAIVE_RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, 65 66 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, 66 67 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_STRAFE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, 67 68 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51), HID_QUIRK_NOGET }, ··· 318 317 #endif 319 318 #if IS_ENABLED(CONFIG_HID_CORSAIR) 320 319 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) }, 320 + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_GLAIVE_RGB) }, 321 321 { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) }, 322 322 #endif 323 323 #if IS_ENABLED(CONFIG_HID_CP2112) ··· 335 333 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 336 334 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 337 335 #endif 336 + #if IS_ENABLED(CONFIG_HID_ELAN) 337 + { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2_10_COVER) }, 338 + #endif 338 339 #if IS_ENABLED(CONFIG_HID_ELECOM) 339 340 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 340 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRED) }, 341 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRELESS) }, 342 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 343 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 344 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) }, 345 - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRELESS) }, 341 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK) }, 342 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK) }, 343 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, 344 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, 345 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, 346 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1URBK) }, 347 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK) }, 346 348 #endif 347 349 #if IS_ENABLED(CONFIG_HID_ELO) 348 350 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) }, ··· 614 608 #if IS_ENABLED(CONFIG_HID_SONY) 615 609 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) }, 616 610 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) }, 611 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE) }, 612 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR7U_REMOTE) }, 617 613 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) }, 618 614 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) }, 619 615 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
+2 -2
drivers/hid/hid-rmi.c
··· 89 89 u8 *writeReport; 90 90 u8 *readReport; 91 91 92 - int input_report_size; 93 - int output_report_size; 92 + u32 input_report_size; 93 + u32 output_report_size; 94 94 95 95 unsigned long flags; 96 96
+125 -6
drivers/hid/hid-sony.c
··· 9 9 * Copyright (c) 2006-2013 Jiri Kosina 10 10 * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com> 11 11 * Copyright (c) 2014-2016 Frank Praznik <frank.praznik@gmail.com> 12 + * Copyright (c) 2018 Todd Kelner 12 13 */ 13 14 14 15 /* ··· 56 55 #define NAVIGATION_CONTROLLER_BT BIT(11) 57 56 #define SINO_LITE_CONTROLLER BIT(12) 58 57 #define FUTUREMAX_DANCE_MAT BIT(13) 58 + #define NSG_MR5U_REMOTE_BT BIT(14) 59 + #define NSG_MR7U_REMOTE_BT BIT(15) 59 60 60 61 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) 61 62 #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) ··· 75 72 MOTION_CONTROLLER) 76 73 #define SONY_BT_DEVICE (SIXAXIS_CONTROLLER_BT | DUALSHOCK4_CONTROLLER_BT |\ 77 74 MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER_BT) 75 + #define NSG_MRXU_REMOTE (NSG_MR5U_REMOTE_BT | NSG_MR7U_REMOTE_BT) 78 76 79 77 #define MAX_LEDS 4 78 + #define NSG_MRXU_MAX_X 1667 79 + #define NSG_MRXU_MAX_Y 1868 80 80 81 81 82 82 /* PS/3 Motion controller */ ··· 1104 1098 } 1105 1099 } 1106 1100 1101 + static void nsg_mrxu_parse_report(struct sony_sc *sc, u8 *rd, int size) 1102 + { 1103 + int n, offset, relx, rely; 1104 + u8 active; 1105 + 1106 + /* 1107 + * The NSG-MRxU multi-touch trackpad data starts at offset 1 and 1108 + * the touch-related data starts at offset 2. 1109 + * For the first byte, bit 0 is set when touchpad button is pressed. 1110 + * Bit 2 is set when a touch is active and the drag (Fn) key is pressed. 1111 + * This drag key is mapped to BTN_LEFT. It is operational only when a 1112 + * touch point is active. 1113 + * Bit 4 is set when only the first touch point is active. 1114 + * Bit 6 is set when only the second touch point is active. 1115 + * Bits 5 and 7 are set when both touch points are active. 1116 + * The next 3 bytes are two 12 bit X/Y coordinates for the first touch. 1117 + * The following byte, offset 5, has the touch width and length. 1118 + * Bits 0-4=X (width), bits 5-7=Y (length). 1119 + * A signed relative X coordinate is at offset 6. 1120 + * The bytes at offset 7-9 are the second touch X/Y coordinates. 1121 + * Offset 10 has the second touch width and length. 1122 + * Offset 11 has the relative Y coordinate. 1123 + */ 1124 + offset = 1; 1125 + 1126 + input_report_key(sc->touchpad, BTN_LEFT, rd[offset] & 0x0F); 1127 + active = (rd[offset] >> 4); 1128 + relx = (s8) rd[offset+5]; 1129 + rely = ((s8) rd[offset+10]) * -1; 1130 + 1131 + offset++; 1132 + 1133 + for (n = 0; n < 2; n++) { 1134 + u16 x, y; 1135 + u8 contactx, contacty; 1136 + 1137 + x = rd[offset] | ((rd[offset+1] & 0x0F) << 8); 1138 + y = ((rd[offset+1] & 0xF0) >> 4) | (rd[offset+2] << 4); 1139 + 1140 + input_mt_slot(sc->touchpad, n); 1141 + input_mt_report_slot_state(sc->touchpad, MT_TOOL_FINGER, active & 0x03); 1142 + 1143 + if (active & 0x03) { 1144 + contactx = rd[offset+3] & 0x0F; 1145 + contacty = rd[offset+3] >> 4; 1146 + input_report_abs(sc->touchpad, ABS_MT_TOUCH_MAJOR, 1147 + max(contactx, contacty)); 1148 + input_report_abs(sc->touchpad, ABS_MT_TOUCH_MINOR, 1149 + min(contactx, contacty)); 1150 + input_report_abs(sc->touchpad, ABS_MT_ORIENTATION, 1151 + (bool) (contactx > contacty)); 1152 + input_report_abs(sc->touchpad, ABS_MT_POSITION_X, x); 1153 + input_report_abs(sc->touchpad, ABS_MT_POSITION_Y, 1154 + NSG_MRXU_MAX_Y - y); 1155 + /* 1156 + * The relative coordinates belong to the first touch 1157 + * point, when present, or to the second touch point 1158 + * when the first is not active. 1159 + */ 1160 + if ((n == 0) || ((n == 1) && (active & 0x01))) { 1161 + input_report_rel(sc->touchpad, REL_X, relx); 1162 + input_report_rel(sc->touchpad, REL_Y, rely); 1163 + } 1164 + } 1165 + 1166 + offset += 5; 1167 + active >>= 2; 1168 + } 1169 + 1170 + input_mt_sync_frame(sc->touchpad); 1171 + 1172 + input_sync(sc->touchpad); 1173 + } 1174 + 1107 1175 static int sony_raw_event(struct hid_device *hdev, struct hid_report *report, 1108 1176 u8 *rd, int size) 1109 1177 { ··· 1286 1206 } 1287 1207 1288 1208 dualshock4_parse_report(sc, rd, size); 1209 + 1210 + } else if ((sc->quirks & NSG_MRXU_REMOTE) && rd[0] == 0x02) { 1211 + nsg_mrxu_parse_report(sc, rd, size); 1212 + return 1; 1289 1213 } 1290 1214 1291 1215 if (sc->defer_initialization) { ··· 1347 1263 } 1348 1264 1349 1265 static int sony_register_touchpad(struct sony_sc *sc, int touch_count, 1350 - int w, int h) 1266 + int w, int h, int touch_major, int touch_minor, int orientation) 1351 1267 { 1352 1268 size_t name_sz; 1353 1269 char *name; ··· 1378 1294 snprintf(name, name_sz, "%s" DS4_TOUCHPAD_SUFFIX, sc->hdev->name); 1379 1295 sc->touchpad->name = name; 1380 1296 1381 - ret = input_mt_init_slots(sc->touchpad, touch_count, INPUT_MT_POINTER); 1382 - if (ret < 0) 1383 - goto err; 1384 - 1385 1297 /* We map the button underneath the touchpad to BTN_LEFT. */ 1386 1298 __set_bit(EV_KEY, sc->touchpad->evbit); 1387 1299 __set_bit(BTN_LEFT, sc->touchpad->keybit); ··· 1385 1305 1386 1306 input_set_abs_params(sc->touchpad, ABS_MT_POSITION_X, 0, w, 0, 0); 1387 1307 input_set_abs_params(sc->touchpad, ABS_MT_POSITION_Y, 0, h, 0, 0); 1308 + 1309 + if (touch_major > 0) { 1310 + input_set_abs_params(sc->touchpad, ABS_MT_TOUCH_MAJOR, 1311 + 0, touch_major, 0, 0); 1312 + if (touch_minor > 0) 1313 + input_set_abs_params(sc->touchpad, ABS_MT_TOUCH_MINOR, 1314 + 0, touch_minor, 0, 0); 1315 + if (orientation > 0) 1316 + input_set_abs_params(sc->touchpad, ABS_MT_ORIENTATION, 1317 + 0, orientation, 0, 0); 1318 + } 1319 + 1320 + if (sc->quirks & NSG_MRXU_REMOTE) { 1321 + __set_bit(EV_REL, sc->touchpad->evbit); 1322 + } 1323 + 1324 + ret = input_mt_init_slots(sc->touchpad, touch_count, INPUT_MT_POINTER); 1325 + if (ret < 0) 1326 + goto err; 1388 1327 1389 1328 ret = input_register_device(sc->touchpad); 1390 1329 if (ret < 0) ··· 2789 2690 * The Dualshock 4 touchpad supports 2 touches and has a 2790 2691 * resolution of 1920x942 (44.86 dots/mm). 2791 2692 */ 2792 - ret = sony_register_touchpad(sc, 2, 1920, 942); 2693 + ret = sony_register_touchpad(sc, 2, 1920, 942, 0, 0, 0); 2793 2694 if (ret) { 2794 2695 hid_err(sc->hdev, 2795 2696 "Unable to initialize multi-touch slots: %d\n", ··· 2820 2721 } 2821 2722 2822 2723 sony_init_output_report(sc, dualshock4_send_output_report); 2724 + } else if (sc->quirks & NSG_MRXU_REMOTE) { 2725 + /* 2726 + * The NSG-MRxU touchpad supports 2 touches and has a 2727 + * resolution of 1667x1868 2728 + */ 2729 + ret = sony_register_touchpad(sc, 2, 2730 + NSG_MRXU_MAX_X, NSG_MRXU_MAX_Y, 15, 15, 1); 2731 + if (ret) { 2732 + hid_err(sc->hdev, 2733 + "Unable to initialize multi-touch slots: %d\n", 2734 + ret); 2735 + goto err_stop; 2736 + } 2737 + 2823 2738 } else if (sc->quirks & MOTION_CONTROLLER) { 2824 2739 sony_init_output_report(sc, motion_send_output_report); 2825 2740 } else { ··· 3082 2969 /* Nyko Core Controller for PS3 */ 3083 2970 { HID_USB_DEVICE(USB_VENDOR_ID_SINO_LITE, USB_DEVICE_ID_SINO_LITE_CONTROLLER), 3084 2971 .driver_data = SIXAXIS_CONTROLLER_USB | SINO_LITE_CONTROLLER }, 2972 + /* SMK-Link NSG-MR5U Remote Control */ 2973 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR5U_REMOTE), 2974 + .driver_data = NSG_MR5U_REMOTE_BT }, 2975 + /* SMK-Link NSG-MR7U Remote Control */ 2976 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_NSG_MR7U_REMOTE), 2977 + .driver_data = NSG_MR7U_REMOTE_BT }, 3085 2978 { } 3086 2979 }; 3087 2980 MODULE_DEVICE_TABLE(hid, sony_devices);
-1
drivers/hid/hid-uclogic.c
··· 946 946 * than the pen, so use QUIRK_MULTI_INPUT for all tablets. 947 947 */ 948 948 hdev->quirks |= HID_QUIRK_MULTI_INPUT; 949 - hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; 950 949 951 950 /* Allocate and assign driver data */ 952 951 drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
+9 -8
drivers/hid/i2c-hid/i2c-hid.c
··· 144 144 * register of the HID 145 145 * descriptor. */ 146 146 unsigned int bufsize; /* i2c buffer size */ 147 - char *inbuf; /* Input buffer */ 148 - char *rawbuf; /* Raw Input buffer */ 149 - char *cmdbuf; /* Command buffer */ 150 - char *argsbuf; /* Command arguments buffer */ 147 + u8 *inbuf; /* Input buffer */ 148 + u8 *rawbuf; /* Raw Input buffer */ 149 + u8 *cmdbuf; /* Command buffer */ 150 + u8 *argsbuf; /* Command arguments buffer */ 151 151 152 152 unsigned long flags; /* device flags */ 153 153 unsigned long quirks; /* Various quirks */ ··· 455 455 456 456 static void i2c_hid_get_input(struct i2c_hid *ihid) 457 457 { 458 - int ret, ret_size; 458 + int ret; 459 + u32 ret_size; 459 460 int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); 460 461 461 462 if (size > ihid->bufsize) ··· 481 480 return; 482 481 } 483 482 484 - if (ret_size > size) { 483 + if ((ret_size > size) || (ret_size <= 2)) { 485 484 dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", 486 485 __func__, size, ret_size); 487 486 return; ··· 892 891 893 892 static void i2c_hid_acpi_fix_up_power(struct device *dev) 894 893 { 895 - acpi_handle handle = ACPI_HANDLE(dev); 896 894 struct acpi_device *adev; 897 895 898 - if (handle && acpi_bus_get_device(handle, &adev) == 0) 896 + adev = ACPI_COMPANION(dev); 897 + if (adev) 899 898 acpi_device_fix_up_power(adev); 900 899 } 901 900
+6 -6
drivers/hid/uhid.c
··· 496 496 goto err_free; 497 497 } 498 498 499 - len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1; 500 - strncpy(hid->name, ev->u.create2.name, len); 501 - len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1; 502 - strncpy(hid->phys, ev->u.create2.phys, len); 503 - len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1; 504 - strncpy(hid->uniq, ev->u.create2.uniq, len); 499 + len = min(sizeof(hid->name), sizeof(ev->u.create2.name)); 500 + strlcpy(hid->name, ev->u.create2.name, len); 501 + len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)); 502 + strlcpy(hid->phys, ev->u.create2.phys, len); 503 + len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)); 504 + strlcpy(hid->uniq, ev->u.create2.uniq, len); 505 505 506 506 hid->ll_driver = &uhid_hid_driver; 507 507 hid->bus = ev->u.create2.bus;
+11 -1
drivers/hid/usbhid/hid-core.c
··· 56 56 module_param_named(jspoll, hid_jspoll_interval, uint, 0644); 57 57 MODULE_PARM_DESC(jspoll, "Polling interval of joysticks"); 58 58 59 + static unsigned int hid_kbpoll_interval; 60 + module_param_named(kbpoll, hid_kbpoll_interval, uint, 0644); 61 + MODULE_PARM_DESC(kbpoll, "Polling interval of keyboards"); 62 + 59 63 static unsigned int ignoreled; 60 64 module_param_named(ignoreled, ignoreled, uint, 0644); 61 65 MODULE_PARM_DESC(ignoreled, "Autosuspend with active leds"); ··· 1098 1094 hid->name, endpoint->bInterval, interval); 1099 1095 } 1100 1096 1101 - /* Change the polling interval of mice and joysticks. */ 1097 + /* Change the polling interval of mice, joysticks 1098 + * and keyboards. 1099 + */ 1102 1100 switch (hid->collection->usage) { 1103 1101 case HID_GD_MOUSE: 1104 1102 if (hid_mousepoll_interval > 0) ··· 1109 1103 case HID_GD_JOYSTICK: 1110 1104 if (hid_jspoll_interval > 0) 1111 1105 interval = hid_jspoll_interval; 1106 + break; 1107 + case HID_GD_KEYBOARD: 1108 + if (hid_kbpoll_interval > 0) 1109 + interval = hid_kbpoll_interval; 1112 1110 break; 1113 1111 } 1114 1112
+2 -2
drivers/hid/wacom_sys.c
··· 219 219 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); 220 220 u8 *data; 221 221 int ret; 222 - int n; 222 + u32 n; 223 223 224 224 switch (equivalent_usage) { 225 225 case HID_DG_CONTACTMAX: ··· 519 519 u8 *rep_data; 520 520 struct hid_report *r; 521 521 struct hid_report_enum *re; 522 - int length; 522 + u32 length; 523 523 int error = -ENOMEM, limit = 0; 524 524 525 525 if (wacom_wac->mode_report < 0)
+176 -47
drivers/hid/wacom_wac.c
··· 1202 1202 1203 1203 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) 1204 1204 { 1205 - const int pen_frame_len = 14; 1206 - const int pen_frames = 7; 1205 + int pen_frame_len, pen_frames; 1207 1206 1208 1207 struct input_dev *pen_input = wacom->pen_input; 1209 1208 unsigned char *data = wacom->data; 1210 1209 int i; 1211 1210 1212 - wacom->serial[0] = get_unaligned_le64(&data[99]); 1213 - wacom->id[0] = get_unaligned_le16(&data[107]); 1211 + if (wacom->features.type == INTUOSP2_BT) { 1212 + wacom->serial[0] = get_unaligned_le64(&data[99]); 1213 + wacom->id[0] = get_unaligned_le16(&data[107]); 1214 + pen_frame_len = 14; 1215 + pen_frames = 7; 1216 + } else { 1217 + wacom->serial[0] = get_unaligned_le64(&data[33]); 1218 + wacom->id[0] = get_unaligned_le16(&data[41]); 1219 + pen_frame_len = 8; 1220 + pen_frames = 4; 1221 + } 1222 + 1214 1223 if (wacom->serial[0] >> 52 == 1) { 1215 1224 /* Add back in missing bits of ID for non-USI pens */ 1216 1225 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; ··· 1236 1227 continue; 1237 1228 1238 1229 if (range) { 1239 - /* Fix rotation alignment: userspace expects zero at left */ 1240 - int16_t rotation = (int16_t)get_unaligned_le16(&frame[9]); 1241 - rotation += 1800/4; 1242 - if (rotation > 899) 1243 - rotation -= 1800; 1244 - 1245 1230 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); 1246 1231 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); 1247 - input_report_abs(pen_input, ABS_TILT_X, (char)frame[7]); 1248 - input_report_abs(pen_input, ABS_TILT_Y, (char)frame[8]); 1249 - input_report_abs(pen_input, ABS_Z, rotation); 1250 - input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11])); 1232 + 1233 + if (wacom->features.type == INTUOSP2_BT) { 1234 + /* Fix rotation alignment: userspace expects zero at left */ 1235 + int16_t rotation = 1236 + (int16_t)get_unaligned_le16(&frame[9]); 1237 + rotation += 1800/4; 1238 + 1239 + if (rotation > 899) 1240 + rotation -= 1800; 1241 + 1242 + input_report_abs(pen_input, ABS_TILT_X, 1243 + (char)frame[7]); 1244 + input_report_abs(pen_input, ABS_TILT_Y, 1245 + (char)frame[8]); 1246 + input_report_abs(pen_input, ABS_Z, rotation); 1247 + input_report_abs(pen_input, ABS_WHEEL, 1248 + get_unaligned_le16(&frame[11])); 1249 + } 1251 1250 } 1252 1251 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); 1253 - input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max); 1252 + if (wacom->features.type == INTUOSP2_BT) { 1253 + input_report_abs(pen_input, ABS_DISTANCE, 1254 + range ? frame[13] : wacom->features.distance_max); 1255 + } else { 1256 + input_report_abs(pen_input, ABS_DISTANCE, 1257 + range ? frame[7] : wacom->features.distance_max); 1258 + } 1254 1259 1255 1260 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); 1256 1261 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); ··· 1380 1357 battery_status, chg, 1, chg); 1381 1358 } 1382 1359 1360 + static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom) 1361 + { 1362 + struct input_dev *pad_input = wacom->pad_input; 1363 + unsigned char *data = wacom->data; 1364 + 1365 + int buttons = data[44]; 1366 + 1367 + wacom_report_numbered_buttons(pad_input, 4, buttons); 1368 + 1369 + input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0); 1370 + input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0); 1371 + input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff); 1372 + 1373 + input_sync(pad_input); 1374 + } 1375 + 1376 + static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom) 1377 + { 1378 + unsigned char *data = wacom->data; 1379 + 1380 + bool chg = data[45] & 0x80; 1381 + int battery_status = data[45] & 0x7F; 1382 + 1383 + wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, 1384 + battery_status, chg, 1, chg); 1385 + } 1386 + 1383 1387 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) 1384 1388 { 1385 1389 unsigned char *data = wacom->data; 1386 1390 1387 - if (data[0] != 0x80) { 1391 + if (data[0] != 0x80 && data[0] != 0x81) { 1388 1392 dev_dbg(wacom->pen_input->dev.parent, 1389 1393 "%s: received unknown report #%d\n", __func__, data[0]); 1390 1394 return 0; 1391 1395 } 1392 1396 1393 1397 wacom_intuos_pro2_bt_pen(wacom); 1394 - wacom_intuos_pro2_bt_touch(wacom); 1395 - wacom_intuos_pro2_bt_pad(wacom); 1396 - wacom_intuos_pro2_bt_battery(wacom); 1398 + if (wacom->features.type == INTUOSP2_BT) { 1399 + wacom_intuos_pro2_bt_touch(wacom); 1400 + wacom_intuos_pro2_bt_pad(wacom); 1401 + wacom_intuos_pro2_bt_battery(wacom); 1402 + } else { 1403 + wacom_intuos_gen3_bt_pad(wacom); 1404 + wacom_intuos_gen3_bt_battery(wacom); 1405 + } 1397 1406 return 0; 1398 1407 } 1399 1408 ··· 1715 1660 usage == WACOM_HID_WD_TOUCHSTRIP || 1716 1661 usage == WACOM_HID_WD_TOUCHSTRIP2 || 1717 1662 usage == WACOM_HID_WD_TOUCHRING || 1718 - usage == WACOM_HID_WD_TOUCHRINGSTATUS) { 1663 + usage == WACOM_HID_WD_TOUCHRINGSTATUS || 1664 + usage == WACOM_HID_WD_REPORT_VALID) { 1719 1665 return usage; 1720 1666 } 1721 1667 ··· 2073 2017 } 2074 2018 2075 2019 static void wacom_wac_pad_report(struct hid_device *hdev, 2076 - struct hid_report *report) 2020 + struct hid_report *report, struct hid_field *field) 2077 2021 { 2078 2022 struct wacom *wacom = hid_get_drvdata(hdev); 2079 2023 struct wacom_wac *wacom_wac = &wacom->wacom_wac; ··· 2081 2025 bool active = wacom_wac->hid_data.inrange_state != 0; 2082 2026 2083 2027 /* report prox for expresskey events */ 2084 - if ((wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) && 2028 + if ((wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) && 2085 2029 wacom_wac->hid_data.pad_input_event_flag) { 2086 2030 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); 2087 2031 input_sync(input); ··· 2200 2144 struct input_dev *input = wacom_wac->pen_input; 2201 2145 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); 2202 2146 2147 + if (wacom_wac->is_invalid_bt_frame) 2148 + return; 2149 + 2203 2150 switch (equivalent_usage) { 2204 2151 case HID_GD_Z: 2205 2152 /* ··· 2299 2240 features->offset_bottom); 2300 2241 features->offset_bottom = value; 2301 2242 return; 2243 + case WACOM_HID_WD_REPORT_VALID: 2244 + wacom_wac->is_invalid_bt_frame = !value; 2245 + return; 2302 2246 } 2303 2247 2304 2248 /* send pen events only when touch is up or forced out ··· 2320 2258 static void wacom_wac_pen_pre_report(struct hid_device *hdev, 2321 2259 struct hid_report *report) 2322 2260 { 2261 + struct wacom *wacom = hid_get_drvdata(hdev); 2262 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 2263 + 2264 + wacom_wac->is_invalid_bt_frame = false; 2323 2265 return; 2324 2266 } 2325 2267 ··· 2335 2269 struct input_dev *input = wacom_wac->pen_input; 2336 2270 bool range = wacom_wac->hid_data.inrange_state; 2337 2271 bool sense = wacom_wac->hid_data.sense_state; 2272 + 2273 + if (wacom_wac->is_invalid_bt_frame) 2274 + return; 2338 2275 2339 2276 if (!wacom_wac->tool[0] && range) { /* first in range */ 2340 2277 /* Going into range select tool */ ··· 2641 2572 wacom_wac_finger_event(hdev, field, usage, value); 2642 2573 } 2643 2574 2644 - static void wacom_report_events(struct hid_device *hdev, struct hid_report *report) 2575 + static void wacom_report_events(struct hid_device *hdev, 2576 + struct hid_report *report, int collection_index, 2577 + int field_index) 2645 2578 { 2646 2579 int r; 2647 2580 2648 - for (r = 0; r < report->maxfield; r++) { 2581 + for (r = field_index; r < report->maxfield; r++) { 2649 2582 struct hid_field *field; 2650 2583 unsigned count, n; 2651 2584 ··· 2657 2586 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) 2658 2587 continue; 2659 2588 2660 - for (n = 0; n < count; n++) 2661 - wacom_wac_event(hdev, field, &field->usage[n], field->value[n]); 2589 + for (n = 0 ; n < count; n++) { 2590 + if (field->usage[n].collection_index == collection_index) 2591 + wacom_wac_event(hdev, field, &field->usage[n], 2592 + field->value[n]); 2593 + else 2594 + return; 2595 + } 2662 2596 } 2663 2597 } 2664 2598 2665 - void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) 2599 + static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report, 2600 + int collection_index, struct hid_field *field, 2601 + int field_index) 2666 2602 { 2667 2603 struct wacom *wacom = hid_get_drvdata(hdev); 2668 - struct wacom_wac *wacom_wac = &wacom->wacom_wac; 2669 - struct hid_field *field = report->field[0]; 2670 2604 2671 - if (wacom_wac->features.type != HID_GENERIC) 2672 - return; 2673 - 2674 - wacom_wac_battery_pre_report(hdev, report); 2675 - 2676 - if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) 2677 - wacom_wac_pad_pre_report(hdev, report); 2678 - else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) 2679 - wacom_wac_pen_pre_report(hdev, report); 2680 - else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) 2681 - wacom_wac_finger_pre_report(hdev, report); 2682 - 2683 - wacom_report_events(hdev, report); 2605 + wacom_report_events(hdev, report, collection_index, field_index); 2684 2606 2685 2607 /* 2686 2608 * Non-input reports may be sent prior to the device being ··· 2683 2619 * processing functions. 2684 2620 */ 2685 2621 if (report->type != HID_INPUT_REPORT) 2686 - return; 2687 - 2688 - wacom_wac_battery_report(hdev, report); 2622 + return -1; 2689 2623 2690 2624 if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) 2691 - wacom_wac_pad_report(hdev, report); 2625 + wacom_wac_pad_report(hdev, report, field); 2692 2626 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) 2693 2627 wacom_wac_pen_report(hdev, report); 2694 2628 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) 2695 2629 wacom_wac_finger_report(hdev, report); 2630 + 2631 + return 0; 2632 + } 2633 + 2634 + void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) 2635 + { 2636 + struct wacom *wacom = hid_get_drvdata(hdev); 2637 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 2638 + struct hid_field *field; 2639 + bool pad_in_hid_field = false, pen_in_hid_field = false, 2640 + finger_in_hid_field = false; 2641 + int r; 2642 + int prev_collection = -1; 2643 + 2644 + if (wacom_wac->features.type != HID_GENERIC) 2645 + return; 2646 + 2647 + for (r = 0; r < report->maxfield; r++) { 2648 + field = report->field[r]; 2649 + 2650 + if (WACOM_PAD_FIELD(field)) 2651 + pad_in_hid_field = true; 2652 + if (WACOM_PEN_FIELD(field)) 2653 + pen_in_hid_field = true; 2654 + if (WACOM_FINGER_FIELD(field)) 2655 + finger_in_hid_field = true; 2656 + } 2657 + 2658 + wacom_wac_battery_pre_report(hdev, report); 2659 + 2660 + if (pad_in_hid_field && wacom->wacom_wac.pad_input) 2661 + wacom_wac_pad_pre_report(hdev, report); 2662 + if (pen_in_hid_field && wacom->wacom_wac.pen_input) 2663 + wacom_wac_pen_pre_report(hdev, report); 2664 + if (finger_in_hid_field && wacom->wacom_wac.touch_input) 2665 + wacom_wac_finger_pre_report(hdev, report); 2666 + 2667 + for (r = 0; r < report->maxfield; r++) { 2668 + field = report->field[r]; 2669 + 2670 + if (field->usage[0].collection_index != prev_collection) { 2671 + if (wacom_wac_collection(hdev, report, 2672 + field->usage[0].collection_index, field, r) < 0) 2673 + return; 2674 + prev_collection = field->usage[0].collection_index; 2675 + } 2676 + } 2677 + 2678 + wacom_wac_battery_report(hdev, report); 2696 2679 } 2697 2680 2698 2681 static int wacom_bpt_touch(struct wacom_wac *wacom) ··· 3204 3093 break; 3205 3094 3206 3095 case INTUOSP2_BT: 3096 + case INTUOSHT3_BT: 3207 3097 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len); 3208 3098 break; 3209 3099 ··· 3381 3269 features->device_type |= WACOM_DEVICETYPE_PEN | 3382 3270 WACOM_DEVICETYPE_PAD | 3383 3271 WACOM_DEVICETYPE_TOUCH; 3272 + features->quirks |= WACOM_QUIRK_BATTERY; 3273 + } 3274 + 3275 + if (features->type == INTUOSHT3_BT) { 3276 + features->device_type |= WACOM_DEVICETYPE_PEN | 3277 + WACOM_DEVICETYPE_PAD; 3384 3278 features->quirks |= WACOM_QUIRK_BATTERY; 3385 3279 } 3386 3280 ··· 3584 3466 case BAMBOO_PT: 3585 3467 case BAMBOO_PEN: 3586 3468 case INTUOSHT2: 3587 - if (features->type == INTUOSHT2) { 3469 + case INTUOSHT3_BT: 3470 + if (features->type == INTUOSHT2 || 3471 + features->type == INTUOSHT3_BT) { 3588 3472 wacom_setup_basic_pro_pen(wacom_wac); 3589 3473 } else { 3590 3474 __clear_bit(ABS_MISC, input_dev->absbit); ··· 4007 3887 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 4008 3888 break; 4009 3889 3890 + case INTUOSHT3_BT: 4010 3891 case HID_GENERIC: 4011 3892 break; 4012 3893 ··· 4536 4415 static const struct wacom_features wacom_features_0x361 = 4537 4416 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63, 4538 4417 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 }; 4418 + static const struct wacom_features wacom_features_0x377 = 4419 + { "Wacom Intuos BT S", 15200, 9500, 4095, 63, 4420 + INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; 4421 + static const struct wacom_features wacom_features_0x379 = 4422 + { "Wacom Intuos BT M", 21600, 13500, 4095, 63, 4423 + INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; 4539 4424 static const struct wacom_features wacom_features_0x37A = 4540 4425 { "Wacom One by Wacom S", 15200, 9500, 2047, 63, 4541 4426 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; ··· 4716 4589 { USB_DEVICE_WACOM(0x343) }, 4717 4590 { BT_DEVICE_WACOM(0x360) }, 4718 4591 { BT_DEVICE_WACOM(0x361) }, 4592 + { BT_DEVICE_WACOM(0x377) }, 4593 + { BT_DEVICE_WACOM(0x379) }, 4719 4594 { USB_DEVICE_WACOM(0x37A) }, 4720 4595 { USB_DEVICE_WACOM(0x37B) }, 4721 4596 { USB_DEVICE_WACOM(0x4001) },
+3 -1
drivers/hid/wacom_wac.h
··· 118 118 #define WACOM_HID_WD_TOUCHSTRIP2 (WACOM_HID_UP_WACOMDIGITIZER | 0x0137) 119 119 #define WACOM_HID_WD_TOUCHRING (WACOM_HID_UP_WACOMDIGITIZER | 0x0138) 120 120 #define WACOM_HID_WD_TOUCHRINGSTATUS (WACOM_HID_UP_WACOMDIGITIZER | 0x0139) 121 + #define WACOM_HID_WD_REPORT_VALID (WACOM_HID_UP_WACOMDIGITIZER | 0x01d0) 121 122 #define WACOM_HID_WD_ACCELEROMETER_X (WACOM_HID_UP_WACOMDIGITIZER | 0x0401) 122 123 #define WACOM_HID_WD_ACCELEROMETER_Y (WACOM_HID_UP_WACOMDIGITIZER | 0x0402) 123 124 #define WACOM_HID_WD_ACCELEROMETER_Z (WACOM_HID_UP_WACOMDIGITIZER | 0x0403) ··· 214 213 INTUOSPM, 215 214 INTUOSPL, 216 215 INTUOSP2_BT, 216 + INTUOSHT3_BT, 217 217 WACOM_21UX2, 218 218 WACOM_22HD, 219 219 DTK, ··· 354 352 bool has_mute_touch_switch; 355 353 bool has_mode_change; 356 354 bool is_direct_mode; 357 - 355 + bool is_invalid_bt_frame; 358 356 }; 359 357 360 358 #endif
+36 -39
include/linux/hid.h
··· 26 26 #define __HID_H 27 27 28 28 29 + #include <linux/bitops.h> 29 30 #include <linux/types.h> 30 31 #include <linux/slab.h> 31 32 #include <linux/list.h> ··· 311 310 * HID connect requests 312 311 */ 313 312 314 - #define HID_CONNECT_HIDINPUT 0x01 315 - #define HID_CONNECT_HIDINPUT_FORCE 0x02 316 - #define HID_CONNECT_HIDRAW 0x04 317 - #define HID_CONNECT_HIDDEV 0x08 318 - #define HID_CONNECT_HIDDEV_FORCE 0x10 319 - #define HID_CONNECT_FF 0x20 320 - #define HID_CONNECT_DRIVER 0x40 313 + #define HID_CONNECT_HIDINPUT BIT(0) 314 + #define HID_CONNECT_HIDINPUT_FORCE BIT(1) 315 + #define HID_CONNECT_HIDRAW BIT(2) 316 + #define HID_CONNECT_HIDDEV BIT(3) 317 + #define HID_CONNECT_HIDDEV_FORCE BIT(4) 318 + #define HID_CONNECT_FF BIT(5) 319 + #define HID_CONNECT_DRIVER BIT(6) 321 320 #define HID_CONNECT_DEFAULT (HID_CONNECT_HIDINPUT|HID_CONNECT_HIDRAW| \ 322 321 HID_CONNECT_HIDDEV|HID_CONNECT_FF) 323 322 ··· 330 329 */ 331 330 #define MAX_USBHID_BOOT_QUIRKS 4 332 331 333 - #define HID_QUIRK_INVERT 0x00000001 334 - #define HID_QUIRK_NOTOUCH 0x00000002 335 - #define HID_QUIRK_IGNORE 0x00000004 336 - #define HID_QUIRK_NOGET 0x00000008 337 - #define HID_QUIRK_HIDDEV_FORCE 0x00000010 338 - #define HID_QUIRK_BADPAD 0x00000020 339 - #define HID_QUIRK_MULTI_INPUT 0x00000040 340 - #define HID_QUIRK_HIDINPUT_FORCE 0x00000080 341 - #define HID_QUIRK_NO_EMPTY_INPUT 0x00000100 342 - /* 0x00000200 reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */ 343 - #define HID_QUIRK_ALWAYS_POLL 0x00000400 344 - #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 345 - #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID 0x00020000 346 - #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP 0x00040000 347 - #define HID_QUIRK_HAVE_SPECIAL_DRIVER 0x00080000 348 - #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 349 - #define HID_QUIRK_NO_INIT_REPORTS 0x20000000 350 - #define HID_QUIRK_NO_IGNORE 0x40000000 351 - #define HID_QUIRK_NO_INPUT_SYNC 0x80000000 332 + #define HID_QUIRK_INVERT BIT(0) 333 + #define HID_QUIRK_NOTOUCH BIT(1) 334 + #define HID_QUIRK_IGNORE BIT(2) 335 + #define HID_QUIRK_NOGET BIT(3) 336 + #define HID_QUIRK_HIDDEV_FORCE BIT(4) 337 + #define HID_QUIRK_BADPAD BIT(5) 338 + #define HID_QUIRK_MULTI_INPUT BIT(6) 339 + #define HID_QUIRK_HIDINPUT_FORCE BIT(7) 340 + /* BIT(8) reserved for backward compatibility, was HID_QUIRK_NO_EMPTY_INPUT */ 341 + /* BIT(9) reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */ 342 + #define HID_QUIRK_ALWAYS_POLL BIT(10) 343 + #define HID_QUIRK_SKIP_OUTPUT_REPORTS BIT(16) 344 + #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID BIT(17) 345 + #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP BIT(18) 346 + #define HID_QUIRK_HAVE_SPECIAL_DRIVER BIT(19) 347 + #define HID_QUIRK_FULLSPEED_INTERVAL BIT(28) 348 + #define HID_QUIRK_NO_INIT_REPORTS BIT(29) 349 + #define HID_QUIRK_NO_IGNORE BIT(30) 350 + #define HID_QUIRK_NO_INPUT_SYNC BIT(31) 352 351 353 352 /* 354 353 * HID device groups ··· 495 494 char *raw_report; 496 495 }; 497 496 498 - #define HID_CLAIMED_INPUT 1 499 - #define HID_CLAIMED_HIDDEV 2 500 - #define HID_CLAIMED_HIDRAW 4 501 - #define HID_CLAIMED_DRIVER 8 497 + #define HID_CLAIMED_INPUT BIT(0) 498 + #define HID_CLAIMED_HIDDEV BIT(1) 499 + #define HID_CLAIMED_HIDRAW BIT(2) 500 + #define HID_CLAIMED_DRIVER BIT(3) 502 501 503 - #define HID_STAT_ADDED 1 504 - #define HID_STAT_PARSED 2 502 + #define HID_STAT_ADDED BIT(0) 503 + #define HID_STAT_PARSED BIT(1) 505 504 506 505 struct hid_input { 507 506 struct list_head list; ··· 687 686 * @input_mapped: invoked on input registering after mapping an usage 688 687 * @input_configured: invoked just before the device is registered 689 688 * @feature_mapping: invoked on feature registering 690 - * @bus_add_driver: invoked when a HID driver is about to be added 691 - * @bus_removed_driver: invoked when a HID driver has been removed 692 689 * @suspend: invoked on suspend (NULL means nop) 693 690 * @resume: invoked on resume if device was not reset (NULL means nop) 694 691 * @reset_resume: invoked on resume if device was reset (NULL means nop) ··· 741 742 void (*feature_mapping)(struct hid_device *hdev, 742 743 struct hid_field *field, 743 744 struct hid_usage *usage); 744 - void (*bus_add_driver)(struct hid_driver *driver); 745 - void (*bus_removed_driver)(struct hid_driver *driver); 746 745 #ifdef CONFIG_PM 747 746 int (*suspend)(struct hid_device *hdev, pm_message_t message); 748 747 int (*resume)(struct hid_device *hdev); ··· 848 851 extern void hidinput_disconnect(struct hid_device *); 849 852 850 853 int hid_set_field(struct hid_field *, unsigned, __s32); 851 - int hid_input_report(struct hid_device *, int type, u8 *, int, int); 854 + int hid_input_report(struct hid_device *, int type, u8 *, u32, int); 852 855 int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 853 856 struct hid_field *hidinput_get_led_field(struct hid_device *hid); 854 857 unsigned int hidinput_count_leds(struct hid_device *hid); ··· 1099 1102 * 1100 1103 * @report: the report we want to know the length 1101 1104 */ 1102 - static inline int hid_report_len(struct hid_report *report) 1105 + static inline u32 hid_report_len(struct hid_report *report) 1103 1106 { 1104 1107 /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ 1105 1108 return ((report->size - 1) >> 3) + 1 + (report->id > 0); 1106 1109 } 1107 1110 1108 - int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 1111 + int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, 1109 1112 int interrupt); 1110 1113 1111 1114 /* HID quirks API */