* New Force Feedback device support - GreenAsia 0x12
@ 2008-11-26 22:33 Łukasz Lubojański
2008-11-26 23:01 ` Marek Vasut
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Łukasz Lubojański @ 2008-11-26 22:33 UTC (permalink / raw)
To: linux-input
[-- Attachment #1: Type: text/plain, Size: 591 bytes --]
Hi..
I have implemented Force Feedback driver for another "GreeAsia" based device
(0e8f:0012 "GreenAsia Inc. USB Joystick ").
The functionality was tested with MANTA Warior MM816 and SpeedLink Strike2
SL-6635 and fftest software - everything seems to work right.
Is there anyone able to check the code say if this good enough to include it
into official kernel ?
If there are any suggestion what I should additionally check or what I
should change before posting it please let me know.
ps. I hope the attachement will be visible :D
Thanx
Lukasz Lubojanski
[-- Attachment #2: greenasia.diff --]
[-- Type: text/x-patch, Size: 7995 bytes --]
Index: include/linux/hid.h
===================================================================
--- include/linux/hid.h (wersja 1)
+++ include/linux/hid.h (kopia robocza)
@@ -547,6 +547,7 @@
int hid_lgff_init(struct hid_device *hid);
int hid_lg2ff_init(struct hid_device *hid);
int hid_plff_init(struct hid_device *hid);
+int hid_gaff_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
Index: drivers/hid/usbhid/Kconfig
===================================================================
--- drivers/hid/usbhid/Kconfig (wersja 1)
+++ drivers/hid/usbhid/Kconfig (kopia robocza)
@@ -87,6 +87,15 @@
Say Y here if you have a PantherLord/GreenAsia based game controller
or adapter and want to enable force feedback support for it.
+config GREENASIA_FF
+ bool "GreenAsia (Product ID 0x12) based device support"
+ depends on HID_FF
+ select INPUT_FF_MEMLESS if USB_HID
+ help
+ Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
+ or adapter and want to enable force feedback support for it.
+ It was tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
+
config THRUSTMASTER_FF
bool "ThrustMaster devices support"
depends on HID_FF
Index: drivers/hid/usbhid/hid-gaff.c
===================================================================
--- drivers/hid/usbhid/hid-gaff.c (wersja 0)
+++ drivers/hid/usbhid/hid-gaff.c (wersja 3)
@@ -0,0 +1,198 @@
+/*
+ * Force feedback support for GreenAsia (Product ID 0x12) based devices
+ *
+ * The devices are distributed under various names and the same USB device ID
+ * can be used in many game controllers.
+ *
+ *
+ * 0e8f:0012 "GreenAsia Inc. USB Joystick "
+ * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
+ *
+ * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
+ */
+
+/*
+ * 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-gaff: " format "\n" , ## arg)
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include "usbhid.h"
+
+struct gaff_device {
+ struct hid_report *report;
+};
+
+static int hid_gaff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct gaff_device *gaff = data;
+ int left, right;
+
+ switch (effect->type) {
+ case FF_CONSTANT:
+
+ left = effect->u.ramp.start_level;
+ right = effect->u.ramp.end_level ;
+ debug("called with %d %d", left, right);
+
+ if ( left )
+ {
+ if ( left < 0 )
+ left = abs(left) * 0xfe / 0x80;
+ else
+ left = left * 0xfe / 0x7f;
+ }
+
+ if (right )
+ {
+ if (right < 0 )
+ right = abs(right) * 0xfe / 0x80;
+ else
+ right = right * 0xfe / 0x7f;
+ }
+
+
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x0;
+ gaff->report->field[0]->value[2] = right;
+ gaff->report->field[0]->value[3] = 0;
+ gaff->report->field[0]->value[4] = left;
+ gaff->report->field[0]->value[5] = 0;
+ debug("running with 0x%02x 0x%02x", left, right);
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ gaff->report->field[0]->value[2] = 0x0;
+ gaff->report->field[0]->value[4] = 0x0;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+
+ break;
+
+ case FF_RUMBLE:
+
+
+
+ left = effect->u.rumble.strong_magnitude;
+ right = effect->u.rumble.weak_magnitude;
+
+ debug("called with 0x%04x 0x%04x", left, right);
+
+ left = left * 0xfe / 0xffff;
+ right = right * 0xfe / 0xffff;
+
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x0;
+ gaff->report->field[0]->value[2] = right;
+ gaff->report->field[0]->value[3] = 0;
+ gaff->report->field[0]->value[4] = left;
+ gaff->report->field[0]->value[5] = 0;
+ debug("running with 0x%02x 0x%02x", left, right);
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ gaff->report->field[0]->value[2] = 0x0;
+ gaff->report->field[0]->value[4] = 0x0;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ break;
+ };
+
+ return 0;
+}
+
+int hid_gaff_init(struct hid_device *hid)
+{
+ struct gaff_device *gaff;
+ 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;
+
+ if (list_empty(report_list)) {
+ printk(KERN_ERR "hid-gaff: 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-gaff: 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-gaff: no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 4) {
+ printk(KERN_ERR "hid-gaff: not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
+ if (!gaff)
+ return -ENOMEM;
+
+ dev = hidinput->input;
+
+ set_bit(FF_CONSTANT, dev->ffbit);
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, gaff, hid_gaff_play);
+ if (error) {
+ kfree(gaff);
+ return error;
+ }
+
+ gaff->report = report;
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x00;
+ gaff->report->field[0]->value[2] = 0x00;
+ gaff->report->field[0]->value[3] = 0x00;
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ }
+
+ printk(KERN_INFO "hid-gaff: Force feedback for GreenAsia gamepads"
+ "devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
+
+ return 0;
+}
Index: drivers/hid/usbhid/Makefile
===================================================================
--- drivers/hid/usbhid/Makefile (wersja 1)
+++ drivers/hid/usbhid/Makefile (kopia robocza)
@@ -22,6 +22,9 @@
ifeq ($(CONFIG_PANTHERLORD_FF),y)
usbhid-objs += hid-plff.o
endif
+ifeq ($(CONFIG_GREENASIA_FF),y)
+ usbhid-objs += hid-gaff.o
+endif
ifeq ($(CONFIG_THRUSTMASTER_FF),y)
usbhid-objs += hid-tmff.o
endif
Index: drivers/hid/usbhid/hid-ff.c
===================================================================
--- drivers/hid/usbhid/hid-ff.c (wersja 1)
+++ drivers/hid/usbhid/hid-ff.c (kopia robocza)
@@ -66,6 +66,9 @@
{ 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */
{ 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */
#endif
+#ifdef CONFIG_GREENASIA_FF
+ { 0xe8f, 0x0012, hid_gaff_init }, /* "GreenAsia Inc. USB Joystick " */
+#endif
#ifdef CONFIG_THRUSTMASTER_FF
{ 0x44f, 0xb300, hid_tmff_init },
{ 0x44f, 0xb304, hid_tmff_init },
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-26 22:33 New Force Feedback device support - GreenAsia 0x12 Łukasz Lubojański
@ 2008-11-26 23:01 ` Marek Vasut
2008-11-26 23:01 ` Jiri Slaby
2008-11-27 12:41 ` Jiri Kosina
2 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2008-11-26 23:01 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: linux-input
On Wednesday 26 of November 2008 23:33:44 Łukasz Lubojański wrote:
> Hi..
>
> I have implemented Force Feedback driver for another "GreeAsia" based
> device (0e8f:0012 "GreenAsia Inc. USB Joystick ").
> The functionality was tested with MANTA Warior MM816 and SpeedLink Strike2
> SL-6635 and fftest software - everything seems to work right.
>
> Is there anyone able to check the code say if this good enough to include
> it into official kernel ?
>
> If there are any suggestion what I should additionally check or what I
> should change before posting it please let me know.
>
> ps. I hope the attachement will be visible :D
>
> Thanx
> Lukasz Lubojanski
1) Please check the patch with checkpatch (scripts/checkpatch.pl) before
posting here
2) Use git format-patch to generate the final patch.
Marek
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-26 22:33 New Force Feedback device support - GreenAsia 0x12 Łukasz Lubojański
2008-11-26 23:01 ` Marek Vasut
@ 2008-11-26 23:01 ` Jiri Slaby
2008-11-27 12:41 ` Jiri Kosina
2 siblings, 0 replies; 17+ messages in thread
From: Jiri Slaby @ 2008-11-26 23:01 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: linux-input
On 11/26/2008 11:33 PM, Łukasz Lubojański wrote:
> Hi..
>
> I have implemented Force Feedback driver for another "GreeAsia" based device
> (0e8f:0012 "GreenAsia Inc. USB Joystick ").
> The functionality was tested with MANTA Warior MM816 and SpeedLink Strike2
> SL-6635 and fftest software - everything seems to work right.
>
> Is there anyone able to check the code say if this good enough to include it
> into official kernel ?
It's based on the old infrastructure.
> If there are any suggestion what I should additionally check or what I
> should change before posting it please let me know.
Rebase it on a later kernel. It's now hard to comment, since you'll change much
of the code :).
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-26 22:33 New Force Feedback device support - GreenAsia 0x12 Łukasz Lubojański
2008-11-26 23:01 ` Marek Vasut
2008-11-26 23:01 ` Jiri Slaby
@ 2008-11-27 12:41 ` Jiri Kosina
2008-11-28 6:18 ` Łukasz Lubojański
2 siblings, 1 reply; 17+ messages in thread
From: Jiri Kosina @ 2008-11-27 12:41 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: linux-input
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1133 bytes --]
On Wed, 26 Nov 2008, Łukasz Lubojański wrote:
> I have implemented Force Feedback driver for another "GreeAsia" based
> device (0e8f:0012 "GreenAsia Inc. USB Joystick "). The
> functionality was tested with MANTA Warior MM816 and SpeedLink Strike2
> SL-6635 and fftest software - everything seems to work right.
> Is there anyone able to check the code say if this good enough to include it
> into official kernel ?
Hi,
thanks for doing this work. The HID code has been redone for 2.6.28, and
HID generic layer now provides proper kernel bus, to which the specialized
drivers should register properly. This has been done in order to keep the
code clean and maintainable, as adding all the quirks during the past
years started turning the HID code into unmaintainable mess.
Could you please rebase your patch on top of current state of Linus'
kernel tree for 2.6.28-rc? Then the code could be reviewed and I'll merge
it through my tree.
For inspiration, you can look into
drivers/hid/hid-pl.c
That driver even contains support for some Greenasia device ... (0x0003).
Thanks!
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-27 12:41 ` Jiri Kosina
@ 2008-11-28 6:18 ` Łukasz Lubojański
2008-11-28 14:21 ` Jiri Kosina
0 siblings, 1 reply; 17+ messages in thread
From: Łukasz Lubojański @ 2008-11-28 6:18 UTC (permalink / raw)
To: Jiri Kosina; +Cc: linux-input
> On Wed, 26 Nov 2008, Łukasz Lubojański wrote:
> > I have implemented Force Feedback driver for another "GreeAsia" based
> > device (0e8f:0012 "GreenAsia Inc. USB Joystick "). The
> > functionality was tested with MANTA Warior MM816 and SpeedLink Strike2
> > SL-6635 and fftest software - everything seems to work right.
> > Is there anyone able to check the code say if this good enough to include
> > it into official kernel ?
>
> Hi,
>
> thanks for doing this work. The HID code has been redone for 2.6.28, and
> HID generic layer now provides proper kernel bus, to which the specialized
> drivers should register properly. This has been done in order to keep the
> code clean and maintainable, as adding all the quirks during the past
> years started turning the HID code into unmaintainable mess.
>
> Could you please rebase your patch on top of current state of Linus'
> kernel tree for 2.6.28-rc? Then the code could be reviewed and I'll merge
> it through my tree.
> For inspiration, you can look into
>
> drivers/hid/hid-pl.c
>
> That driver even contains support for some Greenasia device ... (0x0003).
>
> Thanks!
I have rewriten the code for 2.6.28-rc6 and after testing and checking it with
checkpatch I will send it again.
Anyway I know that pantherlord code is also supporting greenasia devices (first
code was also mostly taken from that) - and I'm still don't know if I'm dooing
right naming my part "greenasia" - because some people could get confused. It
could also happen that someone else will implement other greenasia device and
this will make another confusion.
Maybe warrior_strike will be better name ? Of course there will be still noted
in description that it is supporting other GreenAsia 0x12 based devices.
ps. Do I need to ask Manta and SpeedLink for permission of using they company
and product names in descriptions ?
regards
Lukasz Lubojanski
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-28 6:18 ` Łukasz Lubojański
@ 2008-11-28 14:21 ` Jiri Kosina
2008-11-28 18:27 ` Anssi Hannula
0 siblings, 1 reply; 17+ messages in thread
From: Jiri Kosina @ 2008-11-28 14:21 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: linux-input
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1395 bytes --]
On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
> > Could you please rebase your patch on top of current state of Linus'
> > kernel tree for 2.6.28-rc? Then the code could be reviewed and I'll merge
> > it through my tree.
> > For inspiration, you can look into
> >
> > drivers/hid/hid-pl.c
> >
> > That driver even contains support for some Greenasia device ... (0x0003).
> I have rewriten the code for 2.6.28-rc6 and after testing and checking
> it with checkpatch I will send it again.
Great, thanks.
> Anyway I know that pantherlord code is also supporting greenasia devices
> (first code was also mostly taken from that) - and I'm still don't know
> if I'm dooing right naming my part "greenasia" - because some people
> could get confused. It could also happen that someone else will
> implement other greenasia device and this will make another confusion.
The question is how much the protocol that is used by your device differs
from the one that is already implemented in hid-pl.c? Would it make sense
to have these two implementations in the same driver, or is the protocol
just completely different?
> ps. Do I need to ask Manta and SpeedLink for permission of using they
> company and product names in descriptions ?
I seriously hope you don't have to, we will all be violating this all the
time. But I am not a lawyer, of course :)
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-28 14:21 ` Jiri Kosina
@ 2008-11-28 18:27 ` Anssi Hannula
2008-11-28 19:08 ` Łukasz Lubojański
0 siblings, 1 reply; 17+ messages in thread
From: Anssi Hannula @ 2008-11-28 18:27 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Łukasz Lubojański, linux-input
Jiri Kosina wrote:
> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>
>>> Could you please rebase your patch on top of current state of Linus'
>>> kernel tree for 2.6.28-rc? Then the code could be reviewed and I'll merge
>>> it through my tree.
>>> For inspiration, you can look into
>>>
>>> drivers/hid/hid-pl.c
>>>
>>> That driver even contains support for some Greenasia device ... (0x0003).
>> I have rewriten the code for 2.6.28-rc6 and after testing and checking
>> it with checkpatch I will send it again.
>
> Great, thanks.
>
>> Anyway I know that pantherlord code is also supporting greenasia devices
>> (first code was also mostly taken from that) - and I'm still don't know
>> if I'm dooing right naming my part "greenasia" - because some people
>> could get confused. It could also happen that someone else will
>> implement other greenasia device and this will make another confusion.
>
> The question is how much the protocol that is used by your device differs
> from the one that is already implemented in hid-pl.c? Would it make sense
> to have these two implementations in the same driver, or is the protocol
> just completely different?
It seems the protocol resembles more the hid-lg2ff one. The differences
are the additional 0xfa 0xfe 0x0 report sent to the device, and the
missing 0xf3 stop command.
Łukasz, I see your code implements both FF_RUMBLE and FF_CONSTANT in the
same way. If the device only supports rumble effects, then you should
only implement FF_RUMBLE.
--
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-28 18:27 ` Anssi Hannula
@ 2008-11-28 19:08 ` Łukasz Lubojański
2008-11-29 22:30 ` Jiri Kosina
0 siblings, 1 reply; 17+ messages in thread
From: Łukasz Lubojański @ 2008-11-28 19:08 UTC (permalink / raw)
To: Anssi Hannula, Jiri Kosina; +Cc: linux-input
> Jiri Kosina wrote:
> > On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
> >>> Could you please rebase your patch on top of current state of Linus'
> >>> kernel tree for 2.6.28-rc? Then the code could be reviewed and I'll
> >>> merge it through my tree.
> >>> For inspiration, you can look into
> >>>
> >>> drivers/hid/hid-pl.c
> >>>
> >>> That driver even contains support for some Greenasia device ...
> >>> (0x0003).
> >>
> >> I have rewriten the code for 2.6.28-rc6 and after testing and checking
> >> it with checkpatch I will send it again.
> >
> > Great, thanks.
> >
> >> Anyway I know that pantherlord code is also supporting greenasia devices
> >> (first code was also mostly taken from that) - and I'm still don't know
> >> if I'm dooing right naming my part "greenasia" - because some people
> >> could get confused. It could also happen that someone else will
> >> implement other greenasia device and this will make another confusion.
> >
> > The question is how much the protocol that is used by your device differs
> > from the one that is already implemented in hid-pl.c? Would it make sense
> > to have these two implementations in the same driver, or is the protocol
> > just completely different?
>
> It seems the protocol resembles more the hid-lg2ff one. The differences
> are the additional 0xfa 0xfe 0x0 report sent to the device, and the
> missing 0xf3 stop command.
>
> Łukasz, I see your code implements both FF_RUMBLE and FF_CONSTANT in the
> same way. If the device only supports rumble effects, then you should
> only implement FF_RUMBLE.
Yep - different reports are send in case of Pantherlord and GreenAsia 0x12 - It
could be implemented in it but it will require checking what hardware is used
and send different reports. So it depends on you - what is better in your
opinion ? Please note only that I have only one hardware that it will support
so it will require tests from Pantherlord/Logitech users test.
No problem with the FF_CONSTANT - I will cut off that code. I was thinking it
will be better to have it implemented and as the hardware has the same report
for both effect and it was very easy to made.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-28 19:08 ` Łukasz Lubojański
@ 2008-11-29 22:30 ` Jiri Kosina
2008-12-04 20:35 ` Łukasz Lubojański
0 siblings, 1 reply; 17+ messages in thread
From: Jiri Kosina @ 2008-11-29 22:30 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: Anssi Hannula, linux-input
[-- Attachment #1: Type: TEXT/PLAIN, Size: 934 bytes --]
On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
> > It seems the protocol resembles more the hid-lg2ff one. The differences
> > are the additional 0xfa 0xfe 0x0 report sent to the device, and the
> > missing 0xf3 stop command.
> Yep - different reports are send in case of Pantherlord and GreenAsia
> 0x12 - It could be implemented in it but it will require checking what
> hardware is used and send different reports.
OK, so as the reports are not really identical, and in the future we might
discover that there are many more other Greenasia devices which require a
slightly different handling as well, I would rather prefer to have it as a
separate driver, to avoid additions of here-and-there device-specific
quirks to random places in the code. That's exactly what we are trying to
avoid with the HID bus approach in the first place.
So I think separate driver is fine.
Thanks to both of you.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-11-29 22:30 ` Jiri Kosina
@ 2008-12-04 20:35 ` Łukasz Lubojański
2008-12-04 20:55 ` Łukasz Lubojański
0 siblings, 1 reply; 17+ messages in thread
From: Łukasz Lubojański @ 2008-12-04 20:35 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Anssi Hannula, linux-input
[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]
2008/11/29 Jiri Kosina <jkosina@suse.cz>:
> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>
>> > It seems the protocol resembles more the hid-lg2ff one. The differences
>> > are the additional 0xfa 0xfe 0x0 report sent to the device, and the
>> > missing 0xf3 stop command.
>> Yep - different reports are send in case of Pantherlord and GreenAsia
>> 0x12 - It could be implemented in it but it will require checking what
>> hardware is used and send different reports.
>
> OK, so as the reports are not really identical, and in the future we might
> discover that there are many more other Greenasia devices which require a
> slightly different handling as well, I would rather prefer to have it as a
> separate driver, to avoid additions of here-and-there device-specific
> quirks to random places in the code. That's exactly what we are trying to
> avoid with the HID bus approach in the first place.
>
> So I think separate driver is fine.
>
> Thanks to both of you.
>
> --
> Jiri Kosina
> SUSE Labs
Hi,
Here is new version of the GreenAsia patch - I hope this time
everything will be OK. It is based on the Pantherlord.
Sorry to take so long but I have problems with the 2.6.28 (2.6.28-rc6
was not loading my driver and 2.6.28-rc7 is crashing when IO APIC is
enabled). Anyway I done it and I'm waiting for your feedback :D
regards
Lukasz Lubojanski
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: greenasia.patch --]
[-- Type: text/x-diff; name=greenasia.patch, Size: 1593 bytes --]
Signed-off-by: Lukasz Lubojanski <lukasz@lubojanski.info>
diff --git a/drivers/hid/hid-ga.c b/drivers/hid/hid-ga.c
index 33c9a19..e821898 100644
--- a/drivers/hid/hid-ga.c
+++ b/drivers/hid/hid-ga.c
@@ -65,7 +65,7 @@ static int hid_gaff_play(struct input_dev *dev, void *data,
debug("called with 0x%04x 0x%04x", left, right);
left = left * 0xfe / 0xffff;
- right = right * 0xfe / 0xffff;
+ right = right * 0xfe / 0xffff;
gaff->report->field[0]->value[0] = 0x51;
gaff->report->field[0]->value[1] = 0x0;
@@ -79,8 +79,8 @@ static int hid_gaff_play(struct input_dev *dev, void *data,
gaff->report->field[0]->value[0] = 0xfa;
gaff->report->field[0]->value[1] = 0xfe;
gaff->report->field[0]->value[2] = 0x0;
- gaff->report->field[0]->value[4] = 0x0;
-
+ gaff->report->field[0]->value[4] = 0x0;
+
usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
return 0;
@@ -136,14 +136,14 @@ static int gaff_init(struct hid_device *hid)
kfree(gaff);
return error;
}
-
+
gaff->report = report;
gaff->report->field[0]->value[0] = 0x51;
gaff->report->field[0]->value[1] = 0x00;
gaff->report->field[0]->value[2] = 0x00;
gaff->report->field[0]->value[3] = 0x00;
usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
-
+
gaff->report->field[0]->value[0] = 0xfa;
gaff->report->field[0]->value[1] = 0xfe;
@@ -169,7 +169,7 @@ static inline int gaff_init(struct hid_device *hid)
static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
int ret;
-
+
debug("Greenasia HID hardware probe...");
if (id->driver_data)
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-04 20:35 ` Łukasz Lubojański
@ 2008-12-04 20:55 ` Łukasz Lubojański
2008-12-05 18:32 ` Anssi Hannula
0 siblings, 1 reply; 17+ messages in thread
From: Łukasz Lubojański @ 2008-12-04 20:55 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Anssi Hannula, linux-input
[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]
On Thu, Dec 4, 2008 at 9:35 PM, Łukasz Lubojański
<lukasz@lubojanski.info> wrote:
> 2008/11/29 Jiri Kosina <jkosina@suse.cz>:
>> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>>
>>> > It seems the protocol resembles more the hid-lg2ff one. The differences
>>> > are the additional 0xfa 0xfe 0x0 report sent to the device, and the
>>> > missing 0xf3 stop command.
>>> Yep - different reports are send in case of Pantherlord and GreenAsia
>>> 0x12 - It could be implemented in it but it will require checking what
>>> hardware is used and send different reports.
>>
>> OK, so as the reports are not really identical, and in the future we might
>> discover that there are many more other Greenasia devices which require a
>> slightly different handling as well, I would rather prefer to have it as a
>> separate driver, to avoid additions of here-and-there device-specific
>> quirks to random places in the code. That's exactly what we are trying to
>> avoid with the HID bus approach in the first place.
>>
>> So I think separate driver is fine.
>>
>> Thanks to both of you.
>>
>> --
>> Jiri Kosina
>> SUSE Labs
>
> Hi,
>
> Here is new version of the GreenAsia patch - I hope this time
> everything will be OK. It is based on the Pantherlord.
>
> Sorry to take so long but I have problems with the 2.6.28 (2.6.28-rc6
> was not loading my driver and 2.6.28-rc7 is crashing when IO APIC is
> enabled). Anyway I done it and I'm waiting for your feedback :D
>
> regards
> Lukasz Lubojanski
>
And one more time - because I have generated and attached wrong file previously.
This time should be OK.
regards
Lukasz Lubojanski
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: greenasia.diff --]
[-- Type: text/x-diff; name=greenasia.diff, Size: 8523 bytes --]
Signed-off-by: Lukasz Lubojanski <lukasz@lubojanski.info>
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b4fd8ca..45f25ef 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -217,6 +217,24 @@ config PANTHERLORD_FF
Say Y here if you have a PantherLord/GreenAsia based game controller
or adapter and want to enable force feedback support for it.
+config HID_GREENASIA
+ tristate "GreenAsia (Product ID 0x12) based device support" if EMBEDDED
+ depends on USB_HID
+ default y
+ ---help---
+ Support for GreenAsia (Product ID 0x12) based device support
+ (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635).
+
+config GREENASIA_FF
+ bool "GreenAsia (Product ID 0x12) force feedback support"
+ depends on HID_GREENASIA
+ select INPUT_FF_MEMLESS
+ ---help---
+ Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
+ or adapter and want to enable force feedback support for it.
+
+
+
config HID_PETALYNX
tristate "Petalynx" if EMBEDDED
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index b09e43e..20662b7 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
+obj-$(CONFIG_HID_GREENASIA) += hid-ga.o
obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 40df3e1..f2184cf 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1269,6 +1269,7 @@ static const struct hid_device_id hid_blacklist[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index e148f86..d2b1b37 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -43,6 +43,9 @@ static int __init hid_dummy_init(void)
#ifdef CONFIG_HID_MONTEREY_MODULE
HID_COMPAT_CALL_DRIVER(monterey);
#endif
+#ifdef CONFIG_HID_GREENASIA_MODULE
+ HID_COMPAT_CALL_DRIVER(greenasia);
+#endif
#ifdef CONFIG_HID_PANTHERLORD_MODULE
HID_COMPAT_CALL_DRIVER(pantherlord);
#endif
diff --git a/drivers/hid/hid-ga.c b/drivers/hid/hid-ga.c
new file mode 100644
index 0000000..e50f3f5
--- /dev/null
+++ b/drivers/hid/hid-ga.c
@@ -0,0 +1,223 @@
+/*
+ * Force feedback support for GreenAsia (Product ID 0x12) based devices
+ *
+ * The devices are distributed under various names and the same USB device ID
+ * can be used in many game controllers.
+ *
+ *
+ * 0e8f:0012 "GreenAsia Inc. USB Joystick "
+ * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
+ *
+ * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
+ */
+
+/*
+ * 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-ga: " format "\n" , ## arg)
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+
+#include "hid-ids.h"
+
+#ifdef CONFIG_GREENASIA_FF
+#include "usbhid/usbhid.h"
+
+
+static const signed short ff_rumble[] = {
+ FF_RUMBLE,
+ -1
+};
+
+
+struct gaff_device {
+ struct hid_report *report;
+};
+
+static int hid_gaff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct gaff_device *gaff = 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 * 0xfe / 0xffff;
+ right = right * 0xfe / 0xffff;
+
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x0;
+ gaff->report->field[0]->value[2] = right;
+ gaff->report->field[0]->value[3] = 0;
+ gaff->report->field[0]->value[4] = left;
+ gaff->report->field[0]->value[5] = 0;
+ debug("running with 0x%02x 0x%02x", left, right);
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ gaff->report->field[0]->value[2] = 0x0;
+ gaff->report->field[0]->value[4] = 0x0;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ return 0;
+}
+
+static int gaff_init(struct hid_device *hid)
+{
+ struct gaff_device *gaff;
+ 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;
+
+ if (list_empty(report_list)) {
+ dev_err(&hid->dev, "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) {
+ dev_err(&hid->dev, "required output report is "
+ "missing\n");
+ return -ENODEV;
+ }
+
+ report = list_entry(report_ptr, struct hid_report, list);
+ if (report->maxfield < 1) {
+ dev_err(&hid->dev, "no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 4) {
+ dev_err(&hid->dev, "not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
+ if (!gaff)
+ return -ENOMEM;
+
+ dev = hidinput->input;
+
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, gaff, hid_gaff_play);
+ if (error) {
+ kfree(gaff);
+ return error;
+ }
+
+ gaff->report = report;
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x00;
+ gaff->report->field[0]->value[2] = 0x00;
+ gaff->report->field[0]->value[3] = 0x00;
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+ }
+
+
+ dev_info(&hid->dev, "hid-ga: Force Feedback for GreenAsia 0x12"
+ " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
+
+ return 0;
+}
+#else
+static inline int gaff_init(struct hid_device *hid)
+{
+ dev_info(&hid->dev, "hid-ga: GreenAsia 0x12 "
+ " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
+
+ return 0;
+}
+#endif
+
+static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret;
+
+ debug("Greenasia HID hardware probe...");
+
+ if (id->driver_data)
+ hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "parse failed\n");
+ goto err;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+ if (ret) {
+ dev_err(&hdev->dev, "hw start failed\n");
+ goto err;
+ }
+
+ gaff_init(hdev);
+
+ return 0;
+err:
+ return ret;
+}
+
+static const struct hid_device_id ga_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), }, /* GreenAsia Inc. USB Joystick */
+ { }
+};
+MODULE_DEVICE_TABLE(hid, ga_devices);
+
+static struct hid_driver ga_driver = {
+ .name = "greenasia",
+ .id_table = ga_devices,
+ .probe = ga_probe,
+};
+
+static int ga_init(void)
+{
+ return hid_register_driver(&ga_driver);
+}
+
+static void ga_exit(void)
+{
+ hid_unregister_driver(&ga_driver);
+}
+
+module_init(ga_init);
+module_exit(ga_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(greenasia);
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-04 20:55 ` Łukasz Lubojański
@ 2008-12-05 18:32 ` Anssi Hannula
2008-12-05 20:49 ` Łukasz Lubojański
0 siblings, 1 reply; 17+ messages in thread
From: Anssi Hannula @ 2008-12-05 18:32 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: Jiri Kosina, linux-input
Łukasz Lubojański wrote:
> On Thu, Dec 4, 2008 at 9:35 PM, Łukasz Lubojański
> <lukasz@lubojanski.info> wrote:
>> 2008/11/29 Jiri Kosina <jkosina@suse.cz>:
>>> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>>>
>>>>> It seems the protocol resembles more the hid-lg2ff one. The differences
>>>>> are the additional 0xfa 0xfe 0x0 report sent to the device, and the
>>>>> missing 0xf3 stop command.
>>>> Yep - different reports are send in case of Pantherlord and GreenAsia
>>>> 0x12 - It could be implemented in it but it will require checking what
>>>> hardware is used and send different reports.
>>> OK, so as the reports are not really identical, and in the future we might
>>> discover that there are many more other Greenasia devices which require a
>>> slightly different handling as well, I would rather prefer to have it as a
>>> separate driver, to avoid additions of here-and-there device-specific
>>> quirks to random places in the code. That's exactly what we are trying to
>>> avoid with the HID bus approach in the first place.
>>>
>>> So I think separate driver is fine.
>>>
>>> Thanks to both of you.
>>>
>>> --
>>> Jiri Kosina
>>> SUSE Labs
>> Hi,
>>
>> Here is new version of the GreenAsia patch - I hope this time
>> everything will be OK. It is based on the Pantherlord.
>>
>> Sorry to take so long but I have problems with the 2.6.28 (2.6.28-rc6
>> was not loading my driver and 2.6.28-rc7 is crashing when IO APIC is
>> enabled). Anyway I done it and I'm waiting for your feedback :D
> +static const signed short ff_rumble[] = {
> + FF_RUMBLE,
> + -1
> +};
This seems unnecessary.
> +
> + list_for_each_entry(hidinput, &hid->inputs, list) {
> +
> + report_ptr = report_ptr->next;
> +
> + if (report_ptr == report_list) {
> + dev_err(&hid->dev, "required output report is "
> + "missing\n");
> + return -ENODEV;
> + }
[...]
> + if (id->driver_data)
> + hdev->quirks |= HID_QUIRK_MULTI_INPUT;
>
Is this really a HID_QUIRK_MULTI_INPUT device (Multiple controllers on
one device, for example a 2-in-1 adapter)? Just asking because your
previous patch didn't have this.
If this is not the case, there is also no need to have 2 new Kconfig
entries, but a simple FF-only entry (see ZEROPLUS_FF / hid-zpff.c).
--
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-05 18:32 ` Anssi Hannula
@ 2008-12-05 20:49 ` Łukasz Lubojański
2008-12-06 12:08 ` Jiri Slaby
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Łukasz Lubojański @ 2008-12-05 20:49 UTC (permalink / raw)
To: Anssi Hannula; +Cc: Jiri Kosina, linux-input
[-- Attachment #1: Type: text/plain, Size: 3144 bytes --]
On Fri, Dec 5, 2008 at 7:32 PM, Anssi Hannula <anssi.hannula@gmail.com> wrote:
> Łukasz Lubojański wrote:
>>
>> On Thu, Dec 4, 2008 at 9:35 PM, Łukasz Lubojański
>> <lukasz@lubojanski.info> wrote:
>>>
>>> 2008/11/29 Jiri Kosina <jkosina@suse.cz>:
>>>>
>>>> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>>>>
>>>>>> It seems the protocol resembles more the hid-lg2ff one. The
>>>>>> differences
>>>>>> are the additional 0xfa 0xfe 0x0 report sent to the device, and the
>>>>>> missing 0xf3 stop command.
>>>>>
>>>>> Yep - different reports are send in case of Pantherlord and GreenAsia
>>>>> 0x12 - It could be implemented in it but it will require checking what
>>>>> hardware is used and send different reports.
>>>>
>>>> OK, so as the reports are not really identical, and in the future we
>>>> might
>>>> discover that there are many more other Greenasia devices which require
>>>> a
>>>> slightly different handling as well, I would rather prefer to have it as
>>>> a
>>>> separate driver, to avoid additions of here-and-there device-specific
>>>> quirks to random places in the code. That's exactly what we are trying
>>>> to
>>>> avoid with the HID bus approach in the first place.
>>>>
>>>> So I think separate driver is fine.
>>>>
>>>> Thanks to both of you.
>>>>
>>>> --
>>>> Jiri Kosina
>>>> SUSE Labs
>>>
>>> Hi,
>>>
>>> Here is new version of the GreenAsia patch - I hope this time
>>> everything will be OK. It is based on the Pantherlord.
>>>
>>> Sorry to take so long but I have problems with the 2.6.28 (2.6.28-rc6
>>> was not loading my driver and 2.6.28-rc7 is crashing when IO APIC is
>>> enabled). Anyway I done it and I'm waiting for your feedback :D
>
>
>> +static const signed short ff_rumble[] = {
>> + FF_RUMBLE,
>> + -1
>> +};
>
> This seems unnecessary.
>
>> +
>> + list_for_each_entry(hidinput, &hid->inputs, list) {
>> +
>> + report_ptr = report_ptr->next;
>> +
>> + if (report_ptr == report_list) {
>> + dev_err(&hid->dev, "required output report is "
>> + "missing\n");
>> + return -ENODEV;
>> + }
>
> [...]
>>
>> + if (id->driver_data)
>> + hdev->quirks |= HID_QUIRK_MULTI_INPUT;
>>
>
> Is this really a HID_QUIRK_MULTI_INPUT device (Multiple controllers on one
> device, for example a 2-in-1 adapter)? Just asking because your previous
> patch didn't have this.
>
> If this is not the case, there is also no need to have 2 new Kconfig
> entries, but a simple FF-only entry (see ZEROPLUS_FF / hid-zpff.c).
>
> --
> Anssi Hannula
>
>
In case of both devices that I have the HID_QUIRK_MULTI_INPUT is not
set - so I think the multi input code can be removed. I did that and
it still works properly in my test :D
I have seen that hid-zpff and hid-tmff are modules for FF only and
hid-pl is "dummy" support for the device and if selected also for the
FF. I was confused about it so I have chosen way of hid-pl because I
based on it.
Because the module supports only the FF now - I have changed module
name to hid-gaff.
regards
Lukasz Lubojanski
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: greenasia.diff --]
[-- Type: text/x-diff; name=greenasia.diff, Size: 7742 bytes --]
Signed-off-by: Lukasz Lubojanski <lukasz@lubojanski.info>
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b4fd8ca..47b83c5 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -245,6 +245,15 @@ config HID_SUNPLUS
---help---
Support for Sunplus wireless desktop.
+config GREENASIA_FF
+ tristate "GreenAsia (Product ID 0x12) force feedback support"
+ depends on USB_HID
+ select INPUT_FF_MEMLESS
+ ---help---
+ Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
+ (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635) or adapter
+ and want to enable force feedback support for it.
+
config THRUSTMASTER_FF
tristate "ThrustMaster devices support"
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index b09e43e..dc33bf6 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
obj-$(CONFIG_HID_SONY) += hid-sony.o
obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
+obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o
obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 40df3e1..f2184cf 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1269,6 +1269,7 @@ static const struct hid_device_id hid_blacklist[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index e148f86..76df2ff 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -58,6 +58,9 @@ static int __init hid_dummy_init(void)
#ifdef CONFIG_HID_SUNPLUS_MODULE
HID_COMPAT_CALL_DRIVER(sunplus);
#endif
+#ifdef CONFIG_GREENASIA_FF_MODULE
+ HID_COMPAT_CALL_DRIVER(greenasia);
+#endif
#ifdef CONFIG_THRUSTMASTER_FF_MODULE
HID_COMPAT_CALL_DRIVER(thrustmaster);
#endif
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
new file mode 100644
index 0000000..c25673e
--- /dev/null
+++ b/drivers/hid/hid-gaff.c
@@ -0,0 +1,196 @@
+/*
+ * Force feedback support for GreenAsia (Product ID 0x12) based devices
+ *
+ * The devices are distributed under various names and the same USB device ID
+ * can be used in many game controllers.
+ *
+ *
+ * 0e8f:0012 "GreenAsia Inc. USB Joystick "
+ * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
+ *
+ * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
+ */
+
+/*
+ * 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-gaff: " format "\n" , ## arg)
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include "hid-ids.h"
+#include "usbhid/usbhid.h"
+
+struct gaff_device {
+ struct hid_report *report;
+};
+
+static int hid_gaff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct gaff_device *gaff = 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 * 0xfe / 0xffff;
+ right = right * 0xfe / 0xffff;
+
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x0;
+ gaff->report->field[0]->value[2] = right;
+ gaff->report->field[0]->value[3] = 0;
+ gaff->report->field[0]->value[4] = left;
+ gaff->report->field[0]->value[5] = 0;
+ debug("running with 0x%02x 0x%02x", left, right);
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ gaff->report->field[0]->value[2] = 0x0;
+ gaff->report->field[0]->value[4] = 0x0;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ return 0;
+}
+
+static int gaff_init(struct hid_device *hid)
+{
+ struct gaff_device *gaff;
+ struct hid_report *report;
+ struct hid_input *hidinput = list_entry(hid->inputs.next,
+ struct hid_input, list);
+ struct list_head *report_list =
+ &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+ struct list_head *report_ptr = report_list;
+ struct input_dev *dev = hidinput->input;
+ int error;
+
+ if (list_empty(report_list)) {
+ dev_err(&hid->dev, "no output reports found\n");
+ return -ENODEV;
+ }
+
+ report_ptr = report_ptr->next;
+
+ if (report_ptr == report_list) {
+ dev_err(&hid->dev, "required output report is "
+ "missing\n");
+ return -ENODEV;
+ }
+
+ report = list_entry(report_ptr, struct hid_report, list);
+ if (report->maxfield < 1) {
+ dev_err(&hid->dev, "no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 4) {
+ dev_err(&hid->dev, "not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
+ if (!gaff)
+ return -ENOMEM;
+
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, gaff, hid_gaff_play);
+ if (error) {
+ kfree(gaff);
+ return error;
+ }
+
+ gaff->report = report;
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x00;
+ gaff->report->field[0]->value[2] = 0x00;
+ gaff->report->field[0]->value[3] = 0x00;
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ dev_info(&hid->dev, "hid-gaff: Force Feedback for GreenAsia 0x12"
+ " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
+
+ return 0;
+}
+
+static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret;
+
+ debug("hid-gaff: Greenasia HID hardware probe...");
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "parse failed\n");
+ goto err;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+ if (ret) {
+ dev_err(&hdev->dev, "hw start failed\n");
+ goto err;
+ }
+
+ gaff_init(hdev);
+
+ return 0;
+err:
+ return ret;
+}
+
+static const struct hid_device_id ga_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, ga_devices);
+
+static struct hid_driver ga_driver = {
+ .name = "greenasia",
+ .id_table = ga_devices,
+ .probe = ga_probe,
+};
+
+static int ga_init(void)
+{
+ return hid_register_driver(&ga_driver);
+}
+
+static void ga_exit(void)
+{
+ hid_unregister_driver(&ga_driver);
+}
+
+module_init(ga_init);
+module_exit(ga_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(greenasia);
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-05 20:49 ` Łukasz Lubojański
@ 2008-12-06 12:08 ` Jiri Slaby
2008-12-06 15:50 ` Anssi Hannula
[not found] ` <alpine.LNX.1.10.0812111610330.21089@jikos.suse.cz>
2 siblings, 0 replies; 17+ messages in thread
From: Jiri Slaby @ 2008-12-06 12:08 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: Anssi Hannula, Jiri Kosina, linux-input
On 12/05/2008 09:49 PM, Łukasz Lubojański wrote:
> Because the module supports only the FF now - I have changed module
> name to hid-gaff.
------=_Part_46985_7823613.1228510186768
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
Content-Disposition: inline
:(
+#define debug(format, arg...) pr_debug("hid-gaff: " format "\n" , ## arg)
You don't need yet another pr_debug wrapper, use dev_dbg instead all over the code.
I would call the hid driver "hid-gaff" and won't add this to every print --
dev_* calls will do it on their own.
+static int ga_init(void)
mark as __init
+static void ga_exit(void)
mark as __exit
Otherwise looks good!
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-05 20:49 ` Łukasz Lubojański
2008-12-06 12:08 ` Jiri Slaby
@ 2008-12-06 15:50 ` Anssi Hannula
[not found] ` <alpine.LNX.1.10.0812111610330.21089@jikos.suse.cz>
2 siblings, 0 replies; 17+ messages in thread
From: Anssi Hannula @ 2008-12-06 15:50 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: Jiri Kosina, linux-input
Łukasz Lubojański wrote:
> On Fri, Dec 5, 2008 at 7:32 PM, Anssi Hannula <anssi.hannula@gmail.com> wrote:
>> Łukasz Lubojański wrote:
>>> On Thu, Dec 4, 2008 at 9:35 PM, Łukasz Lubojański
>>> <lukasz@lubojanski.info> wrote:
>>>> 2008/11/29 Jiri Kosina <jkosina@suse.cz>:
>>>>> On Fri, 28 Nov 2008, Łukasz Lubojański wrote:
>>>>>
>>>>>>> It seems the protocol resembles more the hid-lg2ff one. The
>>>>>>> differences
>>>>>>> are the additional 0xfa 0xfe 0x0 report sent to the device, and the
>>>>>>> missing 0xf3 stop command.
>>>>>> Yep - different reports are send in case of Pantherlord and GreenAsia
>>>>>> 0x12 - It could be implemented in it but it will require checking what
>>>>>> hardware is used and send different reports.
>>>>> OK, so as the reports are not really identical, and in the future we
>>>>> might
>>>>> discover that there are many more other Greenasia devices which require
>>>>> a
>>>>> slightly different handling as well, I would rather prefer to have it as
>>>>> a
>>>>> separate driver, to avoid additions of here-and-there device-specific
>>>>> quirks to random places in the code. That's exactly what we are trying
>>>>> to
>>>>> avoid with the HID bus approach in the first place.
>>>>>
>>>>> So I think separate driver is fine.
>>>>>
>>>>> Thanks to both of you.
>>>>>
>>>>> --
>>>>> Jiri Kosina
>>>>> SUSE Labs
>>>> Hi,
>>>>
>>>> Here is new version of the GreenAsia patch - I hope this time
>>>> everything will be OK. It is based on the Pantherlord.
>>>>
>>>> Sorry to take so long but I have problems with the 2.6.28 (2.6.28-rc6
>>>> was not loading my driver and 2.6.28-rc7 is crashing when IO APIC is
>>>> enabled). Anyway I done it and I'm waiting for your feedback :D
>>
>> Is this really a HID_QUIRK_MULTI_INPUT device (Multiple controllers on one
>> device, for example a 2-in-1 adapter)? Just asking because your previous
>> patch didn't have this.
>>
>> If this is not the case, there is also no need to have 2 new Kconfig
>> entries, but a simple FF-only entry (see ZEROPLUS_FF / hid-zpff.c).
>>
>
> In case of both devices that I have the HID_QUIRK_MULTI_INPUT is not
> set - so I think the multi input code can be removed. I did that and
> it still works properly in my test :D
>
> I have seen that hid-zpff and hid-tmff are modules for FF only and
> hid-pl is "dummy" support for the device and if selected also for the
> FF. I was confused about it so I have chosen way of hid-pl because I
> based on it.
hid-pl just sets HID_QUIRK_MULTI_INPUT when FF is disabled. For gaff we
do not need that.
> Because the module supports only the FF now - I have changed module
> name to hid-gaff.
[...]
> + gaff->report->field[0]->value[0] = 0x51;
> + gaff->report->field[0]->value[1] = 0x0;
> + gaff->report->field[0]->value[2] = right;
> + gaff->report->field[0]->value[3] = 0;
> + gaff->report->field[0]->value[4] = left;
> + gaff->report->field[0]->value[5] = 0;
[...]
> + if (list_empty(report_list)) {
> + dev_err(&hid->dev, "no output reports found\n");
> + return -ENODEV;
> + }
> +
> + report_ptr = report_ptr->next;
> + if (report_ptr == report_list) {
> + dev_err(&hid->dev, "required output report is "
> + "missing\n");
> + return -ENODEV;
> + }
Unneeded test. list_empty() call above already confirmed that there are
output reports.
> + report = list_entry(report_ptr, struct hid_report, list);
> + if (report->maxfield < 1) {
> + dev_err(&hid->dev, "no fields in the report\n");
> + return -ENODEV;
> + }
> +
> + if (report->field[0]->report_count < 4) {
> + dev_err(&hid->dev, "not enough values in the field\n");
Here you test for only 4, while in hid_gaff_play() you use 6.
--
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
[not found] ` <alpine.LNX.1.10.0812111610330.21089@jikos.suse.cz>
@ 2008-12-11 19:46 ` Łukasz Lubojański
2008-12-11 21:13 ` Jiri Kosina
0 siblings, 1 reply; 17+ messages in thread
From: Łukasz Lubojański @ 2008-12-11 19:46 UTC (permalink / raw)
To: Jiri Kosina, linux-input
[-- Attachment #1: Type: text/plain, Size: 577 bytes --]
On Thu, Dec 11, 2008 at 4:11 PM, Jiri Kosina <jkosina@suse.cz> wrote:
> Hi Lukasz,
>
> are you planning to re-submit your driver with comments from Jiri and
> Anssi included?
>
> Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
>
I was thinking it is already send - but it looks only Anssi have get
the changes.
So I resend the patch with changed debug to dbg_hid, fixed
report_count, init & exit
functions are properly marked.
I hope I'm now closer to the happy end :D
ps. Should I still send full diff every time or only the changes
between my posts ?
regards
Lukasz Lubojanski
[-- Attachment #2: greenasia.diff --]
[-- Type: application/octet-stream, Size: 7524 bytes --]
Signed-off-by: Lukasz Lubojanski <lukasz@lubojanski.info>
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b4fd8ca..47b83c5 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -245,6 +245,15 @@ config HID_SUNPLUS
---help---
Support for Sunplus wireless desktop.
+config GREENASIA_FF
+ tristate "GreenAsia (Product ID 0x12) force feedback support"
+ depends on USB_HID
+ select INPUT_FF_MEMLESS
+ ---help---
+ Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
+ (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635) or adapter
+ and want to enable force feedback support for it.
+
config THRUSTMASTER_FF
tristate "ThrustMaster devices support"
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index b09e43e..dc33bf6 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
obj-$(CONFIG_HID_SONY) += hid-sony.o
obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
+obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o
obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 40df3e1..f2184cf 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1269,6 +1269,7 @@ static const struct hid_device_id hid_blacklist[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index e148f86..76df2ff 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -58,6 +58,9 @@ static int __init hid_dummy_init(void)
#ifdef CONFIG_HID_SUNPLUS_MODULE
HID_COMPAT_CALL_DRIVER(sunplus);
#endif
+#ifdef CONFIG_GREENASIA_FF_MODULE
+ HID_COMPAT_CALL_DRIVER(greenasia);
+#endif
#ifdef CONFIG_THRUSTMASTER_FF_MODULE
HID_COMPAT_CALL_DRIVER(thrustmaster);
#endif
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
new file mode 100644
index 0000000..71211f6
--- /dev/null
+++ b/drivers/hid/hid-gaff.c
@@ -0,0 +1,185 @@
+/*
+ * Force feedback support for GreenAsia (Product ID 0x12) based devices
+ *
+ * The devices are distributed under various names and the same USB device ID
+ * can be used in many game controllers.
+ *
+ *
+ * 0e8f:0012 "GreenAsia Inc. USB Joystick "
+ * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
+ *
+ * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
+ */
+
+/*
+ * 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
+ */
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include "hid-ids.h"
+#include "usbhid/usbhid.h"
+
+struct gaff_device {
+ struct hid_report *report;
+};
+
+static int hid_gaff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct gaff_device *gaff = data;
+ int left, right;
+
+ left = effect->u.rumble.strong_magnitude;
+ right = effect->u.rumble.weak_magnitude;
+
+ dbg_hid("called with 0x%04x 0x%04x", left, right);
+
+ left = left * 0xfe / 0xffff;
+ right = right * 0xfe / 0xffff;
+
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x0;
+ gaff->report->field[0]->value[2] = right;
+ gaff->report->field[0]->value[3] = 0;
+ gaff->report->field[0]->value[4] = left;
+ gaff->report->field[0]->value[5] = 0;
+ dbg_hid("running with 0x%02x 0x%02x", left, right);
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+ gaff->report->field[0]->value[2] = 0x0;
+ gaff->report->field[0]->value[4] = 0x0;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ return 0;
+}
+
+static int gaff_init(struct hid_device *hid)
+{
+ struct gaff_device *gaff;
+ struct hid_report *report;
+ struct hid_input *hidinput = list_entry(hid->inputs.next,
+ struct hid_input, list);
+ struct list_head *report_list =
+ &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+ struct list_head *report_ptr = report_list;
+ struct input_dev *dev = hidinput->input;
+ int error;
+
+ if (list_empty(report_list)) {
+ dev_err(&hid->dev, "no output reports found\n");
+ return -ENODEV;
+ }
+
+ report_ptr = report_ptr->next;
+
+ report = list_entry(report_ptr, struct hid_report, list);
+ if (report->maxfield < 1) {
+ dev_err(&hid->dev, "no fields in the report\n");
+ return -ENODEV;
+ }
+
+ if (report->field[0]->report_count < 6) {
+ dev_err(&hid->dev, "not enough values in the field\n");
+ return -ENODEV;
+ }
+
+ gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
+ if (!gaff)
+ return -ENOMEM;
+
+ set_bit(FF_RUMBLE, dev->ffbit);
+
+ error = input_ff_create_memless(dev, gaff, hid_gaff_play);
+ if (error) {
+ kfree(gaff);
+ return error;
+ }
+
+ gaff->report = report;
+ gaff->report->field[0]->value[0] = 0x51;
+ gaff->report->field[0]->value[1] = 0x00;
+ gaff->report->field[0]->value[2] = 0x00;
+ gaff->report->field[0]->value[3] = 0x00;
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ gaff->report->field[0]->value[0] = 0xfa;
+ gaff->report->field[0]->value[1] = 0xfe;
+
+ usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
+
+ dev_info(&hid->dev, "Force Feedback for GreenAsia 0x12"
+ " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
+
+ return 0;
+}
+
+static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret;
+
+ dev_dbg(&hdev->dev, "Greenasia HID hardware probe...");
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "parse failed\n");
+ goto err;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+ if (ret) {
+ dev_err(&hdev->dev, "hw start failed\n");
+ goto err;
+ }
+
+ gaff_init(hdev);
+
+ return 0;
+err:
+ return ret;
+}
+
+static const struct hid_device_id ga_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, ga_devices);
+
+static struct hid_driver ga_driver = {
+ .name = "greenasia",
+ .id_table = ga_devices,
+ .probe = ga_probe,
+};
+
+static int __init ga_init(void)
+{
+ return hid_register_driver(&ga_driver);
+}
+
+static void __exit ga_exit(void)
+{
+ hid_unregister_driver(&ga_driver);
+}
+
+module_init(ga_init);
+module_exit(ga_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(greenasia);
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: New Force Feedback device support - GreenAsia 0x12
2008-12-11 19:46 ` Łukasz Lubojański
@ 2008-12-11 21:13 ` Jiri Kosina
0 siblings, 0 replies; 17+ messages in thread
From: Jiri Kosina @ 2008-12-11 21:13 UTC (permalink / raw)
To: Łukasz Lubojański; +Cc: linux-input
[-- Attachment #1: Type: TEXT/PLAIN, Size: 501 bytes --]
On Thu, 11 Dec 2008, Łukasz Lubojański wrote:
> So I resend the patch with changed debug to dbg_hid, fixed report_count,
> init & exit functions are properly marked.
I have applied your patch to my tree.
> ps. Should I still send full diff every time or only the changes between
> my posts ?
Up to now (as the driver hasn't been merged yet), full diffs were the
proper option. Now, as the code is merged, please send only incremental
patches on top of it.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-12-11 21:13 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 22:33 New Force Feedback device support - GreenAsia 0x12 Łukasz Lubojański
2008-11-26 23:01 ` Marek Vasut
2008-11-26 23:01 ` Jiri Slaby
2008-11-27 12:41 ` Jiri Kosina
2008-11-28 6:18 ` Łukasz Lubojański
2008-11-28 14:21 ` Jiri Kosina
2008-11-28 18:27 ` Anssi Hannula
2008-11-28 19:08 ` Łukasz Lubojański
2008-11-29 22:30 ` Jiri Kosina
2008-12-04 20:35 ` Łukasz Lubojański
2008-12-04 20:55 ` Łukasz Lubojański
2008-12-05 18:32 ` Anssi Hannula
2008-12-05 20:49 ` Łukasz Lubojański
2008-12-06 12:08 ` Jiri Slaby
2008-12-06 15:50 ` Anssi Hannula
[not found] ` <alpine.LNX.1.10.0812111610330.21089@jikos.suse.cz>
2008-12-11 19:46 ` Łukasz Lubojański
2008-12-11 21:13 ` 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).