aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-22 23:58:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-22 23:58:23 -0500
commit4988abf1749241bc80600a6b3283d03898d2717c (patch)
tree9660d892d024b8df5b685f3724ed50afdeed77b2
parentfe41c2c018b8af9b370a40845f547e22894ff68a (diff)
parent62813858fb5d1fb661433d7884668aa111115a35 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID updates from Jiri Kosina: - quite some work on hid-sony driver in order to have DualShock 4 device properly supported, from Frank Praznik - fixed support for suspending I2C conntected devices, from Mika Westerberg - regression fix for 0xff05 usage on Microsoft Ergonomy, from Jiri Kosina - support for Synaptics HD touchscreen, from AceLan Kao - workaround for USB 3.0 problem for logitech-dj connected devices, from Benjamin Tisssoires - support for Logitech Dual Action pads, from Vitaly Katraew - quite a few other assorted fixes and device ID additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (33 commits) HID: sony: Use colors for the Dualshock 4 LED names HID: sony: Add annotated HID descriptor for the Dualshock 4 HID: sony: Cache the output report for the Dualshock 4 HID: sony: Map gyroscopes and accelerometers to axes HID: sony: Fix spacing in the device definitions. HID: sony: Use standard output reports instead of raw reports to send data to the Dualshock 4. HID: sony: Use separate identifiers for USB and Bluetooth connected Dualshock 4 controllers. HID: hid-holtek-mouse: add new a070 mouse HID: hid-sensor-hub: Fix buggy report descriptors HID: logitech-dj: Fix USB 3.0 issue HID: sony: Rename worker function HID: sony: Add LED controls for the Dualshock 4 HID: sony: Add force-feedback support for the Dualshock 4 HID: hidraw: make comment more accurate and nicer HID: sony: fix error return code HID: input: fix input sysfs path for hid devices HID: debug: add labels for some new buttons HID: remove SIS entries from hid_have_special_driver[] HID: microsoft: no fallthrough in MS ergonomy 0xff05 usage HID: add support for SiS multitouch panel in the touch monitor LG 23ET83V ...
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-core.c5
-rw-r--r--drivers/hid/hid-debug.c5
-rw-r--r--drivers/hid/hid-holtek-mouse.c3
-rw-r--r--drivers/hid/hid-ids.h15
-rw-r--r--drivers/hid/hid-input.c2
-rw-r--r--drivers/hid/hid-lg.c2
-rw-r--r--drivers/hid/hid-logitech-dj.c8
-rw-r--r--drivers/hid/hid-microsoft.c1
-rw-r--r--drivers/hid/hid-multitouch.c7
-rw-r--r--drivers/hid/hid-sensor-hub.c45
-rw-r--r--drivers/hid/hid-sony.c594
-rw-r--r--drivers/hid/hidraw.c27
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c9
-rw-r--r--drivers/hid/usbhid/usbkbd.c2
16 files changed, 592 insertions, 136 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 34e2d39d4ce8..f7220011a00b 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -344,6 +344,7 @@ config HID_LOGITECH
344 344
345config HID_LOGITECH_DJ 345config HID_LOGITECH_DJ
346 tristate "Logitech Unifying receivers full support" 346 tristate "Logitech Unifying receivers full support"
347 depends on HIDRAW
347 depends on HID_LOGITECH 348 depends on HID_LOGITECH
348 ---help--- 349 ---help---
349 Say Y if you want support for Logitech Unifying receivers and devices. 350 Say Y if you want support for Logitech Unifying receivers and devices.
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 253fe23ef7fe..026ab0fc06f7 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1715,6 +1715,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1715 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, 1715 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) },
1716 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) }, 1716 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) },
1717 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) }, 1717 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
1718 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A070) },
1718 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A072) }, 1719 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A072) },
1719 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081) }, 1720 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081) },
1720 { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_580) }, 1721 { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_580) },
@@ -1823,8 +1824,6 @@ static const struct hid_device_id hid_have_special_driver[] = {
1823 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, 1824 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) },
1824 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1825 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1825 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1826 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
1826 { HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS9200_TOUCH) },
1827 { HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS817_TOUCH) },
1828 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1827 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
1829 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) }, 1828 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) },
1830 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) }, 1829 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) },
@@ -1832,6 +1831,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
1832 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1831 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1833 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1832 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
1834 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1833 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1834 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
1835 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
1835 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1836 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1836 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) }, 1837 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
1837 { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) }, 1838 { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 8453214ec376..53b771d5683c 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -768,6 +768,8 @@ static const char *keys[KEY_MAX + 1] = {
768 [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel", 768 [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel",
769 [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp", 769 [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp",
770 [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", 770 [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown",
771 [BTN_DPAD_UP] = "BtnDPadUp", [BTN_DPAD_DOWN] = "BtnDPadDown",
772 [BTN_DPAD_LEFT] = "BtnDPadLeft", [BTN_DPAD_RIGHT] = "BtnDPadRight",
771 [BTN_0] = "Btn0", [BTN_1] = "Btn1", 773 [BTN_0] = "Btn0", [BTN_1] = "Btn1",
772 [BTN_2] = "Btn2", [BTN_3] = "Btn3", 774 [BTN_2] = "Btn2", [BTN_3] = "Btn3",
773 [BTN_4] = "Btn4", [BTN_5] = "Btn5", 775 [BTN_4] = "Btn4", [BTN_5] = "Btn5",
@@ -797,7 +799,8 @@ static const char *keys[KEY_MAX + 1] = {
797 [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", 799 [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens",
798 [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", 800 [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus",
799 [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap", 801 [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap",
800 [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn", 802 [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_TOOL_QUADTAP] = "ToolQuadrupleTap",
803 [BTN_GEAR_DOWN] = "WheelBtn",
801 [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", 804 [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok",
802 [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", 805 [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto",
803 [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", 806 [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2",
diff --git a/drivers/hid/hid-holtek-mouse.c b/drivers/hid/hid-holtek-mouse.c
index 0caa676de622..d60fbd0adc0c 100644
--- a/drivers/hid/hid-holtek-mouse.c
+++ b/drivers/hid/hid-holtek-mouse.c
@@ -49,6 +49,7 @@ static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
49 } 49 }
50 break; 50 break;
51 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A: 51 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A:
52 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A070:
52 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081: 53 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081:
53 if (*rsize >= 113 && rdesc[106] == 0xff && rdesc[107] == 0x7f 54 if (*rsize >= 113 && rdesc[106] == 0xff && rdesc[107] == 0x7f
54 && rdesc[111] == 0xff && rdesc[112] == 0x7f) { 55 && rdesc[111] == 0xff && rdesc[112] == 0x7f) {
@@ -65,6 +66,8 @@ static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
65static const struct hid_device_id holtek_mouse_devices[] = { 66static const struct hid_device_id holtek_mouse_devices[] = {
66 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, 67 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
67 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) }, 68 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
69 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
70 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A070) },
68 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, 71 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
69 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) }, 72 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) },
70 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, 73 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index f9304cb37154..92b40c09d917 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -445,6 +445,10 @@
445#define USB_VENDOR_ID_ILITEK 0x222a 445#define USB_VENDOR_ID_ILITEK 0x222a
446#define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001 446#define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001
447 447
448#define USB_VENDOR_ID_INTEL_0 0x8086
449#define USB_VENDOR_ID_INTEL_1 0x8087
450#define USB_DEVICE_ID_INTEL_HID_SENSOR 0x09fa
451
448#define USB_VENDOR_ID_ION 0x15e4 452#define USB_VENDOR_ID_ION 0x15e4
449#define USB_DEVICE_ID_ICADE 0x0132 453#define USB_DEVICE_ID_ICADE 0x0132
450 454
@@ -455,6 +459,7 @@
455#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055 459#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055
456#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A 0xa04a 460#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A 0xa04a
457#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067 0xa067 461#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067 0xa067
462#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A070 0xa070
458#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A072 0xa072 463#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A072 0xa072
459#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081 0xa081 464#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081 0xa081
460 465
@@ -552,6 +557,7 @@
552#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a 557#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a
553#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211 558#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211
554#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215 559#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215
560#define USB_DEVICE_ID_LOGITECH_DUAL_ACTION 0xc216
555#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218 561#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218
556#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219 562#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219
557#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 563#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
@@ -755,9 +761,11 @@
755#define USB_VENDOR_ID_SIGMATEL 0x066F 761#define USB_VENDOR_ID_SIGMATEL 0x066F
756#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780 762#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
757 763
758#define USB_VENDOR_ID_SIS2_TOUCH 0x0457 764#define USB_VENDOR_ID_SIS_TOUCH 0x0457
759#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200 765#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200
760#define USB_DEVICE_ID_SIS817_TOUCH 0x0817 766#define USB_DEVICE_ID_SIS817_TOUCH 0x0817
767#define USB_DEVICE_ID_SIS_TS 0x1013
768#define USB_DEVICE_ID_SIS1030_TOUCH 0x1030
761 769
762#define USB_VENDOR_ID_SKYCABLE 0x1223 770#define USB_VENDOR_ID_SKYCABLE 0x1223
763#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 771#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07
@@ -767,6 +775,7 @@
767#define USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE 0x0374 775#define USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE 0x0374
768#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 776#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306
769#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 777#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
778#define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4
770#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f 779#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f
771#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002 780#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
772#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 781#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000
@@ -809,6 +818,8 @@
809#define USB_DEVICE_ID_SYNAPTICS_DPAD 0x0013 818#define USB_DEVICE_ID_SYNAPTICS_DPAD 0x0013
810#define USB_DEVICE_ID_SYNAPTICS_LTS1 0x0af8 819#define USB_DEVICE_ID_SYNAPTICS_LTS1 0x0af8
811#define USB_DEVICE_ID_SYNAPTICS_LTS2 0x1d10 820#define USB_DEVICE_ID_SYNAPTICS_LTS2 0x1d10
821#define USB_DEVICE_ID_SYNAPTICS_HD 0x0ac3
822#define USB_DEVICE_ID_SYNAPTICS_QUAD_HD 0x1ac3
812 823
813#define USB_VENDOR_ID_THINGM 0x27b8 824#define USB_VENDOR_ID_THINGM 0x27b8
814#define USB_DEVICE_ID_BLINK1 0x01ed 825#define USB_DEVICE_ID_BLINK1 0x01ed
@@ -939,7 +950,5 @@
939#define USB_VENDOR_ID_PRIMAX 0x0461 950#define USB_VENDOR_ID_PRIMAX 0x0461
940#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05 951#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05
941 952
942#define USB_VENDOR_ID_SIS 0x0457
943#define USB_DEVICE_ID_SIS_TS 0x1013
944 953
945#endif 954#endif
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index d97f2323af57..d50e7313b171 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1279,7 +1279,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid)
1279 input_dev->id.vendor = hid->vendor; 1279 input_dev->id.vendor = hid->vendor;
1280 input_dev->id.product = hid->product; 1280 input_dev->id.product = hid->product;
1281 input_dev->id.version = hid->version; 1281 input_dev->id.version = hid->version;
1282 input_dev->dev.parent = hid->dev.parent; 1282 input_dev->dev.parent = &hid->dev;
1283 hidinput->input = input_dev; 1283 hidinput->input = input_dev;
1284 list_add_tail(&hidinput->list, &hid->inputs); 1284 list_add_tail(&hidinput->list, &hid->inputs);
1285 1285
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 06eb45fa6331..9fe9d4ac3114 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -758,6 +758,8 @@ static const struct hid_device_id lg_devices[] = {
758 758
759 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D), 759 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D),
760 .driver_data = LG_NOGET }, 760 .driver_data = LG_NOGET },
761 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DUAL_ACTION),
762 .driver_data = LG_NOGET },
761 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL), 763 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL),
762 .driver_data = LG_NOGET | LG_FF4 }, 764 .driver_data = LG_NOGET | LG_FF4 },
763 765
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index a7947d8251a8..f45279c3b11a 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -516,6 +516,14 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
516 dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout; 516 dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout;
517 retval = logi_dj_recv_send_report(djrcv_dev, dj_report); 517 retval = logi_dj_recv_send_report(djrcv_dev, dj_report);
518 kfree(dj_report); 518 kfree(dj_report);
519
520 /*
521 * Ugly sleep to work around a USB 3.0 bug when the receiver is still
522 * processing the "switch-to-dj" command while we send an other command.
523 * 50 msec should gives enough time to the receiver to be ready.
524 */
525 msleep(50);
526
519 return retval; 527 return retval;
520} 528}
521 529
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 551795b7da1d..c6ef6eed3091 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -73,6 +73,7 @@ static int ms_ergonomy_kb_quirk(struct hid_input *hi, struct hid_usage *usage,
73 set_bit(KEY_F16, input->keybit); 73 set_bit(KEY_F16, input->keybit);
74 set_bit(KEY_F17, input->keybit); 74 set_bit(KEY_F17, input->keybit);
75 set_bit(KEY_F18, input->keybit); 75 set_bit(KEY_F18, input->keybit);
76 break;
76 default: 77 default:
77 return 0; 78 return 0;
78 } 79 }
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index d83b1e8b505b..f134d73beca1 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1301,11 +1301,14 @@ static const struct hid_device_id mt_devices[] = {
1301 1301
1302 /* SiS panels */ 1302 /* SiS panels */
1303 { .driver_data = MT_CLS_DEFAULT, 1303 { .driver_data = MT_CLS_DEFAULT,
1304 HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, 1304 HID_USB_DEVICE(USB_VENDOR_ID_SIS_TOUCH,
1305 USB_DEVICE_ID_SIS9200_TOUCH) }, 1305 USB_DEVICE_ID_SIS9200_TOUCH) },
1306 { .driver_data = MT_CLS_DEFAULT, 1306 { .driver_data = MT_CLS_DEFAULT,
1307 HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, 1307 HID_USB_DEVICE(USB_VENDOR_ID_SIS_TOUCH,
1308 USB_DEVICE_ID_SIS817_TOUCH) }, 1308 USB_DEVICE_ID_SIS817_TOUCH) },
1309 { .driver_data = MT_CLS_DEFAULT,
1310 HID_USB_DEVICE(USB_VENDOR_ID_SIS_TOUCH,
1311 USB_DEVICE_ID_SIS1030_TOUCH) },
1309 1312
1310 /* Stantum panels */ 1313 /* Stantum panels */
1311 { .driver_data = MT_CLS_CONFIDENCE, 1314 { .driver_data = MT_CLS_CONFIDENCE,
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 8fab82829f8b..46f4480035bc 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -26,6 +26,8 @@
26#include <linux/hid-sensor-hub.h> 26#include <linux/hid-sensor-hub.h>
27#include "hid-ids.h" 27#include "hid-ids.h"
28 28
29#define HID_SENSOR_HUB_ENUM_QUIRK 0x01
30
29/** 31/**
30 * struct sensor_hub_pending - Synchronous read pending information 32 * struct sensor_hub_pending - Synchronous read pending information
31 * @status: Pending status true/false. 33 * @status: Pending status true/false.
@@ -64,6 +66,7 @@ struct sensor_hub_data {
64 spinlock_t dyn_callback_lock; 66 spinlock_t dyn_callback_lock;
65 struct mfd_cell *hid_sensor_hub_client_devs; 67 struct mfd_cell *hid_sensor_hub_client_devs;
66 int hid_sensor_client_cnt; 68 int hid_sensor_client_cnt;
69 unsigned long quirks;
67}; 70};
68 71
69/** 72/**
@@ -497,6 +500,40 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
497} 500}
498EXPORT_SYMBOL_GPL(sensor_hub_device_close); 501EXPORT_SYMBOL_GPL(sensor_hub_device_close);
499 502
503static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
504 unsigned int *rsize)
505{
506 int index;
507 struct sensor_hub_data *sd = hid_get_drvdata(hdev);
508 unsigned char report_block[] = {
509 0x0a, 0x16, 0x03, 0x15, 0x00, 0x25, 0x05};
510 unsigned char power_block[] = {
511 0x0a, 0x19, 0x03, 0x15, 0x00, 0x25, 0x05};
512
513 if (!(sd->quirks & HID_SENSOR_HUB_ENUM_QUIRK)) {
514 hid_dbg(hdev, "No Enum quirks\n");
515 return rdesc;
516 }
517
518 /* Looks for power and report state usage id and force to 1 */
519 for (index = 0; index < *rsize; ++index) {
520 if (((*rsize - index) > sizeof(report_block)) &&
521 !memcmp(&rdesc[index], report_block,
522 sizeof(report_block))) {
523 rdesc[index + 4] = 0x01;
524 index += sizeof(report_block);
525 }
526 if (((*rsize - index) > sizeof(power_block)) &&
527 !memcmp(&rdesc[index], power_block,
528 sizeof(power_block))) {
529 rdesc[index + 4] = 0x01;
530 index += sizeof(power_block);
531 }
532 }
533
534 return rdesc;
535}
536
500static int sensor_hub_probe(struct hid_device *hdev, 537static int sensor_hub_probe(struct hid_device *hdev,
501 const struct hid_device_id *id) 538 const struct hid_device_id *id)
502{ 539{
@@ -520,6 +557,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
520 return -ENOMEM; 557 return -ENOMEM;
521 } 558 }
522 hid_set_drvdata(hdev, sd); 559 hid_set_drvdata(hdev, sd);
560 sd->quirks = id->driver_data;
523 sd->hsdev->hdev = hdev; 561 sd->hsdev->hdev = hdev;
524 sd->hsdev->vendor_id = hdev->vendor; 562 sd->hsdev->vendor_id = hdev->vendor;
525 sd->hsdev->product_id = hdev->product; 563 sd->hsdev->product_id = hdev->product;
@@ -621,6 +659,12 @@ static void sensor_hub_remove(struct hid_device *hdev)
621} 659}
622 660
623static const struct hid_device_id sensor_hub_devices[] = { 661static const struct hid_device_id sensor_hub_devices[] = {
662 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_0,
663 USB_DEVICE_ID_INTEL_HID_SENSOR),
664 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
665 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
666 USB_DEVICE_ID_INTEL_HID_SENSOR),
667 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
624 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID, 668 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
625 HID_ANY_ID) }, 669 HID_ANY_ID) },
626 { } 670 { }
@@ -633,6 +677,7 @@ static struct hid_driver sensor_hub_driver = {
633 .probe = sensor_hub_probe, 677 .probe = sensor_hub_probe,
634 .remove = sensor_hub_remove, 678 .remove = sensor_hub_remove,
635 .raw_event = sensor_hub_raw_event, 679 .raw_event = sensor_hub_raw_event,
680 .report_fixup = sensor_hub_report_fixup,
636#ifdef CONFIG_PM 681#ifdef CONFIG_PM
637 .suspend = sensor_hub_suspend, 682 .suspend = sensor_hub_suspend,
638 .resume = sensor_hub_resume, 683 .resume = sensor_hub_resume,
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 098af2f84b8c..12354055d474 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -33,11 +33,17 @@
33 33
34#include "hid-ids.h" 34#include "hid-ids.h"
35 35
36#define VAIO_RDESC_CONSTANT (1 << 0) 36#define VAIO_RDESC_CONSTANT BIT(0)
37#define SIXAXIS_CONTROLLER_USB (1 << 1) 37#define SIXAXIS_CONTROLLER_USB BIT(1)
38#define SIXAXIS_CONTROLLER_BT (1 << 2) 38#define SIXAXIS_CONTROLLER_BT BIT(2)
39#define BUZZ_CONTROLLER (1 << 3) 39#define BUZZ_CONTROLLER BIT(3)
40#define PS3REMOTE (1 << 4) 40#define PS3REMOTE BIT(4)
41#define DUALSHOCK4_CONTROLLER_USB BIT(5)
42#define DUALSHOCK4_CONTROLLER_BT BIT(6)
43
44#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB)
45
46#define MAX_LEDS 4
41 47
42static const u8 sixaxis_rdesc_fixup[] = { 48static const u8 sixaxis_rdesc_fixup[] = {
43 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C, 49 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C,
@@ -67,6 +73,265 @@ static const u8 sixaxis_rdesc_fixup2[] = {
67 0xb1, 0x02, 0xc0, 0xc0, 73 0xb1, 0x02, 0xc0, 0xc0,
68}; 74};
69 75
76/* The default descriptor doesn't provide mapping for the accelerometers
77 * or orientation sensors. This fixed descriptor maps the accelerometers
78 * to usage values 0x40, 0x41 and 0x42 and maps the orientation sensors
79 * to usage values 0x43, 0x44 and 0x45.
80 */
81static u8 dualshock4_usb_rdesc[] = {
82 0x05, 0x01, /* Usage Page (Desktop), */
83 0x09, 0x05, /* Usage (Gamepad), */
84 0xA1, 0x01, /* Collection (Application), */
85 0x85, 0x01, /* Report ID (1), */
86 0x09, 0x30, /* Usage (X), */
87 0x09, 0x31, /* Usage (Y), */
88 0x09, 0x32, /* Usage (Z), */
89 0x09, 0x35, /* Usage (Rz), */
90 0x15, 0x00, /* Logical Minimum (0), */
91 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
92 0x75, 0x08, /* Report Size (8), */
93 0x95, 0x04, /* Report Count (4), */
94 0x81, 0x02, /* Input (Variable), */
95 0x09, 0x39, /* Usage (Hat Switch), */
96 0x15, 0x00, /* Logical Minimum (0), */
97 0x25, 0x07, /* Logical Maximum (7), */
98 0x35, 0x00, /* Physical Minimum (0), */
99 0x46, 0x3B, 0x01, /* Physical Maximum (315), */
100 0x65, 0x14, /* Unit (Degrees), */
101 0x75, 0x04, /* Report Size (4), */
102 0x95, 0x01, /* Report Count (1), */
103 0x81, 0x42, /* Input (Variable, Null State), */
104 0x65, 0x00, /* Unit, */
105 0x05, 0x09, /* Usage Page (Button), */
106 0x19, 0x01, /* Usage Minimum (01h), */
107 0x29, 0x0E, /* Usage Maximum (0Eh), */
108 0x15, 0x00, /* Logical Minimum (0), */
109 0x25, 0x01, /* Logical Maximum (1), */
110 0x75, 0x01, /* Report Size (1), */
111 0x95, 0x0E, /* Report Count (14), */
112 0x81, 0x02, /* Input (Variable), */
113 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
114 0x09, 0x20, /* Usage (20h), */
115 0x75, 0x06, /* Report Size (6), */
116 0x95, 0x01, /* Report Count (1), */
117 0x15, 0x00, /* Logical Minimum (0), */
118 0x25, 0x7F, /* Logical Maximum (127), */
119 0x81, 0x02, /* Input (Variable), */
120 0x05, 0x01, /* Usage Page (Desktop), */
121 0x09, 0x33, /* Usage (Rx), */
122 0x09, 0x34, /* Usage (Ry), */
123 0x15, 0x00, /* Logical Minimum (0), */
124 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
125 0x75, 0x08, /* Report Size (8), */
126 0x95, 0x02, /* Report Count (2), */
127 0x81, 0x02, /* Input (Variable), */
128 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
129 0x09, 0x21, /* Usage (21h), */
130 0x95, 0x03, /* Report Count (3), */
131 0x81, 0x02, /* Input (Variable), */
132 0x05, 0x01, /* Usage Page (Desktop), */
133 0x19, 0x40, /* Usage Minimum (40h), */
134 0x29, 0x42, /* Usage Maximum (42h), */
135 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
136 0x26, 0x00, 0x7F, /* Logical Maximum (32767), */
137 0x75, 0x10, /* Report Size (16), */
138 0x95, 0x03, /* Report Count (3), */
139 0x81, 0x02, /* Input (Variable), */
140 0x19, 0x43, /* Usage Minimum (43h), */
141 0x29, 0x45, /* Usage Maximum (45h), */
142 0x16, 0xFF, 0xBF, /* Logical Minimum (-16385), */
143 0x26, 0x00, 0x40, /* Logical Maximum (16384), */
144 0x95, 0x03, /* Report Count (3), */
145 0x81, 0x02, /* Input (Variable), */
146 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
147 0x09, 0x21, /* Usage (21h), */
148 0x15, 0x00, /* Logical Minimum (0), */
149 0x25, 0xFF, /* Logical Maximum (255), */
150 0x75, 0x08, /* Report Size (8), */
151 0x95, 0x27, /* Report Count (39), */
152 0x81, 0x02, /* Input (Variable), */
153 0x85, 0x05, /* Report ID (5), */
154 0x09, 0x22, /* Usage (22h), */
155 0x95, 0x1F, /* Report Count (31), */
156 0x91, 0x02, /* Output (Variable), */
157 0x85, 0x04, /* Report ID (4), */
158 0x09, 0x23, /* Usage (23h), */
159 0x95, 0x24, /* Report Count (36), */
160 0xB1, 0x02, /* Feature (Variable), */
161 0x85, 0x02, /* Report ID (2), */
162 0x09, 0x24, /* Usage (24h), */
163 0x95, 0x24, /* Report Count (36), */
164 0xB1, 0x02, /* Feature (Variable), */
165 0x85, 0x08, /* Report ID (8), */
166 0x09, 0x25, /* Usage (25h), */
167 0x95, 0x03, /* Report Count (3), */
168 0xB1, 0x02, /* Feature (Variable), */
169 0x85, 0x10, /* Report ID (16), */
170 0x09, 0x26, /* Usage (26h), */
171 0x95, 0x04, /* Report Count (4), */
172 0xB1, 0x02, /* Feature (Variable), */
173 0x85, 0x11, /* Report ID (17), */
174 0x09, 0x27, /* Usage (27h), */
175 0x95, 0x02, /* Report Count (2), */
176 0xB1, 0x02, /* Feature (Variable), */
177 0x85, 0x12, /* Report ID (18), */
178 0x06, 0x02, 0xFF, /* Usage Page (FF02h), */
179 0x09, 0x21, /* Usage (21h), */
180 0x95, 0x0F, /* Report Count (15), */
181 0xB1, 0x02, /* Feature (Variable), */
182 0x85, 0x13, /* Report ID (19), */
183 0x09, 0x22, /* Usage (22h), */
184 0x95, 0x16, /* Report Count (22), */
185 0xB1, 0x02, /* Feature (Variable), */
186 0x85, 0x14, /* Report ID (20), */
187 0x06, 0x05, 0xFF, /* Usage Page (FF05h), */
188 0x09, 0x20, /* Usage (20h), */
189 0x95, 0x10, /* Report Count (16), */
190 0xB1, 0x02, /* Feature (Variable), */
191 0x85, 0x15, /* Report ID (21), */
192 0x09, 0x21, /* Usage (21h), */
193 0x95, 0x2C, /* Report Count (44), */
194 0xB1, 0x02, /* Feature (Variable), */
195 0x06, 0x80, 0xFF, /* Usage Page (FF80h), */
196 0x85, 0x80, /* Report ID (128), */
197 0x09, 0x20, /* Usage (20h), */
198 0x95, 0x06, /* Report Count (6), */
199 0xB1, 0x02, /* Feature (Variable), */
200 0x85, 0x81, /* Report ID (129), */
201 0x09, 0x21, /* Usage (21h), */
202 0x95, 0x06, /* Report Count (6), */
203 0xB1, 0x02, /* Feature (Variable), */
204 0x85, 0x82, /* Report ID (130), */
205 0x09, 0x22, /* Usage (22h), */
206 0x95, 0x05, /* Report Count (5), */
207 0xB1, 0x02, /* Feature (Variable), */
208 0x85, 0x83, /* Report ID (131), */
209 0x09, 0x23, /* Usage (23h), */
210 0x95, 0x01, /* Report Count (1), */
211 0xB1, 0x02, /* Feature (Variable), */
212 0x85, 0x84, /* Report ID (132), */
213 0x09, 0x24, /* Usage (24h), */
214 0x95, 0x04, /* Report Count (4), */
215 0xB1, 0x02, /* Feature (Variable), */
216 0x85, 0x85, /* Report ID (133), */
217 0x09, 0x25, /* Usage (25h), */
218 0x95, 0x06, /* Report Count (6), */
219 0xB1, 0x02, /* Feature (Variable), */
220 0x85, 0x86, /* Report ID (134), */
221 0x09, 0x26, /* Usage (26h), */
222 0x95, 0x06, /* Report Count (6), */
223 0xB1, 0x02, /* Feature (Variable), */
224 0x85, 0x87, /* Report ID (135), */
225 0x09, 0x27, /* Usage (27h), */
226 0x95, 0x23, /* Report Count (35), */
227 0xB1, 0x02, /* Feature (Variable), */
228 0x85, 0x88, /* Report ID (136), */
229 0x09, 0x28, /* Usage (28h), */
230 0x95, 0x22, /* Report Count (34), */
231 0xB1, 0x02, /* Feature (Variable), */
232 0x85, 0x89, /* Report ID (137), */
233 0x09, 0x29, /* Usage (29h), */
234 0x95, 0x02, /* Report Count (2), */
235 0xB1, 0x02, /* Feature (Variable), */
236 0x85, 0x90, /* Report ID (144), */
237 0x09, 0x30, /* Usage (30h), */
238 0x95, 0x05, /* Report Count (5), */
239 0xB1, 0x02, /* Feature (Variable), */
240 0x85, 0x91, /* Report ID (145), */
241 0x09, 0x31, /* Usage (31h), */
242 0x95, 0x03, /* Report Count (3), */
243 0xB1, 0x02, /* Feature (Variable), */
244 0x85, 0x92, /* Report ID (146), */
245 0x09, 0x32, /* Usage (32h), */
246 0x95, 0x03, /* Report Count (3), */
247 0xB1, 0x02, /* Feature (Variable), */
248 0x85, 0x93, /* Report ID (147), */
249 0x09, 0x33, /* Usage (33h), */
250 0x95, 0x0C, /* Report Count (12), */
251 0xB1, 0x02, /* Feature (Variable), */
252 0x85, 0xA0, /* Report ID (160), */
253 0x09, 0x40, /* Usage (40h), */
254 0x95, 0x06, /* Report Count (6), */
255 0xB1, 0x02, /* Feature (Variable), */
256 0x85, 0xA1, /* Report ID (161), */
257 0x09, 0x41, /* Usage (41h), */
258 0x95, 0x01, /* Report Count (1), */
259 0xB1, 0x02, /* Feature (Variable), */
260 0x85, 0xA2, /* Report ID (162), */
261 0x09, 0x42, /* Usage (42h), */
262 0x95, 0x01, /* Report Count (1), */
263 0xB1, 0x02, /* Feature (Variable), */
264 0x85, 0xA3, /* Report ID (163), */
265 0x09, 0x43, /* Usage (43h), */
266 0x95, 0x30, /* Report Count (48), */
267 0xB1, 0x02, /* Feature (Variable), */
268 0x85, 0xA4, /* Report ID (164), */
269 0x09, 0x44, /* Usage (44h), */
270 0x95, 0x0D, /* Report Count (13), */
271 0xB1, 0x02, /* Feature (Variable), */
272 0x85, 0xA5, /* Report ID (165), */
273 0x09, 0x45, /* Usage (45h), */
274 0x95, 0x15, /* Report Count (21), */
275 0xB1, 0x02, /* Feature (Variable), */
276 0x85, 0xA6, /* Report ID (166), */
277 0x09, 0x46, /* Usage (46h), */
278 0x95, 0x15, /* Report Count (21), */
279 0xB1, 0x02, /* Feature (Variable), */
280 0x85, 0xF0, /* Report ID (240), */
281 0x09, 0x47, /* Usage (47h), */
282 0x95, 0x3F, /* Report Count (63), */
283 0xB1, 0x02, /* Feature (Variable), */
284 0x85, 0xF1, /* Report ID (241), */
285 0x09, 0x48, /* Usage (48h), */
286 0x95, 0x3F, /* Report Count (63), */
287 0xB1, 0x02, /* Feature (Variable), */
288 0x85, 0xF2, /* Report ID (242), */
289 0x09, 0x49, /* Usage (49h), */
290 0x95, 0x0F, /* Report Count (15), */
291 0xB1, 0x02, /* Feature (Variable), */
292 0x85, 0xA7, /* Report ID (167), */
293 0x09, 0x4A, /* Usage (4Ah), */
294 0x95, 0x01, /* Report Count (1), */
295 0xB1, 0x02, /* Feature (Variable), */
296 0x85, 0xA8, /* Report ID (168), */
297 0x09, 0x4B, /* Usage (4Bh), */
298 0x95, 0x01, /* Report Count (1), */
299 0xB1, 0x02, /* Feature (Variable), */
300 0x85, 0xA9, /* Report ID (169), */
301 0x09, 0x4C, /* Usage (4Ch), */
302 0x95, 0x08, /* Report Count (8), */
303 0xB1, 0x02, /* Feature (Variable), */
304 0x85, 0xAA, /* Report ID (170), */
305 0x09, 0x4E, /* Usage (4Eh), */
306 0x95, 0x01, /* Report Count (1), */
307 0xB1, 0x02, /* Feature (Variable), */
308 0x85, 0xAB, /* Report ID (171), */
309 0x09, 0x4F, /* Usage (4Fh), */
310 0x95, 0x39, /* Report Count (57), */
311 0xB1, 0x02, /* Feature (Variable), */
312 0x85, 0xAC, /* Report ID (172), */
313 0x09, 0x50, /* Usage (50h), */
314 0x95, 0x39, /* Report Count (57), */
315 0xB1, 0x02, /* Feature (Variable), */
316 0x85, 0xAD, /* Report ID (173), */
317 0x09, 0x51, /* Usage (51h), */
318 0x95, 0x0B, /* Report Count (11), */
319 0xB1, 0x02, /* Feature (Variable), */
320 0x85, 0xAE, /* Report ID (174), */
321 0x09, 0x52, /* Usage (52h), */
322 0x95, 0x01, /* Report Count (1), */
323 0xB1, 0x02, /* Feature (Variable), */
324 0x85, 0xAF, /* Report ID (175), */
325 0x09, 0x53, /* Usage (53h), */
326 0x95, 0x02, /* Report Count (2), */
327 0xB1, 0x02, /* Feature (Variable), */
328 0x85, 0xB0, /* Report ID (176), */
329 0x09, 0x54, /* Usage (54h), */
330 0x95, 0x3F, /* Report Count (63), */
331 0xB1, 0x02, /* Feature (Variable), */
332 0xC0 /* End Collection */
333};
334
70static __u8 ps3remote_rdesc[] = { 335static __u8 ps3remote_rdesc[] = {
71 0x05, 0x01, /* GUsagePage Generic Desktop */ 336 0x05, 0x01, /* GUsagePage Generic Desktop */
72 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ 337 0x09, 0x05, /* LUsage 0x05 [Game Pad] */
@@ -223,21 +488,19 @@ static const unsigned int buzz_keymap[] = {
223}; 488};
224 489
225struct sony_sc { 490struct sony_sc {
491 struct hid_device *hdev;
492 struct led_classdev *leds[MAX_LEDS];
493 struct hid_report *output_report;
226 unsigned long quirks; 494 unsigned long quirks;
495 struct work_struct state_worker;
227 496
228#ifdef CONFIG_SONY_FF 497#ifdef CONFIG_SONY_FF
229 struct work_struct rumble_worker;
230 struct hid_device *hdev;
231 __u8 left; 498 __u8 left;
232 __u8 right; 499 __u8 right;
233#endif 500#endif
234 501
235 void *extra; 502 __u8 led_state[MAX_LEDS];
236}; 503 __u8 led_count;
237
238struct buzz_extra {
239 int led_state;
240 struct led_classdev *leds[4];
241}; 504};
242 505
243static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc, 506static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -304,6 +567,17 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
304 rdesc[55] = 0x06; 567 rdesc[55] = 0x06;
305 } 568 }
306 569
570 /*
571 * The default Dualshock 4 USB descriptor doesn't assign
572 * the gyroscope values to corresponding axes so we need a
573 * modified one.
574 */
575 if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && *rsize == 467) {
576 hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n");
577 rdesc = dualshock4_usb_rdesc;
578 *rsize = sizeof(dualshock4_usb_rdesc);
579 }
580
307 /* The HID descriptor exposed over BT has a trailing zero byte */ 581 /* The HID descriptor exposed over BT has a trailing zero byte */
308 if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) || 582 if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) ||
309 ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) && 583 ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) &&
@@ -448,7 +722,7 @@ static int sixaxis_set_operational_bt(struct hid_device *hdev)
448 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT); 722 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
449} 723}
450 724
451static void buzz_set_leds(struct hid_device *hdev, int leds) 725static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
452{ 726{
453 struct list_head *report_list = 727 struct list_head *report_list =
454 &hdev->report_enum[HID_OUTPUT_REPORT].report_list; 728 &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
@@ -457,67 +731,76 @@ static void buzz_set_leds(struct hid_device *hdev, int leds)
457 __s32 *value = report->field[0]->value; 731 __s32 *value = report->field[0]->value;
458 732
459 value[0] = 0x00; 733 value[0] = 0x00;
460 value[1] = (leds & 1) ? 0xff : 0x00; 734 value[1] = leds[0] ? 0xff : 0x00;
461 value[2] = (leds & 2) ? 0xff : 0x00; 735 value[2] = leds[1] ? 0xff : 0x00;
462 value[3] = (leds & 4) ? 0xff : 0x00; 736 value[3] = leds[2] ? 0xff : 0x00;
463 value[4] = (leds & 8) ? 0xff : 0x00; 737 value[4] = leds[3] ? 0xff : 0x00;
464 value[5] = 0x00; 738 value[5] = 0x00;
465 value[6] = 0x00; 739 value[6] = 0x00;
466 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); 740 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
467} 741}
468 742
469static void buzz_led_set_brightness(struct led_classdev *led, 743static void sony_set_leds(struct hid_device *hdev, const __u8 *leds, int count)
744{
745 struct sony_sc *drv_data = hid_get_drvdata(hdev);
746 int n;
747
748 BUG_ON(count > MAX_LEDS);
749
750 if (drv_data->quirks & BUZZ_CONTROLLER && count == 4) {
751 buzz_set_leds(hdev, leds);
752 } else if ((drv_data->quirks & SIXAXIS_CONTROLLER_USB) ||
753 (drv_data->quirks & DUALSHOCK4_CONTROLLER_USB)) {
754 for (n = 0; n < count; n++)
755 drv_data->led_state[n] = leds[n];
756 schedule_work(&drv_data->state_worker);
757 }
758}
759
760static void sony_led_set_brightness(struct led_classdev *led,
470 enum led_brightness value) 761 enum led_brightness value)
471{ 762{
472 struct device *dev = led->dev->parent; 763 struct device *dev = led->dev->parent;
473 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 764 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
474 struct sony_sc *drv_data; 765 struct sony_sc *drv_data;
475 struct buzz_extra *buzz;
476 766
477 int n; 767 int n;
478 768
479 drv_data = hid_get_drvdata(hdev); 769 drv_data = hid_get_drvdata(hdev);
480 if (!drv_data || !drv_data->extra) { 770 if (!drv_data) {
481 hid_err(hdev, "No device data\n"); 771 hid_err(hdev, "No device data\n");
482 return; 772 return;
483 } 773 }
484 buzz = drv_data->extra; 774
485 775 for (n = 0; n < drv_data->led_count; n++) {
486 for (n = 0; n < 4; n++) { 776 if (led == drv_data->leds[n]) {
487 if (led == buzz->leds[n]) { 777 if (value != drv_data->led_state[n]) {
488 int on = !! (buzz->led_state & (1 << n)); 778 drv_data->led_state[n] = value;
489 if (value == LED_OFF && on) { 779 sony_set_leds(hdev, drv_data->led_state, drv_data->led_count);
490 buzz->led_state &= ~(1 << n);
491 buzz_set_leds(hdev, buzz->led_state);
492 } else if (value != LED_OFF && !on) {
493 buzz->led_state |= (1 << n);
494 buzz_set_leds(hdev, buzz->led_state);
495 } 780 }
496 break; 781 break;
497 } 782 }
498 } 783 }
499} 784}
500 785
501static enum led_brightness buzz_led_get_brightness(struct led_classdev *led) 786static enum led_brightness sony_led_get_brightness(struct led_classdev *led)
502{ 787{
503 struct device *dev = led->dev->parent; 788 struct device *dev = led->dev->parent;
504 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 789 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
505 struct sony_sc *drv_data; 790 struct sony_sc *drv_data;
506 struct buzz_extra *buzz;
507 791
508 int n; 792 int n;
509 int on = 0; 793 int on = 0;
510 794
511 drv_data = hid_get_drvdata(hdev); 795 drv_data = hid_get_drvdata(hdev);
512 if (!drv_data || !drv_data->extra) { 796 if (!drv_data) {
513 hid_err(hdev, "No device data\n"); 797 hid_err(hdev, "No device data\n");
514 return LED_OFF; 798 return LED_OFF;
515 } 799 }
516 buzz = drv_data->extra;
517 800
518 for (n = 0; n < 4; n++) { 801 for (n = 0; n < drv_data->led_count; n++) {
519 if (led == buzz->leds[n]) { 802 if (led == drv_data->leds[n]) {
520 on = !! (buzz->led_state & (1 << n)); 803 on = !!(drv_data->led_state[n]);
521 break; 804 break;
522 } 805 }
523 } 806 }
@@ -525,110 +808,122 @@ static enum led_brightness buzz_led_get_brightness(struct led_classdev *led)
525 return on ? LED_FULL : LED_OFF; 808 return on ? LED_FULL : LED_OFF;
526} 809}
527 810
528static int buzz_init(struct hid_device *hdev) 811static void sony_leds_remove(struct hid_device *hdev)
812{
813 struct sony_sc *drv_data;
814 struct led_classdev *led;
815 int n;
816
817 drv_data = hid_get_drvdata(hdev);
818 BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT));
819
820 for (n = 0; n < drv_data->led_count; n++) {
821 led = drv_data->leds[n];
822 drv_data->leds[n] = NULL;
823 if (!led)
824 continue;
825 led_classdev_unregister(led);
826 kfree(led);
827 }
828
829 drv_data->led_count = 0;
830}
831
832static int sony_leds_init(struct hid_device *hdev)
529{ 833{
530 struct sony_sc *drv_data; 834 struct sony_sc *drv_data;
531 struct buzz_extra *buzz;
532 int n, ret = 0; 835 int n, ret = 0;
836 int max_brightness;
837 int use_colors;
533 struct led_classdev *led; 838 struct led_classdev *led;
534 size_t name_sz; 839 size_t name_sz;
535 char *name; 840 char *name;
841 size_t name_len;
842 const char *name_fmt;
843 static const char * const color_str[] = { "red", "green", "blue" };
844 static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 };
536 845
537 drv_data = hid_get_drvdata(hdev); 846 drv_data = hid_get_drvdata(hdev);
538 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER)); 847 BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT));
539 848
540 /* Validate expected report characteristics. */ 849 if (drv_data->quirks & BUZZ_CONTROLLER) {
541 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) 850 drv_data->led_count = 4;
542 return -ENODEV; 851 max_brightness = 1;
543 852 use_colors = 0;
544 buzz = kzalloc(sizeof(*buzz), GFP_KERNEL); 853 name_len = strlen("::buzz#");
545 if (!buzz) { 854 name_fmt = "%s::buzz%d";
546 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n"); 855 /* Validate expected report characteristics. */
547 return -ENOMEM; 856 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
857 return -ENODEV;
858 } else if (drv_data->quirks & DUALSHOCK4_CONTROLLER_USB) {
859 drv_data->led_count = 3;
860 max_brightness = 255;
861 use_colors = 1;
862 name_len = 0;
863 name_fmt = "%s:%s";
864 } else {
865 drv_data->led_count = 4;
866 max_brightness = 1;
867 use_colors = 0;
868 name_len = strlen("::sony#");
869 name_fmt = "%s::sony%d";
548 } 870 }
549 drv_data->extra = buzz;
550 871
551 /* Clear LEDs as we have no way of reading their initial state. This is 872 /* Clear LEDs as we have no way of reading their initial state. This is
552 * only relevant if the driver is loaded after somebody actively set the 873 * only relevant if the driver is loaded after somebody actively set the
553 * LEDs to on */ 874 * LEDs to on */
554 buzz_set_leds(hdev, 0x00); 875 sony_set_leds(hdev, initial_values, drv_data->led_count);
555 876
556 name_sz = strlen(dev_name(&hdev->dev)) + strlen("::buzz#") + 1; 877 name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1;
878
879 for (n = 0; n < drv_data->led_count; n++) {
880
881 if (use_colors)
882 name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2;
557 883
558 for (n = 0; n < 4; n++) {
559 led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL); 884 led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
560 if (!led) { 885 if (!led) {
561 hid_err(hdev, "Couldn't allocate memory for LED %d\n", n); 886 hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
887 ret = -ENOMEM;
562 goto error_leds; 888 goto error_leds;
563 } 889 }
564 890
565 name = (void *)(&led[1]); 891 name = (void *)(&led[1]);
566 snprintf(name, name_sz, "%s::buzz%d", dev_name(&hdev->dev), n + 1); 892 if (use_colors)
893 snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), color_str[n]);
894 else
895 snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1);
567 led->name = name; 896 led->name = name;
568 led->brightness = 0; 897 led->brightness = 0;
569 led->max_brightness = 1; 898 led->max_brightness = max_brightness;
570 led->brightness_get = buzz_led_get_brightness; 899 led->brightness_get = sony_led_get_brightness;
571 led->brightness_set = buzz_led_set_brightness; 900 led->brightness_set = sony_led_set_brightness;
572 901
573 if (led_classdev_register(&hdev->dev, led)) { 902 ret = led_classdev_register(&hdev->dev, led);
903 if (ret) {
574 hid_err(hdev, "Failed to register LED %d\n", n); 904 hid_err(hdev, "Failed to register LED %d\n", n);
575 kfree(led); 905 kfree(led);
576 goto error_leds; 906 goto error_leds;
577 } 907 }
578 908
579 buzz->leds[n] = led; 909 drv_data->leds[n] = led;
580 } 910 }
581 911
582 return ret; 912 return ret;
583 913
584error_leds: 914error_leds:
585 for (n = 0; n < 4; n++) { 915 sony_leds_remove(hdev);
586 led = buzz->leds[n];
587 buzz->leds[n] = NULL;
588 if (!led)
589 continue;
590 led_classdev_unregister(led);
591 kfree(led);
592 }
593 916
594 kfree(drv_data->extra);
595 drv_data->extra = NULL;
596 return ret; 917 return ret;
597} 918}
598 919
599static void buzz_remove(struct hid_device *hdev) 920static void sixaxis_state_worker(struct work_struct *work)
600{
601 struct sony_sc *drv_data;
602 struct buzz_extra *buzz;
603 struct led_classdev *led;
604 int n;
605
606 drv_data = hid_get_drvdata(hdev);
607 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
608
609 buzz = drv_data->extra;
610
611 for (n = 0; n < 4; n++) {
612 led = buzz->leds[n];
613 buzz->leds[n] = NULL;
614 if (!led)
615 continue;
616 led_classdev_unregister(led);
617 kfree(led);
618 }
619
620 kfree(drv_data->extra);
621 drv_data->extra = NULL;
622}
623
624#ifdef CONFIG_SONY_FF
625static void sony_rumble_worker(struct work_struct *work)
626{ 921{
627 struct sony_sc *sc = container_of(work, struct sony_sc, rumble_worker); 922 struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
628 unsigned char buf[] = { 923 unsigned char buf[] = {
629 0x01, 924 0x01,
630 0x00, 0xff, 0x00, 0xff, 0x00, 925 0x00, 0xff, 0x00, 0xff, 0x00,
631 0x00, 0x00, 0x00, 0x00, 0x03, 926 0x00, 0x00, 0x00, 0x00, 0x00,
632 0xff, 0x27, 0x10, 0x00, 0x32, 927 0xff, 0x27, 0x10, 0x00, 0x32,
633 0xff, 0x27, 0x10, 0x00, 0x32, 928 0xff, 0x27, 0x10, 0x00, 0x32,
634 0xff, 0x27, 0x10, 0x00, 0x32, 929 0xff, 0x27, 0x10, 0x00, 0x32,
@@ -636,13 +931,42 @@ static void sony_rumble_worker(struct work_struct *work)
636 0x00, 0x00, 0x00, 0x00, 0x00 931 0x00, 0x00, 0x00, 0x00, 0x00
637 }; 932 };
638 933
639 buf[3] = sc->right; 934#ifdef CONFIG_SONY_FF
935 buf[3] = sc->right ? 1 : 0;
640 buf[5] = sc->left; 936 buf[5] = sc->left;
937#endif
938
939 buf[10] |= sc->led_state[0] << 1;
940 buf[10] |= sc->led_state[1] << 2;
941 buf[10] |= sc->led_state[2] << 3;
942 buf[10] |= sc->led_state[3] << 4;
641 943
642 sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf), 944 sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf),
643 HID_OUTPUT_REPORT); 945 HID_OUTPUT_REPORT);
644} 946}
645 947
948static void dualshock4_state_worker(struct work_struct *work)
949{
950 struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
951 struct hid_device *hdev = sc->hdev;
952 struct hid_report *report = sc->output_report;
953 __s32 *value = report->field[0]->value;
954
955 value[0] = 0x03;
956
957#ifdef CONFIG_SONY_FF
958 value[3] = sc->right;
959 value[4] = sc->left;
960#endif
961
962 value[5] = sc->led_state[0];
963 value[6] = sc->led_state[1];
964 value[7] = sc->led_state[2];
965
966 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
967}
968
969#ifdef CONFIG_SONY_FF
646static int sony_play_effect(struct input_dev *dev, void *data, 970static int sony_play_effect(struct input_dev *dev, void *data,
647 struct ff_effect *effect) 971 struct ff_effect *effect)
648{ 972{
@@ -653,9 +977,9 @@ static int sony_play_effect(struct input_dev *dev, void *data,
653 return 0; 977 return 0;
654 978
655 sc->left = effect->u.rumble.strong_magnitude / 256; 979 sc->left = effect->u.rumble.strong_magnitude / 256;
656 sc->right = effect->u.rumble.weak_magnitude ? 1 : 0; 980 sc->right = effect->u.rumble.weak_magnitude / 256;
657 981
658 schedule_work(&sc->rumble_worker); 982 schedule_work(&sc->state_worker);
659 return 0; 983 return 0;
660} 984}
661 985
@@ -664,10 +988,6 @@ static int sony_init_ff(struct hid_device *hdev)
664 struct hid_input *hidinput = list_entry(hdev->inputs.next, 988 struct hid_input *hidinput = list_entry(hdev->inputs.next,
665 struct hid_input, list); 989 struct hid_input, list);
666 struct input_dev *input_dev = hidinput->input; 990 struct input_dev *input_dev = hidinput->input;
667 struct sony_sc *sc = hid_get_drvdata(hdev);
668
669 sc->hdev = hdev;
670 INIT_WORK(&sc->rumble_worker, sony_rumble_worker);
671 991
672 input_set_capability(input_dev, EV_FF, FF_RUMBLE); 992 input_set_capability(input_dev, EV_FF, FF_RUMBLE);
673 return input_ff_create_memless(input_dev, NULL, sony_play_effect); 993 return input_ff_create_memless(input_dev, NULL, sony_play_effect);
@@ -677,7 +997,7 @@ static void sony_destroy_ff(struct hid_device *hdev)
677{ 997{
678 struct sony_sc *sc = hid_get_drvdata(hdev); 998 struct sony_sc *sc = hid_get_drvdata(hdev);
679 999
680 cancel_work_sync(&sc->rumble_worker); 1000 cancel_work_sync(&sc->state_worker);
681} 1001}
682 1002
683#else 1003#else
@@ -691,6 +1011,33 @@ static void sony_destroy_ff(struct hid_device *hdev)
691} 1011}
692#endif 1012#endif
693 1013
1014static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size)
1015{
1016 struct list_head *head, *list;
1017 struct hid_report *report;
1018 struct hid_device *hdev = sc->hdev;
1019
1020 list = &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
1021
1022 list_for_each(head, list) {
1023 report = list_entry(head, struct hid_report, list);
1024
1025 if (report->id == req_id) {
1026 if (report->size < req_size) {
1027 hid_err(hdev, "Output report 0x%02x (%i bits) is smaller than requested size (%i bits)\n",
1028 req_id, report->size, req_size);
1029 return -EINVAL;
1030 }
1031 sc->output_report = report;
1032 return 0;
1033 }
1034 }
1035
1036 hid_err(hdev, "Unable to locate output report 0x%02x\n", req_id);
1037
1038 return -EINVAL;
1039}
1040
694static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) 1041static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
695{ 1042{
696 int ret; 1043 int ret;
@@ -706,6 +1053,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
706 1053
707 sc->quirks = quirks; 1054 sc->quirks = quirks;
708 hid_set_drvdata(hdev, sc); 1055 hid_set_drvdata(hdev, sc);
1056 sc->hdev = hdev;
709 1057
710 ret = hid_parse(hdev); 1058 ret = hid_parse(hdev);
711 if (ret) { 1059 if (ret) {
@@ -729,23 +1077,38 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
729 if (sc->quirks & SIXAXIS_CONTROLLER_USB) { 1077 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
730 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report; 1078 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
731 ret = sixaxis_set_operational_usb(hdev); 1079 ret = sixaxis_set_operational_usb(hdev);
1080 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
732 } 1081 }
733 else if (sc->quirks & SIXAXIS_CONTROLLER_BT) 1082 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
734 ret = sixaxis_set_operational_bt(hdev); 1083 ret = sixaxis_set_operational_bt(hdev);
735 else if (sc->quirks & BUZZ_CONTROLLER) 1084 else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
736 ret = buzz_init(hdev); 1085 /* Report 5 (31 bytes) is used to send data to the controller via USB */
737 else 1086 ret = sony_set_output_report(sc, 0x05, 248);
1087 if (ret < 0)
1088 goto err_stop;
1089
1090 INIT_WORK(&sc->state_worker, dualshock4_state_worker);
1091 } else {
738 ret = 0; 1092 ret = 0;
1093 }
739 1094
740 if (ret < 0) 1095 if (ret < 0)
741 goto err_stop; 1096 goto err_stop;
742 1097
1098 if (sc->quirks & SONY_LED_SUPPORT) {
1099 ret = sony_leds_init(hdev);
1100 if (ret < 0)
1101 goto err_stop;
1102 }
1103
743 ret = sony_init_ff(hdev); 1104 ret = sony_init_ff(hdev);
744 if (ret < 0) 1105 if (ret < 0)
745 goto err_stop; 1106 goto err_stop;
746 1107
747 return 0; 1108 return 0;
748err_stop: 1109err_stop:
1110 if (sc->quirks & SONY_LED_SUPPORT)
1111 sony_leds_remove(hdev);
749 hid_hw_stop(hdev); 1112 hid_hw_stop(hdev);
750 return ret; 1113 return ret;
751} 1114}
@@ -754,8 +1117,8 @@ static void sony_remove(struct hid_device *hdev)
754{ 1117{
755 struct sony_sc *sc = hid_get_drvdata(hdev); 1118 struct sony_sc *sc = hid_get_drvdata(hdev);
756 1119
757 if (sc->quirks & BUZZ_CONTROLLER) 1120 if (sc->quirks & SONY_LED_SUPPORT)
758 buzz_remove(hdev); 1121 sony_leds_remove(hdev);
759 1122
760 sony_destroy_ff(hdev); 1123 sony_destroy_ff(hdev);
761 1124
@@ -785,6 +1148,11 @@ static const struct hid_device_id sony_devices[] = {
785 /* Logitech Harmony Adapter for PS3 */ 1148 /* Logitech Harmony Adapter for PS3 */
786 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3), 1149 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3),
787 .driver_data = PS3REMOTE }, 1150 .driver_data = PS3REMOTE },
1151 /* Sony Dualshock 4 controllers for PS4 */
1152 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
1153 .driver_data = DUALSHOCK4_CONTROLLER_USB },
1154 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
1155 .driver_data = DUALSHOCK4_CONTROLLER_BT },
788 { } 1156 { }
789}; 1157};
790MODULE_DEVICE_TABLE(hid, sony_devices); 1158MODULE_DEVICE_TABLE(hid, sony_devices);
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 6a6dd5cd7833..cb0137b3718d 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -6,7 +6,7 @@
6 * to work on raw hid events as they want to, and avoids a need to 6 * to work on raw hid events as they want to, and avoids a need to
7 * use a transport-specific userspace libhid/libusb libraries. 7 * use a transport-specific userspace libhid/libusb libraries.
8 * 8 *
9 * Copyright (c) 2007 Jiri Kosina 9 * Copyright (c) 2007-2014 Jiri Kosina
10 */ 10 */
11 11
12/* 12/*
@@ -104,8 +104,11 @@ out:
104 return ret; 104 return ret;
105} 105}
106 106
107/* The first byte is expected to be a report number. 107/*
108 * This function is to be called with the minors_lock mutex held */ 108 * The first byte of the report buffer is expected to be a report number.
109 *
110 * This function is to be called with the minors_lock mutex held.
111 */
109static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, size_t count, unsigned char report_type) 112static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, size_t count, unsigned char report_type)
110{ 113{
111 unsigned int minor = iminor(file_inode(file)); 114 unsigned int minor = iminor(file_inode(file));
@@ -157,7 +160,6 @@ out:
157 return ret; 160 return ret;
158} 161}
159 162
160/* the first byte is expected to be a report number */
161static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 163static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
162{ 164{
163 ssize_t ret; 165 ssize_t ret;
@@ -168,12 +170,15 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
168} 170}
169 171
170 172
171/* This function performs a Get_Report transfer over the control endpoint 173/*
174 * This function performs a Get_Report transfer over the control endpoint
172 * per section 7.2.1 of the HID specification, version 1.1. The first byte 175 * per section 7.2.1 of the HID specification, version 1.1. The first byte
173 * of buffer is the report number to request, or 0x0 if the defice does not 176 * of buffer is the report number to request, or 0x0 if the defice does not
174 * use numbered reports. The report_type parameter can be HID_FEATURE_REPORT 177 * use numbered reports. The report_type parameter can be HID_FEATURE_REPORT
175 * or HID_INPUT_REPORT. This function is to be called with the minors_lock 178 * or HID_INPUT_REPORT.
176 * mutex held. */ 179 *
180 * This function is to be called with the minors_lock mutex held.
181 */
177static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t count, unsigned char report_type) 182static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t count, unsigned char report_type)
178{ 183{
179 unsigned int minor = iminor(file_inode(file)); 184 unsigned int minor = iminor(file_inode(file));
@@ -209,8 +214,10 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
209 goto out; 214 goto out;
210 } 215 }
211 216
212 /* Read the first byte from the user. This is the report number, 217 /*
213 * which is passed to dev->hid_get_raw_report(). */ 218 * Read the first byte from the user. This is the report number,
219 * which is passed to dev->hid_get_raw_report().
220 */
214 if (copy_from_user(&report_number, buffer, 1)) { 221 if (copy_from_user(&report_number, buffer, 1)) {
215 ret = -EFAULT; 222 ret = -EFAULT;
216 goto out_free; 223 goto out_free;
@@ -498,7 +505,7 @@ int hidraw_connect(struct hid_device *hid)
498 int minor, result; 505 int minor, result;
499 struct hidraw *dev; 506 struct hidraw *dev;
500 507
501 /* we accept any HID device, no matter the applications */ 508 /* we accept any HID device, all applications */
502 509
503 dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL); 510 dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL);
504 if (!dev) 511 if (!dev)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 5f7e55f4b7f0..e914f2755491 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -1061,6 +1061,7 @@ static int i2c_hid_suspend(struct device *dev)
1061{ 1061{
1062 struct i2c_client *client = to_i2c_client(dev); 1062 struct i2c_client *client = to_i2c_client(dev);
1063 1063
1064 disable_irq(client->irq);
1064 if (device_may_wakeup(&client->dev)) 1065 if (device_may_wakeup(&client->dev))
1065 enable_irq_wake(client->irq); 1066 enable_irq_wake(client->irq);
1066 1067
@@ -1075,6 +1076,7 @@ static int i2c_hid_resume(struct device *dev)
1075 int ret; 1076 int ret;
1076 struct i2c_client *client = to_i2c_client(dev); 1077 struct i2c_client *client = to_i2c_client(dev);
1077 1078
1079 enable_irq(client->irq);
1078 ret = i2c_hid_hwreset(client); 1080 ret = i2c_hid_hwreset(client);
1079 if (ret) 1081 if (ret)
1080 return ret; 1082 return ret;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 0db9a67278ba..175ec0afb70c 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -84,8 +84,10 @@ static const struct hid_blacklist {
84 { USB_VENDOR_ID_REALTEK, USB_DEVICE_ID_REALTEK_READER, HID_QUIRK_NO_INIT_REPORTS }, 84 { USB_VENDOR_ID_REALTEK, USB_DEVICE_ID_REALTEK_READER, HID_QUIRK_NO_INIT_REPORTS },
85 { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET }, 85 { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET },
86 { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET }, 86 { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET },
87 { USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS9200_TOUCH, HID_QUIRK_NOGET }, 87 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS9200_TOUCH, HID_QUIRK_NOGET },
88 { USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS817_TOUCH, HID_QUIRK_NOGET }, 88 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS817_TOUCH, HID_QUIRK_NOGET },
89 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS_TS, HID_QUIRK_NO_INIT_REPORTS },
90 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS1030_TOUCH, HID_QUIRK_NOGET },
89 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 91 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
90 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET }, 92 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET },
91 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET }, 93 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET },
@@ -114,7 +116,8 @@ static const struct hid_blacklist {
114 { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS }, 116 { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS },
115 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_LTS1, HID_QUIRK_NO_INIT_REPORTS }, 117 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_LTS1, HID_QUIRK_NO_INIT_REPORTS },
116 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_LTS2, HID_QUIRK_NO_INIT_REPORTS }, 118 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_LTS2, HID_QUIRK_NO_INIT_REPORTS },
117 { USB_VENDOR_ID_SIS, USB_DEVICE_ID_SIS_TS, HID_QUIRK_NO_INIT_REPORTS }, 119 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_HD, HID_QUIRK_NO_INIT_REPORTS },
120 { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS },
118 121
119 { 0, 0 } 122 { 0, 0 }
120}; 123};
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 796086980f4a..9a332e683db7 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -146,7 +146,7 @@ static void usb_kbd_irq(struct urb *urb)
146 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); 146 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1);
147 else 147 else
148 hid_info(urb->dev, 148 hid_info(urb->dev,
149 "Unknown key (scancode %#x) released.\n", 149 "Unknown key (scancode %#x) pressed.\n",
150 kbd->new[i]); 150 kbd->new[i]);
151 } 151 }
152 } 152 }