LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support
@ 2007-01-11 14:51 Anssi Hannula
2007-01-11 14:51 ` [patch 1/3] hid: allow force feedback for multi-input devices Anssi Hannula
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Anssi Hannula @ 2007-01-11 14:51 UTC (permalink / raw)
To: Vojtech Pavlik, Greg KH; +Cc: linux-usb-devel, linux-input, linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 1/3] hid: allow force feedback for multi-input devices
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
@ 2007-01-11 14:51 ` Anssi Hannula
2007-01-11 14:51 ` [patch 2/3] hid: quirk for multi-input devices with unneeded output reports Anssi Hannula
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anssi Hannula @ 2007-01-11 14:51 UTC (permalink / raw)
To: Vojtech Pavlik, Greg KH
Cc: linux-usb-devel, linux-input, linux-kernel, Anssi Hannula
[-- Attachment #1: input-hid-allow-multi-input-ff.diff --]
[-- Type: text/plain, Size: 1152 bytes --]
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.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/usb/input/hid-core.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/usb/input/hid-core.c 2007-01-06 00:38:41.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c 2007-01-07 20:53:21.000000000 +0200
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 2/3] hid: quirk for multi-input devices with unneeded output reports
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
2007-01-11 14:51 ` [patch 1/3] hid: allow force feedback for multi-input devices Anssi Hannula
@ 2007-01-11 14:51 ` Anssi Hannula
2007-01-11 14:51 ` [patch 3/3] hid: force feedback driver for PantherLord USB/PS2 2in1 Adapter Anssi Hannula
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anssi Hannula @ 2007-01-11 14:51 UTC (permalink / raw)
To: Vojtech Pavlik, Greg KH
Cc: linux-usb-devel, linux-input, linux-kernel, Anssi Hannula
[-- Attachment #1: input-hid-multi-input-skip-output-report.diff --]
[-- Type: text/plain, Size: 3390 bytes --]
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.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
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(-)
Index: linux-2.6.20-rc3-ptr/drivers/hid/hid-input.c
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/hid/hid-input.c 2007-01-06 00:38:33.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/hid/hid-input.c 2007-01-07 21:07:34.000000000 +0200
@@ -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)
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/usb/input/hid-core.c 2007-01-07 20:53:21.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/hid-core.c 2007-01-07 21:02:39.000000000 +0200
@@ -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 }
};
Index: linux-2.6.20-rc3-ptr/include/linux/hid.h
===================================================================
--- linux-2.6.20-rc3-ptr.orig/include/linux/hid.h 2007-01-07 20:53:42.000000000 +0200
+++ linux-2.6.20-rc3-ptr/include/linux/hid.h 2007-01-07 20:56:10.000000000 +0200
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 3/3] hid: force feedback driver for PantherLord USB/PS2 2in1 Adapter
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
2007-01-11 14:51 ` [patch 1/3] hid: allow force feedback for multi-input devices Anssi Hannula
2007-01-11 14:51 ` [patch 2/3] hid: quirk for multi-input devices with unneeded output reports Anssi Hannula
@ 2007-01-11 14:51 ` Anssi Hannula
2007-01-11 16:51 ` [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Greg KH
2007-01-11 18:56 ` Jiri Kosina
4 siblings, 0 replies; 6+ messages in thread
From: Anssi Hannula @ 2007-01-11 14:51 UTC (permalink / raw)
To: Vojtech Pavlik, Greg KH
Cc: linux-usb-devel, linux-input, linux-kernel, Anssi Hannula
[-- Attachment #1: input-hid-ff-pantherlord.diff --]
[-- Type: text/plain, Size: 7139 bytes --]
Add a force feedback driver for PantherLord USB/PS2 2in1 Adapter,
0810:0001. The device identifies itself as "Twin USB Joystick".
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
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(+)
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-ff.c
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/usb/input/hid-ff.c 2007-01-07 20:53:42.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/hid-ff.c 2007-01-07 21:08:16.000000000 +0200
@@ -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
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/hid-plff.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/hid-plff.c 2007-01-11 16:10:10.000000000 +0200
@@ -0,0 +1,129 @@
+/*
+ * Force feedback support for PantherLord USB/PS2 2in1 Adapter devices
+ *
+ * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com>
+ */
+
+/*
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+/* #define DEBUG */
+
+#define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg)
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include "usbhid.h"
+
+struct plff_device {
+ struct hid_report *report;
+};
+
+static int hid_plff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = dev->private;
+ struct plff_device *plff = data;
+ int left, right;
+
+ left = effect->u.rumble.strong_magnitude;
+ right = effect->u.rumble.weak_magnitude;
+ debug("called with 0x%04x 0x%04x", left, right);
+
+ left = left * 0x7f / 0xffff;
+ right = right * 0x7f / 0xffff;
+
+ plff->report->field[0]->value[2] = left;
+ plff->report->field[0]->value[3] = right;
+ debug("running with 0x%02x 0x%02x", left, right);
+ usbhid_submit_report(hid, plff->report, USB_DIR_OUT);
+
+ return 0;
+}
+
+int hid_plff_init(struct hid_device *hid)
+{
+ struct plff_device *plff;
+ struct hid_report *report;
+ struct hid_input *hidinput;
+ struct list_head *report_list =
+ &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+ struct list_head *report_ptr = report_list;
+ struct input_dev *dev;
+ int error;
+
+ /* The device contains 2 output reports (one for each
+ HID_QUIRK_MULTI_INPUT device), both containing 1 field, which
+ contains 4 ff00.0002 usages and 4 16bit absolute values.
+
+ The 2 input reports also contain a field which contains
+ 8 ff00.0001 usages and 8 boolean values. Their meaning is
+ currently unknown. */
+
+ if (list_empty(report_list)) {
+ printk(KERN_ERR "hid-plff: no output reports found\n");
+ return -ENODEV;
+ }
+
+ list_for_each_entry(hidinput, &hid->inputs, list) {
+
+ report_ptr = report_ptr->next;
+
+ if (report_ptr == report_list) {
+ printk(KERN_ERR "hid-plff: required output report is missing\n");
+ return -ENODEV;
+ }
+
+ report = list_entry(report_ptr, struct hid_report, list);
+ if (report->maxfield < 1) {
+ printk(KERN_ERR "hid-plff: no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 4) {
+ printk(KERN_ERR "hid-plff: not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ plff = kzalloc(sizeof(struct plff_device), GFP_KERNEL);
+ if (!plff)
+ return -ENOMEM;
+
+ dev = hidinput->input;
+
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, plff, hid_plff_play);
+ if (error) {
+ kfree(plff);
+ return error;
+ }
+
+ plff->report = report;
+ plff->report->field[0]->value[0] = 0x00;
+ plff->report->field[0]->value[1] = 0x00;
+ plff->report->field[0]->value[2] = 0x00;
+ plff->report->field[0]->value[3] = 0x00;
+ usbhid_submit_report(hid, plff->report, USB_DIR_OUT);
+ }
+
+ printk(KERN_INFO "hid-plff: Force feedback for PantherLord USB/PS2 "
+ "2in1 Adapters by Anssi Hannula <anssi.hannula@gmail.com>\n");
+
+ return 0;
+}
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/Kconfig
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/usb/input/Kconfig 2007-01-07 20:53:42.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/Kconfig 2007-01-11 15:41:54.000000000 +0200
@@ -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
Index: linux-2.6.20-rc3-ptr/drivers/usb/input/Makefile
===================================================================
--- linux-2.6.20-rc3-ptr.orig/drivers/usb/input/Makefile 2007-01-07 20:53:42.000000000 +0200
+++ linux-2.6.20-rc3-ptr/drivers/usb/input/Makefile 2007-01-07 21:08:17.000000000 +0200
@@ -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
Index: linux-2.6.20-rc3-ptr/include/linux/hid.h
===================================================================
--- linux-2.6.20-rc3-ptr.orig/include/linux/hid.h 2007-01-07 20:56:10.000000000 +0200
+++ linux-2.6.20-rc3-ptr/include/linux/hid.h 2007-01-07 21:08:17.000000000 +0200
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
` (2 preceding siblings ...)
2007-01-11 14:51 ` [patch 3/3] hid: force feedback driver for PantherLord USB/PS2 2in1 Adapter Anssi Hannula
@ 2007-01-11 16:51 ` Greg KH
2007-01-11 18:56 ` Jiri Kosina
4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2007-01-11 16:51 UTC (permalink / raw)
To: Anssi Hannula, jkosina
Cc: Vojtech Pavlik, linux-usb-devel, linux-input, linux-kernel
On Thu, Jan 11, 2007 at 04:51:15PM +0200, Anssi Hannula wrote:
> 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 <jkosina@suse.cz>), I suggest
copying him on patches like this for the code.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
` (3 preceding siblings ...)
2007-01-11 16:51 ` [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Greg KH
@ 2007-01-11 18:56 ` Jiri Kosina
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2007-01-11 18:56 UTC (permalink / raw)
To: Anssi Hannula
Cc: Vojtech Pavlik, Greg KH, Dmitry Torokhov, linux-usb-devel,
linux-input, linux-kernel
On Thu, 11 Jan 2007, Anssi Hannula wrote:
> 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,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-01-11 19:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-11 14:51 [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Anssi Hannula
2007-01-11 14:51 ` [patch 1/3] hid: allow force feedback for multi-input devices Anssi Hannula
2007-01-11 14:51 ` [patch 2/3] hid: quirk for multi-input devices with unneeded output reports Anssi Hannula
2007-01-11 14:51 ` [patch 3/3] hid: force feedback driver for PantherLord USB/PS2 2in1 Adapter Anssi Hannula
2007-01-11 16:51 ` [patch 0/3] hid: series of patches for PantherLord USB/PS2 2in1 Adapter support Greg KH
2007-01-11 18:56 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).