From: Anssi Hannula <anssi.hannula@gmail.com>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: linux-joystick@atrey.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org
Subject: [patch 09/13] input: force feedback driver for Zeroplus devices
Date: Fri, 26 May 2006 19:11:38 +0300 [thread overview]
Message-ID: <20060526162907.625479000@gmail.com> (raw)
In-Reply-To: 20060526161129.557416000@gmail.com
[-- Attachment #1: ff-refactoring-new-driver-zpff.diff --]
[-- Type: text/plain, Size: 6624 bytes --]
Add force feedback driver for some PSX-style Zeroplus devices.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/usb/input/Kconfig | 7 ++
drivers/usb/input/Makefile | 3 +
drivers/usb/input/hid-ff.c | 4 +
drivers/usb/input/hid-zpff.c | 124 +++++++++++++++++++++++++++++++++++++++++++
drivers/usb/input/hid.h | 1
5 files changed, 139 insertions(+)
Index: linux-2.6.17-rc4-git12/drivers/usb/input/hid-ff.c
===================================================================
--- linux-2.6.17-rc4-git12.orig/drivers/usb/input/hid-ff.c 2006-05-24 21:14:35.000000000 +0300
+++ linux-2.6.17-rc4-git12/drivers/usb/input/hid-ff.c 2006-05-24 21:15:25.000000000 +0300
@@ -54,6 +54,10 @@ static struct hid_ff_initializer inits[]
#ifdef CONFIG_THRUSTMASTER_FF
{0x44f, 0xb304, hid_tmff_init},
#endif
+#ifdef CONFIG_ZEROPLUS_FF
+ {0xc12, 0x0005, zpff_init},
+ {0xc12, 0x0030, zpff_init},
+#endif
{0, 0, NULL} /* Terminating entry */
};
Index: linux-2.6.17-rc4-git12/drivers/usb/input/hid-zpff.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.17-rc4-git12/drivers/usb/input/hid-zpff.c 2006-05-24 21:15:52.000000000 +0300
@@ -0,0 +1,124 @@
+/*
+ * Force feedback support for Zeroplus based devices
+ *
+ * Copyright (c) 2005, 2006 Anssi Hannula <anssi.hannula@gmail.com>
+ */
+
+/*
+ * 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-zpff: " format "\n" , ## arg)
+
+#include <linux/input.h>
+#include <linux/usb.h>
+#include "hid.h"
+struct zpff_device {
+ struct hid_report *report;
+};
+
+static int zpff_play(struct input_dev *dev, struct ff_effect *effect,
+ struct ff_effect *old)
+{
+ struct hid_device *hid = dev->private;
+ struct zpff_device *zpff = hid->ff_private;
+ int left, right;
+
+ /* The following is specified the other way around in the Zeroplus
+ datasheet, but the order below is correct for the XFX Executioner */
+ /* However it is possible that the XFX Executioner is an exception */
+
+ left = effect->u.rumble.strong_magnitude;
+ right = effect->u.rumble.weak_magnitude;
+ debug("called with 0x%04x 0x%04x", left, right);
+
+ left = left * 0x7f / 0xffff;
+ right = right * 0x7f / 0xffff;
+
+ zpff->report->field[2]->value[0] = left;
+ zpff->report->field[3]->value[0] = right;
+ debug("running with 0x%02x 0x%02x", left, right);
+ hid_submit_report(hid, zpff->report, USB_DIR_OUT);
+ return 0;
+}
+
+static void zpff_exit(struct hid_device *hid)
+{
+ struct zpff_device *zpff = hid->ff_private;
+ hid->ff_private = NULL;
+ kfree(zpff);
+}
+
+static struct ff_driver zpff_driver = {
+ .upload = zpff_play,
+};
+
+int zpff_init(struct hid_device *hid)
+{
+ struct zpff_device *zpff;
+ struct hid_report *report;
+ struct hid_input *hidinput =
+ list_entry(hid->inputs.next, struct hid_input, list);
+ struct input_dev *dev = hidinput->input;
+ int ret;
+
+ if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) {
+ printk(KERN_ERR "hid-zpff: no output report found\n");
+ return -1;
+ }
+ report =
+ list_entry(hid->report_enum[HID_OUTPUT_REPORT].report_list.next,
+ struct hid_report, list);
+
+ if (report->maxfield < 4) {
+ printk(KERN_ERR "hid-zpff: not enough fields in report\n");
+ return -1;
+ }
+
+ ret = input_ff_allocate(dev);
+ if (ret)
+ return ret;
+
+ zpff = kzalloc(sizeof(*zpff), GFP_KERNEL);
+ if (!zpff) {
+ return -ENOMEM;
+ }
+
+ hid->ff_private = zpff;
+ hid->ff_exit = zpff_exit;
+
+ set_bit(FF_RUMBLE, dev->ff->flags);
+
+ zpff->report = report;
+ zpff->report->field[0]->value[0] = 0x00;
+ zpff->report->field[1]->value[0] = 0x02;
+ zpff->report->field[2]->value[0] = 0x00;
+ zpff->report->field[3]->value[0] = 0x00;
+ hid_submit_report(hid, zpff->report, USB_DIR_OUT);
+
+ ret = input_ff_register(dev, &zpff_driver);
+ if (ret) {
+ kfree(zpff);
+ return ret;
+ }
+
+ printk(KERN_INFO "Force feedback for Zeroplus based devices by "
+ "Anssi Hannula <anssi.hannula@gmail.com>\n");
+
+ return 0;
+}
Index: linux-2.6.17-rc4-git12/drivers/usb/input/Kconfig
===================================================================
--- linux-2.6.17-rc4-git12.orig/drivers/usb/input/Kconfig 2006-05-24 21:14:35.000000000 +0300
+++ linux-2.6.17-rc4-git12/drivers/usb/input/Kconfig 2006-05-24 21:15:25.000000000 +0300
@@ -87,6 +87,13 @@ config THRUSTMASTER_FF
Note: if you say N here, this device will still be supported, but without
force feedback.
+config ZEROPLUS_FF
+ bool "Zeroplus based game controller support"
+ depends on HID_FF
+ help
+ Say Y here if you have a Zeroplus based game controller and want to
+ enable force feedback for it.
+
config USB_HIDDEV
bool "/dev/hiddev raw HID device support"
depends on USB_HID
Index: linux-2.6.17-rc4-git12/drivers/usb/input/Makefile
===================================================================
--- linux-2.6.17-rc4-git12.orig/drivers/usb/input/Makefile 2006-05-24 21:14:35.000000000 +0300
+++ linux-2.6.17-rc4-git12/drivers/usb/input/Makefile 2006-05-24 21:15:25.000000000 +0300
@@ -22,6 +22,9 @@ endif
ifeq ($(CONFIG_THRUSTMASTER_FF),y)
usbhid-objs += hid-tmff.o
endif
+ifeq ($(CONFIG_ZEROPLUS_FF),y)
+ usbhid-objs += hid-zpff.o
+endif
ifeq ($(CONFIG_HID_FF),y)
usbhid-objs += hid-ff.o
endif
Index: linux-2.6.17-rc4-git12/drivers/usb/input/hid.h
===================================================================
--- linux-2.6.17-rc4-git12.orig/drivers/usb/input/hid.h 2006-05-24 21:14:35.000000000 +0300
+++ linux-2.6.17-rc4-git12/drivers/usb/input/hid.h 2006-05-24 21:15:25.000000000 +0300
@@ -527,6 +527,7 @@ static inline void hid_ff_exit(struct hi
int hid_lgff_init(struct hid_device* hid);
int hid_tmff_init(struct hid_device* hid);
+int zpff_init(struct hid_device* hid);
#ifdef CONFIG_HID_PID
int pidff_init(struct hid_device *hid);
--
Anssi Hannula
next prev parent reply other threads:[~2006-05-26 16:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-26 16:11 [patch 00/13] input: force feedback updates, second time Anssi Hannula
2006-05-26 16:11 ` [patch 01/13] input: move fixp-arith.h to drivers/input Anssi Hannula
2006-05-26 16:11 ` [patch 02/13] input: fix accuracy of fixp-arith.h Anssi Hannula
2006-05-26 16:11 ` [patch 03/13] input: make input a multi-object module Anssi Hannula
2006-05-26 21:16 ` Andrew Morton
2006-05-26 21:29 ` Anssi Hannula
2006-05-26 21:43 ` Andrew Morton
2006-05-26 21:53 ` Anssi Hannula
2006-05-26 22:08 ` Andrew Morton
2006-05-26 22:22 ` Anssi Hannula
2006-05-26 22:32 ` Andrew Morton
2006-05-26 23:07 ` Anssi Hannula
2006-05-26 23:28 ` Andrew Morton
2006-05-26 23:35 ` Anssi Hannula
2006-05-26 23:45 ` Andrew Morton
2006-05-27 0:46 ` [patch] input: new force feedback interface Anssi Hannula
2006-05-27 0:53 ` [patch] input: use event handler in ff drivers Anssi Hannula
2006-05-26 16:11 ` [patch 04/13] input: new force feedback interface Anssi Hannula
2006-05-26 16:11 ` [patch 05/13] input: adapt hid force feedback drivers for the new interface Anssi Hannula
2006-05-26 16:11 ` [patch 06/13] input: adapt uinput for the new force feedback interface Anssi Hannula
2006-05-26 16:11 ` [patch 07/13] input: adapt iforce driver " Anssi Hannula
2006-05-26 16:11 ` [patch 08/13] input: force feedback driver for PID devices Anssi Hannula
2006-05-26 16:11 ` Anssi Hannula [this message]
2006-05-26 16:11 ` [patch 10/13] input: update documentation of force feedback Anssi Hannula
2006-05-26 16:11 ` [patch 11/13] input: drop the remains of the old ff interface Anssi Hannula
2006-05-26 16:11 ` [patch 12/13] input: drop the old PID driver Anssi Hannula
2006-05-26 16:11 ` [patch 13/13] input: use -ENOSPC instead of -ENOMEM in iforce when device full Anssi Hannula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060526162907.625479000@gmail.com \
--to=anssi.hannula@gmail.com \
--cc=dtor_core@ameritech.net \
--cc=linux-joystick@atrey.karlin.mff.cuni.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox