Re: Regression post "HID: core: move Usage Page concatenation to Main item"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

The broken test in question is representing an actual, shipped device. The test
uses development vendor id 0x18d1 and product id 0x2c40. The actual shipped
device was Asus Gamepad, which is still being used and sold today.
Asus Gamepad has vendor id 0x0b05 and product id 0x4500.
The descriptor in the Android CTS test is identical to the one reported by
the actual joystick.

This patch means that all of the existing Asus Gamepad controllers will no longer
function on Linux and Android.

If reverting this patch is not feasible, can we please consider adding a custom
driver for Asus Gamepad?
I'm attaching a patch to fix up the descriptor that is based on the updated
descriptor provided by a partner.


>From 0fcd0fb045e450d895f79de7377b00e08f4bd720 Mon Sep 17 00:00:00 2001
From: Siarhei Vishniakou <svv@xxxxxxxxxx>
Date: Fri, 23 Aug 2019 14:20:32 +0100
Subject: [PATCH] Add Asus Gamepad descriptor fix

Asus Gamepad descriptor got broken by a recent kernel update. Fix it
here by overriding with a custom value.

Test: atest AsusGamepadTestCase
Signed-Off-By: Siarhei Vishniakou <svv@xxxxxxxxxx>
---
 drivers/hid/Kconfig                 |  6 +++
 drivers/hid/Makefile                |  1 +
 drivers/hid/hid-asus-gamepad.c      | 66 +++++++++++++++++++++++++++++
 drivers/hid/hid-core.c              |  1 +
 drivers/hid/hid-ids.h               |  1 +
 5 files changed, 75 insertions(+)
 create mode 100644 drivers/hid/hid-asus-gamepad.c

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 8eed456a67be..7ba54b2ddf7a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -144,6 +144,12 @@ config HID_ASUS
 	- EeeBook X205TA
 	- VivoBook E200HA
 
+config HID_ASUS_GAMEPAD
+	tristate "Asus Gamepad"
+	depends on HID
+	---help---
+	Support for Asus Gamepad joystick.
+
 config HID_AUREAL
 	tristate "Aureal"
 	depends on HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 86b2b5785fd2..d8a622a4feea 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_HID_ACRUX)		+= hid-axff.o
 obj-$(CONFIG_HID_APPLE)		+= hid-apple.o
 obj-$(CONFIG_HID_APPLEIR)	+= hid-appleir.o
 obj-$(CONFIG_HID_ASUS)		+= hid-asus.o
+obj-$(CONFIG_HID_ASUS_GAMEPAD)	+= hid-asus-gamepad.o
 obj-$(CONFIG_HID_AUREAL)	+= hid-aureal.o
 obj-$(CONFIG_HID_BELKIN)	+= hid-belkin.o
 obj-$(CONFIG_HID_BETOP_FF)	+= hid-betopff.o
diff --git a/drivers/hid/hid-asus-gamepad.c b/drivers/hid/hid-asus-gamepad.c
new file mode 100644
index 000000000000..799c3c9f5057
--- /dev/null
+++ b/drivers/hid/hid-asus-gamepad.c
@@ -0,0 +1,66 @@
+/*
+ *  HID driver for Asus Gamepad.
+ *  Fix the descriptor due to tightening HID specifications.
+ *  Copyright (c) 2019 Siarhei Vishniakou <svv@xxxxxxxxxx>
+ *
+ *  Based on a patch contributed by JeiFeng Lee and Thunder Yu.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+static __u8 GAMEPAD_DESCRIPTOR[] = {
+	0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a,
+	0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00,
+	0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00, 0x0a, 0x0e, 0x00, 0x0a, 0x0f,
+	0x00, 0x0a, 0x0d, 0x00, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95,
+	0x09, 0x81, 0x02, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a, 0x23, 0x02,
+	0x95, 0x02, 0x81, 0x02, 0x75, 0x01, 0x95, 0x01, 0x81, 0x03, 0x05,
+	0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
+	0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01,
+	0xa1, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x15,
+	0x00, 0x26, 0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08,
+	0x95, 0x04, 0x81, 0x02, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x95,
+	0x02, 0x81, 0x02, 0xc0, 0x85, 0x02, 0x05, 0x08, 0x0a, 0x01, 0x00,
+	0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00, 0x15, 0x00,
+	0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95,
+	0x01, 0x91, 0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85,
+	0x03, 0x05, 0x01, 0x09, 0x06, 0xa1, 0x02, 0x05, 0x06, 0x09, 0x20,
+	0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x02,
+	0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81,
+	0x02, 0xc0, 0xc0};
+
+static __u8 *asus_gamepad_report_fixup(struct hid_device *hdev,
+					__u8 *rdesc, unsigned int *rsize)
+{
+	if (hdev->product == USB_DEVICE_ID_ASUSTEK_GAMEPAD) {
+		hid_info(hdev, "Fixing up Asus Gamepad report descriptor\n");
+		*rsize = ARRAY_SIZE(GAMEPAD_DESCRIPTOR);
+		return GAMEPAD_DESCRIPTOR;
+	}
+	return rdesc;
+}
+
+static const struct hid_device_id asus_devices[] = {
+	{HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
+					USB_DEVICE_ID_ASUSTEK_GAMEPAD)},
+};
+MODULE_DEVICE_TABLE(hid, asus_devices);
+
+static struct hid_driver asus_driver = {
+	.name = "asus-gamepad",
+	.id_table = asus_devices,
+	.report_fixup = asus_gamepad_report_fixup};
+module_hid_driver(asus_driver);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 832ff592a4bf..b51e0ba093aa 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1873,6 +1873,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
 	{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_GAMEPAD) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185BFM, 0x2208) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 6f4c84d824e6..138c28639107 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -173,6 +173,7 @@
 #define USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO	0x0186
 
 #define USB_VENDOR_ID_ASUSTEK		0x0b05
+#define USB_DEVICE_ID_ASUSTEK_GAMEPAD      0x4500
 #define USB_DEVICE_ID_ASUSTEK_LCM	0x1726
 #define USB_DEVICE_ID_ASUSTEK_LCM2	0x175b
 #define USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD	0x8585
-- 




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux