Skip to contentSkip to conversation

hid: series of patches for PantherLord USB/PS2 2in1 Adapter support

PATCH In review Anssi Hannula 3 participants 6 messages Jan 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hid: series of patches for PantherLord USB/PS2 2in1 Adapter support

These three patches fix PantherLord USB/PS2 2in1 Adapter support so that it appears as two input devices, and add force feedback support for it.

--
Anssi Hannula

#1 lore raw

PATCH 1/3 hid: allow force feedback for multi-input devices

Allow hid devices with HID_QUIRK_MULTI_INPUT to have force feedback. This was previously disabled because there were not any force feedback drivers for such devices. This will change with my upcoming patch.

---
 drivers/usb/input/hid-core.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/input/hid-core.c +1 -5
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c
===================================================================
@@ -1315,11 +1315,7 @@ static int hid_probe(struct usb_interfac
 		return -ENODEV;
 	}
 
-	/* This only gets called when we are a single-input (most of the
-	 * time). IOW, not a HID_QUIRK_MULTI_INPUT. The hid_ff_init() is
-	 * only useful in this case, and not for multi-input quirks. */
-	if ((hid->claimed & HID_CLAIMED_INPUT) &&
-			!(hid->quirks & HID_QUIRK_MULTI_INPUT))
+	if ((hid->claimed & HID_CLAIMED_INPUT))
 		hid_ff_init(hid);
 
 	printk(KERN_INFO);

--
Anssi Hannula

#2 lore raw

PATCH 2/3 hid: quirk for multi-input devices with unneeded output reports

In reply to Anssi Hannula

Add new quirk HID_QUIRK_SKIP_OUTPUT_REPORTS to skip output reports when enumerating reports on a hid-input device. Add this quirk and HID_QUIRK_MULTI_INPUT to 0810:0001.

PantherLord Twin USB Joystick, 0810:0001 has separate input reports for 2 distinct game controllers in the same interface, so it needs HID_QUIRK_MULTI_INPUT. However, the device also contains one output report per controller which is used to control the force feedback function, and we do not want those to appear as separate input devices as well. The simplest approach seems to be to add a quirk to skip output reports on 0810:0001, and allow the force feedback driver to handle those.

---
 drivers/hid/hid-input.c      |    6 +++++-
 drivers/usb/input/hid-core.c |    5 +++++
 include/linux/hid.h          |    1 +
 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +5 -1
Index: linux-2.6.20-rc3-ptr/drivers/hid/hid-input.c
===================================================================
@@ -796,6 +796,7 @@ int hidinput_connect(struct hid_device *
 	struct hid_input *hidinput = NULL;
 	struct input_dev *input_dev;
 	int i, j, k;
+	int max_report_type = HID_OUTPUT_REPORT;
 
 	INIT_LIST_HEAD(&hid->inputs);
 
@@ -808,7 +809,10 @@ int hidinput_connect(struct hid_device *
 	if (i == hid->maxcollection)
 		return -1;
 
-	for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++)
+	if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)
+		max_report_type = HID_INPUT_REPORT;
+
+	for (k = HID_INPUT_REPORT; k <= max_report_type; k++)
 		list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
 
 			if (!report->maxfield)
drivers/usb/input/hid-core.c +5 -0
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c
===================================================================
@@ -791,6 +791,9 @@ void usbhid_init_reports(struct hid_devi
 #define USB_VENDOR_ID_LOGITECH		0x046d
 #define USB_DEVICE_ID_LOGITECH_USB_RECEIVER	0xc101
 
+#define USB_VENDOR_ID_PANTHERLORD	0x0810
+#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK	0x0001
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -965,6 +968,8 @@ static const struct hid_blacklist {
 
 	{ USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_USB_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS },
 
+	{ USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
+
 	{ 0, 0 }
 };
 
include/linux/hid.h +1 -0
Index: linux-2.6.20-rc3-ptr/include/linux/hid.h
===================================================================
@@ -264,6 +264,7 @@ struct hid_item {
 #define HID_QUIRK_INVERT_HWHEEL			0x00004000
 #define HID_QUIRK_POWERBOOK_ISO_KEYBOARD        0x00008000
 #define HID_QUIRK_BAD_RELATIVE_KEYS		0x00010000
+#define HID_QUIRK_SKIP_OUTPUT_REPORTS		0x00020000
 
 /*
  * This is the global environment of the parser. This information is

--
Anssi Hannula

#3 lore raw

PATCH 3/3 hid: force feedback driver for PantherLord USB/PS2 2in1 Adapter

In reply to Anssi Hannula

Add a force feedback driver for PantherLord USB/PS2 2in1 Adapter, 0810:0001. The device identifies itself as "Twin USB Joystick".

---
 drivers/usb/input/Kconfig    |    8 ++
 drivers/usb/input/Makefile   |    3 +
 drivers/usb/input/hid-ff.c   |    3 +
 drivers/usb/input/hid-plff.c |  129 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/hid.h          |    1 
 5 files changed, 144 insertions(+)
drivers/usb/input/hid-ff.c +3 -0
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-ff.c
===================================================================
@@ -57,6 +57,9 @@ static struct hid_ff_initializer inits[]
 	{ 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */
 	{ 0x46d, 0xc219, hid_lgff_init }, /* Logitech Cordless rumble pad 2 */
 #endif
+#ifdef CONFIG_PANTHERLORD_FF
+	{ 0x810, 0x0001, hid_plff_init },
+#endif
 #ifdef CONFIG_THRUSTMASTER_FF
 	{ 0x44f, 0xb304, hid_tmff_init },
 #endif
drivers/usb/input/hid-plff.c new file +129 -0

129 lines not on this page · raw message

drivers/usb/input/Kconfig +8 -0
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/Kconfig
===================================================================
@@ -71,6 +71,14 @@ config LOGITECH_FF
 	  Note: if you say N here, this device will still be supported, but without
 	  force feedback.
 
+config PANTHERLORD_FF
+	bool "PantherLord USB/PS2 2in1 Adapter support"
+	depends on HID_FF
+	select INPUT_FF_MEMLESS if USB_HID
+	help
+	  Say Y here if you have a PantherLord USB/PS2 2in1 Adapter and want
+	  to enable force feedback support for it.
+
 config THRUSTMASTER_FF
 	bool "ThrustMaster FireStorm Dual Power 2 support (EXPERIMENTAL)"
 	depends on HID_FF && EXPERIMENTAL
drivers/usb/input/Makefile +3 -0
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/Makefile
===================================================================
@@ -17,6 +17,9 @@ endif
 ifeq ($(CONFIG_LOGITECH_FF),y)
 	usbhid-objs	+= hid-lgff.o
 endif
+ifeq ($(CONFIG_PANTHERLORD_FF),y)
+	usbhid-objs	+= hid-plff.o
+endif
 ifeq ($(CONFIG_THRUSTMASTER_FF),y)
 	usbhid-objs	+= hid-tmff.o
 endif
include/linux/hid.h +1 -0
Index: linux-2.6.20-rc3-ptr/include/linux/hid.h
===================================================================
@@ -505,6 +505,7 @@ struct hid_device *hid_parse_report(__u8
 int hid_ff_init(struct hid_device *hid);
 
 int hid_lgff_init(struct hid_device *hid);
+int hid_plff_init(struct hid_device *hid);
 int hid_tmff_init(struct hid_device *hid);
 int hid_zpff_init(struct hid_device *hid);
 #ifdef CONFIG_HID_PID

--
Anssi Hannula

#4 lore raw
In reply to Anssi Hannula
Quoted 3 lines · Anssi Hannula

These three patches fix PantherLord USB/PS2 2in1 Adapter support so that it appears as two input devices, and add force feedback support for it.

HID has a real maintainer now (Jiri Kosina <[email protected]>), I suggest copying him on patches like this for the code.

thanks,

greg k-h

#5 lore raw
In reply to Anssi Hannula
Quoted 3 lines · Anssi Hannula

These three patches fix PantherLord USB/PS2 2in1 Adapter support so that it appears as two input devices, and add force feedback support for it.

Hi Anssi,

looks fine to me. If neither Greg nor Dmitry (added to CC) have any objections, I will queue it in my tree for 2.6.21-rc1.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs