aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/Kconfig9
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-core.c4
-rw-r--r--drivers/hid/hid-dummy.c3
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-tmff.c (renamed from drivers/hid/usbhid/hid-tmff.c)132
-rw-r--r--drivers/hid/usbhid/Kconfig11
-rw-r--r--drivers/hid/usbhid/Makefile3
-rw-r--r--drivers/hid/usbhid/hid-ff.c6
-rw-r--r--include/linux/hid.h1
10 files changed, 106 insertions, 66 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index c836caba82d6..78e3ba9504f3 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -243,6 +243,15 @@ config HID_SUNPLUS
243 ---help--- 243 ---help---
244 Support for Sunplus WDesktop input device. 244 Support for Sunplus WDesktop input device.
245 245
246config THRUSTMASTER_FF
247 tristate "ThrustMaster devices support"
248 default m
249 depends on USB_HID
250 select INPUT_FF_MEMLESS
251 help
252 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
253 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel.
254
246endmenu 255endmenu
247 256
248endif # HID_SUPPORT 257endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index e60706835243..9bd6daf6aaa4 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
37obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 37obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
38obj-$(CONFIG_HID_SONY) += hid-sony.o 38obj-$(CONFIG_HID_SONY) += hid-sony.o
39obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 39obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
40obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
40 41
41obj-$(CONFIG_USB_HID) += usbhid/ 42obj-$(CONFIG_USB_HID) += usbhid/
42obj-$(CONFIG_USB_MOUSE) += usbhid/ 43obj-$(CONFIG_USB_MOUSE) += usbhid/
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 48a76e791e02..b0996ff1462b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1516,6 +1516,10 @@ static const struct hid_device_id hid_ignore_list[] = {
1516 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1516 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1517 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1517 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1518 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1518 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1519 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1520 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1519 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1523 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1520 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1524 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1525 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index 2f5d9a1a352c..ae122a122faa 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -55,6 +55,9 @@ static int __init hid_dummy_init(void)
55#ifdef CONFIG_HID_SUNPLUS_MODULE 55#ifdef CONFIG_HID_SUNPLUS_MODULE
56 HID_COMPAT_CALL_DRIVER(sunplus); 56 HID_COMPAT_CALL_DRIVER(sunplus);
57#endif 57#endif
58#ifdef CONFIG_THRUSTMASTER_FF_MODULE
59 HID_COMPAT_CALL_DRIVER(thrustmaster);
60#endif
58 61
59 return -EIO; 62 return -EIO;
60} 63}
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index fdd2d13036f7..b8cc0196ec00 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -357,6 +357,8 @@
357#define USB_DEVICE_ID_TENX_IBUDDY1 0x0001 357#define USB_DEVICE_ID_TENX_IBUDDY1 0x0001
358#define USB_DEVICE_ID_TENX_IBUDDY2 0x0002 358#define USB_DEVICE_ID_TENX_IBUDDY2 0x0002
359 359
360#define USB_VENDOR_ID_THRUSTMASTER 0x044f
361
360#define USB_VENDOR_ID_TOPMAX 0x0663 362#define USB_VENDOR_ID_TOPMAX 0x0663
361#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 363#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
362 364
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 144578b1a00c..be7ebe286a16 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -27,23 +27,17 @@
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */ 28 */
29 29
30#include <linux/hid.h>
30#include <linux/input.h> 31#include <linux/input.h>
31
32#undef DEBUG
33#include <linux/usb.h> 32#include <linux/usb.h>
34 33
35#include <linux/hid.h> 34#include "hid-ids.h"
36#include "usbhid.h" 35
36#include "usbhid/usbhid.h"
37 37
38/* Usages for thrustmaster devices I know about */ 38/* Usages for thrustmaster devices I know about */
39#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb) 39#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
40 40
41struct dev_type {
42 u16 idVendor;
43 u16 idProduct;
44 const signed short *ff;
45};
46
47static const signed short ff_rumble[] = { 41static const signed short ff_rumble[] = {
48 FF_RUMBLE, 42 FF_RUMBLE,
49 -1 43 -1
@@ -54,21 +48,13 @@ static const signed short ff_joystick[] = {
54 -1 48 -1
55}; 49};
56 50
57static const struct dev_type devices[] = {
58 { 0x44f, 0xb300, ff_rumble },
59 { 0x44f, 0xb304, ff_rumble },
60 { 0x44f, 0xb651, ff_rumble }, /* FGT Rumble Force Wheel */
61 { 0x44f, 0xb654, ff_joystick }, /* FGT Force Feedback Wheel */
62};
63
64struct tmff_device { 51struct tmff_device {
65 struct hid_report *report; 52 struct hid_report *report;
66 struct hid_field *ff_field; 53 struct hid_field *ff_field;
67}; 54};
68 55
69/* Changes values from 0 to 0xffff into values from minimum to maximum */ 56/* Changes values from 0 to 0xffff into values from minimum to maximum */
70static inline int hid_tmff_scale_u16(unsigned int in, 57static inline int tmff_scale_u16(unsigned int in, int minimum, int maximum)
71 int minimum, int maximum)
72{ 58{
73 int ret; 59 int ret;
74 60
@@ -81,8 +67,7 @@ static inline int hid_tmff_scale_u16(unsigned int in,
81} 67}
82 68
83/* Changes values from -0x80 to 0x7f into values from minimum to maximum */ 69/* Changes values from -0x80 to 0x7f into values from minimum to maximum */
84static inline int hid_tmff_scale_s8(int in, 70static inline int tmff_scale_s8(int in, int minimum, int maximum)
85 int minimum, int maximum)
86{ 71{
87 int ret; 72 int ret;
88 73
@@ -94,7 +79,8 @@ static inline int hid_tmff_scale_s8(int in,
94 return ret; 79 return ret;
95} 80}
96 81
97static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 82static int tmff_play(struct input_dev *dev, void *data,
83 struct ff_effect *effect)
98{ 84{
99 struct hid_device *hid = input_get_drvdata(dev); 85 struct hid_device *hid = input_get_drvdata(dev);
100 struct tmff_device *tmff = data; 86 struct tmff_device *tmff = data;
@@ -104,10 +90,10 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
104 90
105 switch (effect->type) { 91 switch (effect->type) {
106 case FF_CONSTANT: 92 case FF_CONSTANT:
107 x = hid_tmff_scale_s8(effect->u.ramp.start_level, 93 x = tmff_scale_s8(effect->u.ramp.start_level,
108 ff_field->logical_minimum, 94 ff_field->logical_minimum,
109 ff_field->logical_maximum); 95 ff_field->logical_maximum);
110 y = hid_tmff_scale_s8(effect->u.ramp.end_level, 96 y = tmff_scale_s8(effect->u.ramp.end_level,
111 ff_field->logical_minimum, 97 ff_field->logical_minimum,
112 ff_field->logical_maximum); 98 ff_field->logical_maximum);
113 99
@@ -118,10 +104,10 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
118 break; 104 break;
119 105
120 case FF_RUMBLE: 106 case FF_RUMBLE:
121 left = hid_tmff_scale_u16(effect->u.rumble.weak_magnitude, 107 left = tmff_scale_u16(effect->u.rumble.weak_magnitude,
122 ff_field->logical_minimum, 108 ff_field->logical_minimum,
123 ff_field->logical_maximum); 109 ff_field->logical_maximum);
124 right = hid_tmff_scale_u16(effect->u.rumble.strong_magnitude, 110 right = tmff_scale_u16(effect->u.rumble.strong_magnitude,
125 ff_field->logical_minimum, 111 ff_field->logical_minimum,
126 ff_field->logical_maximum); 112 ff_field->logical_maximum);
127 113
@@ -134,14 +120,14 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
134 return 0; 120 return 0;
135} 121}
136 122
137int hid_tmff_init(struct hid_device *hid) 123static int tmff_init(struct hid_device *hid, const signed short *ff_bits)
138{ 124{
139 struct tmff_device *tmff; 125 struct tmff_device *tmff;
140 struct hid_report *report; 126 struct hid_report *report;
141 struct list_head *report_list; 127 struct list_head *report_list;
142 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 128 struct hid_input *hidinput = list_entry(hid->inputs.next,
129 struct hid_input, list);
143 struct input_dev *input_dev = hidinput->input; 130 struct input_dev *input_dev = hidinput->input;
144 const signed short *ff_bits = ff_joystick;
145 int error; 131 int error;
146 int i; 132 int i;
147 133
@@ -163,17 +149,22 @@ int hid_tmff_init(struct hid_device *hid)
163 switch (field->usage[0].hid) { 149 switch (field->usage[0].hid) {
164 case THRUSTMASTER_USAGE_FF: 150 case THRUSTMASTER_USAGE_FF:
165 if (field->report_count < 2) { 151 if (field->report_count < 2) {
166 warn("ignoring FF field with report_count < 2"); 152 warn("ignoring FF field with "
153 "report_count < 2");
167 continue; 154 continue;
168 } 155 }
169 156
170 if (field->logical_maximum == field->logical_minimum) { 157 if (field->logical_maximum ==
171 warn("ignoring FF field with logical_maximum == logical_minimum"); 158 field->logical_minimum) {
159 warn("ignoring FF field with "
160 "logical_maximum == "
161 "logical_minimum");
172 continue; 162 continue;
173 } 163 }
174 164
175 if (tmff->report && tmff->report != report) { 165 if (tmff->report && tmff->report != report) {
176 warn("ignoring FF field in other report"); 166 warn("ignoring FF field in other "
167 "report");
177 continue; 168 continue;
178 } 169 }
179 170
@@ -185,21 +176,14 @@ int hid_tmff_init(struct hid_device *hid)
185 tmff->report = report; 176 tmff->report = report;
186 tmff->ff_field = field; 177 tmff->ff_field = field;
187 178
188 for (i = 0; i < ARRAY_SIZE(devices); i++) {
189 if (input_dev->id.vendor == devices[i].idVendor &&
190 input_dev->id.product == devices[i].idProduct) {
191 ff_bits = devices[i].ff;
192 break;
193 }
194 }
195
196 for (i = 0; ff_bits[i] >= 0; i++) 179 for (i = 0; ff_bits[i] >= 0; i++)
197 set_bit(ff_bits[i], input_dev->ffbit); 180 set_bit(ff_bits[i], input_dev->ffbit);
198 181
199 break; 182 break;
200 183
201 default: 184 default:
202 warn("ignoring unknown output usage %08x", field->usage[0].hid); 185 warn("ignoring unknown output usage %08x",
186 field->usage[0].hid);
203 continue; 187 continue;
204 } 188 }
205 } 189 }
@@ -211,15 +195,73 @@ int hid_tmff_init(struct hid_device *hid)
211 goto fail; 195 goto fail;
212 } 196 }
213 197
214 error = input_ff_create_memless(input_dev, tmff, hid_tmff_play); 198 error = input_ff_create_memless(input_dev, tmff, tmff_play);
215 if (error) 199 if (error)
216 goto fail; 200 goto fail;
217 201
218 info("Force feedback for ThrustMaster devices by Zinx Verituse <zinx@epicsol.org>"); 202 info("Force feedback for ThrustMaster devices by Zinx Verituse "
203 "<zinx@epicsol.org>");
219 return 0; 204 return 0;
220 205
221 fail: 206fail:
222 kfree(tmff); 207 kfree(tmff);
223 return error; 208 return error;
224} 209}
225 210
211static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
212{
213 int ret;
214
215 ret = hid_parse(hdev);
216 if (ret) {
217 dev_err(&hdev->dev, "parse failed\n");
218 goto err;
219 }
220
221 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
222 if (ret) {
223 dev_err(&hdev->dev, "hw start failed\n");
224 goto err;
225 }
226
227 tmff_init(hdev, (void *)id->driver_data);
228
229 return 0;
230err:
231 return ret;
232}
233
234static const struct hid_device_id tm_devices[] = {
235 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300),
236 .driver_data = (unsigned long)ff_rumble },
237 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304),
238 .driver_data = (unsigned long)ff_rumble },
239 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */
240 .driver_data = (unsigned long)ff_rumble },
241 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */
242 .driver_data = (unsigned long)ff_joystick },
243 { }
244};
245MODULE_DEVICE_TABLE(hid, tm_devices);
246
247static struct hid_driver tm_driver = {
248 .name = "thrustmaster",
249 .id_table = tm_devices,
250 .probe = tm_probe,
251};
252
253static int tm_init(void)
254{
255 return hid_register_driver(&tm_driver);
256}
257
258static void tm_exit(void)
259{
260 hid_unregister_driver(&tm_driver);
261}
262
263module_init(tm_init);
264module_exit(tm_exit);
265MODULE_LICENSE("GPL");
266
267HID_COMPAT_LOAD_DRIVER(thrustmaster);
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 02c8228ed7ee..c236fb3deb59 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -44,17 +44,6 @@ config HID_PID
44 feedback for it. Microsoft Sidewinder Force Feedback 2 is one of such 44 feedback for it. Microsoft Sidewinder Force Feedback 2 is one of such
45 devices. 45 devices.
46 46
47config THRUSTMASTER_FF
48 bool "ThrustMaster devices support"
49 depends on HID_FF
50 select INPUT_FF_MEMLESS if USB_HID
51 help
52 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
53 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel,
54 and want to enable force feedback support for it.
55 Note: if you say N here, this device will still be supported, but without
56 force feedback.
57
58config ZEROPLUS_FF 47config ZEROPLUS_FF
59 bool "Zeroplus based game controller support" 48 bool "Zeroplus based game controller support"
60 depends on HID_FF 49 depends on HID_FF
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile
index 0ee4803375b2..dd3b8634800f 100644
--- a/drivers/hid/usbhid/Makefile
+++ b/drivers/hid/usbhid/Makefile
@@ -13,9 +13,6 @@ endif
13ifeq ($(CONFIG_HID_PID),y) 13ifeq ($(CONFIG_HID_PID),y)
14 usbhid-objs += hid-pidff.o 14 usbhid-objs += hid-pidff.o
15endif 15endif
16ifeq ($(CONFIG_THRUSTMASTER_FF),y)
17 usbhid-objs += hid-tmff.o
18endif
19ifeq ($(CONFIG_ZEROPLUS_FF),y) 16ifeq ($(CONFIG_ZEROPLUS_FF),y)
20 usbhid-objs += hid-zpff.o 17 usbhid-objs += hid-zpff.o
21endif 18endif
diff --git a/drivers/hid/usbhid/hid-ff.c b/drivers/hid/usbhid/hid-ff.c
index a868eef06189..ed3a869d54e3 100644
--- a/drivers/hid/usbhid/hid-ff.c
+++ b/drivers/hid/usbhid/hid-ff.c
@@ -50,12 +50,6 @@ struct hid_ff_initializer {
50 * be a PID device 50 * be a PID device
51 */ 51 */
52static struct hid_ff_initializer inits[] = { 52static struct hid_ff_initializer inits[] = {
53#ifdef CONFIG_THRUSTMASTER_FF
54 { 0x44f, 0xb300, hid_tmff_init },
55 { 0x44f, 0xb304, hid_tmff_init },
56 { 0x44f, 0xb651, hid_tmff_init }, /* FGT Rumble Force Wheel */
57 { 0x44f, 0xb654, hid_tmff_init }, /* FGT Force Feedback Wheel */
58#endif
59#ifdef CONFIG_ZEROPLUS_FF 53#ifdef CONFIG_ZEROPLUS_FF
60 { 0xc12, 0x0005, hid_zpff_init }, 54 { 0xc12, 0x0005, hid_zpff_init },
61 { 0xc12, 0x0030, hid_zpff_init }, 55 { 0xc12, 0x0030, hid_zpff_init },
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 63b808067203..8266e50637b4 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -760,7 +760,6 @@ void usbhid_set_leds(struct hid_device *hid);
760#ifdef CONFIG_HID_FF 760#ifdef CONFIG_HID_FF
761int hid_ff_init(struct hid_device *hid); 761int hid_ff_init(struct hid_device *hid);
762 762
763int hid_tmff_init(struct hid_device *hid);
764int hid_zpff_init(struct hid_device *hid); 763int hid_zpff_init(struct hid_device *hid);
765#ifdef CONFIG_HID_PID 764#ifdef CONFIG_HID_PID
766int hid_pidff_init(struct hid_device *hid); 765int hid_pidff_init(struct hid_device *hid);