diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2009-05-13 04:54:38 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2009-05-15 08:28:44 -0400 |
commit | fac733f029251a393c42a8313432f2d9fe43bb83 (patch) | |
tree | a552e16369cb5a19a9527962060e06195610d3ff | |
parent | ca2dcd40f54c8928b3994712a6cadd2078a087fa (diff) |
HID: force feedback support for SmartJoy PLUS PS2/USB adapter
This driver adds force feedback support for SmartJoy PLUS PS2/USB adapter. I
made this driver one device spesific instead of making generic 'wisegroup-ff'
because I have another Wisegroup PS2/USB adapter that doesn't work same way as
SmartJoy PLUS. If another device that is compatible pops up, this driver could
be then renamed to something more generic.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/Kconfig | 15 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 1 | ||||
-rw-r--r-- | drivers/hid/hid-sjoy.c | 180 |
5 files changed, 198 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 21edf407bbda..4cdf846da62c 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -256,6 +256,21 @@ config GREENASIA_FF | |||
256 | (like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter | 256 | (like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter |
257 | and want to enable force feedback support for it. | 257 | and want to enable force feedback support for it. |
258 | 258 | ||
259 | config HID_SMARTJOYPLUS | ||
260 | tristate "SmartJoy PLUS PS2/USB adapter support" if EMBEDDED | ||
261 | depends on USB_HID | ||
262 | default !EMBEDDED | ||
263 | ---help--- | ||
264 | Support for SmartJoy PLUS PS2/USB adapter. | ||
265 | |||
266 | config SMARTJOYPLUS_FF | ||
267 | bool "SmartJoy PLUS PS2/USB adapter force feedback support" | ||
268 | depends on HID_SMARTJOYPLUS | ||
269 | select INPUT_FF_MEMLESS | ||
270 | ---help--- | ||
271 | Say Y here if you have a SmartJoy PLUS PS2/USB adapter and want to | ||
272 | enable force feedback support for it. | ||
273 | |||
259 | config HID_TOPSEED | 274 | config HID_TOPSEED |
260 | tristate "TopSeed Cyberlink remote control support" if EMBEDDED | 275 | tristate "TopSeed Cyberlink remote control support" if EMBEDDED |
261 | depends on USB_HID | 276 | depends on USB_HID |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 39cebcfa898c..eddd5b633b63 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -34,6 +34,7 @@ obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o | |||
34 | obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o | 34 | obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o |
35 | obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o | 35 | obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o |
36 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o | 36 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o |
37 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o | ||
37 | obj-$(CONFIG_HID_SONY) += hid-sony.o | 38 | obj-$(CONFIG_HID_SONY) += hid-sony.o |
38 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o | 39 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o |
39 | obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o | 40 | obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9f38ab874c93..f2c21d5d24e8 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1312,6 +1312,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1312 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, | 1312 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, |
1313 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, | 1313 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, |
1314 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, | 1314 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, |
1315 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, | ||
1315 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, | 1316 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, |
1316 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, | 1317 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
1317 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, | 1318 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index b519692732db..630101037921 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -417,6 +417,7 @@ | |||
417 | #define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81 | 417 | #define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81 |
418 | 418 | ||
419 | #define USB_VENDOR_ID_WISEGROUP 0x0925 | 419 | #define USB_VENDOR_ID_WISEGROUP 0x0925 |
420 | #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 | ||
420 | #define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 | 421 | #define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 |
421 | #define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 | 422 | #define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 |
422 | #define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 | 423 | #define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 |
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c new file mode 100644 index 000000000000..eab169e5c371 --- /dev/null +++ b/drivers/hid/hid-sjoy.c | |||
@@ -0,0 +1,180 @@ | |||
1 | /* | ||
2 | * Force feedback support for SmartJoy PLUS PS2->USB adapter | ||
3 | * | ||
4 | * Copyright (c) 2009 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | ||
5 | * | ||
6 | * Based of hid-pl.c and hid-gaff.c | ||
7 | * Copyright (c) 2007, 2009 Anssi Hannula <anssi.hannula@gmail.com> | ||
8 | * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info> | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | /* #define DEBUG */ | ||
28 | |||
29 | #include <linux/input.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/hid.h> | ||
32 | #include "hid-ids.h" | ||
33 | |||
34 | #ifdef CONFIG_SMARTJOYPLUS_FF | ||
35 | #include "usbhid/usbhid.h" | ||
36 | |||
37 | struct sjoyff_device { | ||
38 | struct hid_report *report; | ||
39 | }; | ||
40 | |||
41 | static int hid_sjoyff_play(struct input_dev *dev, void *data, | ||
42 | struct ff_effect *effect) | ||
43 | { | ||
44 | struct hid_device *hid = input_get_drvdata(dev); | ||
45 | struct sjoyff_device *sjoyff = data; | ||
46 | u32 left, right; | ||
47 | |||
48 | left = effect->u.rumble.strong_magnitude; | ||
49 | right = effect->u.rumble.weak_magnitude; | ||
50 | dev_dbg(&dev->dev, "called with 0x%08x 0x%08x\n", left, right); | ||
51 | |||
52 | left = left * 0xff / 0xffff; | ||
53 | right = (right != 0); /* on/off only */ | ||
54 | |||
55 | sjoyff->report->field[0]->value[1] = right; | ||
56 | sjoyff->report->field[0]->value[2] = left; | ||
57 | dev_dbg(&dev->dev, "running with 0x%02x 0x%02x\n", left, right); | ||
58 | usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT); | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static int sjoyff_init(struct hid_device *hid) | ||
64 | { | ||
65 | struct sjoyff_device *sjoyff; | ||
66 | struct hid_report *report; | ||
67 | struct hid_input *hidinput = list_entry(hid->inputs.next, | ||
68 | struct hid_input, list); | ||
69 | struct list_head *report_list = | ||
70 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
71 | struct list_head *report_ptr = report_list; | ||
72 | struct input_dev *dev; | ||
73 | int error; | ||
74 | |||
75 | if (list_empty(report_list)) { | ||
76 | dev_err(&hid->dev, "no output reports found\n"); | ||
77 | return -ENODEV; | ||
78 | } | ||
79 | |||
80 | report_ptr = report_ptr->next; | ||
81 | |||
82 | if (report_ptr == report_list) { | ||
83 | dev_err(&hid->dev, "required output report is " | ||
84 | "missing\n"); | ||
85 | return -ENODEV; | ||
86 | } | ||
87 | |||
88 | report = list_entry(report_ptr, struct hid_report, list); | ||
89 | if (report->maxfield < 1) { | ||
90 | dev_err(&hid->dev, "no fields in the report\n"); | ||
91 | return -ENODEV; | ||
92 | } | ||
93 | |||
94 | if (report->field[0]->report_count < 3) { | ||
95 | dev_err(&hid->dev, "not enough values in the field\n"); | ||
96 | return -ENODEV; | ||
97 | } | ||
98 | |||
99 | sjoyff = kzalloc(sizeof(struct sjoyff_device), GFP_KERNEL); | ||
100 | if (!sjoyff) | ||
101 | return -ENOMEM; | ||
102 | |||
103 | dev = hidinput->input; | ||
104 | |||
105 | set_bit(FF_RUMBLE, dev->ffbit); | ||
106 | |||
107 | error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play); | ||
108 | if (error) { | ||
109 | kfree(sjoyff); | ||
110 | return error; | ||
111 | } | ||
112 | |||
113 | sjoyff->report = report; | ||
114 | sjoyff->report->field[0]->value[0] = 0x01; | ||
115 | sjoyff->report->field[0]->value[1] = 0x00; | ||
116 | sjoyff->report->field[0]->value[2] = 0x00; | ||
117 | usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT); | ||
118 | |||
119 | dev_info(&hid->dev, | ||
120 | "Force feedback for SmartJoy PLUS PS2/USB adapter\n"); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | #else | ||
125 | static inline int sjoyff_init(struct hid_device *hid) | ||
126 | { | ||
127 | return 0; | ||
128 | } | ||
129 | #endif | ||
130 | |||
131 | static int sjoy_probe(struct hid_device *hdev, const struct hid_device_id *id) | ||
132 | { | ||
133 | int ret; | ||
134 | |||
135 | ret = hid_parse(hdev); | ||
136 | if (ret) { | ||
137 | dev_err(&hdev->dev, "parse failed\n"); | ||
138 | goto err; | ||
139 | } | ||
140 | |||
141 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | ||
142 | if (ret) { | ||
143 | dev_err(&hdev->dev, "hw start failed\n"); | ||
144 | goto err; | ||
145 | } | ||
146 | |||
147 | sjoyff_init(hdev); | ||
148 | |||
149 | return 0; | ||
150 | err: | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | static const struct hid_device_id sjoy_devices[] = { | ||
155 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, | ||
156 | { } | ||
157 | }; | ||
158 | MODULE_DEVICE_TABLE(hid, sjoy_devices); | ||
159 | |||
160 | static struct hid_driver sjoy_driver = { | ||
161 | .name = "smartjoyplus", | ||
162 | .id_table = sjoy_devices, | ||
163 | .probe = sjoy_probe, | ||
164 | }; | ||
165 | |||
166 | static int sjoy_init(void) | ||
167 | { | ||
168 | return hid_register_driver(&sjoy_driver); | ||
169 | } | ||
170 | |||
171 | static void sjoy_exit(void) | ||
172 | { | ||
173 | hid_unregister_driver(&sjoy_driver); | ||
174 | } | ||
175 | |||
176 | module_init(sjoy_init); | ||
177 | module_exit(sjoy_exit); | ||
178 | MODULE_LICENSE("GPL"); | ||
179 | MODULE_AUTHOR("Jussi Kivilinna"); | ||
180 | |||