aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-07-04 17:06:45 -0400
committerJiri Kosina <jkosina@suse.cz>2008-10-14 17:50:56 -0400
commit606bd0a8616a0e59021cb2997e942513f24f641d (patch)
treef4884ef8d1beb2c13eaa3af45512c7b43def30ae /drivers/hid/usbhid
parent6edfa8dc33803a49ad936ead9840e453bee6ca3b (diff)
HID: move logitech FF processing
Merge the logitech force feedback processing directly into logitech driver from the usbhid core. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r--drivers/hid/usbhid/Kconfig24
-rw-r--r--drivers/hid/usbhid/Makefile6
-rw-r--r--drivers/hid/usbhid/hid-core.c1
-rw-r--r--drivers/hid/usbhid/hid-ff.c12
-rw-r--r--drivers/hid/usbhid/hid-lg2ff.c114
-rw-r--r--drivers/hid/usbhid/hid-lgff.c151
6 files changed, 1 insertions, 307 deletions
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 177bfa1a3e5b..0e7e2e6d975e 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -44,30 +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 LOGITECH_FF
48 bool "Logitech devices support"
49 depends on HID_FF
50 select INPUT_FF_MEMLESS if USB_HID
51 help
52 Say Y here if you have one of these devices:
53 - Logitech WingMan Cordless RumblePad
54 - Logitech WingMan Cordless RumblePad 2
55 - Logitech WingMan Force 3D
56 - Logitech Formula Force EX
57 - Logitech MOMO Force wheel
58
59 and if you want to enable force feedback for them.
60 Note: if you say N here, this device will still be supported, but without
61 force feedback.
62
63config LOGIRUMBLEPAD2_FF
64 bool "Logitech Rumblepad 2 support"
65 depends on HID_FF
66 select INPUT_FF_MEMLESS if USB_HID
67 help
68 Say Y here if you want to enable force feedback support for Logitech
69 Rumblepad 2 devices.
70
71config PANTHERLORD_FF 47config PANTHERLORD_FF
72 bool "PantherLord/GreenAsia based device support" 48 bool "PantherLord/GreenAsia based device support"
73 depends on HID_FF 49 depends on HID_FF
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile
index 00a7b7090192..224c62dc6a32 100644
--- a/drivers/hid/usbhid/Makefile
+++ b/drivers/hid/usbhid/Makefile
@@ -13,12 +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_LOGITECH_FF),y)
17 usbhid-objs += hid-lgff.o
18endif
19ifeq ($(CONFIG_LOGIRUMBLEPAD2_FF),y)
20 usbhid-objs += hid-lg2ff.o
21endif
22ifeq ($(CONFIG_PANTHERLORD_FF),y) 16ifeq ($(CONFIG_PANTHERLORD_FF),y)
23 usbhid-objs += hid-plff.o 17 usbhid-objs += hid-plff.o
24endif 18endif
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 402ace751271..4ec10aa618db 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -444,6 +444,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
444 444
445 spin_unlock_irqrestore(&usbhid->ctrllock, flags); 445 spin_unlock_irqrestore(&usbhid->ctrllock, flags);
446} 446}
447EXPORT_SYMBOL_GPL(usbhid_submit_report);
447 448
448static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 449static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
449{ 450{
diff --git a/drivers/hid/usbhid/hid-ff.c b/drivers/hid/usbhid/hid-ff.c
index 1d0dac52f166..8891f60d3beb 100644
--- a/drivers/hid/usbhid/hid-ff.c
+++ b/drivers/hid/usbhid/hid-ff.c
@@ -50,18 +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_LOGITECH_FF
54 { 0x46d, 0xc211, hid_lgff_init }, /* Logitech Cordless rumble pad */
55 { 0x46d, 0xc219, hid_lgff_init }, /* Logitech Cordless rumble pad 2 */
56 { 0x46d, 0xc283, hid_lgff_init }, /* Logitech Wingman Force 3d */
57 { 0x46d, 0xc286, hid_lgff_init }, /* Logitech Force 3D Pro Joystick */
58 { 0x46d, 0xc294, hid_lgff_init }, /* Logitech Formula Force EX */
59 { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */
60 { 0x46d, 0xca03, hid_lgff_init }, /* Logitech MOMO force wheel */
61#endif
62#ifdef CONFIG_LOGIRUMBLEPAD2_FF
63 { 0x46d, 0xc218, hid_lg2ff_init }, /* Logitech Rumblepad 2 */
64#endif
65#ifdef CONFIG_PANTHERLORD_FF 53#ifdef CONFIG_PANTHERLORD_FF
66 { 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */ 54 { 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */
67 { 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */ 55 { 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */
diff --git a/drivers/hid/usbhid/hid-lg2ff.c b/drivers/hid/usbhid/hid-lg2ff.c
deleted file mode 100644
index d469bd0061c9..000000000000
--- a/drivers/hid/usbhid/hid-lg2ff.c
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * Force feedback support for Logitech Rumblepad 2
3 *
4 * Copyright (c) 2008 Anssi Hannula <anssi.hannula@gmail.com>
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24#include <linux/input.h>
25#include <linux/usb.h>
26#include <linux/hid.h>
27#include "usbhid.h"
28
29struct lg2ff_device {
30 struct hid_report *report;
31};
32
33static int play_effect(struct input_dev *dev, void *data,
34 struct ff_effect *effect)
35{
36 struct hid_device *hid = input_get_drvdata(dev);
37 struct lg2ff_device *lg2ff = data;
38 int weak, strong;
39
40 strong = effect->u.rumble.strong_magnitude;
41 weak = effect->u.rumble.weak_magnitude;
42
43 if (weak || strong) {
44 weak = weak * 0xff / 0xffff;
45 strong = strong * 0xff / 0xffff;
46
47 lg2ff->report->field[0]->value[0] = 0x51;
48 lg2ff->report->field[0]->value[2] = weak;
49 lg2ff->report->field[0]->value[4] = strong;
50 } else {
51 lg2ff->report->field[0]->value[0] = 0xf3;
52 lg2ff->report->field[0]->value[2] = 0x00;
53 lg2ff->report->field[0]->value[4] = 0x00;
54 }
55
56 usbhid_submit_report(hid, lg2ff->report, USB_DIR_OUT);
57 return 0;
58}
59
60int hid_lg2ff_init(struct hid_device *hid)
61{
62 struct lg2ff_device *lg2ff;
63 struct hid_report *report;
64 struct hid_input *hidinput = list_entry(hid->inputs.next,
65 struct hid_input, list);
66 struct list_head *report_list =
67 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
68 struct input_dev *dev = hidinput->input;
69 int error;
70
71 if (list_empty(report_list)) {
72 printk(KERN_ERR "hid-lg2ff: no output report found\n");
73 return -ENODEV;
74 }
75
76 report = list_entry(report_list->next, struct hid_report, list);
77
78 if (report->maxfield < 1) {
79 printk(KERN_ERR "hid-lg2ff: output report is empty\n");
80 return -ENODEV;
81 }
82 if (report->field[0]->report_count < 7) {
83 printk(KERN_ERR "hid-lg2ff: not enough values in the field\n");
84 return -ENODEV;
85 }
86
87 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
88 if (!lg2ff)
89 return -ENOMEM;
90
91 set_bit(FF_RUMBLE, dev->ffbit);
92
93 error = input_ff_create_memless(dev, lg2ff, play_effect);
94 if (error) {
95 kfree(lg2ff);
96 return error;
97 }
98
99 lg2ff->report = report;
100 report->field[0]->value[0] = 0xf3;
101 report->field[0]->value[1] = 0x00;
102 report->field[0]->value[2] = 0x00;
103 report->field[0]->value[3] = 0x00;
104 report->field[0]->value[4] = 0x00;
105 report->field[0]->value[5] = 0x00;
106 report->field[0]->value[6] = 0x00;
107
108 usbhid_submit_report(hid, report, USB_DIR_OUT);
109
110 printk(KERN_INFO "Force feedback for Logitech Rumblepad 2 by "
111 "Anssi Hannula <anssi.hannula@gmail.com>\n");
112
113 return 0;
114}
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c
deleted file mode 100644
index 4b7ab6a46d93..000000000000
--- a/drivers/hid/usbhid/hid-lgff.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * Force feedback support for hid-compliant for some of the devices from
3 * Logitech, namely:
4 * - WingMan Cordless RumblePad
5 * - WingMan Force 3D
6 *
7 * Copyright (c) 2002-2004 Johann Deneux
8 * Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com>
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 * Should you need to contact me, the author, you can do so by
27 * e-mail - mail your message to <johann.deneux@it.uu.se>
28 */
29
30#include <linux/input.h>
31#include <linux/usb.h>
32#include <linux/hid.h>
33#include "usbhid.h"
34
35struct dev_type {
36 u16 idVendor;
37 u16 idProduct;
38 const signed short *ff;
39};
40
41static const signed short ff_rumble[] = {
42 FF_RUMBLE,
43 -1
44};
45
46static const signed short ff_joystick[] = {
47 FF_CONSTANT,
48 -1
49};
50
51static const struct dev_type devices[] = {
52 { 0x046d, 0xc211, ff_rumble },
53 { 0x046d, 0xc219, ff_rumble },
54 { 0x046d, 0xc283, ff_joystick },
55 { 0x046d, 0xc286, ff_joystick },
56 { 0x046d, 0xc294, ff_joystick },
57 { 0x046d, 0xc295, ff_joystick },
58 { 0x046d, 0xca03, ff_joystick },
59};
60
61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
62{
63 struct hid_device *hid = input_get_drvdata(dev);
64 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
65 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
66 int x, y;
67 unsigned int left, right;
68
69#define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff
70
71 switch (effect->type) {
72 case FF_CONSTANT:
73 x = effect->u.ramp.start_level + 0x7f; /* 0x7f is center */
74 y = effect->u.ramp.end_level + 0x7f;
75 CLAMP(x);
76 CLAMP(y);
77 report->field[0]->value[0] = 0x51;
78 report->field[0]->value[1] = 0x08;
79 report->field[0]->value[2] = x;
80 report->field[0]->value[3] = y;
81 dbg_hid("(x, y)=(%04x, %04x)\n", x, y);
82 usbhid_submit_report(hid, report, USB_DIR_OUT);
83 break;
84
85 case FF_RUMBLE:
86 right = effect->u.rumble.strong_magnitude;
87 left = effect->u.rumble.weak_magnitude;
88 right = right * 0xff / 0xffff;
89 left = left * 0xff / 0xffff;
90 CLAMP(left);
91 CLAMP(right);
92 report->field[0]->value[0] = 0x42;
93 report->field[0]->value[1] = 0x00;
94 report->field[0]->value[2] = left;
95 report->field[0]->value[3] = right;
96 dbg_hid("(left, right)=(%04x, %04x)\n", left, right);
97 usbhid_submit_report(hid, report, USB_DIR_OUT);
98 break;
99 }
100 return 0;
101}
102
103int hid_lgff_init(struct hid_device* hid)
104{
105 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
106 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
107 struct input_dev *dev = hidinput->input;
108 struct hid_report *report;
109 struct hid_field *field;
110 const signed short *ff_bits = ff_joystick;
111 int error;
112 int i;
113
114 /* Find the report to use */
115 if (list_empty(report_list)) {
116 err_hid("No output report found");
117 return -1;
118 }
119
120 /* Check that the report looks ok */
121 report = list_entry(report_list->next, struct hid_report, list);
122 if (!report) {
123 err_hid("NULL output report");
124 return -1;
125 }
126
127 field = report->field[0];
128 if (!field) {
129 err_hid("NULL field");
130 return -1;
131 }
132
133 for (i = 0; i < ARRAY_SIZE(devices); i++) {
134 if (dev->id.vendor == devices[i].idVendor &&
135 dev->id.product == devices[i].idProduct) {
136 ff_bits = devices[i].ff;
137 break;
138 }
139 }
140
141 for (i = 0; ff_bits[i] >= 0; i++)
142 set_bit(ff_bits[i], dev->ffbit);
143
144 error = input_ff_create_memless(dev, NULL, hid_lgff_play);
145 if (error)
146 return error;
147
148 printk(KERN_INFO "Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n");
149
150 return 0;
151}