diff options
author | Lukasz Lubojanski <lukasz@lubojanski.info> | 2008-12-11 16:07:59 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2009-01-03 19:00:53 -0500 |
commit | 42859e0bd21daba9974757fcfe4a4dde265fe28d (patch) | |
tree | 564a60ccdcd1197a052b356dc95e10197d31ded9 /drivers | |
parent | d04b431e3d769fbbf26c4f4072002375c8cc4ed9 (diff) |
HID: force feedback driver for GreenAsia 0x12 PID
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.
Signed-off-by: Lukasz Lubojanski <lukasz@lubojanski.info>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/Kconfig | 9 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-dummy.c | 3 | ||||
-rw-r--r-- | drivers/hid/hid-gaff.c | 185 |
5 files changed, 199 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 1033129d4767..81dd9b8eeeaa 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -237,6 +237,15 @@ config HID_SUNPLUS | |||
237 | ---help--- | 237 | ---help--- |
238 | Support for Sunplus wireless desktop. | 238 | Support for Sunplus wireless desktop. |
239 | 239 | ||
240 | config GREENASIA_FF | ||
241 | tristate "GreenAsia (Product ID 0x12) force feedback support" | ||
242 | depends on USB_HID | ||
243 | select INPUT_FF_MEMLESS | ||
244 | ---help--- | ||
245 | Say Y here if you have a GreenAsia (Product ID 0x12) based game controller | ||
246 | (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635) or adapter | ||
247 | and want to enable force feedback support for it. | ||
248 | |||
240 | config THRUSTMASTER_FF | 249 | config THRUSTMASTER_FF |
241 | tristate "ThrustMaster devices support" | 250 | tristate "ThrustMaster devices support" |
242 | depends on USB_HID | 251 | depends on USB_HID |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 7d34e8bf3de5..3354eacffa49 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -37,6 +37,7 @@ obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o | |||
37 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o | 37 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o |
38 | obj-$(CONFIG_HID_SONY) += hid-sony.o | 38 | obj-$(CONFIG_HID_SONY) += hid-sony.o |
39 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o | 39 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o |
40 | obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o | ||
40 | obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o | 41 | obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o |
41 | obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o | 42 | obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o |
42 | 43 | ||
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 34cc3b0d01f6..8fd35a697c5b 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1265,6 +1265,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1265 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, | 1265 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, |
1266 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, | 1266 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, |
1267 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, | 1267 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, |
1268 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, | ||
1268 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, | 1269 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, |
1269 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, | 1270 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
1270 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, | 1271 | { 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 4a6af3cf192d..b4cc0f743d63 100644 --- a/drivers/hid/hid-dummy.c +++ b/drivers/hid/hid-dummy.c | |||
@@ -61,6 +61,9 @@ static int __init hid_dummy_init(void) | |||
61 | #ifdef CONFIG_HID_SUNPLUS_MODULE | 61 | #ifdef CONFIG_HID_SUNPLUS_MODULE |
62 | HID_COMPAT_CALL_DRIVER(sunplus); | 62 | HID_COMPAT_CALL_DRIVER(sunplus); |
63 | #endif | 63 | #endif |
64 | #ifdef CONFIG_GREENASIA_FF_MODULE | ||
65 | HID_COMPAT_CALL_DRIVER(greenasia); | ||
66 | #endif | ||
64 | #ifdef CONFIG_THRUSTMASTER_FF_MODULE | 67 | #ifdef CONFIG_THRUSTMASTER_FF_MODULE |
65 | HID_COMPAT_CALL_DRIVER(thrustmaster); | 68 | HID_COMPAT_CALL_DRIVER(thrustmaster); |
66 | #endif | 69 | #endif |
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c new file mode 100644 index 000000000000..71211f6a4f02 --- /dev/null +++ b/drivers/hid/hid-gaff.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * Force feedback support for GreenAsia (Product ID 0x12) based devices | ||
3 | * | ||
4 | * The devices are distributed under various names and the same USB device ID | ||
5 | * can be used in many game controllers. | ||
6 | * | ||
7 | * | ||
8 | * 0e8f:0012 "GreenAsia Inc. USB Joystick " | ||
9 | * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635. | ||
10 | * | ||
11 | * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info> | ||
12 | */ | ||
13 | |||
14 | /* | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 | */ | ||
29 | |||
30 | #include <linux/input.h> | ||
31 | #include <linux/usb.h> | ||
32 | #include <linux/hid.h> | ||
33 | #include "hid-ids.h" | ||
34 | #include "usbhid/usbhid.h" | ||
35 | |||
36 | struct gaff_device { | ||
37 | struct hid_report *report; | ||
38 | }; | ||
39 | |||
40 | static int hid_gaff_play(struct input_dev *dev, void *data, | ||
41 | struct ff_effect *effect) | ||
42 | { | ||
43 | struct hid_device *hid = input_get_drvdata(dev); | ||
44 | struct gaff_device *gaff = data; | ||
45 | int left, right; | ||
46 | |||
47 | left = effect->u.rumble.strong_magnitude; | ||
48 | right = effect->u.rumble.weak_magnitude; | ||
49 | |||
50 | dbg_hid("called with 0x%04x 0x%04x", left, right); | ||
51 | |||
52 | left = left * 0xfe / 0xffff; | ||
53 | right = right * 0xfe / 0xffff; | ||
54 | |||
55 | gaff->report->field[0]->value[0] = 0x51; | ||
56 | gaff->report->field[0]->value[1] = 0x0; | ||
57 | gaff->report->field[0]->value[2] = right; | ||
58 | gaff->report->field[0]->value[3] = 0; | ||
59 | gaff->report->field[0]->value[4] = left; | ||
60 | gaff->report->field[0]->value[5] = 0; | ||
61 | dbg_hid("running with 0x%02x 0x%02x", left, right); | ||
62 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); | ||
63 | |||
64 | gaff->report->field[0]->value[0] = 0xfa; | ||
65 | gaff->report->field[0]->value[1] = 0xfe; | ||
66 | gaff->report->field[0]->value[2] = 0x0; | ||
67 | gaff->report->field[0]->value[4] = 0x0; | ||
68 | |||
69 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int gaff_init(struct hid_device *hid) | ||
75 | { | ||
76 | struct gaff_device *gaff; | ||
77 | struct hid_report *report; | ||
78 | struct hid_input *hidinput = list_entry(hid->inputs.next, | ||
79 | struct hid_input, list); | ||
80 | struct list_head *report_list = | ||
81 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
82 | struct list_head *report_ptr = report_list; | ||
83 | struct input_dev *dev = hidinput->input; | ||
84 | int error; | ||
85 | |||
86 | if (list_empty(report_list)) { | ||
87 | dev_err(&hid->dev, "no output reports found\n"); | ||
88 | return -ENODEV; | ||
89 | } | ||
90 | |||
91 | report_ptr = report_ptr->next; | ||
92 | |||
93 | report = list_entry(report_ptr, struct hid_report, list); | ||
94 | if (report->maxfield < 1) { | ||
95 | dev_err(&hid->dev, "no fields in the report\n"); | ||
96 | return -ENODEV; | ||
97 | } | ||
98 | |||
99 | if (report->field[0]->report_count < 6) { | ||
100 | dev_err(&hid->dev, "not enough values in the field\n"); | ||
101 | return -ENODEV; | ||
102 | } | ||
103 | |||
104 | gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL); | ||
105 | if (!gaff) | ||
106 | return -ENOMEM; | ||
107 | |||
108 | set_bit(FF_RUMBLE, dev->ffbit); | ||
109 | |||
110 | error = input_ff_create_memless(dev, gaff, hid_gaff_play); | ||
111 | if (error) { | ||
112 | kfree(gaff); | ||
113 | return error; | ||
114 | } | ||
115 | |||
116 | gaff->report = report; | ||
117 | gaff->report->field[0]->value[0] = 0x51; | ||
118 | gaff->report->field[0]->value[1] = 0x00; | ||
119 | gaff->report->field[0]->value[2] = 0x00; | ||
120 | gaff->report->field[0]->value[3] = 0x00; | ||
121 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); | ||
122 | |||
123 | gaff->report->field[0]->value[0] = 0xfa; | ||
124 | gaff->report->field[0]->value[1] = 0xfe; | ||
125 | |||
126 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); | ||
127 | |||
128 | dev_info(&hid->dev, "Force Feedback for GreenAsia 0x12" | ||
129 | " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n"); | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id) | ||
135 | { | ||
136 | int ret; | ||
137 | |||
138 | dev_dbg(&hdev->dev, "Greenasia HID hardware probe..."); | ||
139 | |||
140 | ret = hid_parse(hdev); | ||
141 | if (ret) { | ||
142 | dev_err(&hdev->dev, "parse failed\n"); | ||
143 | goto err; | ||
144 | } | ||
145 | |||
146 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | ||
147 | if (ret) { | ||
148 | dev_err(&hdev->dev, "hw start failed\n"); | ||
149 | goto err; | ||
150 | } | ||
151 | |||
152 | gaff_init(hdev); | ||
153 | |||
154 | return 0; | ||
155 | err: | ||
156 | return ret; | ||
157 | } | ||
158 | |||
159 | static const struct hid_device_id ga_devices[] = { | ||
160 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), }, | ||
161 | { } | ||
162 | }; | ||
163 | MODULE_DEVICE_TABLE(hid, ga_devices); | ||
164 | |||
165 | static struct hid_driver ga_driver = { | ||
166 | .name = "greenasia", | ||
167 | .id_table = ga_devices, | ||
168 | .probe = ga_probe, | ||
169 | }; | ||
170 | |||
171 | static int __init ga_init(void) | ||
172 | { | ||
173 | return hid_register_driver(&ga_driver); | ||
174 | } | ||
175 | |||
176 | static void __exit ga_exit(void) | ||
177 | { | ||
178 | hid_unregister_driver(&ga_driver); | ||
179 | } | ||
180 | |||
181 | module_init(ga_init); | ||
182 | module_exit(ga_exit); | ||
183 | MODULE_LICENSE("GPL"); | ||
184 | |||
185 | HID_COMPAT_LOAD_DRIVER(greenasia); | ||