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:

- spurious power/wakeup sysfs files removal for I2C-HID devices, from
Andrew Duggan

- Logitech M560 support, from Goffredo Baroncelli

- a lot of housekeeping cleanups to hid-lg4ff driver, from Michal Maly

- improved support for Plantronics devices, from Terry Junge

- Sony Motion Controller and Navigation Controller support and
subsequent cleanups of hid-sony driver, from Frank Praznik and Simon
Wood

- HW support improvements to the Wacom driver, from Jason Gerecke and
Ping Cheng

- assorted small cleanups and device ID additions all over the place

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (69 commits)
HID: cypress: use swap() in cp_report_fixup()
HID: microsoft: Add Surface Power Cover
HID: hid-sony: Fix report descriptor for Navigation Controller
HID: hid-sony: Navigation controller only has 1 LED and no rumble
HID: hid-sony: Add BT support for Navigation Controller
HID: wacom: Introduce new 'touch_input' device
HID: wacom: Split apart 'wacom_setup_pentouch_input_capabilites'
HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type
HID: wacom: Treat features->device_type values as flags
HID: wacom: Simplify 'wacom_update_name'
HID: rmi: Disable populating F30 when the touchpad has physical buttons
HID: plantronics: Update to map volume up/down controls
HID: sony: PS Move fix report descriptor
HID: sony: PS3 Move enable LEDs and Rumble via BT
HID: sony: Add support PS3 Move Battery via BT
HID: sony: Add quirk for MOTION_CONTROLLER_BT
HID: sony: Support PS3 Move Controller when connected via Bluetooth
HID: i2c-hid: Do not set the ACPI companion field in the HID device
usb, HID: Remove Vernier devices from lsusb and hid_ignore_list
HID: hidpp: Add driver for mouse logitech M560
...

+1579 -629
+4 -4
Documentation/ABI/testing/sysfs-driver-hid-logitech-lg4ff
··· 1 - What: /sys/module/hid_logitech/drivers/hid:logitech/<dev>/range. 1 + What: /sys/bus/hid/drivers/logitech/<dev>/range 2 2 Date: July 2011 3 3 KernelVersion: 3.2 4 - Contact: Michal Malý <madcatxster@gmail.com> 4 + Contact: Michal Malý <madcatxster@devoid-pointer.net> 5 5 Description: Display minimum, maximum and current range of the steering 6 6 wheel. Writing a value within min and max boundaries sets the 7 7 range of the wheel. ··· 9 9 What: /sys/bus/hid/drivers/logitech/<dev>/alternate_modes 10 10 Date: Feb 2015 11 11 KernelVersion: 4.1 12 - Contact: Michal Malý <madcatxster@gmail.com> 12 + Contact: Michal Malý <madcatxster@devoid-pointer.net> 13 13 Description: Displays a set of alternate modes supported by a wheel. Each 14 14 mode is listed as follows: 15 15 Tag: Mode Name ··· 45 45 What: /sys/bus/hid/drivers/logitech/<dev>/real_id 46 46 Date: Feb 2015 47 47 KernelVersion: 4.1 48 - Contact: Michal Malý <madcatxster@gmail.com> 48 + Contact: Michal Malý <madcatxster@devoid-pointer.net> 49 49 Description: Displays the real model of the wheel regardless of any 50 50 alternate mode the wheel might be switched to. 51 51 It is a read-only value.
+12
MAINTAINERS
··· 4650 4650 F: include/linux/hid* 4651 4651 F: include/uapi/linux/hid* 4652 4652 4653 + HID SENSOR HUB DRIVERS 4654 + M: Jiri Kosina <jkosina@suse.cz> 4655 + M: Jonathan Cameron <jic23@kernel.org> 4656 + M: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> 4657 + L: linux-input@vger.kernel.org 4658 + L: linux-iio@vger.kernel.org 4659 + S: Maintained 4660 + F: Documentation/hid/hid-sensor* 4661 + F: drivers/hid/hid-sensor-* 4662 + F: drivers/iio/*/hid-* 4663 + F: include/linux/hid-sensor-* 4664 + 4653 4665 HIGH-RESOLUTION TIMERS, CLOCKEVENTS, DYNTICKS 4654 4666 M: Thomas Gleixner <tglx@linutronix.de> 4655 4667 L: linux-kernel@vger.kernel.org
+6 -1
drivers/hid/Kconfig
··· 634 634 tristate "Plantronics USB HID Driver" 635 635 depends on HID 636 636 ---help--- 637 - Provides HID support for Plantronics telephony devices. 637 + Provides HID support for Plantronics USB audio devices. 638 + Correctly maps vendor unique volume up/down HID usages to 639 + KEY_VOLUMEUP and KEY_VOLUMEDOWN events and prevents core mapping 640 + of other vendor unique HID usages to random mouse events. 641 + 642 + Say M here if you may ever plug in a Plantronics USB audio device. 638 643 639 644 config HID_PRIMAX 640 645 tristate "Primax non-fully HID-compliant devices"
+3 -3
drivers/hid/Makefile
··· 24 24 obj-$(CONFIG_HID_ACRUX) += hid-axff.o 25 25 obj-$(CONFIG_HID_APPLE) += hid-apple.o 26 26 obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o 27 - obj-$(CONFIG_HID_AUREAL) += hid-aureal.o 27 + obj-$(CONFIG_HID_AUREAL) += hid-aureal.o 28 28 obj-$(CONFIG_HID_BELKIN) += hid-belkin.o 29 29 obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o 30 30 obj-$(CONFIG_HID_CHERRY) += hid-cherry.o ··· 46 46 obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o 47 47 obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o 48 48 obj-$(CONFIG_HID_KYE) += hid-kye.o 49 - obj-$(CONFIG_HID_LCPOWER) += hid-lcpower.o 49 + obj-$(CONFIG_HID_LCPOWER) += hid-lcpower.o 50 50 obj-$(CONFIG_HID_LENOVO) += hid-lenovo.o 51 51 obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 52 52 obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o 53 53 obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o 54 - obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o 54 + obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o 55 55 obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 56 56 obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o 57 57 obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o
+15 -23
drivers/hid/hid-core.c
··· 706 706 707 707 if (hid->vendor == USB_VENDOR_ID_MICROSOFT && 708 708 (hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 || 709 - hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3_JP) && 709 + hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3_JP || 710 + hid->product == USB_DEVICE_ID_MS_POWER_COVER) && 710 711 hid->group == HID_GROUP_MULTITOUCH) 711 712 hid->group = HID_GROUP_GENERIC; 712 713 ··· 1062 1061 * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 1063 1062 */ 1064 1063 1065 - static __u32 extract(const struct hid_device *hid, __u8 *report, 1064 + __u32 hid_field_extract(const struct hid_device *hid, __u8 *report, 1066 1065 unsigned offset, unsigned n) 1067 1066 { 1068 1067 u64 x; 1069 1068 1070 1069 if (n > 32) 1071 - hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 1070 + hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n", 1072 1071 n, current->comm); 1073 1072 1074 1073 report += offset >> 3; /* adjust byte index */ ··· 1077 1076 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 1078 1077 return (u32) x; 1079 1078 } 1079 + EXPORT_SYMBOL_GPL(hid_field_extract); 1080 1080 1081 1081 /* 1082 1082 * "implement" : set bits in a little endian bit stream. ··· 1223 1221 for (n = 0; n < count; n++) { 1224 1222 1225 1223 value[n] = min < 0 ? 1226 - snto32(extract(hid, data, offset + n * size, size), 1227 - size) : 1228 - extract(hid, data, offset + n * size, size); 1224 + snto32(hid_field_extract(hid, data, offset + n * size, 1225 + size), size) : 1226 + hid_field_extract(hid, data, offset + n * size, size); 1229 1227 1230 1228 /* Ignore report if ErrorRollOver */ 1231 1229 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && ··· 1853 1851 { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, 1854 1852 { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) }, 1855 1853 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) }, 1854 + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) }, 1856 1855 #endif 1857 1856 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 1858 1857 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, ··· 1904 1901 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) }, 1905 1902 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3) }, 1906 1903 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP) }, 1904 + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER) }, 1907 1905 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1908 1906 { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) }, 1909 1907 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, ··· 1963 1959 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) }, 1964 1960 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) }, 1965 1961 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) }, 1962 + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) }, 1963 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) }, 1964 + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1965 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1966 1966 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) }, 1967 1967 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1968 - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1969 1968 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1970 1969 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, 1971 1970 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, ··· 2004 1997 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 2005 1998 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 2006 1999 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 2000 + { HID_USB_DEVICE(USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII) }, 2007 2001 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 2008 2002 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 2009 2003 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, ··· 2273 2265 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 2274 2266 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 2275 2267 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 2276 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 2277 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 2278 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 2279 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 2280 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 2281 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 2282 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 2283 - { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 2284 2268 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 2285 2269 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 2286 2270 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, ··· 2399 2399 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) }, 2400 2400 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) }, 2401 2401 #endif 2402 - { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 2403 - { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 2404 - { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 2405 - { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 2406 - { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 2407 - { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 2408 - { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 2409 - { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 2410 2402 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 2411 2403 { HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) }, 2412 2404 { }
+1 -5
drivers/hid/hid-cypress.c
··· 41 41 42 42 for (i = 0; i < *rsize - 4; i++) 43 43 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { 44 - __u8 tmp; 45 - 46 44 rdesc[i] = 0x19; 47 45 rdesc[i + 2] = 0x29; 48 - tmp = rdesc[i + 3]; 49 - rdesc[i + 3] = rdesc[i + 1]; 50 - rdesc[i + 1] = tmp; 46 + swap(rdesc[i + 3], rdesc[i + 1]); 51 47 } 52 48 return rdesc; 53 49 }
+11 -20
drivers/hid/hid-ids.h
··· 227 227 #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 228 228 #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d 229 229 #define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 230 + #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053 230 231 #define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123 231 232 #define USB_DEVICE_ID_CHICONY_AK1D 0x1125 232 233 ··· 363 362 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106 0x0106 364 363 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a 365 364 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100 366 - 367 - #define USB_VENDOR_ID_GLAB 0x06c2 368 - #define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 369 - #define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 370 - #define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040 371 - #define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044 372 - #define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045 373 - #define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051 374 - #define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053 375 - #define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058 376 365 377 366 #define USB_VENDOR_ID_GOODTOUCH 0x1aad 378 367 #define USB_DEVICE_ID_GOODTOUCH_000f 0x000f ··· 577 586 #define USB_DEVICE_ID_LENOVO_TPKBD 0x6009 578 587 #define USB_DEVICE_ID_LENOVO_CUSBKBD 0x6047 579 588 #define USB_DEVICE_ID_LENOVO_CBTKBD 0x6048 589 + #define USB_DEVICE_ID_LENOVO_TPPRODOCK 0x6067 580 590 581 591 #define USB_VENDOR_ID_LG 0x1fd2 582 592 #define USB_DEVICE_ID_LG_MULTITOUCH 0x0064 ··· 665 673 #define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 666 674 #define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07dc 667 675 #define USB_DEVICE_ID_MS_TYPE_COVER_3_JP 0x07dd 676 + #define USB_DEVICE_ID_MS_POWER_COVER 0x07da 668 677 669 678 #define USB_VENDOR_ID_MOJO 0x8282 670 679 #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 ··· 845 852 #define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 846 853 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 847 854 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 855 + #define USB_DEVICE_ID_SONY_MOTION_CONTROLLER 0x03d5 848 856 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f 849 857 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002 850 858 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 ··· 952 958 #define USB_DEVICE_ID_VELLEMAN_K8061_FIRST 0x8061 953 959 #define USB_DEVICE_ID_VELLEMAN_K8061_LAST 0x8068 954 960 955 - #define USB_VENDOR_ID_VERNIER 0x08f7 956 - #define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 957 - #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 958 - #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 959 - #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 960 - #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 961 - 962 961 #define USB_VENDOR_ID_VTL 0x0306 963 962 #define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f 964 963 ··· 970 983 971 984 #define USB_VENDOR_ID_WISEGROUP 0x0925 972 985 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 973 - #define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 974 - #define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 975 - #define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 976 986 #define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888 977 987 #define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800 978 988 #define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 ··· 1022 1038 1023 1039 #define USB_VENDOR_ID_RISO_KAGAKU 0x1294 /* Riso Kagaku Corp. */ 1024 1040 #define USB_DEVICE_ID_RI_KA_WEBMAIL 0x1320 /* Webmail Notifier */ 1041 + 1042 + #define USB_VENDOR_ID_MULTIPLE_1781 0x1781 1043 + #define USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD 0x0a8d 1044 + 1045 + #define USB_VENDOR_ID_DRACAL_RAPHNET 0x289b 1046 + #define USB_DEVICE_ID_RAPHNET_2NES2SNES 0x0002 1047 + #define USB_DEVICE_ID_RAPHNET_4NES4SNES 0x0003 1025 1048 1026 1049 #endif
+2 -1
drivers/hid/hid-input.c
··· 1157 1157 return; 1158 1158 1159 1159 /* report the usage code as scancode if the key status has changed */ 1160 - if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value) 1160 + if (usage->type == EV_KEY && 1161 + (!test_bit(usage->code, input->key)) == value) 1161 1162 input_event(input, EV_MSC, MSC_SCAN, usage->hid); 1162 1163 1163 1164 input_event(input, usage->type, usage->code, value);
+57 -2
drivers/hid/hid-lenovo.c
··· 43 43 44 44 #define map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c)) 45 45 46 + static const __u8 lenovo_pro_dock_need_fixup_collection[] = { 47 + 0x05, 0x88, /* Usage Page (Vendor Usage Page 0x88) */ 48 + 0x09, 0x01, /* Usage (Vendor Usage 0x01) */ 49 + 0xa1, 0x01, /* Collection (Application) */ 50 + 0x85, 0x04, /* Report ID (4) */ 51 + 0x19, 0x00, /* Usage Minimum (0) */ 52 + 0x2a, 0xff, 0xff, /* Usage Maximum (65535) */ 53 + }; 54 + 55 + static __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc, 56 + unsigned int *rsize) 57 + { 58 + switch (hdev->product) { 59 + case USB_DEVICE_ID_LENOVO_TPPRODOCK: 60 + /* the fixups that need to be done: 61 + * - get a reasonable usage max for the vendor collection 62 + * 0x8801 from the report ID 4 63 + */ 64 + if (*rsize >= 153 && 65 + memcmp(&rdesc[140], lenovo_pro_dock_need_fixup_collection, 66 + sizeof(lenovo_pro_dock_need_fixup_collection)) == 0) { 67 + rdesc[151] = 0x01; 68 + rdesc[152] = 0x00; 69 + } 70 + break; 71 + } 72 + return rdesc; 73 + } 74 + 46 75 static int lenovo_input_mapping_tpkbd(struct hid_device *hdev, 47 76 struct hid_input *hi, struct hid_field *field, 48 77 struct hid_usage *usage, unsigned long **bit, int *max) ··· 628 599 GFP_KERNEL); 629 600 if (data_pointer == NULL) { 630 601 hid_err(hdev, "Could not allocate memory for driver data\n"); 631 - return -ENOMEM; 602 + ret = -ENOMEM; 603 + goto err; 632 604 } 633 605 634 606 // set same default values as windows driver ··· 640 610 name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); 641 611 if (name_mute == NULL || name_micmute == NULL) { 642 612 hid_err(hdev, "Could not allocate memory for led data\n"); 643 - return -ENOMEM; 613 + ret = -ENOMEM; 614 + goto err; 644 615 } 645 616 snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(dev)); 646 617 snprintf(name_micmute, name_sz, "%s:amber:micmute", dev_name(dev)); ··· 665 634 lenovo_features_set_tpkbd(hdev); 666 635 667 636 return 0; 637 + err: 638 + sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd); 639 + return ret; 668 640 } 669 641 670 642 static int lenovo_probe_cptkbd(struct hid_device *hdev) ··· 796 762 hid_hw_stop(hdev); 797 763 } 798 764 765 + static void lenovo_input_configured(struct hid_device *hdev, 766 + struct hid_input *hi) 767 + { 768 + switch (hdev->product) { 769 + case USB_DEVICE_ID_LENOVO_TPKBD: 770 + case USB_DEVICE_ID_LENOVO_CUSBKBD: 771 + case USB_DEVICE_ID_LENOVO_CBTKBD: 772 + if (test_bit(EV_REL, hi->input->evbit)) { 773 + /* set only for trackpoint device */ 774 + __set_bit(INPUT_PROP_POINTER, hi->input->propbit); 775 + __set_bit(INPUT_PROP_POINTING_STICK, 776 + hi->input->propbit); 777 + } 778 + break; 779 + } 780 + } 781 + 782 + 799 783 static const struct hid_device_id lenovo_devices[] = { 800 784 { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, 801 785 { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) }, 802 786 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) }, 787 + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) }, 803 788 { } 804 789 }; 805 790 ··· 827 774 static struct hid_driver lenovo_driver = { 828 775 .name = "lenovo", 829 776 .id_table = lenovo_devices, 777 + .input_configured = lenovo_input_configured, 830 778 .input_mapping = lenovo_input_mapping, 831 779 .probe = lenovo_probe, 832 780 .remove = lenovo_remove, 833 781 .raw_event = lenovo_raw_event, 782 + .report_fixup = lenovo_report_fixup, 834 783 }; 835 784 module_hid_driver(lenovo_driver); 836 785
+14 -10
drivers/hid/hid-lg.c
··· 700 700 /* insert a little delay of 10 jiffies ~ 40ms */ 701 701 wait_queue_head_t wait; 702 702 init_waitqueue_head (&wait); 703 - wait_event_interruptible_timeout(wait, 0, 10); 703 + wait_event_interruptible_timeout(wait, 0, 704 + msecs_to_jiffies(40)); 704 705 705 706 /* Select random Address */ 706 707 buf[1] = 0xB2; ··· 713 712 } 714 713 715 714 if (drv_data->quirks & LG_FF) 716 - lgff_init(hdev); 717 - if (drv_data->quirks & LG_FF2) 718 - lg2ff_init(hdev); 719 - if (drv_data->quirks & LG_FF3) 720 - lg3ff_init(hdev); 721 - if (drv_data->quirks & LG_FF4) 722 - lg4ff_init(hdev); 715 + ret = lgff_init(hdev); 716 + else if (drv_data->quirks & LG_FF2) 717 + ret = lg2ff_init(hdev); 718 + else if (drv_data->quirks & LG_FF3) 719 + ret = lg3ff_init(hdev); 720 + else if (drv_data->quirks & LG_FF4) 721 + ret = lg4ff_init(hdev); 722 + 723 + if (ret) 724 + goto err_free; 723 725 724 726 return 0; 725 727 err_free: ··· 735 731 struct lg_drv_data *drv_data = hid_get_drvdata(hdev); 736 732 if (drv_data->quirks & LG_FF4) 737 733 lg4ff_deinit(hdev); 738 - 739 - hid_hw_stop(hdev); 734 + else 735 + hid_hw_stop(hdev); 740 736 kfree(drv_data); 741 737 } 742 738
+299 -157
drivers/hid/hid-lg4ff.c
··· 68 68 #define LG4FF_FFEX_REV_MAJ 0x21 69 69 #define LG4FF_FFEX_REV_MIN 0x00 70 70 71 - static void hid_lg4ff_set_range_dfp(struct hid_device *hid, u16 range); 72 - static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range); 71 + static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range); 72 + static void lg4ff_set_range_g25(struct hid_device *hid, u16 range); 73 73 74 - struct lg4ff_device_entry { 75 - __u32 product_id; 76 - __u16 range; 77 - __u16 min_range; 78 - __u16 max_range; 74 + struct lg4ff_wheel_data { 75 + const u32 product_id; 76 + u16 range; 77 + const u16 min_range; 78 + const u16 max_range; 79 79 #ifdef CONFIG_LEDS_CLASS 80 - __u8 led_state; 80 + u8 led_state; 81 81 struct led_classdev *led[5]; 82 82 #endif 83 - u32 alternate_modes; 84 - const char *real_tag; 85 - const char *real_name; 86 - u16 real_product_id; 87 - struct list_head list; 83 + const u32 alternate_modes; 84 + const char * const real_tag; 85 + const char * const real_name; 86 + const u16 real_product_id; 87 + 88 88 void (*set_range)(struct hid_device *hid, u16 range); 89 + }; 90 + 91 + struct lg4ff_device_entry { 92 + spinlock_t report_lock; /* Protect output HID report */ 93 + struct hid_report *report; 94 + struct lg4ff_wheel_data wdata; 89 95 }; 90 96 91 97 static const signed short lg4ff_wheel_effects[] = { ··· 101 95 }; 102 96 103 97 struct lg4ff_wheel { 104 - const __u32 product_id; 98 + const u32 product_id; 105 99 const signed short *ff_effects; 106 - const __u16 min_range; 107 - const __u16 max_range; 100 + const u16 min_range; 101 + const u16 max_range; 108 102 void (*set_range)(struct hid_device *hid, u16 range); 109 103 }; 110 104 111 105 struct lg4ff_compat_mode_switch { 112 - const __u8 cmd_count; /* Number of commands to send */ 113 - const __u8 cmd[]; 106 + const u8 cmd_count; /* Number of commands to send */ 107 + const u8 cmd[]; 114 108 }; 115 109 116 110 struct lg4ff_wheel_ident_info { ··· 140 134 static const struct lg4ff_wheel lg4ff_devices[] = { 141 135 {USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, 142 136 {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, 143 - {USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_dfp}, 144 - {USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, 145 - {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, 146 - {USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, 137 + {USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_dfp}, 138 + {USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25}, 139 + {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25}, 140 + {USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25}, 147 141 {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2, lg4ff_wheel_effects, 40, 270, NULL}, 148 142 {USB_DEVICE_ID_LOGITECH_WII_WHEEL, lg4ff_wheel_effects, 40, 270, NULL} 149 143 }; ··· 251 245 }; 252 246 253 247 /* Recalculates X axis value accordingly to currently selected range */ 254 - static __s32 lg4ff_adjust_dfp_x_axis(__s32 value, __u16 range) 248 + static s32 lg4ff_adjust_dfp_x_axis(s32 value, u16 range) 255 249 { 256 - __u16 max_range; 257 - __s32 new_value; 250 + u16 max_range; 251 + s32 new_value; 258 252 259 253 if (range == 900) 260 254 return value; ··· 275 269 } 276 270 277 271 int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, 278 - struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data) 272 + struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data) 279 273 { 280 274 struct lg4ff_device_entry *entry = drv_data->device_props; 281 - __s32 new_value = 0; 275 + s32 new_value = 0; 282 276 283 277 if (!entry) { 284 278 hid_err(hid, "Device properties not found"); 285 279 return 0; 286 280 } 287 281 288 - switch (entry->product_id) { 282 + switch (entry->wdata.product_id) { 289 283 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL: 290 284 switch (usage->code) { 291 285 case ABS_X: 292 - new_value = lg4ff_adjust_dfp_x_axis(value, entry->range); 286 + new_value = lg4ff_adjust_dfp_x_axis(value, entry->wdata.range); 293 287 input_event(field->hidinput->input, usage->type, usage->code, new_value); 294 288 return 1; 295 289 default: ··· 300 294 } 301 295 } 302 296 303 - static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 297 + static void lg4ff_init_wheel_data(struct lg4ff_wheel_data * const wdata, const struct lg4ff_wheel *wheel, 298 + const struct lg4ff_multimode_wheel *mmode_wheel, 299 + const u16 real_product_id) 300 + { 301 + u32 alternate_modes = 0; 302 + const char *real_tag = NULL; 303 + const char *real_name = NULL; 304 + 305 + if (mmode_wheel) { 306 + alternate_modes = mmode_wheel->alternate_modes; 307 + real_tag = mmode_wheel->real_tag; 308 + real_name = mmode_wheel->real_name; 309 + } 310 + 311 + { 312 + struct lg4ff_wheel_data t_wdata = { .product_id = wheel->product_id, 313 + .real_product_id = real_product_id, 314 + .min_range = wheel->min_range, 315 + .max_range = wheel->max_range, 316 + .set_range = wheel->set_range, 317 + .alternate_modes = alternate_modes, 318 + .real_tag = real_tag, 319 + .real_name = real_name }; 320 + 321 + memcpy(wdata, &t_wdata, sizeof(t_wdata)); 322 + } 323 + } 324 + 325 + static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 304 326 { 305 327 struct hid_device *hid = input_get_drvdata(dev); 306 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 307 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 308 - __s32 *value = report->field[0]->value; 328 + struct lg4ff_device_entry *entry; 329 + struct lg_drv_data *drv_data; 330 + unsigned long flags; 331 + s32 *value; 309 332 int x; 333 + 334 + drv_data = hid_get_drvdata(hid); 335 + if (!drv_data) { 336 + hid_err(hid, "Private driver data not found!\n"); 337 + return -EINVAL; 338 + } 339 + 340 + entry = drv_data->device_props; 341 + if (!entry) { 342 + hid_err(hid, "Device properties not found!\n"); 343 + return -EINVAL; 344 + } 345 + value = entry->report->field[0]->value; 310 346 311 347 #define CLAMP(x) do { if (x < 0) x = 0; else if (x > 0xff) x = 0xff; } while (0) 312 348 ··· 357 309 x = effect->u.ramp.start_level + 0x80; /* 0x80 is no force */ 358 310 CLAMP(x); 359 311 312 + spin_lock_irqsave(&entry->report_lock, flags); 360 313 if (x == 0x80) { 361 314 /* De-activate force in slot-1*/ 362 315 value[0] = 0x13; ··· 368 319 value[5] = 0x00; 369 320 value[6] = 0x00; 370 321 371 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 322 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 323 + spin_unlock_irqrestore(&entry->report_lock, flags); 372 324 return 0; 373 325 } 374 326 ··· 381 331 value[5] = 0x00; 382 332 value[6] = 0x00; 383 333 384 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 334 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 335 + spin_unlock_irqrestore(&entry->report_lock, flags); 385 336 break; 386 337 } 387 338 return 0; ··· 390 339 391 340 /* Sends default autocentering command compatible with 392 341 * all wheels except Formula Force EX */ 393 - static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) 342 + static void lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) 394 343 { 395 344 struct hid_device *hid = input_get_drvdata(dev); 396 345 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 397 346 struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 398 - __s32 *value = report->field[0]->value; 399 - __u32 expand_a, expand_b; 347 + s32 *value = report->field[0]->value; 348 + u32 expand_a, expand_b; 400 349 struct lg4ff_device_entry *entry; 401 350 struct lg_drv_data *drv_data; 351 + unsigned long flags; 402 352 403 353 drv_data = hid_get_drvdata(hid); 404 354 if (!drv_data) { ··· 412 360 hid_err(hid, "Device properties not found!\n"); 413 361 return; 414 362 } 363 + value = entry->report->field[0]->value; 415 364 416 365 /* De-activate Auto-Center */ 366 + spin_lock_irqsave(&entry->report_lock, flags); 417 367 if (magnitude == 0) { 418 368 value[0] = 0xf5; 419 369 value[1] = 0x00; ··· 425 371 value[5] = 0x00; 426 372 value[6] = 0x00; 427 373 428 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 374 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 375 + spin_unlock_irqrestore(&entry->report_lock, flags); 429 376 return; 430 377 } 431 378 ··· 439 384 } 440 385 441 386 /* Adjust for non-MOMO wheels */ 442 - switch (entry->product_id) { 387 + switch (entry->wdata.product_id) { 443 388 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL: 444 389 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2: 445 390 break; ··· 456 401 value[5] = 0x00; 457 402 value[6] = 0x00; 458 403 459 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 404 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 460 405 461 406 /* Activate Auto-Center */ 462 407 value[0] = 0x14; ··· 467 412 value[5] = 0x00; 468 413 value[6] = 0x00; 469 414 470 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 415 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 416 + spin_unlock_irqrestore(&entry->report_lock, flags); 471 417 } 472 418 473 419 /* Sends autocentering command compatible with Formula Force EX */ 474 - static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude) 420 + static void lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude) 475 421 { 476 422 struct hid_device *hid = input_get_drvdata(dev); 477 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 478 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 479 - __s32 *value = report->field[0]->value; 423 + struct lg4ff_device_entry *entry; 424 + struct lg_drv_data *drv_data; 425 + unsigned long flags; 426 + s32 *value; 480 427 magnitude = magnitude * 90 / 65535; 481 428 429 + drv_data = hid_get_drvdata(hid); 430 + if (!drv_data) { 431 + hid_err(hid, "Private driver data not found!\n"); 432 + return; 433 + } 434 + 435 + entry = drv_data->device_props; 436 + if (!entry) { 437 + hid_err(hid, "Device properties not found!\n"); 438 + return; 439 + } 440 + value = entry->report->field[0]->value; 441 + 442 + spin_lock_irqsave(&entry->report_lock, flags); 482 443 value[0] = 0xfe; 483 444 value[1] = 0x03; 484 445 value[2] = magnitude >> 14; ··· 503 432 value[5] = 0x00; 504 433 value[6] = 0x00; 505 434 506 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 435 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 436 + spin_unlock_irqrestore(&entry->report_lock, flags); 507 437 } 508 438 509 439 /* Sends command to set range compatible with G25/G27/Driving Force GT */ 510 - static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range) 440 + static void lg4ff_set_range_g25(struct hid_device *hid, u16 range) 511 441 { 512 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 513 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 514 - __s32 *value = report->field[0]->value; 442 + struct lg4ff_device_entry *entry; 443 + struct lg_drv_data *drv_data; 444 + unsigned long flags; 445 + s32 *value; 515 446 447 + drv_data = hid_get_drvdata(hid); 448 + if (!drv_data) { 449 + hid_err(hid, "Private driver data not found!\n"); 450 + return; 451 + } 452 + 453 + entry = drv_data->device_props; 454 + if (!entry) { 455 + hid_err(hid, "Device properties not found!\n"); 456 + return; 457 + } 458 + value = entry->report->field[0]->value; 516 459 dbg_hid("G25/G27/DFGT: setting range to %u\n", range); 517 460 461 + spin_lock_irqsave(&entry->report_lock, flags); 518 462 value[0] = 0xf8; 519 463 value[1] = 0x81; 520 464 value[2] = range & 0x00ff; ··· 538 452 value[5] = 0x00; 539 453 value[6] = 0x00; 540 454 541 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 455 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 456 + spin_unlock_irqrestore(&entry->report_lock, flags); 542 457 } 543 458 544 459 /* Sends commands to set range compatible with Driving Force Pro wheel */ 545 - static void hid_lg4ff_set_range_dfp(struct hid_device *hid, __u16 range) 460 + static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range) 546 461 { 547 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 548 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 462 + struct lg4ff_device_entry *entry; 463 + struct lg_drv_data *drv_data; 464 + unsigned long flags; 549 465 int start_left, start_right, full_range; 550 - __s32 *value = report->field[0]->value; 466 + s32 *value; 551 467 468 + drv_data = hid_get_drvdata(hid); 469 + if (!drv_data) { 470 + hid_err(hid, "Private driver data not found!\n"); 471 + return; 472 + } 473 + 474 + entry = drv_data->device_props; 475 + if (!entry) { 476 + hid_err(hid, "Device properties not found!\n"); 477 + return; 478 + } 479 + value = entry->report->field[0]->value; 552 480 dbg_hid("Driving Force Pro: setting range to %u\n", range); 553 481 554 482 /* Prepare "coarse" limit command */ 483 + spin_lock_irqsave(&entry->report_lock, flags); 555 484 value[0] = 0xf8; 556 485 value[1] = 0x00; /* Set later */ 557 486 value[2] = 0x00; ··· 576 475 value[6] = 0x00; 577 476 578 477 if (range > 200) { 579 - report->field[0]->value[1] = 0x03; 478 + value[1] = 0x03; 580 479 full_range = 900; 581 480 } else { 582 - report->field[0]->value[1] = 0x02; 481 + value[1] = 0x02; 583 482 full_range = 200; 584 483 } 585 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 484 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 586 485 587 486 /* Prepare "fine" limit command */ 588 487 value[0] = 0x81; ··· 594 493 value[6] = 0x00; 595 494 596 495 if (range == 200 || range == 900) { /* Do not apply any fine limit */ 597 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 496 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 497 + spin_unlock_irqrestore(&entry->report_lock, flags); 598 498 return; 599 499 } 600 500 ··· 609 507 value[5] = (start_right & 0xe) << 4 | (start_left & 0xe); 610 508 value[6] = 0xff; 611 509 612 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 510 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 511 + spin_unlock_irqrestore(&entry->report_lock, flags); 613 512 } 614 513 615 514 static const struct lg4ff_compat_mode_switch *lg4ff_get_mode_switch_command(const u16 real_product_id, const u16 target_product_id) ··· 672 569 673 570 static int lg4ff_switch_compatibility_mode(struct hid_device *hid, const struct lg4ff_compat_mode_switch *s) 674 571 { 675 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 676 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 677 - __s32 *value = report->field[0]->value; 572 + struct lg4ff_device_entry *entry; 573 + struct lg_drv_data *drv_data; 574 + unsigned long flags; 575 + s32 *value; 678 576 u8 i; 679 577 578 + drv_data = hid_get_drvdata(hid); 579 + if (!drv_data) { 580 + hid_err(hid, "Private driver data not found!\n"); 581 + return -EINVAL; 582 + } 583 + 584 + entry = drv_data->device_props; 585 + if (!entry) { 586 + hid_err(hid, "Device properties not found!\n"); 587 + return -EINVAL; 588 + } 589 + value = entry->report->field[0]->value; 590 + 591 + spin_lock_irqsave(&entry->report_lock, flags); 680 592 for (i = 0; i < s->cmd_count; i++) { 681 593 u8 j; 682 594 683 595 for (j = 0; j < 7; j++) 684 596 value[j] = s->cmd[j + (7*i)]; 685 597 686 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 598 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 687 599 } 600 + spin_unlock_irqrestore(&entry->report_lock, flags); 688 601 hid_hw_wait(hid); 689 602 return 0; 690 603 } ··· 725 606 return 0; 726 607 } 727 608 728 - if (!entry->real_name) { 609 + if (!entry->wdata.real_name) { 729 610 hid_err(hid, "NULL pointer to string\n"); 730 611 return 0; 731 612 } 732 613 733 614 for (i = 0; i < LG4FF_MODE_MAX_IDX; i++) { 734 - if (entry->alternate_modes & BIT(i)) { 615 + if (entry->wdata.alternate_modes & BIT(i)) { 735 616 /* Print tag and full name */ 736 617 count += scnprintf(buf + count, PAGE_SIZE - count, "%s: %s", 737 618 lg4ff_alternate_modes[i].tag, 738 - !lg4ff_alternate_modes[i].product_id ? entry->real_name : lg4ff_alternate_modes[i].name); 619 + !lg4ff_alternate_modes[i].product_id ? entry->wdata.real_name : lg4ff_alternate_modes[i].name); 739 620 if (count >= PAGE_SIZE - 1) 740 621 return count; 741 622 742 623 /* Mark the currently active mode with an asterisk */ 743 - if (lg4ff_alternate_modes[i].product_id == entry->product_id || 744 - (lg4ff_alternate_modes[i].product_id == 0 && entry->product_id == entry->real_product_id)) 624 + if (lg4ff_alternate_modes[i].product_id == entry->wdata.product_id || 625 + (lg4ff_alternate_modes[i].product_id == 0 && entry->wdata.product_id == entry->wdata.real_product_id)) 745 626 count += scnprintf(buf + count, PAGE_SIZE - count, " *\n"); 746 627 else 747 628 count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); ··· 794 675 const u16 mode_product_id = lg4ff_alternate_modes[i].product_id; 795 676 const char *tag = lg4ff_alternate_modes[i].tag; 796 677 797 - if (entry->alternate_modes & BIT(i)) { 678 + if (entry->wdata.alternate_modes & BIT(i)) { 798 679 if (!strcmp(tag, lbuf)) { 799 680 if (!mode_product_id) 800 - target_product_id = entry->real_product_id; 681 + target_product_id = entry->wdata.real_product_id; 801 682 else 802 683 target_product_id = mode_product_id; 803 684 break; ··· 812 693 } 813 694 kfree(lbuf); /* Not needed anymore */ 814 695 815 - if (target_product_id == entry->product_id) /* Nothing to do */ 696 + if (target_product_id == entry->wdata.product_id) /* Nothing to do */ 816 697 return count; 817 698 818 699 /* Automatic switching has to be disabled for the switch to DF-EX mode to work correctly */ 819 700 if (target_product_id == USB_DEVICE_ID_LOGITECH_WHEEL && !lg4ff_no_autoswitch) { 820 701 hid_info(hid, "\"%s\" cannot be switched to \"DF-EX\" mode. Load the \"hid_logitech\" module with \"lg4ff_no_autoswitch=1\" parameter set and try again\n", 821 - entry->real_name); 702 + entry->wdata.real_name); 822 703 return -EINVAL; 823 704 } 824 705 825 706 /* Take care of hardware limitations */ 826 - if ((entry->real_product_id == USB_DEVICE_ID_LOGITECH_DFP_WHEEL || entry->real_product_id == USB_DEVICE_ID_LOGITECH_G25_WHEEL) && 827 - entry->product_id > target_product_id) { 828 - hid_info(hid, "\"%s\" cannot be switched back into \"%s\" mode\n", entry->real_name, lg4ff_alternate_modes[i].name); 707 + if ((entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_DFP_WHEEL || entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_G25_WHEEL) && 708 + entry->wdata.product_id > target_product_id) { 709 + hid_info(hid, "\"%s\" cannot be switched back into \"%s\" mode\n", entry->wdata.real_name, lg4ff_alternate_modes[i].name); 829 710 return -EINVAL; 830 711 } 831 712 832 - s = lg4ff_get_mode_switch_command(entry->real_product_id, target_product_id); 713 + s = lg4ff_get_mode_switch_command(entry->wdata.real_product_id, target_product_id); 833 714 if (!s) { 834 715 hid_err(hid, "Invalid target product ID %X\n", target_product_id); 835 716 return -EINVAL; ··· 840 721 } 841 722 static DEVICE_ATTR(alternate_modes, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_alternate_modes_show, lg4ff_alternate_modes_store); 842 723 843 - /* Read current range and display it in terminal */ 844 - static ssize_t range_show(struct device *dev, struct device_attribute *attr, 845 - char *buf) 724 + /* Export the currently set range of the wheel */ 725 + static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr, 726 + char *buf) 846 727 { 847 728 struct hid_device *hid = to_hid_device(dev); 848 729 struct lg4ff_device_entry *entry; ··· 861 742 return 0; 862 743 } 863 744 864 - count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->range); 745 + count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.range); 865 746 return count; 866 747 } 867 748 868 749 /* Set range to user specified value, call appropriate function 869 750 * according to the type of the wheel */ 870 - static ssize_t range_store(struct device *dev, struct device_attribute *attr, 871 - const char *buf, size_t count) 751 + static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr, 752 + const char *buf, size_t count) 872 753 { 873 754 struct hid_device *hid = to_hid_device(dev); 874 755 struct lg4ff_device_entry *entry; 875 756 struct lg_drv_data *drv_data; 876 - __u16 range = simple_strtoul(buf, NULL, 10); 757 + u16 range = simple_strtoul(buf, NULL, 10); 877 758 878 759 drv_data = hid_get_drvdata(hid); 879 760 if (!drv_data) { ··· 888 769 } 889 770 890 771 if (range == 0) 891 - range = entry->max_range; 772 + range = entry->wdata.max_range; 892 773 893 774 /* Check if the wheel supports range setting 894 775 * and that the range is within limits for the wheel */ 895 - if (entry->set_range != NULL && range >= entry->min_range && range <= entry->max_range) { 896 - entry->set_range(hid, range); 897 - entry->range = range; 776 + if (entry->wdata.set_range && range >= entry->wdata.min_range && range <= entry->wdata.max_range) { 777 + entry->wdata.set_range(hid, range); 778 + entry->wdata.range = range; 898 779 } 899 780 900 781 return count; 901 782 } 902 - static DEVICE_ATTR_RW(range); 783 + static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_range_show, lg4ff_range_store); 903 784 904 785 static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *attr, char *buf) 905 786 { ··· 920 801 return 0; 921 802 } 922 803 923 - if (!entry->real_tag || !entry->real_name) { 804 + if (!entry->wdata.real_tag || !entry->wdata.real_name) { 924 805 hid_err(hid, "NULL pointer to string\n"); 925 806 return 0; 926 807 } 927 808 928 - count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->real_tag, entry->real_name); 809 + count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name); 929 810 return count; 930 811 } 931 812 ··· 937 818 static DEVICE_ATTR(real_id, S_IRUGO, lg4ff_real_id_show, lg4ff_real_id_store); 938 819 939 820 #ifdef CONFIG_LEDS_CLASS 940 - static void lg4ff_set_leds(struct hid_device *hid, __u8 leds) 821 + static void lg4ff_set_leds(struct hid_device *hid, u8 leds) 941 822 { 942 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 943 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 944 - __s32 *value = report->field[0]->value; 823 + struct lg_drv_data *drv_data; 824 + struct lg4ff_device_entry *entry; 825 + unsigned long flags; 826 + s32 *value; 945 827 828 + drv_data = hid_get_drvdata(hid); 829 + if (!drv_data) { 830 + hid_err(hid, "Private driver data not found!\n"); 831 + return; 832 + } 833 + 834 + entry = drv_data->device_props; 835 + if (!entry) { 836 + hid_err(hid, "Device properties not found!\n"); 837 + return; 838 + } 839 + value = entry->report->field[0]->value; 840 + 841 + spin_lock_irqsave(&entry->report_lock, flags); 946 842 value[0] = 0xf8; 947 843 value[1] = 0x12; 948 844 value[2] = leds; ··· 965 831 value[4] = 0x00; 966 832 value[5] = 0x00; 967 833 value[6] = 0x00; 968 - hid_hw_request(hid, report, HID_REQ_SET_REPORT); 834 + hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT); 835 + spin_unlock_irqrestore(&entry->report_lock, flags); 969 836 } 970 837 971 838 static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, ··· 983 848 return; 984 849 } 985 850 986 - entry = (struct lg4ff_device_entry *)drv_data->device_props; 851 + entry = drv_data->device_props; 987 852 988 853 if (!entry) { 989 854 hid_err(hid, "Device properties not found."); ··· 991 856 } 992 857 993 858 for (i = 0; i < 5; i++) { 994 - if (led_cdev != entry->led[i]) 859 + if (led_cdev != entry->wdata.led[i]) 995 860 continue; 996 - state = (entry->led_state >> i) & 1; 861 + state = (entry->wdata.led_state >> i) & 1; 997 862 if (value == LED_OFF && state) { 998 - entry->led_state &= ~(1 << i); 999 - lg4ff_set_leds(hid, entry->led_state); 863 + entry->wdata.led_state &= ~(1 << i); 864 + lg4ff_set_leds(hid, entry->wdata.led_state); 1000 865 } else if (value != LED_OFF && !state) { 1001 - entry->led_state |= 1 << i; 1002 - lg4ff_set_leds(hid, entry->led_state); 866 + entry->wdata.led_state |= 1 << i; 867 + lg4ff_set_leds(hid, entry->wdata.led_state); 1003 868 } 1004 869 break; 1005 870 } ··· 1018 883 return LED_OFF; 1019 884 } 1020 885 1021 - entry = (struct lg4ff_device_entry *)drv_data->device_props; 886 + entry = drv_data->device_props; 1022 887 1023 888 if (!entry) { 1024 889 hid_err(hid, "Device properties not found."); ··· 1026 891 } 1027 892 1028 893 for (i = 0; i < 5; i++) 1029 - if (led_cdev == entry->led[i]) { 1030 - value = (entry->led_state >> i) & 1; 894 + if (led_cdev == entry->wdata.led[i]) { 895 + value = (entry->wdata.led_state >> i) & 1; 1031 896 break; 1032 897 } 1033 898 ··· 1126 991 { 1127 992 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 1128 993 struct input_dev *dev = hidinput->input; 994 + struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 995 + struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 1129 996 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); 1130 997 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); 998 + const struct lg4ff_multimode_wheel *mmode_wheel = NULL; 1131 999 struct lg4ff_device_entry *entry; 1132 1000 struct lg_drv_data *drv_data; 1133 1001 int error, i, j; ··· 1141 1003 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) 1142 1004 return -1; 1143 1005 1006 + drv_data = hid_get_drvdata(hid); 1007 + if (!drv_data) { 1008 + hid_err(hid, "Cannot add device, private driver data not allocated\n"); 1009 + return -1; 1010 + } 1011 + entry = kzalloc(sizeof(*entry), GFP_KERNEL); 1012 + if (!entry) 1013 + return -ENOMEM; 1014 + spin_lock_init(&entry->report_lock); 1015 + entry->report = report; 1016 + drv_data->device_props = entry; 1017 + 1144 1018 /* Check if a multimode wheel has been connected and 1145 1019 * handle it appropriately */ 1146 1020 mmode_ret = lg4ff_handle_multimode_wheel(hid, &real_product_id, bcdDevice); ··· 1162 1012 */ 1163 1013 if (mmode_ret == LG4FF_MMODE_SWITCHED) 1164 1014 return 0; 1015 + else if (mmode_ret < 0) { 1016 + hid_err(hid, "Unable to switch device mode during initialization, errno %d\n", mmode_ret); 1017 + error = mmode_ret; 1018 + goto err_init; 1019 + } 1165 1020 1166 1021 /* Check what wheel has been connected */ 1167 1022 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { ··· 1177 1022 } 1178 1023 1179 1024 if (i == ARRAY_SIZE(lg4ff_devices)) { 1180 - hid_err(hid, "Device is not supported by lg4ff driver. If you think it should be, consider reporting a bug to" 1181 - "LKML, Simon Wood <simon@mungewell.org> or Michal Maly <madcatxster@gmail.com>\n"); 1182 - return -1; 1025 + hid_err(hid, "This device is flagged to be handled by the lg4ff module but this module does not know how to handle it. " 1026 + "Please report this as a bug to LKML, Simon Wood <simon@mungewell.org> or " 1027 + "Michal Maly <madcatxster@devoid-pointer.net>\n"); 1028 + error = -1; 1029 + goto err_init; 1183 1030 } 1184 1031 1185 1032 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { ··· 1192 1035 1193 1036 if (mmode_idx == ARRAY_SIZE(lg4ff_multimode_wheels)) { 1194 1037 hid_err(hid, "Device product ID %X is not listed as a multimode wheel", real_product_id); 1195 - return -1; 1038 + error = -1; 1039 + goto err_init; 1196 1040 } 1197 1041 } 1198 1042 ··· 1201 1043 for (j = 0; lg4ff_devices[i].ff_effects[j] >= 0; j++) 1202 1044 set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit); 1203 1045 1204 - error = input_ff_create_memless(dev, NULL, hid_lg4ff_play); 1046 + error = input_ff_create_memless(dev, NULL, lg4ff_play); 1205 1047 1206 1048 if (error) 1207 - return error; 1208 - 1209 - /* Get private driver data */ 1210 - drv_data = hid_get_drvdata(hid); 1211 - if (!drv_data) { 1212 - hid_err(hid, "Cannot add device, private driver data not allocated\n"); 1213 - return -1; 1214 - } 1049 + goto err_init; 1215 1050 1216 1051 /* Initialize device properties */ 1217 - entry = kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL); 1218 - if (!entry) { 1219 - hid_err(hid, "Cannot add device, insufficient memory to allocate device properties.\n"); 1220 - return -ENOMEM; 1221 - } 1222 - drv_data->device_props = entry; 1223 - 1224 - entry->product_id = lg4ff_devices[i].product_id; 1225 - entry->real_product_id = real_product_id; 1226 - entry->min_range = lg4ff_devices[i].min_range; 1227 - entry->max_range = lg4ff_devices[i].max_range; 1228 - entry->set_range = lg4ff_devices[i].set_range; 1229 1052 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { 1230 1053 BUG_ON(mmode_idx == -1); 1231 - entry->alternate_modes = lg4ff_multimode_wheels[mmode_idx].alternate_modes; 1232 - entry->real_tag = lg4ff_multimode_wheels[mmode_idx].real_tag; 1233 - entry->real_name = lg4ff_multimode_wheels[mmode_idx].real_name; 1054 + mmode_wheel = &lg4ff_multimode_wheels[mmode_idx]; 1234 1055 } 1056 + lg4ff_init_wheel_data(&entry->wdata, &lg4ff_devices[i], mmode_wheel, real_product_id); 1235 1057 1236 1058 /* Check if autocentering is available and 1237 1059 * set the centering force to zero by default */ ··· 1219 1081 /* Formula Force EX expects different autocentering command */ 1220 1082 if ((bcdDevice >> 8) == LG4FF_FFEX_REV_MAJ && 1221 1083 (bcdDevice & 0xff) == LG4FF_FFEX_REV_MIN) 1222 - dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex; 1084 + dev->ff->set_autocenter = lg4ff_set_autocenter_ffex; 1223 1085 else 1224 - dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default; 1086 + dev->ff->set_autocenter = lg4ff_set_autocenter_default; 1225 1087 1226 1088 dev->ff->set_autocenter(dev, 0); 1227 1089 } ··· 1229 1091 /* Create sysfs interface */ 1230 1092 error = device_create_file(&hid->dev, &dev_attr_range); 1231 1093 if (error) 1232 - return error; 1094 + hid_warn(hid, "Unable to create sysfs interface for \"range\", errno %d\n", error); 1233 1095 if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { 1234 1096 error = device_create_file(&hid->dev, &dev_attr_real_id); 1235 1097 if (error) 1236 - return error; 1098 + hid_warn(hid, "Unable to create sysfs interface for \"real_id\", errno %d\n", error); 1237 1099 error = device_create_file(&hid->dev, &dev_attr_alternate_modes); 1238 1100 if (error) 1239 - return error; 1101 + hid_warn(hid, "Unable to create sysfs interface for \"alternate_modes\", errno %d\n", error); 1240 1102 } 1241 1103 dbg_hid("sysfs interface created\n"); 1242 1104 1243 1105 /* Set the maximum range to start with */ 1244 - entry->range = entry->max_range; 1245 - if (entry->set_range != NULL) 1246 - entry->set_range(hid, entry->range); 1106 + entry->wdata.range = entry->wdata.max_range; 1107 + if (entry->wdata.set_range) 1108 + entry->wdata.set_range(hid, entry->wdata.range); 1247 1109 1248 1110 #ifdef CONFIG_LEDS_CLASS 1249 1111 /* register led subsystem - G27 only */ 1250 - entry->led_state = 0; 1112 + entry->wdata.led_state = 0; 1251 1113 for (j = 0; j < 5; j++) 1252 - entry->led[j] = NULL; 1114 + entry->wdata.led[j] = NULL; 1253 1115 1254 1116 if (lg4ff_devices[i].product_id == USB_DEVICE_ID_LOGITECH_G27_WHEEL) { 1255 1117 struct led_classdev *led; ··· 1264 1126 led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL); 1265 1127 if (!led) { 1266 1128 hid_err(hid, "can't allocate memory for LED %d\n", j); 1267 - goto err; 1129 + goto err_leds; 1268 1130 } 1269 1131 1270 1132 name = (void *)(&led[1]); ··· 1275 1137 led->brightness_get = lg4ff_led_get_brightness; 1276 1138 led->brightness_set = lg4ff_led_set_brightness; 1277 1139 1278 - entry->led[j] = led; 1140 + entry->wdata.led[j] = led; 1279 1141 error = led_classdev_register(&hid->dev, led); 1280 1142 1281 1143 if (error) { 1282 1144 hid_err(hid, "failed to register LED %d. Aborting.\n", j); 1283 - err: 1145 + err_leds: 1284 1146 /* Deregister LEDs (if any) */ 1285 1147 for (j = 0; j < 5; j++) { 1286 - led = entry->led[j]; 1287 - entry->led[j] = NULL; 1148 + led = entry->wdata.led[j]; 1149 + entry->wdata.led[j] = NULL; 1288 1150 if (!led) 1289 1151 continue; 1290 1152 led_classdev_unregister(led); ··· 1298 1160 #endif 1299 1161 hid_info(hid, "Force feedback support for Logitech Gaming Wheels\n"); 1300 1162 return 0; 1163 + 1164 + err_init: 1165 + drv_data->device_props = NULL; 1166 + kfree(entry); 1167 + return error; 1301 1168 } 1302 1169 1303 1170 int lg4ff_deinit(struct hid_device *hid) ··· 1319 1176 if (!entry) 1320 1177 goto out; /* Nothing more to do */ 1321 1178 1322 - device_remove_file(&hid->dev, &dev_attr_range); 1323 - 1324 1179 /* Multimode devices will have at least the "MODE_NATIVE" bit set */ 1325 - if (entry->alternate_modes) { 1180 + if (entry->wdata.alternate_modes) { 1326 1181 device_remove_file(&hid->dev, &dev_attr_real_id); 1327 1182 device_remove_file(&hid->dev, &dev_attr_alternate_modes); 1328 1183 } 1329 1184 1185 + device_remove_file(&hid->dev, &dev_attr_range); 1330 1186 #ifdef CONFIG_LEDS_CLASS 1331 1187 { 1332 1188 int j; ··· 1334 1192 /* Deregister LEDs (if any) */ 1335 1193 for (j = 0; j < 5; j++) { 1336 1194 1337 - led = entry->led[j]; 1338 - entry->led[j] = NULL; 1195 + led = entry->wdata.led[j]; 1196 + entry->wdata.led[j] = NULL; 1339 1197 if (!led) 1340 1198 continue; 1341 1199 led_classdev_unregister(led); ··· 1343 1201 } 1344 1202 } 1345 1203 #endif 1204 + hid_hw_stop(hid); 1205 + drv_data->device_props = NULL; 1346 1206 1347 - /* Deallocate memory */ 1348 1207 kfree(entry); 1349 - 1350 1208 out: 1351 1209 dbg_hid("Device successfully unregistered\n"); 1352 1210 return 0;
+2 -2
drivers/hid/hid-lg4ff.h
··· 5 5 extern int lg4ff_no_autoswitch; /* From hid-lg.c */ 6 6 7 7 int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, 8 - struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data); 8 + struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data); 9 9 int lg4ff_init(struct hid_device *hdev); 10 10 int lg4ff_deinit(struct hid_device *hdev); 11 11 #else 12 12 static inline int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, 13 - struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data) { return 0; } 13 + struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data) { return 0; } 14 14 static inline int lg4ff_init(struct hid_device *hdev) { return -1; } 15 15 static inline int lg4ff_deinit(struct hid_device *hdev) { return -1; } 16 16 #endif
+224 -3
drivers/hid/hid-logitech-hidpp.c
··· 40 40 #define HIDPP_REPORT_LONG_LENGTH 20 41 41 42 42 #define HIDPP_QUIRK_CLASS_WTP BIT(0) 43 + #define HIDPP_QUIRK_CLASS_M560 BIT(1) 43 44 44 - /* bits 1..20 are reserved for classes */ 45 + /* bits 2..20 are reserved for classes */ 45 46 #define HIDPP_QUIRK_DELAYED_INIT BIT(21) 46 47 #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) 47 48 ··· 931 930 true, true); 932 931 } 933 932 933 + /* ------------------------------------------------------------------------- */ 934 + /* Logitech M560 devices */ 935 + /* ------------------------------------------------------------------------- */ 936 + 937 + /* 938 + * Logitech M560 protocol overview 939 + * 940 + * The Logitech M560 mouse, is designed for windows 8. When the middle and/or 941 + * the sides buttons are pressed, it sends some keyboard keys events 942 + * instead of buttons ones. 943 + * To complicate things further, the middle button keys sequence 944 + * is different from the odd press and the even press. 945 + * 946 + * forward button -> Super_R 947 + * backward button -> Super_L+'d' (press only) 948 + * middle button -> 1st time: Alt_L+SuperL+XF86TouchpadOff (press only) 949 + * 2nd time: left-click (press only) 950 + * NB: press-only means that when the button is pressed, the 951 + * KeyPress/ButtonPress and KeyRelease/ButtonRelease events are generated 952 + * together sequentially; instead when the button is released, no event is 953 + * generated ! 954 + * 955 + * With the command 956 + * 10<xx>0a 3500af03 (where <xx> is the mouse id), 957 + * the mouse reacts differently: 958 + * - it never sends a keyboard key event 959 + * - for the three mouse button it sends: 960 + * middle button press 11<xx>0a 3500af00... 961 + * side 1 button (forward) press 11<xx>0a 3500b000... 962 + * side 2 button (backward) press 11<xx>0a 3500ae00... 963 + * middle/side1/side2 button release 11<xx>0a 35000000... 964 + */ 965 + 966 + static const u8 m560_config_parameter[] = {0x00, 0xaf, 0x03}; 967 + 968 + struct m560_private_data { 969 + struct input_dev *input; 970 + }; 971 + 972 + /* how buttons are mapped in the report */ 973 + #define M560_MOUSE_BTN_LEFT 0x01 974 + #define M560_MOUSE_BTN_RIGHT 0x02 975 + #define M560_MOUSE_BTN_WHEEL_LEFT 0x08 976 + #define M560_MOUSE_BTN_WHEEL_RIGHT 0x10 977 + 978 + #define M560_SUB_ID 0x0a 979 + #define M560_BUTTON_MODE_REGISTER 0x35 980 + 981 + static int m560_send_config_command(struct hid_device *hdev, bool connected) 982 + { 983 + struct hidpp_report response; 984 + struct hidpp_device *hidpp_dev; 985 + 986 + hidpp_dev = hid_get_drvdata(hdev); 987 + 988 + if (!connected) 989 + return -ENODEV; 990 + 991 + return hidpp_send_rap_command_sync( 992 + hidpp_dev, 993 + REPORT_ID_HIDPP_SHORT, 994 + M560_SUB_ID, 995 + M560_BUTTON_MODE_REGISTER, 996 + (u8 *)m560_config_parameter, 997 + sizeof(m560_config_parameter), 998 + &response 999 + ); 1000 + } 1001 + 1002 + static int m560_allocate(struct hid_device *hdev) 1003 + { 1004 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 1005 + struct m560_private_data *d; 1006 + 1007 + d = devm_kzalloc(&hdev->dev, sizeof(struct m560_private_data), 1008 + GFP_KERNEL); 1009 + if (!d) 1010 + return -ENOMEM; 1011 + 1012 + hidpp->private_data = d; 1013 + 1014 + return 0; 1015 + }; 1016 + 1017 + static int m560_raw_event(struct hid_device *hdev, u8 *data, int size) 1018 + { 1019 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 1020 + struct m560_private_data *mydata = hidpp->private_data; 1021 + 1022 + /* sanity check */ 1023 + if (!mydata || !mydata->input) { 1024 + hid_err(hdev, "error in parameter\n"); 1025 + return -EINVAL; 1026 + } 1027 + 1028 + if (size < 7) { 1029 + hid_err(hdev, "error in report\n"); 1030 + return 0; 1031 + } 1032 + 1033 + if (data[0] == REPORT_ID_HIDPP_LONG && 1034 + data[2] == M560_SUB_ID && data[6] == 0x00) { 1035 + /* 1036 + * m560 mouse report for middle, forward and backward button 1037 + * 1038 + * data[0] = 0x11 1039 + * data[1] = device-id 1040 + * data[2] = 0x0a 1041 + * data[5] = 0xaf -> middle 1042 + * 0xb0 -> forward 1043 + * 0xae -> backward 1044 + * 0x00 -> release all 1045 + * data[6] = 0x00 1046 + */ 1047 + 1048 + switch (data[5]) { 1049 + case 0xaf: 1050 + input_report_key(mydata->input, BTN_MIDDLE, 1); 1051 + break; 1052 + case 0xb0: 1053 + input_report_key(mydata->input, BTN_FORWARD, 1); 1054 + break; 1055 + case 0xae: 1056 + input_report_key(mydata->input, BTN_BACK, 1); 1057 + break; 1058 + case 0x00: 1059 + input_report_key(mydata->input, BTN_BACK, 0); 1060 + input_report_key(mydata->input, BTN_FORWARD, 0); 1061 + input_report_key(mydata->input, BTN_MIDDLE, 0); 1062 + break; 1063 + default: 1064 + hid_err(hdev, "error in report\n"); 1065 + return 0; 1066 + } 1067 + input_sync(mydata->input); 1068 + 1069 + } else if (data[0] == 0x02) { 1070 + /* 1071 + * Logitech M560 mouse report 1072 + * 1073 + * data[0] = type (0x02) 1074 + * data[1..2] = buttons 1075 + * data[3..5] = xy 1076 + * data[6] = wheel 1077 + */ 1078 + 1079 + int v; 1080 + 1081 + input_report_key(mydata->input, BTN_LEFT, 1082 + !!(data[1] & M560_MOUSE_BTN_LEFT)); 1083 + input_report_key(mydata->input, BTN_RIGHT, 1084 + !!(data[1] & M560_MOUSE_BTN_RIGHT)); 1085 + 1086 + if (data[1] & M560_MOUSE_BTN_WHEEL_LEFT) 1087 + input_report_rel(mydata->input, REL_HWHEEL, -1); 1088 + else if (data[1] & M560_MOUSE_BTN_WHEEL_RIGHT) 1089 + input_report_rel(mydata->input, REL_HWHEEL, 1); 1090 + 1091 + v = hid_snto32(hid_field_extract(hdev, data+3, 0, 12), 12); 1092 + input_report_rel(mydata->input, REL_X, v); 1093 + 1094 + v = hid_snto32(hid_field_extract(hdev, data+3, 12, 12), 12); 1095 + input_report_rel(mydata->input, REL_Y, v); 1096 + 1097 + v = hid_snto32(data[6], 8); 1098 + input_report_rel(mydata->input, REL_WHEEL, v); 1099 + 1100 + input_sync(mydata->input); 1101 + } 1102 + 1103 + return 1; 1104 + } 1105 + 1106 + static void m560_populate_input(struct hidpp_device *hidpp, 1107 + struct input_dev *input_dev, bool origin_is_hid_core) 1108 + { 1109 + struct m560_private_data *mydata = hidpp->private_data; 1110 + 1111 + mydata->input = input_dev; 1112 + 1113 + __set_bit(EV_KEY, mydata->input->evbit); 1114 + __set_bit(BTN_MIDDLE, mydata->input->keybit); 1115 + __set_bit(BTN_RIGHT, mydata->input->keybit); 1116 + __set_bit(BTN_LEFT, mydata->input->keybit); 1117 + __set_bit(BTN_BACK, mydata->input->keybit); 1118 + __set_bit(BTN_FORWARD, mydata->input->keybit); 1119 + 1120 + __set_bit(EV_REL, mydata->input->evbit); 1121 + __set_bit(REL_X, mydata->input->relbit); 1122 + __set_bit(REL_Y, mydata->input->relbit); 1123 + __set_bit(REL_WHEEL, mydata->input->relbit); 1124 + __set_bit(REL_HWHEEL, mydata->input->relbit); 1125 + } 1126 + 1127 + static int m560_input_mapping(struct hid_device *hdev, struct hid_input *hi, 1128 + struct hid_field *field, struct hid_usage *usage, 1129 + unsigned long **bit, int *max) 1130 + { 1131 + return -1; 1132 + } 1133 + 934 1134 /* -------------------------------------------------------------------------- */ 935 1135 /* Generic HID++ devices */ 936 1136 /* -------------------------------------------------------------------------- */ ··· 1144 942 1145 943 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 1146 944 return wtp_input_mapping(hdev, hi, field, usage, bit, max); 945 + else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && 946 + field->application != HID_GD_MOUSE) 947 + return m560_input_mapping(hdev, hi, field, usage, bit, max); 1147 948 1148 949 return 0; 1149 950 } ··· 1156 951 { 1157 952 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 1158 953 wtp_populate_input(hidpp, input, origin_is_hid_core); 954 + else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) 955 + m560_populate_input(hidpp, input, origin_is_hid_core); 1159 956 } 1160 957 1161 958 static void hidpp_input_configured(struct hid_device *hdev, ··· 1245 1038 1246 1039 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 1247 1040 return wtp_raw_event(hdev, data, size); 1041 + else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) 1042 + return m560_raw_event(hdev, data, size); 1248 1043 1249 1044 return 0; 1250 1045 } ··· 1324 1115 ret = wtp_connect(hdev, connected); 1325 1116 if (ret) 1326 1117 return; 1118 + } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { 1119 + ret = m560_send_config_command(hdev, connected); 1120 + if (ret) 1121 + return; 1327 1122 } 1328 1123 1329 1124 if (!connected || hidpp->delayed_input) ··· 1403 1190 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { 1404 1191 ret = wtp_allocate(hdev, id); 1405 1192 if (ret) 1406 - goto wtp_allocate_fail; 1193 + goto allocate_fail; 1194 + } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { 1195 + ret = m560_allocate(hdev); 1196 + if (ret) 1197 + goto allocate_fail; 1407 1198 } 1408 1199 1409 1200 INIT_WORK(&hidpp->work, delayed_work_cb); ··· 1470 1253 hid_parse_fail: 1471 1254 cancel_work_sync(&hidpp->work); 1472 1255 mutex_destroy(&hidpp->send_mutex); 1473 - wtp_allocate_fail: 1256 + allocate_fail: 1474 1257 hid_set_drvdata(hdev, NULL); 1475 1258 return ret; 1476 1259 } ··· 1498 1281 HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 1499 1282 USB_DEVICE_ID_LOGITECH_T651), 1500 1283 .driver_data = HIDPP_QUIRK_CLASS_WTP }, 1284 + { /* Mouse logitech M560 */ 1285 + HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1286 + USB_VENDOR_ID_LOGITECH, 0x402d), 1287 + .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 }, 1501 1288 1502 1289 { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1503 1290 USB_VENDOR_ID_LOGITECH, HID_ANY_ID)},
+2
drivers/hid/hid-microsoft.c
··· 280 280 .driver_data = MS_HIDINPUT }, 281 281 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP), 282 282 .driver_data = MS_HIDINPUT }, 283 + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER), 284 + .driver_data = MS_HIDINPUT }, 283 285 284 286 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), 285 287 .driver_data = MS_PRESENTER },
+124 -8
drivers/hid/hid-plantronics.c
··· 2 2 * Plantronics USB HID Driver 3 3 * 4 4 * Copyright (c) 2014 JD Cole <jd.cole@plantronics.com> 5 - * Copyright (c) 2014 Terry Junge <terry.junge@plantronics.com> 5 + * Copyright (c) 2015 Terry Junge <terry.junge@plantronics.com> 6 6 */ 7 7 8 8 /* ··· 17 17 #include <linux/hid.h> 18 18 #include <linux/module.h> 19 19 20 + #define PLT_HID_1_0_PAGE 0xffa00000 21 + #define PLT_HID_2_0_PAGE 0xffa20000 22 + 23 + #define PLT_BASIC_TELEPHONY 0x0003 24 + #define PLT_BASIC_EXCEPTION 0x0005 25 + 26 + #define PLT_VOL_UP 0x00b1 27 + #define PLT_VOL_DOWN 0x00b2 28 + 29 + #define PLT1_VOL_UP (PLT_HID_1_0_PAGE | PLT_VOL_UP) 30 + #define PLT1_VOL_DOWN (PLT_HID_1_0_PAGE | PLT_VOL_DOWN) 31 + #define PLT2_VOL_UP (PLT_HID_2_0_PAGE | PLT_VOL_UP) 32 + #define PLT2_VOL_DOWN (PLT_HID_2_0_PAGE | PLT_VOL_DOWN) 33 + 34 + #define PLT_DA60 0xda60 35 + #define PLT_BT300_MIN 0x0413 36 + #define PLT_BT300_MAX 0x0418 37 + 38 + 39 + #define PLT_ALLOW_CONSUMER (field->application == HID_CP_CONSUMERCONTROL && \ 40 + (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) 41 + 20 42 static int plantronics_input_mapping(struct hid_device *hdev, 21 43 struct hid_input *hi, 22 44 struct hid_field *field, 23 45 struct hid_usage *usage, 24 46 unsigned long **bit, int *max) 25 47 { 26 - if (field->application == HID_CP_CONSUMERCONTROL 27 - && (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { 28 - hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n", 29 - usage->hid, field->application); 30 - return 0; 48 + unsigned short mapped_key; 49 + unsigned long plt_type = (unsigned long)hid_get_drvdata(hdev); 50 + 51 + /* handle volume up/down mapping */ 52 + /* non-standard types or multi-HID interfaces - plt_type is PID */ 53 + if (!(plt_type & HID_USAGE_PAGE)) { 54 + switch (plt_type) { 55 + case PLT_DA60: 56 + if (PLT_ALLOW_CONSUMER) 57 + goto defaulted; 58 + goto ignored; 59 + default: 60 + if (PLT_ALLOW_CONSUMER) 61 + goto defaulted; 62 + } 63 + } 64 + /* handle standard types - plt_type is 0xffa0uuuu or 0xffa2uuuu */ 65 + /* 'basic telephony compliant' - allow default consumer page map */ 66 + else if ((plt_type & HID_USAGE) >= PLT_BASIC_TELEPHONY && 67 + (plt_type & HID_USAGE) != PLT_BASIC_EXCEPTION) { 68 + if (PLT_ALLOW_CONSUMER) 69 + goto defaulted; 70 + } 71 + /* not 'basic telephony' - apply legacy mapping */ 72 + /* only map if the field is in the device's primary vendor page */ 73 + else if (!((field->application ^ plt_type) & HID_USAGE_PAGE)) { 74 + switch (usage->hid) { 75 + case PLT1_VOL_UP: 76 + case PLT2_VOL_UP: 77 + mapped_key = KEY_VOLUMEUP; 78 + goto mapped; 79 + case PLT1_VOL_DOWN: 80 + case PLT2_VOL_DOWN: 81 + mapped_key = KEY_VOLUMEDOWN; 82 + goto mapped; 83 + } 31 84 } 32 85 33 - hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n", 34 - usage->hid, field->application); 86 + /* 87 + * Future mapping of call control or other usages, 88 + * if and when keys are defined would go here 89 + * otherwise, ignore everything else that was not mapped 90 + */ 35 91 92 + ignored: 36 93 return -1; 94 + 95 + defaulted: 96 + hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n", 97 + usage->hid, field->application); 98 + return 0; 99 + 100 + mapped: 101 + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, mapped_key); 102 + hid_dbg(hdev, "usage: %08x (appl: %08x) - mapped to key %d\n", 103 + usage->hid, field->application, mapped_key); 104 + return 1; 105 + } 106 + 107 + static unsigned long plantronics_device_type(struct hid_device *hdev) 108 + { 109 + unsigned i, col_page; 110 + unsigned long plt_type = hdev->product; 111 + 112 + /* multi-HID interfaces? - plt_type is PID */ 113 + if (plt_type >= PLT_BT300_MIN && plt_type <= PLT_BT300_MAX) 114 + goto exit; 115 + 116 + /* determine primary vendor page */ 117 + for (i = 0; i < hdev->maxcollection; i++) { 118 + col_page = hdev->collection[i].usage & HID_USAGE_PAGE; 119 + if (col_page == PLT_HID_2_0_PAGE) { 120 + plt_type = hdev->collection[i].usage; 121 + break; 122 + } 123 + if (col_page == PLT_HID_1_0_PAGE) 124 + plt_type = hdev->collection[i].usage; 125 + } 126 + 127 + exit: 128 + hid_dbg(hdev, "plt_type decoded as: %08lx\n", plt_type); 129 + return plt_type; 130 + } 131 + 132 + static int plantronics_probe(struct hid_device *hdev, 133 + const struct hid_device_id *id) 134 + { 135 + int ret; 136 + 137 + ret = hid_parse(hdev); 138 + if (ret) { 139 + hid_err(hdev, "parse failed\n"); 140 + goto err; 141 + } 142 + 143 + hid_set_drvdata(hdev, (void *)plantronics_device_type(hdev)); 144 + 145 + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | 146 + HID_CONNECT_HIDINPUT_FORCE | HID_CONNECT_HIDDEV_FORCE); 147 + if (ret) 148 + hid_err(hdev, "hw start failed\n"); 149 + 150 + err: 151 + return ret; 37 152 } 38 153 39 154 static const struct hid_device_id plantronics_devices[] = { ··· 161 46 .name = "plantronics", 162 47 .id_table = plantronics_devices, 163 48 .input_mapping = plantronics_input_mapping, 49 + .probe = plantronics_probe, 164 50 }; 165 51 module_hid_driver(plantronics_driver); 166 52
+1 -2
drivers/hid/hid-prodikeys.c
··· 395 395 396 396 /* break keys */ 397 397 for (bit_index = 0; bit_index < 24; bit_index++) { 398 - key = pm->last_key[bit_index]; 399 398 if (!((0x01 << bit_index) & bit_mask)) { 400 399 input_event(pm->input_ep82, EV_KEY, 401 400 pm->last_key[bit_index], 0); 402 - pm->last_key[bit_index] = 0; 401 + pm->last_key[bit_index] = 0; 403 402 } 404 403 } 405 404
+9 -6
drivers/hid/hid-rmi.c
··· 29 29 #define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */ 30 30 31 31 /* flags */ 32 - #define RMI_READ_REQUEST_PENDING BIT(0) 33 - #define RMI_READ_DATA_PENDING BIT(1) 34 - #define RMI_STARTED BIT(2) 32 + #define RMI_READ_REQUEST_PENDING 0 33 + #define RMI_READ_DATA_PENDING 1 34 + #define RMI_STARTED 2 35 35 36 36 /* device flags */ 37 37 #define RMI_DEVICE BIT(0) ··· 1013 1013 1014 1014 static int rmi_populate(struct hid_device *hdev) 1015 1015 { 1016 + struct rmi_data *data = hid_get_drvdata(hdev); 1016 1017 int ret; 1017 1018 1018 1019 ret = rmi_scan_pdt(hdev); ··· 1034 1033 return ret; 1035 1034 } 1036 1035 1037 - ret = rmi_populate_f30(hdev); 1038 - if (ret) 1039 - hid_warn(hdev, "Error while initializing F30 (%d).\n", ret); 1036 + if (!(data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)) { 1037 + ret = rmi_populate_f30(hdev); 1038 + if (ret) 1039 + hid_warn(hdev, "Error while initializing F30 (%d).\n", ret); 1040 + } 1040 1041 1041 1042 return 0; 1042 1043 }
+3
drivers/hid/hid-sjoy.c
··· 166 166 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD), 167 167 .driver_data = HID_QUIRK_MULTI_INPUT | 168 168 HID_QUIRK_SKIP_OUTPUT_REPORTS }, 169 + { HID_USB_DEVICE(USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII), 170 + .driver_data = HID_QUIRK_MULTI_INPUT | 171 + HID_QUIRK_SKIP_OUTPUT_REPORTS }, 169 172 { } 170 173 }; 171 174 MODULE_DEVICE_TABLE(hid, sjoy_devices);
+332 -48
drivers/hid/hid-sony.c
··· 46 46 #define PS3REMOTE BIT(4) 47 47 #define DUALSHOCK4_CONTROLLER_USB BIT(5) 48 48 #define DUALSHOCK4_CONTROLLER_BT BIT(6) 49 + #define MOTION_CONTROLLER_USB BIT(7) 50 + #define MOTION_CONTROLLER_BT BIT(8) 51 + #define NAVIGATION_CONTROLLER_USB BIT(9) 52 + #define NAVIGATION_CONTROLLER_BT BIT(10) 49 53 50 54 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) 55 + #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) 56 + #define NAVIGATION_CONTROLLER (NAVIGATION_CONTROLLER_USB |\ 57 + NAVIGATION_CONTROLLER_BT) 51 58 #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\ 52 59 DUALSHOCK4_CONTROLLER_BT) 53 60 #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ 54 - DUALSHOCK4_CONTROLLER) 55 - #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) 56 - #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) 61 + DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER |\ 62 + NAVIGATION_CONTROLLER) 63 + #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\ 64 + MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER) 65 + #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\ 66 + MOTION_CONTROLLER) 57 67 58 68 #define MAX_LEDS 4 59 69 70 + /* 71 + * The Sixaxis reports both digital and analog values for each button on the 72 + * controller except for Start, Select and the PS button. The controller ends 73 + * up reporting 27 axes which causes them to spill over into the multi-touch 74 + * axis values. Additionally, the controller only has 20 actual, physical axes 75 + * so there are several unused axes in between the used ones. 76 + */ 60 77 static __u8 sixaxis_rdesc[] = { 61 78 0x05, 0x01, /* Usage Page (Desktop), */ 62 - 0x09, 0x04, /* Usage (Joystik), */ 79 + 0x09, 0x04, /* Usage (Joystick), */ 63 80 0xA1, 0x01, /* Collection (Application), */ 64 81 0xA1, 0x02, /* Collection (Logical), */ 65 82 0x85, 0x01, /* Report ID (1), */ ··· 126 109 0x46, 0xFF, 0x03, /* Physical Maximum (1023), */ 127 110 0x09, 0x01, /* Usage (Pointer), */ 128 111 0x81, 0x02, /* Input (Variable), */ 112 + 0xC0, /* End Collection, */ 113 + 0xA1, 0x02, /* Collection (Logical), */ 114 + 0x85, 0x02, /* Report ID (2), */ 115 + 0x75, 0x08, /* Report Size (8), */ 116 + 0x95, 0x30, /* Report Count (48), */ 117 + 0x09, 0x01, /* Usage (Pointer), */ 118 + 0xB1, 0x02, /* Feature (Variable), */ 119 + 0xC0, /* End Collection, */ 120 + 0xA1, 0x02, /* Collection (Logical), */ 121 + 0x85, 0xEE, /* Report ID (238), */ 122 + 0x75, 0x08, /* Report Size (8), */ 123 + 0x95, 0x30, /* Report Count (48), */ 124 + 0x09, 0x01, /* Usage (Pointer), */ 125 + 0xB1, 0x02, /* Feature (Variable), */ 126 + 0xC0, /* End Collection, */ 127 + 0xA1, 0x02, /* Collection (Logical), */ 128 + 0x85, 0xEF, /* Report ID (239), */ 129 + 0x75, 0x08, /* Report Size (8), */ 130 + 0x95, 0x30, /* Report Count (48), */ 131 + 0x09, 0x01, /* Usage (Pointer), */ 132 + 0xB1, 0x02, /* Feature (Variable), */ 133 + 0xC0, /* End Collection, */ 134 + 0xC0 /* End Collection */ 135 + }; 136 + 137 + /* PS/3 Motion controller */ 138 + static __u8 motion_rdesc[] = { 139 + 0x05, 0x01, /* Usage Page (Desktop), */ 140 + 0x09, 0x04, /* Usage (Joystick), */ 141 + 0xA1, 0x01, /* Collection (Application), */ 142 + 0xA1, 0x02, /* Collection (Logical), */ 143 + 0x85, 0x01, /* Report ID (1), */ 144 + 0x75, 0x01, /* Report Size (1), */ 145 + 0x95, 0x15, /* Report Count (21), */ 146 + 0x15, 0x00, /* Logical Minimum (0), */ 147 + 0x25, 0x01, /* Logical Maximum (1), */ 148 + 0x35, 0x00, /* Physical Minimum (0), */ 149 + 0x45, 0x01, /* Physical Maximum (1), */ 150 + 0x05, 0x09, /* Usage Page (Button), */ 151 + 0x19, 0x01, /* Usage Minimum (01h), */ 152 + 0x29, 0x15, /* Usage Maximum (15h), */ 153 + 0x81, 0x02, /* Input (Variable), * Buttons */ 154 + 0x95, 0x0B, /* Report Count (11), */ 155 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 156 + 0x81, 0x03, /* Input (Constant, Variable), * Padding */ 157 + 0x15, 0x00, /* Logical Minimum (0), */ 158 + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 159 + 0x05, 0x01, /* Usage Page (Desktop), */ 160 + 0xA1, 0x00, /* Collection (Physical), */ 161 + 0x75, 0x08, /* Report Size (8), */ 162 + 0x95, 0x01, /* Report Count (1), */ 163 + 0x35, 0x00, /* Physical Minimum (0), */ 164 + 0x46, 0xFF, 0x00, /* Physical Maximum (255), */ 165 + 0x09, 0x30, /* Usage (X), */ 166 + 0x81, 0x02, /* Input (Variable), * Trigger */ 167 + 0xC0, /* End Collection, */ 168 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 169 + 0x75, 0x08, /* Report Size (8), */ 170 + 0x95, 0x07, /* Report Count (7), * skip 7 bytes */ 171 + 0x81, 0x02, /* Input (Variable), */ 172 + 0x05, 0x01, /* Usage Page (Desktop), */ 173 + 0x75, 0x10, /* Report Size (16), */ 174 + 0x46, 0xFF, 0xFF, /* Physical Maximum (65535), */ 175 + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum (65535), */ 176 + 0x95, 0x03, /* Report Count (3), * 3x Accels */ 177 + 0x09, 0x33, /* Usage (rX), */ 178 + 0x09, 0x34, /* Usage (rY), */ 179 + 0x09, 0x35, /* Usage (rZ), */ 180 + 0x81, 0x02, /* Input (Variable), */ 181 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 182 + 0x95, 0x03, /* Report Count (3), * Skip Accels 2nd frame */ 183 + 0x81, 0x02, /* Input (Variable), */ 184 + 0x05, 0x01, /* Usage Page (Desktop), */ 185 + 0x09, 0x01, /* Usage (Pointer), */ 186 + 0x95, 0x03, /* Report Count (3), * 3x Gyros */ 187 + 0x81, 0x02, /* Input (Variable), */ 188 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 189 + 0x95, 0x03, /* Report Count (3), * Skip Gyros 2nd frame */ 190 + 0x81, 0x02, /* Input (Variable), */ 191 + 0x75, 0x0C, /* Report Size (12), */ 192 + 0x46, 0xFF, 0x0F, /* Physical Maximum (4095), */ 193 + 0x26, 0xFF, 0x0F, /* Logical Maximum (4095), */ 194 + 0x95, 0x04, /* Report Count (4), * Skip Temp and Magnetometers */ 195 + 0x81, 0x02, /* Input (Variable), */ 196 + 0x75, 0x08, /* Report Size (8), */ 197 + 0x46, 0xFF, 0x00, /* Physical Maximum (255), */ 198 + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 199 + 0x95, 0x06, /* Report Count (6), * Skip Timestamp and Extension Bytes */ 200 + 0x81, 0x02, /* Input (Variable), */ 201 + 0x75, 0x08, /* Report Size (8), */ 202 + 0x95, 0x30, /* Report Count (48), */ 203 + 0x09, 0x01, /* Usage (Pointer), */ 204 + 0x91, 0x02, /* Output (Variable), */ 205 + 0x75, 0x08, /* Report Size (8), */ 206 + 0x95, 0x30, /* Report Count (48), */ 207 + 0x09, 0x01, /* Usage (Pointer), */ 208 + 0xB1, 0x02, /* Feature (Variable), */ 209 + 0xC0, /* End Collection, */ 210 + 0xA1, 0x02, /* Collection (Logical), */ 211 + 0x85, 0x02, /* Report ID (2), */ 212 + 0x75, 0x08, /* Report Size (8), */ 213 + 0x95, 0x30, /* Report Count (48), */ 214 + 0x09, 0x01, /* Usage (Pointer), */ 215 + 0xB1, 0x02, /* Feature (Variable), */ 216 + 0xC0, /* End Collection, */ 217 + 0xA1, 0x02, /* Collection (Logical), */ 218 + 0x85, 0xEE, /* Report ID (238), */ 219 + 0x75, 0x08, /* Report Size (8), */ 220 + 0x95, 0x30, /* Report Count (48), */ 221 + 0x09, 0x01, /* Usage (Pointer), */ 222 + 0xB1, 0x02, /* Feature (Variable), */ 223 + 0xC0, /* End Collection, */ 224 + 0xA1, 0x02, /* Collection (Logical), */ 225 + 0x85, 0xEF, /* Report ID (239), */ 226 + 0x75, 0x08, /* Report Size (8), */ 227 + 0x95, 0x30, /* Report Count (48), */ 228 + 0x09, 0x01, /* Usage (Pointer), */ 229 + 0xB1, 0x02, /* Feature (Variable), */ 230 + 0xC0, /* End Collection, */ 231 + 0xC0 /* End Collection */ 232 + }; 233 + 234 + /* PS/3 Navigation controller */ 235 + static __u8 navigation_rdesc[] = { 236 + 0x05, 0x01, /* Usage Page (Desktop), */ 237 + 0x09, 0x04, /* Usage (Joystik), */ 238 + 0xA1, 0x01, /* Collection (Application), */ 239 + 0xA1, 0x02, /* Collection (Logical), */ 240 + 0x85, 0x01, /* Report ID (1), */ 241 + 0x75, 0x08, /* Report Size (8), */ 242 + 0x95, 0x01, /* Report Count (1), */ 243 + 0x15, 0x00, /* Logical Minimum (0), */ 244 + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 245 + 0x81, 0x03, /* Input (Constant, Variable), */ 246 + 0x75, 0x01, /* Report Size (1), */ 247 + 0x95, 0x13, /* Report Count (19), */ 248 + 0x15, 0x00, /* Logical Minimum (0), */ 249 + 0x25, 0x01, /* Logical Maximum (1), */ 250 + 0x35, 0x00, /* Physical Minimum (0), */ 251 + 0x45, 0x01, /* Physical Maximum (1), */ 252 + 0x05, 0x09, /* Usage Page (Button), */ 253 + 0x19, 0x01, /* Usage Minimum (01h), */ 254 + 0x29, 0x13, /* Usage Maximum (13h), */ 255 + 0x81, 0x02, /* Input (Variable), */ 256 + 0x75, 0x01, /* Report Size (1), */ 257 + 0x95, 0x0D, /* Report Count (13), */ 258 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 259 + 0x81, 0x03, /* Input (Constant, Variable), */ 260 + 0x15, 0x00, /* Logical Minimum (0), */ 261 + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 262 + 0x05, 0x01, /* Usage Page (Desktop), */ 263 + 0x09, 0x01, /* Usage (Pointer), */ 264 + 0xA1, 0x00, /* Collection (Physical), */ 265 + 0x75, 0x08, /* Report Size (8), */ 266 + 0x95, 0x02, /* Report Count (2), */ 267 + 0x35, 0x00, /* Physical Minimum (0), */ 268 + 0x46, 0xFF, 0x00, /* Physical Maximum (255), */ 269 + 0x09, 0x30, /* Usage (X), */ 270 + 0x09, 0x31, /* Usage (Y), */ 271 + 0x81, 0x02, /* Input (Variable), */ 272 + 0xC0, /* End Collection, */ 273 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 274 + 0x95, 0x06, /* Report Count (6), */ 275 + 0x81, 0x03, /* Input (Constant, Variable), */ 276 + 0x05, 0x01, /* Usage Page (Desktop), */ 277 + 0x75, 0x08, /* Report Size (8), */ 278 + 0x95, 0x05, /* Report Count (5), */ 279 + 0x09, 0x01, /* Usage (Pointer), */ 280 + 0x81, 0x02, /* Input (Variable), */ 281 + 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 282 + 0x95, 0x20, /* Report Count (26), */ 283 + 0x81, 0x02, /* Input (Variable), */ 284 + 0x75, 0x08, /* Report Size (8), */ 285 + 0x95, 0x30, /* Report Count (48), */ 286 + 0x09, 0x01, /* Usage (Pointer), */ 287 + 0x91, 0x02, /* Output (Variable), */ 288 + 0x75, 0x08, /* Report Size (8), */ 289 + 0x95, 0x30, /* Report Count (48), */ 290 + 0x09, 0x01, /* Usage (Pointer), */ 291 + 0xB1, 0x02, /* Feature (Variable), */ 129 292 0xC0, /* End Collection, */ 130 293 0xA1, 0x02, /* Collection (Logical), */ 131 294 0x85, 0x02, /* Report ID (2), */ ··· 995 798 __u8 buf[36]; 996 799 }; 997 800 801 + struct motion_output_report_02 { 802 + u8 type, zero; 803 + u8 r, g, b; 804 + u8 zero2; 805 + u8 rumble; 806 + }; 807 + 998 808 #define DS4_REPORT_0x02_SIZE 37 999 809 #define DS4_REPORT_0x05_SIZE 32 1000 810 #define DS4_REPORT_0x11_SIZE 78 1001 811 #define DS4_REPORT_0x81_SIZE 7 1002 812 #define SIXAXIS_REPORT_0xF2_SIZE 17 1003 813 #define SIXAXIS_REPORT_0xF5_SIZE 8 814 + #define MOTION_REPORT_0x02_SIZE 49 1004 815 1005 816 static DEFINE_SPINLOCK(sony_dev_list_lock); 1006 817 static LIST_HEAD(sony_device_list); ··· 1047 842 { 1048 843 *rsize = sizeof(sixaxis_rdesc); 1049 844 return sixaxis_rdesc; 845 + } 846 + 847 + static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc, 848 + unsigned int *rsize) 849 + { 850 + *rsize = sizeof(motion_rdesc); 851 + return motion_rdesc; 852 + } 853 + 854 + static u8 *navigation_fixup(struct hid_device *hdev, u8 *rdesc, 855 + unsigned int *rsize) 856 + { 857 + *rsize = sizeof(navigation_rdesc); 858 + return navigation_rdesc; 1050 859 } 1051 860 1052 861 static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc, ··· 1143 924 if (sc->quirks & SIXAXIS_CONTROLLER) 1144 925 return sixaxis_fixup(hdev, rdesc, rsize); 1145 926 927 + if (sc->quirks & MOTION_CONTROLLER) 928 + return motion_fixup(hdev, rdesc, rsize); 929 + 930 + if (sc->quirks & NAVIGATION_CONTROLLER) 931 + return navigation_fixup(hdev, rdesc, rsize); 932 + 1146 933 if (sc->quirks & PS3REMOTE) 1147 934 return ps3remote_fixup(hdev, rdesc, rsize); 1148 935 ··· 1159 934 { 1160 935 static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 }; 1161 936 unsigned long flags; 937 + int offset; 1162 938 __u8 cable_state, battery_capacity, battery_charging; 1163 939 1164 940 /* ··· 1168 942 * It does not report the actual level while charging so it 1169 943 * is set to 100% while charging is in progress. 1170 944 */ 1171 - if (rd[30] >= 0xee) { 945 + offset = (sc->quirks & MOTION_CONTROLLER) ? 12 : 30; 946 + 947 + if (rd[offset] >= 0xee) { 1172 948 battery_capacity = 100; 1173 - battery_charging = !(rd[30] & 0x01); 949 + battery_charging = !(rd[offset] & 0x01); 1174 950 cable_state = 1; 1175 951 } else { 1176 - __u8 index = rd[30] <= 5 ? rd[30] : 5; 952 + __u8 index = rd[offset] <= 5 ? rd[offset] : 5; 1177 953 battery_capacity = sixaxis_battery_capacity[index]; 1178 954 battery_charging = 0; 1179 955 cable_state = 0; ··· 1275 1047 swap(rd[45], rd[46]); 1276 1048 swap(rd[47], rd[48]); 1277 1049 1050 + sixaxis_parse_report(sc, rd, size); 1051 + } else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) { 1052 + sixaxis_parse_report(sc, rd, size); 1053 + } else if ((sc->quirks & NAVIGATION_CONTROLLER) && rd[0] == 0x01 && 1054 + size == 49) { 1278 1055 sixaxis_parse_report(sc, rd, size); 1279 1056 } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && 1280 1057 size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ··· 1441 1208 return ret; 1442 1209 } 1443 1210 1444 - static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS]) 1211 + static void sixaxis_set_leds_from_id(struct sony_sc *sc) 1445 1212 { 1446 1213 static const __u8 sixaxis_leds[10][4] = { 1447 1214 { 0x01, 0x00, 0x00, 0x00 }, ··· 1456 1223 { 0x01, 0x01, 0x01, 0x01 } 1457 1224 }; 1458 1225 1459 - BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0])); 1226 + int id = sc->device_id; 1227 + 1228 + BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0])); 1460 1229 1461 1230 if (id < 0) 1462 1231 return; 1463 1232 1464 1233 id %= 10; 1465 - memcpy(values, sixaxis_leds[id], sizeof(sixaxis_leds[id])); 1234 + memcpy(sc->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id])); 1466 1235 } 1467 1236 1468 - static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS]) 1237 + static void dualshock4_set_leds_from_id(struct sony_sc *sc) 1469 1238 { 1470 1239 /* The first 4 color/index entries match what the PS4 assigns */ 1471 1240 static const __u8 color_code[7][3] = { ··· 1480 1245 /* White */ { 0x01, 0x01, 0x01 } 1481 1246 }; 1482 1247 1483 - BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0])); 1248 + int id = sc->device_id; 1249 + 1250 + BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0])); 1484 1251 1485 1252 if (id < 0) 1486 1253 return; 1487 1254 1488 1255 id %= 7; 1489 - memcpy(values, color_code[id], sizeof(color_code[id])); 1256 + memcpy(sc->led_state, color_code[id], sizeof(color_code[id])); 1490 1257 } 1491 1258 1492 - static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds) 1259 + static void buzz_set_leds(struct sony_sc *sc) 1493 1260 { 1261 + struct hid_device *hdev = sc->hdev; 1494 1262 struct list_head *report_list = 1495 1263 &hdev->report_enum[HID_OUTPUT_REPORT].report_list; 1496 1264 struct hid_report *report = list_entry(report_list->next, 1497 1265 struct hid_report, list); 1498 1266 __s32 *value = report->field[0]->value; 1499 1267 1268 + BUILD_BUG_ON(MAX_LEDS < 4); 1269 + 1500 1270 value[0] = 0x00; 1501 - value[1] = leds[0] ? 0xff : 0x00; 1502 - value[2] = leds[1] ? 0xff : 0x00; 1503 - value[3] = leds[2] ? 0xff : 0x00; 1504 - value[4] = leds[3] ? 0xff : 0x00; 1271 + value[1] = sc->led_state[0] ? 0xff : 0x00; 1272 + value[2] = sc->led_state[1] ? 0xff : 0x00; 1273 + value[3] = sc->led_state[2] ? 0xff : 0x00; 1274 + value[4] = sc->led_state[3] ? 0xff : 0x00; 1505 1275 value[5] = 0x00; 1506 1276 value[6] = 0x00; 1507 1277 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); 1508 1278 } 1509 1279 1510 - static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count) 1280 + static void sony_set_leds(struct sony_sc *sc) 1511 1281 { 1512 - int n; 1513 - 1514 - BUG_ON(count > MAX_LEDS); 1515 - 1516 - if (sc->quirks & BUZZ_CONTROLLER && count == 4) { 1517 - buzz_set_leds(sc->hdev, leds); 1518 - } else { 1519 - for (n = 0; n < count; n++) 1520 - sc->led_state[n] = leds[n]; 1282 + if (!(sc->quirks & BUZZ_CONTROLLER)) 1521 1283 schedule_work(&sc->state_worker); 1522 - } 1284 + else 1285 + buzz_set_leds(sc); 1523 1286 } 1524 1287 1525 1288 static void sony_led_set_brightness(struct led_classdev *led, ··· 1557 1324 drv_data->led_delay_on[n] = 0; 1558 1325 drv_data->led_delay_off[n] = 0; 1559 1326 1560 - sony_set_leds(drv_data, drv_data->led_state, 1561 - drv_data->led_count); 1327 + sony_set_leds(drv_data); 1562 1328 break; 1563 1329 } 1564 1330 } ··· 1663 1431 const char *name_fmt; 1664 1432 static const char * const ds4_name_str[] = { "red", "green", "blue", 1665 1433 "global" }; 1666 - __u8 initial_values[MAX_LEDS] = { 0 }; 1667 1434 __u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 }; 1668 1435 __u8 use_hw_blink[MAX_LEDS] = { 0 }; 1669 1436 ··· 1677 1446 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) 1678 1447 return -ENODEV; 1679 1448 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { 1680 - dualshock4_set_leds_from_id(sc->device_id, initial_values); 1681 - initial_values[3] = 1; 1449 + dualshock4_set_leds_from_id(sc); 1450 + sc->led_state[3] = 1; 1682 1451 sc->led_count = 4; 1683 1452 memset(max_brightness, 255, 3); 1684 1453 use_hw_blink[3] = 1; 1685 1454 use_ds4_names = 1; 1686 1455 name_len = 0; 1687 1456 name_fmt = "%s:%s"; 1457 + } else if (sc->quirks & MOTION_CONTROLLER) { 1458 + sc->led_count = 3; 1459 + memset(max_brightness, 255, 3); 1460 + use_ds4_names = 1; 1461 + name_len = 0; 1462 + name_fmt = "%s:%s"; 1463 + } else if (sc->quirks & NAVIGATION_CONTROLLER) { 1464 + static const __u8 navigation_leds[4] = {0x01, 0x00, 0x00, 0x00}; 1465 + 1466 + memcpy(sc->led_state, navigation_leds, sizeof(navigation_leds)); 1467 + sc->led_count = 1; 1468 + memset(use_hw_blink, 1, 4); 1469 + use_ds4_names = 0; 1470 + name_len = strlen("::sony#"); 1471 + name_fmt = "%s::sony%d"; 1688 1472 } else { 1689 - sixaxis_set_leds_from_id(sc->device_id, initial_values); 1473 + sixaxis_set_leds_from_id(sc); 1690 1474 sc->led_count = 4; 1691 1475 memset(use_hw_blink, 1, 4); 1692 1476 use_ds4_names = 0; ··· 1714 1468 * only relevant if the driver is loaded after somebody actively set the 1715 1469 * LEDs to on 1716 1470 */ 1717 - sony_set_leds(sc, initial_values, sc->led_count); 1471 + sony_set_leds(sc); 1718 1472 1719 1473 name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; 1720 1474 ··· 1737 1491 else 1738 1492 snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1); 1739 1493 led->name = name; 1740 - led->brightness = initial_values[n]; 1494 + led->brightness = sc->led_state[n]; 1741 1495 led->max_brightness = max_brightness[n]; 1742 1496 led->brightness_get = sony_led_get_brightness; 1743 1497 led->brightness_set = sony_led_set_brightness; ··· 1868 1622 HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); 1869 1623 } 1870 1624 1625 + static void motion_state_worker(struct work_struct *work) 1626 + { 1627 + struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); 1628 + struct hid_device *hdev = sc->hdev; 1629 + struct motion_output_report_02 *report = 1630 + (struct motion_output_report_02 *)sc->output_report_dmabuf; 1631 + 1632 + memset(report, 0, MOTION_REPORT_0x02_SIZE); 1633 + 1634 + report->type = 0x02; /* set leds */ 1635 + report->r = sc->led_state[0]; 1636 + report->g = sc->led_state[1]; 1637 + report->b = sc->led_state[2]; 1638 + 1639 + #ifdef CONFIG_SONY_FF 1640 + report->rumble = max(sc->right, sc->left); 1641 + #endif 1642 + 1643 + hid_hw_output_report(hdev, (__u8 *)report, MOTION_REPORT_0x02_SIZE); 1644 + } 1645 + 1871 1646 static int sony_allocate_output_report(struct sony_sc *sc) 1872 1647 { 1873 - if (sc->quirks & SIXAXIS_CONTROLLER) 1648 + if ((sc->quirks & SIXAXIS_CONTROLLER) || 1649 + (sc->quirks & NAVIGATION_CONTROLLER)) 1874 1650 sc->output_report_dmabuf = 1875 1651 kmalloc(sizeof(union sixaxis_output_report_01), 1876 1652 GFP_KERNEL); ··· 1901 1633 GFP_KERNEL); 1902 1634 else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) 1903 1635 sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, 1636 + GFP_KERNEL); 1637 + else if (sc->quirks & MOTION_CONTROLLER) 1638 + sc->output_report_dmabuf = kmalloc(MOTION_REPORT_0x02_SIZE, 1904 1639 GFP_KERNEL); 1905 1640 else 1906 1641 return 0; ··· 2110 1839 int n, ret; 2111 1840 2112 1841 if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) || 1842 + (sc->quirks & MOTION_CONTROLLER_BT) || 1843 + (sc->quirks & NAVIGATION_CONTROLLER_BT) || 2113 1844 (sc->quirks & SIXAXIS_CONTROLLER_BT)) { 2114 1845 /* 2115 1846 * sony_get_bt_devaddr() attempts to parse the Bluetooth MAC ··· 2144 1871 } 2145 1872 2146 1873 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); 2147 - } else if (sc->quirks & SIXAXIS_CONTROLLER_USB) { 1874 + } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || 1875 + (sc->quirks & NAVIGATION_CONTROLLER_USB)) { 2148 1876 buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL); 2149 1877 if (!buf) 2150 1878 return -ENOMEM; ··· 2267 1993 return ret; 2268 1994 } 2269 1995 2270 - ret = sony_allocate_output_report(sc); 2271 - if (ret < 0) { 2272 - hid_err(hdev, "failed to allocate the output report buffer\n"); 2273 - goto err_stop; 2274 - } 2275 - 2276 1996 ret = sony_set_device_id(sc); 2277 1997 if (ret < 0) { 2278 1998 hid_err(hdev, "failed to allocate the device id\n"); 2279 1999 goto err_stop; 2280 2000 } 2281 2001 2282 - if (sc->quirks & SIXAXIS_CONTROLLER_USB) { 2002 + ret = sony_allocate_output_report(sc); 2003 + if (ret < 0) { 2004 + hid_err(hdev, "failed to allocate the output report buffer\n"); 2005 + goto err_stop; 2006 + } 2007 + 2008 + if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || 2009 + (sc->quirks & NAVIGATION_CONTROLLER_USB)) { 2283 2010 /* 2284 2011 * The Sony Sixaxis does not handle HID Output Reports on the 2285 2012 * Interrupt EP like it could, so we need to force HID Output ··· 2295 2020 hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; 2296 2021 ret = sixaxis_set_operational_usb(hdev); 2297 2022 sony_init_work(sc, sixaxis_state_worker); 2298 - } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { 2023 + } else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) || 2024 + (sc->quirks & NAVIGATION_CONTROLLER_BT)) { 2299 2025 /* 2300 2026 * The Sixaxis wants output reports sent on the ctrl endpoint 2301 2027 * when connected via Bluetooth. ··· 2319 2043 } 2320 2044 2321 2045 sony_init_work(sc, dualshock4_state_worker); 2046 + } else if (sc->quirks & MOTION_CONTROLLER) { 2047 + sony_init_work(sc, motion_state_worker); 2322 2048 } else { 2323 2049 ret = 0; 2324 2050 } ··· 2400 2122 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), 2401 2123 .driver_data = SIXAXIS_CONTROLLER_USB }, 2402 2124 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER), 2403 - .driver_data = SIXAXIS_CONTROLLER_USB }, 2125 + .driver_data = NAVIGATION_CONTROLLER_USB }, 2126 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER), 2127 + .driver_data = NAVIGATION_CONTROLLER_BT }, 2128 + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER), 2129 + .driver_data = MOTION_CONTROLLER_USB }, 2130 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER), 2131 + .driver_data = MOTION_CONTROLLER_BT }, 2404 2132 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), 2405 2133 .driver_data = SIXAXIS_CONTROLLER_BT }, 2406 2134 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
+3 -4
drivers/hid/i2c-hid/i2c-hid.c
··· 42 42 #include <linux/i2c/i2c-hid.h> 43 43 44 44 /* flags */ 45 - #define I2C_HID_STARTED (1 << 0) 46 - #define I2C_HID_RESET_PENDING (1 << 1) 47 - #define I2C_HID_READ_PENDING (1 << 2) 45 + #define I2C_HID_STARTED 0 46 + #define I2C_HID_RESET_PENDING 1 47 + #define I2C_HID_READ_PENDING 2 48 48 49 49 #define I2C_HID_PWR_ON 0x00 50 50 #define I2C_HID_PWR_SLEEP 0x01 ··· 1019 1019 hid->driver_data = client; 1020 1020 hid->ll_driver = &i2c_hid_ll_driver; 1021 1021 hid->dev.parent = &client->dev; 1022 - ACPI_COMPANION_SET(&hid->dev, ACPI_COMPANION(&client->dev)); 1023 1022 hid->bus = BUS_I2C; 1024 1023 hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); 1025 1024 hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
+5 -1
drivers/hid/usbhid/hid-quirks.c
··· 52 52 { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH_2968, HID_QUIRK_MULTI_INPUT }, 53 53 { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT }, 54 54 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 55 - { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, 56 55 { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT }, 57 56 58 57 { USB_VENDOR_ID_AIREN, USB_DEVICE_ID_AIREN_SLIMPLUS, HID_QUIRK_NOGET }, ··· 69 70 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, 70 71 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, 71 72 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, 73 + { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, 72 74 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 73 75 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, 74 76 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL }, ··· 89 89 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 90 90 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS }, 91 91 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP, HID_QUIRK_NO_INIT_REPORTS }, 92 + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER, HID_QUIRK_NO_INIT_REPORTS }, 92 93 { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, 93 94 { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, 94 95 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, ··· 142 141 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS }, 143 142 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103, HID_QUIRK_NO_INIT_REPORTS }, 144 143 { USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096, HID_QUIRK_NO_INIT_INPUT_REPORTS }, 144 + { USB_VENDOR_ID_MULTIPLE_1781, USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD, HID_QUIRK_MULTI_INPUT }, 145 + { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES, HID_QUIRK_MULTI_INPUT }, 146 + { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES, HID_QUIRK_MULTI_INPUT }, 145 147 146 148 { 0, 0 } 147 149 };
+4 -2
drivers/hid/wacom.h
··· 134 134 extern const struct hid_device_id wacom_ids[]; 135 135 136 136 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 137 - void wacom_setup_device_quirks(struct wacom_features *features); 138 - int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, 137 + void wacom_setup_device_quirks(struct wacom *wacom); 138 + int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, 139 + struct wacom_wac *wacom_wac); 140 + int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, 139 141 struct wacom_wac *wacom_wac); 140 142 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, 141 143 struct wacom_wac *wacom_wac);
+187 -124
drivers/hid/wacom_sys.c
··· 35 35 do { 36 36 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, 37 37 HID_REQ_GET_REPORT); 38 - } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 38 + } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); 39 + 40 + if (retval < 0) 41 + hid_err(hdev, "wacom_get_report: ran out of retries " 42 + "(last error = %d)\n", retval); 39 43 40 44 return retval; 41 45 } ··· 52 48 do { 53 49 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, 54 50 HID_REQ_SET_REPORT); 55 - } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); 51 + } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); 52 + 53 + if (retval < 0) 54 + hid_err(hdev, "wacom_set_report: ran out of retries " 55 + "(last error = %d)\n", retval); 56 56 57 57 return retval; 58 58 } ··· 125 117 break; 126 118 data[0] = field->report->id; 127 119 ret = wacom_get_report(hdev, HID_FEATURE_REPORT, 128 - data, 2, 0); 129 - if (ret == 2) 120 + data, 2, WAC_CMD_RETRIES); 121 + if (ret == 2) { 130 122 features->touch_max = data[1]; 123 + } else { 124 + features->touch_max = 16; 125 + hid_warn(hdev, "wacom_feature_mapping: " 126 + "could not get HID_DG_CONTACTMAX, " 127 + "defaulting to %d\n", 128 + features->touch_max); 129 + } 131 130 kfree(data); 132 131 } 133 132 break; ··· 196 181 * X/Y values and some cases of invalid Digitizer X/Y 197 182 * values commonly reported. 198 183 */ 199 - if (!pen && !finger) 184 + if (pen) 185 + features->device_type |= WACOM_DEVICETYPE_PEN; 186 + else if (finger) 187 + features->device_type |= WACOM_DEVICETYPE_TOUCH; 188 + else 200 189 return; 201 190 202 191 /* ··· 217 198 case HID_GD_X: 218 199 features->x_max = field->logical_maximum; 219 200 if (finger) { 220 - features->device_type = BTN_TOOL_FINGER; 221 201 features->x_phy = field->physical_maximum; 222 202 if (features->type != BAMBOO_PT) { 223 203 features->unit = field->unit; 224 204 features->unitExpo = field->unit_exponent; 225 205 } 226 - } else { 227 - features->device_type = BTN_TOOL_PEN; 228 206 } 229 207 break; 230 208 case HID_GD_Y: ··· 253 237 if (features->type == HID_GENERIC) { 254 238 /* Any last-minute generic device setup */ 255 239 if (features->touch_max > 1) { 256 - input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max, 240 + input_mt_init_slots(wacom_wac->touch_input, wacom_wac->features.touch_max, 257 241 INPUT_MT_DIRECT); 258 242 } 259 243 } ··· 411 395 if (features->type == HID_GENERIC) 412 396 return wacom_hid_set_device_mode(hdev); 413 397 414 - if (features->device_type == BTN_TOOL_FINGER) { 398 + if (features->device_type & WACOM_DEVICETYPE_TOUCH) { 415 399 if (features->type > TABLETPC) { 416 400 /* MT Tablet PC touch */ 417 401 return wacom_set_device_mode(hdev, 3, 4, 4); ··· 425 409 else if (features->type == BAMBOO_PAD) { 426 410 return wacom_set_device_mode(hdev, 2, 2, 2); 427 411 } 428 - } else if (features->device_type == BTN_TOOL_PEN) { 412 + } else if (features->device_type & WACOM_DEVICETYPE_PEN) { 429 413 if (features->type <= BAMBOO_PT && features->type != WIRELESS) { 430 414 return wacom_set_device_mode(hdev, 2, 2, 2); 431 415 } ··· 441 425 struct usb_interface *intf = wacom->intf; 442 426 443 427 /* default features */ 444 - features->device_type = BTN_TOOL_PEN; 445 428 features->x_fuzz = 4; 446 429 features->y_fuzz = 4; 447 430 features->pressure_fuzz = 0; ··· 454 439 */ 455 440 if (features->type == WIRELESS) { 456 441 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 457 - features->device_type = 0; 442 + features->device_type = WACOM_DEVICETYPE_NONE; 458 443 } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { 459 - features->device_type = BTN_TOOL_FINGER; 444 + features->device_type |= WACOM_DEVICETYPE_TOUCH; 460 445 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 461 446 } 462 447 } 463 - 464 - /* only devices that support touch need to retrieve the info */ 465 - if (features->type < BAMBOO_PT) 466 - return; 467 448 468 449 wacom_parse_hid(hdev, features); 469 450 } ··· 538 527 539 528 wacom_wac->shared = &data->shared; 540 529 541 - if (wacom_wac->features.device_type == BTN_TOOL_FINGER) 530 + if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) 542 531 wacom_wac->shared->touch = hdev; 543 - else if (wacom_wac->features.device_type == BTN_TOOL_PEN) 532 + else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) 544 533 wacom_wac->shared->pen = hdev; 545 534 546 535 out: ··· 859 848 { 860 849 int error; 861 850 851 + if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD)) 852 + return 0; 853 + 862 854 /* Initialize default values */ 863 855 switch (wacom->wacom_wac.features.type) { 864 856 case INTUOS4S: ··· 895 881 case INTUOSPS: 896 882 case INTUOSPM: 897 883 case INTUOSPL: 898 - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { 899 - wacom->led.select[0] = 0; 900 - wacom->led.select[1] = 0; 901 - wacom->led.llv = 32; 902 - wacom->led.hlv = 0; 903 - wacom->led.img_lum = 0; 884 + wacom->led.select[0] = 0; 885 + wacom->led.select[1] = 0; 886 + wacom->led.llv = 32; 887 + wacom->led.hlv = 0; 888 + wacom->led.img_lum = 0; 904 889 905 - error = sysfs_create_group(&wacom->hdev->dev.kobj, 906 - &intuos5_led_attr_group); 907 - } else 908 - return 0; 890 + error = sysfs_create_group(&wacom->hdev->dev.kobj, 891 + &intuos5_led_attr_group); 909 892 break; 910 893 911 894 default: ··· 923 912 static void wacom_destroy_leds(struct wacom *wacom) 924 913 { 925 914 if (!wacom->led_initialized) 915 + return; 916 + 917 + if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD)) 926 918 return; 927 919 928 920 wacom->led_initialized = false; ··· 951 937 case INTUOSPS: 952 938 case INTUOSPM: 953 939 case INTUOSPL: 954 - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) 955 - sysfs_remove_group(&wacom->hdev->dev.kobj, 956 - &intuos5_led_attr_group); 940 + sysfs_remove_group(&wacom->hdev->dev.kobj, 941 + &intuos5_led_attr_group); 957 942 break; 958 943 } 959 944 } ··· 1130 1117 if (!input_dev) 1131 1118 return NULL; 1132 1119 1133 - input_dev->name = wacom_wac->name; 1120 + input_dev->name = wacom_wac->pen_name; 1134 1121 input_dev->phys = hdev->phys; 1135 1122 input_dev->dev.parent = &hdev->dev; 1136 1123 input_dev->open = wacom_open; ··· 1149 1136 { 1150 1137 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1151 1138 1152 - if (wacom_wac->input) 1153 - input_free_device(wacom_wac->input); 1139 + if (wacom_wac->pen_input) 1140 + input_free_device(wacom_wac->pen_input); 1141 + if (wacom_wac->touch_input) 1142 + input_free_device(wacom_wac->touch_input); 1154 1143 if (wacom_wac->pad_input) 1155 1144 input_free_device(wacom_wac->pad_input); 1156 - wacom_wac->input = NULL; 1145 + wacom_wac->pen_input = NULL; 1146 + wacom_wac->touch_input = NULL; 1157 1147 wacom_wac->pad_input = NULL; 1158 1148 } 1159 1149 1160 1150 static int wacom_allocate_inputs(struct wacom *wacom) 1161 1151 { 1162 - struct input_dev *input_dev, *pad_input_dev; 1152 + struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev; 1163 1153 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1164 1154 1165 - input_dev = wacom_allocate_input(wacom); 1155 + pen_input_dev = wacom_allocate_input(wacom); 1156 + touch_input_dev = wacom_allocate_input(wacom); 1166 1157 pad_input_dev = wacom_allocate_input(wacom); 1167 - if (!input_dev || !pad_input_dev) { 1158 + if (!pen_input_dev || !touch_input_dev || !pad_input_dev) { 1168 1159 wacom_free_inputs(wacom); 1169 1160 return -ENOMEM; 1170 1161 } 1171 1162 1172 - wacom_wac->input = input_dev; 1163 + wacom_wac->pen_input = pen_input_dev; 1164 + wacom_wac->touch_input = touch_input_dev; 1165 + wacom_wac->touch_input->name = wacom_wac->touch_name; 1173 1166 wacom_wac->pad_input = pad_input_dev; 1174 1167 wacom_wac->pad_input->name = wacom_wac->pad_name; 1175 1168 ··· 1184 1165 1185 1166 static void wacom_clean_inputs(struct wacom *wacom) 1186 1167 { 1187 - if (wacom->wacom_wac.input) { 1188 - if (wacom->wacom_wac.input_registered) 1189 - input_unregister_device(wacom->wacom_wac.input); 1168 + if (wacom->wacom_wac.pen_input) { 1169 + if (wacom->wacom_wac.pen_registered) 1170 + input_unregister_device(wacom->wacom_wac.pen_input); 1190 1171 else 1191 - input_free_device(wacom->wacom_wac.input); 1172 + input_free_device(wacom->wacom_wac.pen_input); 1173 + } 1174 + if (wacom->wacom_wac.touch_input) { 1175 + if (wacom->wacom_wac.touch_registered) 1176 + input_unregister_device(wacom->wacom_wac.touch_input); 1177 + else 1178 + input_free_device(wacom->wacom_wac.touch_input); 1192 1179 } 1193 1180 if (wacom->wacom_wac.pad_input) { 1194 1181 if (wacom->wacom_wac.pad_registered) ··· 1202 1177 else 1203 1178 input_free_device(wacom->wacom_wac.pad_input); 1204 1179 } 1205 - wacom->wacom_wac.input = NULL; 1180 + wacom->wacom_wac.pen_input = NULL; 1181 + wacom->wacom_wac.touch_input = NULL; 1206 1182 wacom->wacom_wac.pad_input = NULL; 1207 1183 wacom_destroy_leds(wacom); 1208 1184 } 1209 1185 1210 1186 static int wacom_register_inputs(struct wacom *wacom) 1211 1187 { 1212 - struct input_dev *input_dev, *pad_input_dev; 1188 + struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev; 1213 1189 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1214 - int error; 1190 + int error = 0; 1215 1191 1216 - input_dev = wacom_wac->input; 1192 + pen_input_dev = wacom_wac->pen_input; 1193 + touch_input_dev = wacom_wac->touch_input; 1217 1194 pad_input_dev = wacom_wac->pad_input; 1218 1195 1219 - if (!input_dev || !pad_input_dev) 1196 + if (!pen_input_dev || !touch_input_dev || !pad_input_dev) 1220 1197 return -EINVAL; 1221 1198 1222 - error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac); 1223 - if (!error) { 1224 - error = input_register_device(input_dev); 1199 + error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac); 1200 + if (error) { 1201 + /* no pen in use on this interface */ 1202 + input_free_device(pen_input_dev); 1203 + wacom_wac->pen_input = NULL; 1204 + pen_input_dev = NULL; 1205 + } else { 1206 + error = input_register_device(pen_input_dev); 1225 1207 if (error) 1226 - return error; 1227 - wacom_wac->input_registered = true; 1208 + goto fail_register_pen_input; 1209 + wacom_wac->pen_registered = true; 1210 + } 1211 + 1212 + error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac); 1213 + if (error) { 1214 + /* no touch in use on this interface */ 1215 + input_free_device(touch_input_dev); 1216 + wacom_wac->touch_input = NULL; 1217 + touch_input_dev = NULL; 1218 + } else { 1219 + error = input_register_device(touch_input_dev); 1220 + if (error) 1221 + goto fail_register_touch_input; 1222 + wacom_wac->touch_registered = true; 1228 1223 } 1229 1224 1230 1225 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); ··· 1271 1226 pad_input_dev = NULL; 1272 1227 wacom_wac->pad_registered = false; 1273 1228 fail_register_pad_input: 1274 - input_unregister_device(input_dev); 1275 - wacom_wac->input = NULL; 1276 - wacom_wac->input_registered = false; 1229 + input_unregister_device(touch_input_dev); 1230 + wacom_wac->touch_input = NULL; 1231 + wacom_wac->touch_registered = false; 1232 + fail_register_touch_input: 1233 + input_unregister_device(pen_input_dev); 1234 + wacom_wac->pen_input = NULL; 1235 + wacom_wac->pen_registered = false; 1236 + fail_register_pen_input: 1277 1237 return error; 1278 1238 } 1279 1239 ··· 1335 1285 /* Stylus interface */ 1336 1286 wacom_wac1->features = 1337 1287 *((struct wacom_features *)id->driver_data); 1338 - wacom_wac1->features.device_type = BTN_TOOL_PEN; 1339 - snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1288 + wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN; 1289 + if (wacom_wac1->features.type != INTUOSHT && 1290 + wacom_wac1->features.type != BAMBOO_PT) 1291 + wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; 1292 + snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", 1340 1293 wacom_wac1->features.name); 1341 1294 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", 1342 1295 wacom_wac1->features.name); ··· 1357 1304 wacom_wac2->features = 1358 1305 *((struct wacom_features *)id->driver_data); 1359 1306 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1360 - wacom_wac2->features.device_type = BTN_TOOL_FINGER; 1361 1307 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1362 - if (wacom_wac2->features.touch_max) 1363 - snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1364 - "%s (WL) Finger",wacom_wac2->features.name); 1365 - else 1366 - snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1367 - "%s (WL) Pad",wacom_wac2->features.name); 1308 + snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, 1309 + "%s (WL) Finger",wacom_wac2->features.name); 1368 1310 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, 1369 - "%s (WL) Pad", wacom_wac2->features.name); 1311 + "%s (WL) Pad",wacom_wac2->features.name); 1312 + if (wacom_wac1->features.touch_max) 1313 + wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH; 1314 + if (wacom_wac1->features.type == INTUOSHT || 1315 + wacom_wac1->features.type == BAMBOO_PT) 1316 + wacom_wac2->features.device_type |= WACOM_DEVICETYPE_PAD; 1370 1317 wacom_wac2->pid = wacom_wac->pid; 1371 1318 error = wacom_allocate_inputs(wacom2) || 1372 1319 wacom_register_inputs(wacom2); ··· 1375 1322 1376 1323 if (wacom_wac1->features.type == INTUOSHT && 1377 1324 wacom_wac1->features.touch_max) 1378 - wacom_wac->shared->touch_input = wacom_wac2->input; 1325 + wacom_wac->shared->touch_input = wacom_wac2->touch_input; 1379 1326 } 1380 1327 1381 1328 error = wacom_initialize_battery(wacom); ··· 1422 1369 1423 1370 static void wacom_calculate_res(struct wacom_features *features) 1424 1371 { 1372 + /* set unit to "100th of a mm" for devices not reported by HID */ 1373 + if (!features->unit) { 1374 + features->unit = 0x11; 1375 + features->unitExpo = -3; 1376 + } 1377 + 1425 1378 features->x_resolution = wacom_calc_hid_res(features->x_max, 1426 1379 features->x_phy, 1427 1380 features->unit, ··· 1453 1394 } 1454 1395 1455 1396 return size; 1397 + } 1398 + 1399 + static void wacom_update_name(struct wacom *wacom) 1400 + { 1401 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1402 + struct wacom_features *features = &wacom_wac->features; 1403 + char name[WACOM_NAME_MAX]; 1404 + 1405 + /* Generic devices name unspecified */ 1406 + if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { 1407 + if (strstr(wacom->hdev->name, "Wacom") || 1408 + strstr(wacom->hdev->name, "wacom") || 1409 + strstr(wacom->hdev->name, "WACOM")) { 1410 + /* name is in HID descriptor, use it */ 1411 + strlcpy(name, wacom->hdev->name, sizeof(name)); 1412 + 1413 + /* strip out excess whitespaces */ 1414 + while (1) { 1415 + char *gap = strstr(name, " "); 1416 + if (gap == NULL) 1417 + break; 1418 + /* shift everything including the terminator */ 1419 + memmove(gap, gap+1, strlen(gap)); 1420 + } 1421 + /* get rid of trailing whitespace */ 1422 + if (name[strlen(name)-1] == ' ') 1423 + name[strlen(name)-1] = '\0'; 1424 + } else { 1425 + /* no meaningful name retrieved. use product ID */ 1426 + snprintf(name, sizeof(name), 1427 + "%s %X", features->name, wacom->hdev->product); 1428 + } 1429 + } else { 1430 + strlcpy(name, features->name, sizeof(name)); 1431 + } 1432 + 1433 + /* Append the device type to the name */ 1434 + snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name), 1435 + "%s Pen", name); 1436 + snprintf(wacom_wac->touch_name, sizeof(wacom_wac->touch_name), 1437 + "%s Finger", name); 1438 + snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), 1439 + "%s Pad", name); 1456 1440 } 1457 1441 1458 1442 static int wacom_probe(struct hid_device *hdev, ··· 1576 1474 1577 1475 /* Retrieve the physical and logical size for touch devices */ 1578 1476 wacom_retrieve_hid_descriptor(hdev, features); 1477 + wacom_setup_device_quirks(wacom); 1579 1478 1580 - /* 1581 - * Intuos5 has no useful data about its touch interface in its 1582 - * HID descriptor. If this is the touch interface (PacketSize 1583 - * of WACOM_PKGLEN_BBTOUCH3), override the table values. 1584 - */ 1585 - if (features->type >= INTUOS5S && features->type <= INTUOSHT) { 1586 - if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 1587 - features->device_type = BTN_TOOL_FINGER; 1479 + if (features->device_type == WACOM_DEVICETYPE_NONE && 1480 + features->type != WIRELESS) { 1481 + error = features->type == HID_GENERIC ? -ENODEV : 0; 1588 1482 1589 - features->x_max = 4096; 1590 - features->y_max = 4096; 1591 - } else { 1592 - features->device_type = BTN_TOOL_PEN; 1593 - } 1483 + dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.", 1484 + hdev->name, 1485 + error ? "Ignoring" : "Assuming pen"); 1486 + 1487 + if (error) 1488 + goto fail_shared_data; 1489 + 1490 + features->device_type |= WACOM_DEVICETYPE_PEN; 1594 1491 } 1595 1492 1596 - /* 1597 - * Same thing for Bamboo 3rd gen. 1598 - */ 1599 - if ((features->type == BAMBOO_PT) && 1600 - (features->pktlen == WACOM_PKGLEN_BBTOUCH3) && 1601 - (features->device_type == BTN_TOOL_PEN)) { 1602 - features->device_type = BTN_TOOL_FINGER; 1603 - 1604 - features->x_max = 4096; 1605 - features->y_max = 4096; 1606 - } 1607 - 1608 - /* 1609 - * Same thing for Bamboo PAD 1610 - */ 1611 - if (features->type == BAMBOO_PAD) 1612 - features->device_type = BTN_TOOL_FINGER; 1613 - 1614 - if (hdev->bus == BUS_BLUETOOTH) 1615 - features->quirks |= WACOM_QUIRK_BATTERY; 1616 - 1617 - wacom_setup_device_quirks(features); 1618 - 1619 - /* set unit to "100th of a mm" for devices not reported by HID */ 1620 - if (!features->unit) { 1621 - features->unit = 0x11; 1622 - features->unitExpo = -3; 1623 - } 1624 1493 wacom_calculate_res(features); 1625 1494 1626 - strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 1627 - snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), 1628 - "%s Pad", features->name); 1629 - 1630 - /* Append the device type to the name */ 1631 - if (features->device_type != BTN_TOOL_FINGER) 1632 - strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); 1633 - else if (features->touch_max) 1634 - strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); 1635 - else 1636 - strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); 1495 + wacom_update_name(wacom); 1637 1496 1638 1497 error = wacom_add_shared_data(hdev); 1639 1498 if (error) ··· 1637 1574 if (features->quirks & WACOM_QUIRK_MONITOR) 1638 1575 error = hid_hw_open(hdev); 1639 1576 1640 - if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { 1641 - if (wacom_wac->features.device_type == BTN_TOOL_FINGER) 1642 - wacom_wac->shared->touch_input = wacom_wac->input; 1577 + if (wacom_wac->features.type == INTUOSHT && 1578 + wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) { 1579 + wacom_wac->shared->touch_input = wacom_wac->touch_input; 1643 1580 } 1644 1581 1645 1582 return 0;
+240 -183
drivers/hid/wacom_wac.c
··· 69 69 static int wacom_penpartner_irq(struct wacom_wac *wacom) 70 70 { 71 71 unsigned char *data = wacom->data; 72 - struct input_dev *input = wacom->input; 72 + struct input_dev *input = wacom->pen_input; 73 73 74 74 switch (data[0]) { 75 75 case 1: ··· 114 114 { 115 115 struct wacom_features *features = &wacom->features; 116 116 unsigned char *data = wacom->data; 117 - struct input_dev *input = wacom->input; 117 + struct input_dev *input = wacom->pen_input; 118 118 int prox, pressure; 119 119 120 120 if (data[0] != WACOM_REPORT_PENABLED) { ··· 186 186 static int wacom_ptu_irq(struct wacom_wac *wacom) 187 187 { 188 188 unsigned char *data = wacom->data; 189 - struct input_dev *input = wacom->input; 189 + struct input_dev *input = wacom->pen_input; 190 190 191 191 if (data[0] != WACOM_REPORT_PENABLED) { 192 192 dev_dbg(input->dev.parent, ··· 215 215 static int wacom_dtu_irq(struct wacom_wac *wacom) 216 216 { 217 217 unsigned char *data = wacom->data; 218 - struct input_dev *input = wacom->input; 218 + struct input_dev *input = wacom->pen_input; 219 219 int prox = data[1] & 0x20; 220 220 221 221 dev_dbg(input->dev.parent, ··· 245 245 static int wacom_dtus_irq(struct wacom_wac *wacom) 246 246 { 247 247 char *data = wacom->data; 248 - struct input_dev *input = wacom->input; 248 + struct input_dev *input = wacom->pen_input; 249 249 unsigned short prox, pressure = 0; 250 250 251 251 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { ··· 297 297 { 298 298 struct wacom_features *features = &wacom->features; 299 299 unsigned char *data = wacom->data; 300 - struct input_dev *input = wacom->input; 300 + struct input_dev *input = wacom->pen_input; 301 301 struct input_dev *pad_input = wacom->pad_input; 302 302 int battery_capacity, ps_connected; 303 303 int prox; ··· 464 464 { 465 465 struct wacom_features *features = &wacom->features; 466 466 unsigned char *data = wacom->data; 467 - struct input_dev *input = wacom->input; 467 + struct input_dev *input = wacom->pen_input; 468 468 int idx = 0; 469 469 470 470 /* tool number */ ··· 649 649 { 650 650 struct wacom_features *features = &wacom->features; 651 651 unsigned char *data = wacom->data; 652 - struct input_dev *input = wacom->input; 652 + struct input_dev *input = wacom->pen_input; 653 653 unsigned int t; 654 654 655 655 /* general pen packet */ ··· 681 681 { 682 682 struct wacom_features *features = &wacom->features; 683 683 unsigned char *data = wacom->data; 684 - struct input_dev *input = wacom->input; 684 + struct input_dev *input = wacom->pen_input; 685 685 unsigned int t; 686 686 int idx = 0, result; 687 687 ··· 1025 1025 memcpy(wacom->data, data, 10); 1026 1026 wacom_intuos_irq(wacom); 1027 1027 1028 - input_sync(wacom->input); 1028 + input_sync(wacom->pen_input); 1029 1029 if (wacom->pad_input) 1030 1030 input_sync(wacom->pad_input); 1031 1031 } ··· 1057 1057 ps_connected); 1058 1058 break; 1059 1059 default: 1060 - dev_dbg(wacom->input->dev.parent, 1060 + dev_dbg(wacom->pen_input->dev.parent, 1061 1061 "Unknown report: %d,%d size:%zu\n", 1062 1062 data[0], data[1], len); 1063 1063 return 0; ··· 1067 1067 1068 1068 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) 1069 1069 { 1070 - struct input_dev *input = wacom->input; 1070 + struct input_dev *input = wacom->touch_input; 1071 1071 unsigned touch_max = wacom->features.touch_max; 1072 1072 int count = 0; 1073 1073 int i; ··· 1075 1075 if (!touch_max) 1076 1076 return 0; 1077 1077 1078 - /* non-HID_GENERIC single touch input doesn't call this routine */ 1079 - if ((touch_max == 1) && (wacom->features.type == HID_GENERIC)) 1080 - return wacom->hid_data.tipswitch && 1078 + if (touch_max == 1) 1079 + return test_bit(BTN_TOUCH, input->key) && 1081 1080 !wacom->shared->stylus_in_proximity; 1082 1081 1083 1082 for (i = 0; i < input->mt->num_slots; i++) { ··· 1091 1092 1092 1093 static int wacom_24hdt_irq(struct wacom_wac *wacom) 1093 1094 { 1094 - struct input_dev *input = wacom->input; 1095 + struct input_dev *input = wacom->touch_input; 1095 1096 unsigned char *data = wacom->data; 1096 1097 int i; 1097 1098 int current_num_contacts = data[61]; ··· 1159 1160 1160 1161 static int wacom_mt_touch(struct wacom_wac *wacom) 1161 1162 { 1162 - struct input_dev *input = wacom->input; 1163 + struct input_dev *input = wacom->touch_input; 1163 1164 unsigned char *data = wacom->data; 1164 1165 int i; 1165 1166 int current_num_contacts = data[2]; ··· 1210 1211 1211 1212 static int wacom_tpc_mt_touch(struct wacom_wac *wacom) 1212 1213 { 1213 - struct input_dev *input = wacom->input; 1214 + struct input_dev *input = wacom->touch_input; 1214 1215 unsigned char *data = wacom->data; 1215 1216 int i; 1216 1217 ··· 1239 1240 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) 1240 1241 { 1241 1242 unsigned char *data = wacom->data; 1242 - struct input_dev *input = wacom->input; 1243 + struct input_dev *input = wacom->touch_input; 1243 1244 bool prox = !wacom->shared->stylus_in_proximity; 1244 1245 int x = 0, y = 0; 1245 1246 ··· 1275 1276 static int wacom_tpc_pen(struct wacom_wac *wacom) 1276 1277 { 1277 1278 unsigned char *data = wacom->data; 1278 - struct input_dev *input = wacom->input; 1279 + struct input_dev *input = wacom->pen_input; 1279 1280 bool prox = data[1] & 0x20; 1280 1281 1281 1282 if (!wacom->shared->stylus_in_proximity) /* first in prox */ ··· 1304 1305 { 1305 1306 unsigned char *data = wacom->data; 1306 1307 1307 - dev_dbg(wacom->input->dev.parent, 1308 - "%s: received report #%d\n", __func__, data[0]); 1308 + if (wacom->pen_input) 1309 + dev_dbg(wacom->pen_input->dev.parent, 1310 + "%s: received report #%d\n", __func__, data[0]); 1311 + else if (wacom->touch_input) 1312 + dev_dbg(wacom->touch_input->dev.parent, 1313 + "%s: received report #%d\n", __func__, data[0]); 1309 1314 1310 1315 switch (len) { 1311 1316 case WACOM_PKGLEN_TPC1FG: ··· 1341 1338 return 0; 1342 1339 } 1343 1340 1344 - static void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage, 1341 + static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, 1345 1342 struct hid_field *field, __u8 type, __u16 code, int fuzz) 1346 1343 { 1347 - struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1348 - struct input_dev *input = wacom_wac->input; 1349 1344 int fmin = field->logical_minimum; 1350 1345 int fmax = field->logical_maximum; 1351 1346 ··· 1371 1370 struct hid_field *field, struct hid_usage *usage) 1372 1371 { 1373 1372 struct wacom *wacom = hid_get_drvdata(hdev); 1373 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1374 + struct input_dev *input = wacom_wac->pen_input; 1374 1375 1375 1376 switch (usage->hid) { 1376 1377 case HID_GD_X: 1377 - wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); 1378 + wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); 1378 1379 break; 1379 1380 case HID_GD_Y: 1380 - wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); 1381 + wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); 1381 1382 break; 1382 1383 case HID_DG_TIPPRESSURE: 1383 - wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0); 1384 + wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0); 1384 1385 break; 1385 1386 case HID_DG_INRANGE: 1386 - wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0); 1387 + wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); 1387 1388 break; 1388 1389 case HID_DG_INVERT: 1389 - wacom_map_usage(wacom, usage, field, EV_KEY, 1390 + wacom_map_usage(input, usage, field, EV_KEY, 1390 1391 BTN_TOOL_RUBBER, 0); 1391 1392 break; 1392 1393 case HID_DG_ERASER: 1393 1394 case HID_DG_TIPSWITCH: 1394 - wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); 1395 + wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); 1395 1396 break; 1396 1397 case HID_DG_BARRELSWITCH: 1397 - wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0); 1398 + wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0); 1398 1399 break; 1399 1400 case HID_DG_BARRELSWITCH2: 1400 - wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0); 1401 + wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0); 1401 1402 break; 1402 1403 case HID_DG_TOOLSERIALNUMBER: 1403 - wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0); 1404 + wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0); 1404 1405 break; 1405 1406 } 1406 1407 } ··· 1412 1409 { 1413 1410 struct wacom *wacom = hid_get_drvdata(hdev); 1414 1411 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1415 - struct input_dev *input = wacom_wac->input; 1412 + struct input_dev *input = wacom_wac->pen_input; 1416 1413 1417 1414 /* checking which Tool / tip switch to send */ 1418 1415 switch (usage->hid) { ··· 1442 1439 { 1443 1440 struct wacom *wacom = hid_get_drvdata(hdev); 1444 1441 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1445 - struct input_dev *input = wacom_wac->input; 1442 + struct input_dev *input = wacom_wac->pen_input; 1446 1443 bool prox = wacom_wac->hid_data.inrange_state; 1447 1444 1448 1445 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */ ··· 1471 1468 struct wacom *wacom = hid_get_drvdata(hdev); 1472 1469 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1473 1470 struct wacom_features *features = &wacom_wac->features; 1471 + struct input_dev *input = wacom_wac->touch_input; 1474 1472 unsigned touch_max = wacom_wac->features.touch_max; 1475 1473 1476 1474 switch (usage->hid) { 1477 1475 case HID_GD_X: 1478 1476 features->last_slot_field = usage->hid; 1479 1477 if (touch_max == 1) 1480 - wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); 1478 + wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); 1481 1479 else 1482 - wacom_map_usage(wacom, usage, field, EV_ABS, 1480 + wacom_map_usage(input, usage, field, EV_ABS, 1483 1481 ABS_MT_POSITION_X, 4); 1484 1482 break; 1485 1483 case HID_GD_Y: 1486 1484 features->last_slot_field = usage->hid; 1487 1485 if (touch_max == 1) 1488 - wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); 1486 + wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); 1489 1487 else 1490 - wacom_map_usage(wacom, usage, field, EV_ABS, 1488 + wacom_map_usage(input, usage, field, EV_ABS, 1491 1489 ABS_MT_POSITION_Y, 4); 1492 1490 break; 1493 1491 case HID_DG_CONTACTID: ··· 1502 1498 break; 1503 1499 case HID_DG_TIPSWITCH: 1504 1500 features->last_slot_field = usage->hid; 1505 - wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); 1501 + wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); 1506 1502 break; 1507 1503 } 1508 1504 } ··· 1558 1554 1559 1555 if (usage->usage_index + 1 == field->report_count) { 1560 1556 if (usage->hid == wacom_wac->features.last_slot_field) 1561 - wacom_wac_finger_slot(wacom_wac, wacom_wac->input); 1557 + wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); 1562 1558 } 1563 1559 1564 1560 return 0; ··· 1569 1565 { 1570 1566 struct wacom *wacom = hid_get_drvdata(hdev); 1571 1567 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1572 - struct input_dev *input = wacom_wac->input; 1568 + struct input_dev *input = wacom_wac->touch_input; 1573 1569 unsigned touch_max = wacom_wac->features.touch_max; 1574 1570 1575 1571 if (touch_max > 1) ··· 1586 1582 { 1587 1583 struct wacom *wacom = hid_get_drvdata(hdev); 1588 1584 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1589 - struct input_dev *input = wacom_wac->input; 1590 1585 1591 1586 /* currently, only direct devices have proper hid report descriptors */ 1592 - __set_bit(INPUT_PROP_DIRECT, input->propbit); 1587 + __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit); 1588 + __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit); 1593 1589 1594 1590 if (WACOM_PEN_FIELD(field)) 1595 1591 return wacom_wac_pen_usage_mapping(hdev, field, usage); ··· 1634 1630 static int wacom_bpt_touch(struct wacom_wac *wacom) 1635 1631 { 1636 1632 struct wacom_features *features = &wacom->features; 1637 - struct input_dev *input = wacom->input; 1633 + struct input_dev *input = wacom->touch_input; 1638 1634 struct input_dev *pad_input = wacom->pad_input; 1639 1635 unsigned char *data = wacom->data; 1640 1636 int i; ··· 1682 1678 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) 1683 1679 { 1684 1680 struct wacom_features *features = &wacom->features; 1685 - struct input_dev *input = wacom->input; 1681 + struct input_dev *input = wacom->touch_input; 1686 1682 bool touch = data[1] & 0x80; 1687 1683 int slot = input_mt_get_slot_by_key(input, data[0]); 1688 1684 ··· 1740 1736 1741 1737 static int wacom_bpt3_touch(struct wacom_wac *wacom) 1742 1738 { 1743 - struct input_dev *input = wacom->input; 1744 1739 unsigned char *data = wacom->data; 1745 1740 int count = data[1] & 0x07; 1746 1741 int i; ··· 1758 1755 wacom_bpt3_button_msg(wacom, data + offset); 1759 1756 1760 1757 } 1761 - input_mt_sync_frame(input); 1762 - wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); 1758 + 1759 + /* only update the touch if we actually have a touchpad */ 1760 + if (wacom->touch_registered) { 1761 + input_mt_sync_frame(wacom->touch_input); 1762 + wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); 1763 + } 1763 1764 1764 1765 return 1; 1765 1766 } ··· 1771 1764 static int wacom_bpt_pen(struct wacom_wac *wacom) 1772 1765 { 1773 1766 struct wacom_features *features = &wacom->features; 1774 - struct input_dev *input = wacom->input; 1767 + struct input_dev *input = wacom->pen_input; 1775 1768 unsigned char *data = wacom->data; 1776 1769 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; 1777 1770 ··· 1880 1873 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, 1881 1874 unsigned char *data) 1882 1875 { 1883 - struct input_dev *input = wacom->input; 1876 + struct input_dev *input = wacom->touch_input; 1884 1877 unsigned char *finger_data, prefix; 1885 1878 unsigned id; 1886 1879 int x, y; ··· 2124 2117 } 2125 2118 2126 2119 if (sync) { 2127 - input_sync(wacom_wac->input); 2120 + if (wacom_wac->pen_input) 2121 + input_sync(wacom_wac->pen_input); 2122 + if (wacom_wac->touch_input) 2123 + input_sync(wacom_wac->touch_input); 2128 2124 if (wacom_wac->pad_input) 2129 2125 input_sync(wacom_wac->pad_input); 2130 2126 } ··· 2135 2125 2136 2126 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) 2137 2127 { 2138 - struct input_dev *input_dev = wacom_wac->input; 2128 + struct input_dev *input_dev = wacom_wac->pen_input; 2139 2129 2140 2130 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 2141 2131 ··· 2158 2148 2159 2149 static void wacom_setup_intuos(struct wacom_wac *wacom_wac) 2160 2150 { 2161 - struct input_dev *input_dev = wacom_wac->input; 2151 + struct input_dev *input_dev = wacom_wac->pen_input; 2162 2152 2163 2153 input_set_capability(input_dev, EV_REL, REL_WHEEL); 2164 2154 ··· 2177 2167 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); 2178 2168 } 2179 2169 2180 - void wacom_setup_device_quirks(struct wacom_features *features) 2170 + void wacom_setup_device_quirks(struct wacom *wacom) 2181 2171 { 2172 + struct wacom_features *features = &wacom->wacom_wac.features; 2173 + 2174 + /* The pen and pad share the same interface on most devices */ 2175 + if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || 2176 + features->type == DTUS || features->type == WACOM_MO || 2177 + (features->type >= INTUOS3S && features->type <= WACOM_13HD && 2178 + features->type != INTUOSHT)) { 2179 + if (features->device_type & WACOM_DEVICETYPE_PEN) 2180 + features->device_type |= WACOM_DEVICETYPE_PAD; 2181 + } 2182 2182 2183 2183 /* touch device found but size is not defined. use default */ 2184 - if (features->device_type == BTN_TOOL_FINGER && !features->x_max) { 2184 + if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { 2185 2185 features->x_max = 1023; 2186 2186 features->y_max = 1023; 2187 2187 } 2188 + 2189 + /* 2190 + * Intuos5/Pro and Bamboo 3rd gen have no useful data about its 2191 + * touch interface in its HID descriptor. If this is the touch 2192 + * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the 2193 + * tablet values. 2194 + */ 2195 + if ((features->type >= INTUOS5S && features->type <= INTUOSHT) || 2196 + (features->type == BAMBOO_PT)) { 2197 + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 2198 + if (features->touch_max) 2199 + features->device_type |= WACOM_DEVICETYPE_TOUCH; 2200 + if (features->type == BAMBOO_PT || features->type == INTUOSHT) 2201 + features->device_type |= WACOM_DEVICETYPE_PAD; 2202 + 2203 + features->x_max = 4096; 2204 + features->y_max = 4096; 2205 + } 2206 + } 2207 + 2208 + /* 2209 + * Raw Wacom-mode pen and touch events both come from interface 2210 + * 0, whose HID descriptor has an application usage of 0xFF0D 2211 + * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back 2212 + * out through the HID_GENERIC device created for interface 1, 2213 + * so rewrite this one to be of type BTN_TOOL_FINGER. 2214 + */ 2215 + if (features->type == BAMBOO_PAD) 2216 + features->device_type |= WACOM_DEVICETYPE_TOUCH; 2217 + 2218 + if (wacom->hdev->bus == BUS_BLUETOOTH) 2219 + features->quirks |= WACOM_QUIRK_BATTERY; 2188 2220 2189 2221 /* quirk for bamboo touch with 2 low res touches */ 2190 2222 if (features->type == BAMBOO_PT && ··· 2244 2192 features->quirks |= WACOM_QUIRK_NO_INPUT; 2245 2193 2246 2194 /* must be monitor interface if no device_type set */ 2247 - if (!features->device_type) { 2195 + if (features->device_type == WACOM_DEVICETYPE_NONE) { 2248 2196 features->quirks |= WACOM_QUIRK_MONITOR; 2249 2197 features->quirks |= WACOM_QUIRK_BATTERY; 2250 2198 } 2251 2199 } 2252 2200 } 2253 2201 2254 - static void wacom_abs_set_axis(struct input_dev *input_dev, 2255 - struct wacom_wac *wacom_wac) 2256 - { 2257 - struct wacom_features *features = &wacom_wac->features; 2258 - 2259 - if (features->device_type == BTN_TOOL_PEN) { 2260 - input_set_abs_params(input_dev, ABS_X, features->x_min, 2261 - features->x_max, features->x_fuzz, 0); 2262 - input_set_abs_params(input_dev, ABS_Y, features->y_min, 2263 - features->y_max, features->y_fuzz, 0); 2264 - input_set_abs_params(input_dev, ABS_PRESSURE, 0, 2265 - features->pressure_max, features->pressure_fuzz, 0); 2266 - 2267 - /* penabled devices have fixed resolution for each model */ 2268 - input_abs_set_res(input_dev, ABS_X, features->x_resolution); 2269 - input_abs_set_res(input_dev, ABS_Y, features->y_resolution); 2270 - } else { 2271 - if (features->touch_max == 1) { 2272 - input_set_abs_params(input_dev, ABS_X, 0, 2273 - features->x_max, features->x_fuzz, 0); 2274 - input_set_abs_params(input_dev, ABS_Y, 0, 2275 - features->y_max, features->y_fuzz, 0); 2276 - input_abs_set_res(input_dev, ABS_X, 2277 - features->x_resolution); 2278 - input_abs_set_res(input_dev, ABS_Y, 2279 - features->y_resolution); 2280 - } 2281 - 2282 - if (features->touch_max > 1) { 2283 - input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 2284 - features->x_max, features->x_fuzz, 0); 2285 - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 2286 - features->y_max, features->y_fuzz, 0); 2287 - input_abs_set_res(input_dev, ABS_MT_POSITION_X, 2288 - features->x_resolution); 2289 - input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 2290 - features->y_resolution); 2291 - } 2292 - } 2293 - } 2294 - 2295 - int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, 2202 + int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, 2296 2203 struct wacom_wac *wacom_wac) 2297 2204 { 2298 2205 struct wacom_features *features = &wacom_wac->features; 2299 2206 2300 2207 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2208 + 2209 + if (!(features->device_type & WACOM_DEVICETYPE_PEN)) 2210 + return -ENODEV; 2301 2211 2302 2212 if (features->type == HID_GENERIC) 2303 2213 /* setup has already been done */ ··· 2268 2254 __set_bit(BTN_TOUCH, input_dev->keybit); 2269 2255 __set_bit(ABS_MISC, input_dev->absbit); 2270 2256 2271 - wacom_abs_set_axis(input_dev, wacom_wac); 2257 + input_set_abs_params(input_dev, ABS_X, features->x_min, 2258 + features->x_max, features->x_fuzz, 0); 2259 + input_set_abs_params(input_dev, ABS_Y, features->y_min, 2260 + features->y_max, features->y_fuzz, 0); 2261 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, 2262 + features->pressure_max, features->pressure_fuzz, 0); 2263 + 2264 + /* penabled devices have fixed resolution for each model */ 2265 + input_abs_set_res(input_dev, ABS_X, features->x_resolution); 2266 + input_abs_set_res(input_dev, ABS_Y, features->y_resolution); 2267 + 2272 2268 2273 2269 switch (features->type) { 2274 2270 case GRAPHIRE_BT: ··· 2347 2323 case INTUOSPS: 2348 2324 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2349 2325 2350 - if (features->device_type == BTN_TOOL_PEN) { 2351 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2352 - features->distance_max, 2353 - 0, 0); 2326 + input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2327 + features->distance_max, 2328 + 0, 0); 2354 2329 2355 - input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2356 - input_abs_set_res(input_dev, ABS_Z, 287); 2330 + input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2331 + input_abs_set_res(input_dev, ABS_Z, 287); 2357 2332 2358 - wacom_setup_intuos(wacom_wac); 2359 - } else if (features->device_type == BTN_TOOL_FINGER) { 2360 - __clear_bit(ABS_MISC, input_dev->absbit); 2361 - 2362 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 2363 - 0, features->x_max, 0, 0); 2364 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 2365 - 0, features->y_max, 0, 0); 2366 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2367 - } 2333 + wacom_setup_intuos(wacom_wac); 2368 2334 break; 2369 2335 2370 2336 case WACOM_24HDT: 2371 - if (features->device_type == BTN_TOOL_FINGER) { 2372 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2373 - input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); 2374 - input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); 2375 - input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 2376 - } 2377 - /* fall through */ 2378 - 2379 2337 case WACOM_27QHDT: 2380 2338 case MTSCREEN: 2381 2339 case MTTPC: 2382 2340 case MTTPC_B: 2383 2341 case TABLETPC2FG: 2384 - if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1) 2385 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); 2386 - /* fall through */ 2387 - 2388 2342 case TABLETPC: 2389 2343 case TABLETPCE: 2390 2344 __clear_bit(ABS_MISC, input_dev->absbit); 2391 - 2392 - __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2393 - 2394 - if (features->device_type != BTN_TOOL_PEN) 2395 - break; /* no need to process stylus stuff */ 2396 - 2397 2345 /* fall through */ 2398 2346 2399 2347 case DTUS: ··· 2393 2397 break; 2394 2398 2395 2399 case INTUOSHT: 2396 - if (features->touch_max && 2397 - features->device_type == BTN_TOOL_FINGER) { 2398 - input_dev->evbit[0] |= BIT_MASK(EV_SW); 2399 - __set_bit(SW_MUTE_DEVICE, input_dev->swbit); 2400 - } 2401 - /* fall through */ 2402 - 2403 2400 case BAMBOO_PT: 2404 2401 __clear_bit(ABS_MISC, input_dev->absbit); 2405 2402 2406 - if (features->device_type == BTN_TOOL_FINGER) { 2407 - 2408 - if (features->touch_max) { 2409 - if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 2410 - input_set_abs_params(input_dev, 2411 - ABS_MT_TOUCH_MAJOR, 2412 - 0, features->x_max, 0, 0); 2413 - input_set_abs_params(input_dev, 2414 - ABS_MT_TOUCH_MINOR, 2415 - 0, features->y_max, 0, 0); 2416 - } 2417 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2418 - } else { 2419 - /* buttons/keys only interface */ 2420 - __clear_bit(ABS_X, input_dev->absbit); 2421 - __clear_bit(ABS_Y, input_dev->absbit); 2422 - __clear_bit(BTN_TOUCH, input_dev->keybit); 2423 - 2424 - /* PAD is setup by wacom_setup_pad_input_capabilities later */ 2425 - return 1; 2426 - } 2427 - } else if (features->device_type == BTN_TOOL_PEN) { 2428 - __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2429 - __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 2430 - __set_bit(BTN_TOOL_PEN, input_dev->keybit); 2431 - __set_bit(BTN_STYLUS, input_dev->keybit); 2432 - __set_bit(BTN_STYLUS2, input_dev->keybit); 2433 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2434 - features->distance_max, 2435 - 0, 0); 2436 - } 2403 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2404 + __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 2405 + __set_bit(BTN_TOOL_PEN, input_dev->keybit); 2406 + __set_bit(BTN_STYLUS, input_dev->keybit); 2407 + __set_bit(BTN_STYLUS2, input_dev->keybit); 2408 + input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2409 + features->distance_max, 2410 + 0, 0); 2437 2411 break; 2438 2412 case BAMBOO_PAD: 2439 2413 __clear_bit(ABS_MISC, input_dev->absbit); 2414 + break; 2415 + } 2416 + return 0; 2417 + } 2418 + 2419 + int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, 2420 + struct wacom_wac *wacom_wac) 2421 + { 2422 + struct wacom_features *features = &wacom_wac->features; 2423 + 2424 + input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2425 + 2426 + if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) 2427 + return -ENODEV; 2428 + 2429 + if (features->type == HID_GENERIC) 2430 + /* setup has already been done */ 2431 + return 0; 2432 + 2433 + __set_bit(BTN_TOUCH, input_dev->keybit); 2434 + 2435 + if (features->touch_max == 1) { 2436 + input_set_abs_params(input_dev, ABS_X, 0, 2437 + features->x_max, features->x_fuzz, 0); 2438 + input_set_abs_params(input_dev, ABS_Y, 0, 2439 + features->y_max, features->y_fuzz, 0); 2440 + input_abs_set_res(input_dev, ABS_X, 2441 + features->x_resolution); 2442 + input_abs_set_res(input_dev, ABS_Y, 2443 + features->y_resolution); 2444 + } 2445 + else if (features->touch_max > 1) { 2446 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 2447 + features->x_max, features->x_fuzz, 0); 2448 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 2449 + features->y_max, features->y_fuzz, 0); 2450 + input_abs_set_res(input_dev, ABS_MT_POSITION_X, 2451 + features->x_resolution); 2452 + input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 2453 + features->y_resolution); 2454 + } 2455 + 2456 + switch (features->type) { 2457 + case INTUOS5: 2458 + case INTUOS5L: 2459 + case INTUOSPM: 2460 + case INTUOSPL: 2461 + case INTUOS5S: 2462 + case INTUOSPS: 2463 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2464 + 2465 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2466 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); 2467 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2468 + break; 2469 + 2470 + case WACOM_24HDT: 2471 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2472 + input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); 2473 + input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); 2474 + input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 2475 + /* fall through */ 2476 + 2477 + case WACOM_27QHDT: 2478 + case MTSCREEN: 2479 + case MTTPC: 2480 + case MTTPC_B: 2481 + case TABLETPC2FG: 2482 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); 2483 + /*fall through */ 2484 + 2485 + case TABLETPC: 2486 + case TABLETPCE: 2487 + __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2488 + break; 2489 + 2490 + case INTUOSHT: 2491 + input_dev->evbit[0] |= BIT_MASK(EV_SW); 2492 + __set_bit(SW_MUTE_DEVICE, input_dev->swbit); 2493 + /* fall through */ 2494 + 2495 + case BAMBOO_PT: 2496 + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 2497 + input_set_abs_params(input_dev, 2498 + ABS_MT_TOUCH_MAJOR, 2499 + 0, features->x_max, 0, 0); 2500 + input_set_abs_params(input_dev, 2501 + ABS_MT_TOUCH_MINOR, 2502 + 0, features->y_max, 0, 0); 2503 + } 2504 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2505 + break; 2506 + 2507 + case BAMBOO_PAD: 2440 2508 input_mt_init_slots(input_dev, features->touch_max, 2441 2509 INPUT_MT_POINTER); 2442 2510 __set_bit(BTN_LEFT, input_dev->keybit); ··· 2515 2455 { 2516 2456 struct wacom_features *features = &wacom_wac->features; 2517 2457 int i; 2458 + 2459 + if (!(features->device_type & WACOM_DEVICETYPE_PAD)) 2460 + return -ENODEV; 2518 2461 2519 2462 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2520 2463 ··· 2655 2592 2656 2593 case INTUOS5S: 2657 2594 case INTUOSPS: 2658 - /* touch interface does not have the pad device */ 2659 - if (features->device_type != BTN_TOOL_PEN) 2660 - return -ENODEV; 2661 - 2662 2595 for (i = 0; i < 7; i++) 2663 2596 __set_bit(BTN_0 + i, input_dev->keybit); 2664 2597 ··· 2696 2637 2697 2638 case INTUOSHT: 2698 2639 case BAMBOO_PT: 2699 - /* pad device is on the touch interface */ 2700 - if ((features->device_type != BTN_TOOL_FINGER) || 2701 - /* Bamboo Pen only tablet does not have pad */ 2702 - ((features->type == BAMBOO_PT) && !features->touch_max)) 2703 - return -ENODEV; 2704 - 2705 2640 __clear_bit(ABS_MISC, input_dev->absbit); 2706 2641 2707 2642 __set_bit(BTN_LEFT, input_dev->keybit); ··· 2975 2922 { "Wacom DTU1031X", 22472, 12728, 511, 0, 2976 2923 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2977 2924 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; 2925 + static const struct wacom_features wacom_features_0x336 = 2926 + { "Wacom DTU1141", 23472, 13203, 1023, 0, 2927 + DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2978 2928 static const struct wacom_features wacom_features_0x57 = 2979 2929 { "Wacom DTK2241", 95640, 54060, 2047, 63, 2980 2930 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, ··· 3331 3275 { USB_DEVICE_WACOM(0x32F) }, 3332 3276 { USB_DEVICE_WACOM(0x333) }, 3333 3277 { USB_DEVICE_WACOM(0x335) }, 3278 + { USB_DEVICE_WACOM(0x336) }, 3334 3279 { USB_DEVICE_WACOM(0x4001) }, 3335 3280 { USB_DEVICE_WACOM(0x4004) }, 3336 3281 { USB_DEVICE_WACOM(0x5000) },
+17 -10
drivers/hid/wacom_wac.h
··· 18 18 #define WACOM_NAME_MAX 64 19 19 20 20 /* packet length for individual models */ 21 - #define WACOM_PKGLEN_PENPRTN 7 22 - #define WACOM_PKGLEN_GRAPHIRE 8 23 21 #define WACOM_PKGLEN_BBFUN 9 24 - #define WACOM_PKGLEN_INTUOS 10 25 22 #define WACOM_PKGLEN_TPC1FG 5 26 23 #define WACOM_PKGLEN_TPC1FG_B 10 27 24 #define WACOM_PKGLEN_TPC2FG 14 ··· 26 29 #define WACOM_PKGLEN_BBTOUCH3 64 27 30 #define WACOM_PKGLEN_BBPEN 10 28 31 #define WACOM_PKGLEN_WIRELESS 32 29 - #define WACOM_PKGLEN_MTOUCH 62 30 - #define WACOM_PKGLEN_MTTPC 40 31 - #define WACOM_PKGLEN_DTUS 68 32 32 #define WACOM_PKGLEN_PENABLED 8 33 33 #define WACOM_PKGLEN_BPAD_TOUCH 32 34 34 #define WACOM_PKGLEN_BPAD_TOUCH_USB 64 ··· 72 78 #define WACOM_QUIRK_MONITOR 0x0004 73 79 #define WACOM_QUIRK_BATTERY 0x0008 74 80 81 + /* device types */ 82 + #define WACOM_DEVICETYPE_NONE 0x0000 83 + #define WACOM_DEVICETYPE_PEN 0x0001 84 + #define WACOM_DEVICETYPE_TOUCH 0x0002 85 + #define WACOM_DEVICETYPE_PAD 0x0004 86 + 87 + #define WACOM_VENDORDEFINED_PEN 0xff0d0001 88 + 75 89 #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \ 76 90 ((f)->physical == HID_DG_STYLUS) || \ 77 91 ((f)->physical == HID_DG_PEN) || \ 78 - ((f)->application == HID_DG_PEN)) 92 + ((f)->application == HID_DG_PEN) || \ 93 + ((f)->application == HID_DG_DIGITIZER) || \ 94 + ((f)->application == WACOM_VENDORDEFINED_PEN)) 79 95 #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \ 80 96 ((f)->physical == HID_DG_FINGER) || \ 81 97 ((f)->application == HID_DG_TOUCHSCREEN)) ··· 196 192 }; 197 193 198 194 struct wacom_wac { 199 - char name[WACOM_NAME_MAX]; 195 + char pen_name[WACOM_NAME_MAX]; 196 + char touch_name[WACOM_NAME_MAX]; 200 197 char pad_name[WACOM_NAME_MAX]; 201 198 char bat_name[WACOM_NAME_MAX]; 202 199 char ac_name[WACOM_NAME_MAX]; ··· 208 203 bool reporting_data; 209 204 struct wacom_features features; 210 205 struct wacom_shared *shared; 211 - struct input_dev *input; 206 + struct input_dev *pen_input; 207 + struct input_dev *touch_input; 212 208 struct input_dev *pad_input; 213 - bool input_registered; 209 + bool pen_registered; 210 + bool touch_registered; 214 211 bool pad_registered; 215 212 int pid; 216 213 int battery_capacity;
-10
drivers/usb/misc/ldusb.c
··· 69 69 #define USB_DEVICE_ID_LD_HYBRID 0x2090 /* USB Product ID of Automotive Hybrid */ 70 70 #define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 /* USB Product ID of Heat control */ 71 71 72 - #define USB_VENDOR_ID_VERNIER 0x08f7 73 - #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 74 - #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 75 - #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 76 - #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 77 - 78 72 #ifdef CONFIG_USB_DYNAMIC_MINORS 79 73 #define USB_LD_MINOR_BASE 0 80 74 #else ··· 109 115 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 110 116 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 111 117 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 112 - { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 113 - { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 114 - { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 115 - { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 116 118 { } /* Terminating entry */ 117 119 }; 118 120 MODULE_DEVICE_TABLE(usb, ld_usb_table);
+2
include/linux/hid.h
··· 815 815 const struct hid_device_id *hid_match_id(struct hid_device *hdev, 816 816 const struct hid_device_id *id); 817 817 s32 hid_snto32(__u32 value, unsigned n); 818 + __u32 hid_field_extract(const struct hid_device *hid, __u8 *report, 819 + unsigned offset, unsigned n); 818 820 819 821 /** 820 822 * hid_device_io_start - enable HID input during probe, remove