[PATCH 2/2] Input: remove gameport subsystem

From: Dmitry Torokhov
Date: Tue Aug 19 2014 - 12:42:29 EST


Gameport support hasn't been working well ever since cpufreq became
mainstream and it becomes increasingly hard to find hardware and software
that would run on such old hardware.

It is time to retire it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/Makefile | 1 -
drivers/input/Kconfig | 2 -
drivers/input/gameport/Kconfig | 63 ---
drivers/input/gameport/Makefile | 11 -
drivers/input/gameport/emu10k1-gp.c | 127 ------
drivers/input/gameport/fm801-gp.c | 159 -------
drivers/input/gameport/gameport.c | 823 ------------------------------------
drivers/input/gameport/lightning.c | 341 ---------------
drivers/input/gameport/ns558.c | 286 -------------
drivers/input/joystick/Kconfig | 127 ------
drivers/input/joystick/Makefile | 12 -
drivers/input/joystick/a3d.c | 415 ------------------
drivers/input/joystick/adi.c | 568 -------------------------
drivers/input/joystick/analog.c | 769 ---------------------------------
drivers/input/joystick/cobra.c | 263 ------------
drivers/input/joystick/gf2k.c | 375 ----------------
drivers/input/joystick/grip.c | 426 -------------------
drivers/input/joystick/grip_mp.c | 689 ------------------------------
drivers/input/joystick/guillemot.c | 283 -------------
drivers/input/joystick/interact.c | 313 --------------
drivers/input/joystick/joydump.c | 161 -------
drivers/input/joystick/sidewinder.c | 822 -----------------------------------
drivers/input/joystick/tmdc.c | 438 -------------------
include/linux/gameport.h | 219 ----------
include/uapi/linux/Kbuild | 1 -
include/uapi/linux/gameport.h | 28 --
26 files changed, 7722 deletions(-)
delete mode 100644 drivers/input/gameport/Kconfig
delete mode 100644 drivers/input/gameport/Makefile
delete mode 100644 drivers/input/gameport/emu10k1-gp.c
delete mode 100644 drivers/input/gameport/fm801-gp.c
delete mode 100644 drivers/input/gameport/gameport.c
delete mode 100644 drivers/input/gameport/lightning.c
delete mode 100644 drivers/input/gameport/ns558.c
delete mode 100644 drivers/input/joystick/a3d.c
delete mode 100644 drivers/input/joystick/adi.c
delete mode 100644 drivers/input/joystick/analog.c
delete mode 100644 drivers/input/joystick/cobra.c
delete mode 100644 drivers/input/joystick/gf2k.c
delete mode 100644 drivers/input/joystick/grip.c
delete mode 100644 drivers/input/joystick/grip_mp.c
delete mode 100644 drivers/input/joystick/guillemot.c
delete mode 100644 drivers/input/joystick/interact.c
delete mode 100644 drivers/input/joystick/joydump.c
delete mode 100644 drivers/input/joystick/sidewinder.c
delete mode 100644 drivers/input/joystick/tmdc.c
delete mode 100644 include/linux/gameport.h
delete mode 100644 include/uapi/linux/gameport.h

diff --git a/drivers/Makefile b/drivers/Makefile
index f98b50d..e9e0278 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -92,7 +92,6 @@ obj-$(CONFIG_USB) += usb/
obj-$(CONFIG_PCI) += usb/
obj-$(CONFIG_USB_GADGET) += usb/
obj-$(CONFIG_SERIO) += input/serio/
-obj-$(CONFIG_GAMEPORT) += input/gameport/
obj-$(CONFIG_INPUT) += input/
obj-$(CONFIG_I2O) += message/
obj-$(CONFIG_RTC_LIB) += rtc/
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 1f68e5a..edef9e6 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -196,8 +196,6 @@ menu "Hardware I/O ports"

source "drivers/input/serio/Kconfig"

-source "drivers/input/gameport/Kconfig"
-
endmenu

endmenu
diff --git a/drivers/input/gameport/Kconfig b/drivers/input/gameport/Kconfig
deleted file mode 100644
index d279454..0000000
--- a/drivers/input/gameport/Kconfig
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Gameport configuration
-#
-config GAMEPORT
- tristate "Gameport support"
- ---help---
- Gameport support is for the standard 15-pin PC gameport. If you
- have a joystick, gamepad, gameport card, a soundcard with a gameport
- or anything else that uses the gameport, say Y or M here and also to
- at least one of the hardware specific drivers.
-
- For Ensoniq AudioPCI (ES1370), AudioPCI 97 (ES1371), ESS Solo1,
- S3 SonicVibes, Trident 4DWave, SiS7018, and ALi 5451 gameport
- support is provided by the sound drivers, so you won't need any
- from the below listed modules. You still need to say Y here.
-
- If unsure, say Y.
-
- To compile this driver as a module, choose M here: the
- module will be called gameport.
-
-if GAMEPORT
-
-config GAMEPORT_NS558
- tristate "Classic ISA and PnP gameport support"
- help
- Say Y here if you have an ISA or PnP gameport.
-
- If unsure, say Y.
-
- To compile this driver as a module, choose M here: the
- module will be called ns558.
-
-config GAMEPORT_L4
- tristate "PDPI Lightning 4 gamecard support"
- help
- Say Y here if you have a PDPI Lightning 4 gamecard.
-
- To compile this driver as a module, choose M here: the
- module will be called lightning.
-
-config GAMEPORT_EMU10K1
- tristate "SB Live and Audigy gameport support"
- depends on PCI
- help
- Say Y here if you have a SoundBlaster Live! or SoundBlaster
- Audigy card and want to use its gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called emu10k1-gp.
-
-config GAMEPORT_FM801
- tristate "ForteMedia FM801 gameport support"
- depends on PCI
- help
- Say Y here if you have ForteMedia FM801 PCI audio controller
- (Abit AU10, Genius Sound Maker, HP Workstation zx2000,
- and others), and want to use its gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called fm801-gp.
-
-endif
diff --git a/drivers/input/gameport/Makefile b/drivers/input/gameport/Makefile
deleted file mode 100644
index b6f6097..0000000
--- a/drivers/input/gameport/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile for the gameport drivers.
-#
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_GAMEPORT) += gameport.o
-obj-$(CONFIG_GAMEPORT_EMU10K1) += emu10k1-gp.o
-obj-$(CONFIG_GAMEPORT_FM801) += fm801-gp.o
-obj-$(CONFIG_GAMEPORT_L4) += lightning.o
-obj-$(CONFIG_GAMEPORT_NS558) += ns558.o
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
deleted file mode 100644
index 2909e95..0000000
--- a/drivers/input/gameport/emu10k1-gp.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2001 Vojtech Pavlik
- */
-
-/*
- * EMU10k1 - SB Live / Audigy - gameport driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <asm/io.h>
-
-#include <linux/module.h>
-#include <linux/ioport.h>
-#include <linux/gameport.h>
-#include <linux/slab.h>
-#include <linux/pci.h>
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION("EMU10k1 gameport driver");
-MODULE_LICENSE("GPL");
-
-struct emu {
- struct pci_dev *dev;
- struct gameport *gameport;
- int io;
- int size;
-};
-
-static const struct pci_device_id emu_tbl[] = {
-
- { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
- { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
- { 0x1102, 0x7004, PCI_ANY_ID, PCI_ANY_ID }, /* Dell SB Live */
- { 0x1102, 0x7005, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy LS gameport */
- { 0, }
-};
-
-MODULE_DEVICE_TABLE(pci, emu_tbl);
-
-static int emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- struct emu *emu;
- struct gameport *port;
- int error;
-
- emu = kzalloc(sizeof(struct emu), GFP_KERNEL);
- port = gameport_allocate_port();
- if (!emu || !port) {
- printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
- error = -ENOMEM;
- goto err_out_free;
- }
-
- error = pci_enable_device(pdev);
- if (error)
- goto err_out_free;
-
- emu->io = pci_resource_start(pdev, 0);
- emu->size = pci_resource_len(pdev, 0);
-
- emu->dev = pdev;
- emu->gameport = port;
-
- gameport_set_name(port, "EMU10K1");
- gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
- port->dev.parent = &pdev->dev;
- port->io = emu->io;
-
- if (!request_region(emu->io, emu->size, "emu10k1-gp")) {
- printk(KERN_ERR "emu10k1-gp: unable to grab region 0x%x-0x%x\n",
- emu->io, emu->io + emu->size - 1);
- error = -EBUSY;
- goto err_out_disable_dev;
- }
-
- pci_set_drvdata(pdev, emu);
-
- gameport_register_port(port);
-
- return 0;
-
- err_out_disable_dev:
- pci_disable_device(pdev);
- err_out_free:
- gameport_free_port(port);
- kfree(emu);
- return error;
-}
-
-static void emu_remove(struct pci_dev *pdev)
-{
- struct emu *emu = pci_get_drvdata(pdev);
-
- gameport_unregister_port(emu->gameport);
- release_region(emu->io, emu->size);
- kfree(emu);
-
- pci_disable_device(pdev);
-}
-
-static struct pci_driver emu_driver = {
- .name = "Emu10k1_gameport",
- .id_table = emu_tbl,
- .probe = emu_probe,
- .remove = emu_remove,
-};
-
-module_pci_driver(emu_driver);
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
deleted file mode 100644
index 7c03114..0000000
--- a/drivers/input/gameport/fm801-gp.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * FM801 gameport driver for Linux
- *
- * Copyright (c) by Takashi Iwai <tiwai@xxxxxxx>
- *
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/gameport.h>
-
-#define PCI_VENDOR_ID_FORTEMEDIA 0x1319
-#define PCI_DEVICE_ID_FM801_GP 0x0802
-
-#define HAVE_COOKED
-
-struct fm801_gp {
- struct gameport *gameport;
- struct resource *res_port;
-};
-
-#ifdef HAVE_COOKED
-static int fm801_gp_cooked_read(struct gameport *gameport, int *axes, int *buttons)
-{
- unsigned short w;
-
- w = inw(gameport->io + 2);
- *buttons = (~w >> 14) & 0x03;
- axes[0] = (w == 0xffff) ? -1 : ((w & 0x1fff) << 5);
- w = inw(gameport->io + 4);
- axes[1] = (w == 0xffff) ? -1 : ((w & 0x1fff) << 5);
- w = inw(gameport->io + 6);
- *buttons |= ((~w >> 14) & 0x03) << 2;
- axes[2] = (w == 0xffff) ? -1 : ((w & 0x1fff) << 5);
- w = inw(gameport->io + 8);
- axes[3] = (w == 0xffff) ? -1 : ((w & 0x1fff) << 5);
- outw(0xff, gameport->io); /* reset */
-
- return 0;
-}
-#endif
-
-static int fm801_gp_open(struct gameport *gameport, int mode)
-{
- switch (mode) {
-#ifdef HAVE_COOKED
- case GAMEPORT_MODE_COOKED:
- return 0;
-#endif
- case GAMEPORT_MODE_RAW:
- return 0;
- default:
- return -1;
- }
-
- return 0;
-}
-
-static int fm801_gp_probe(struct pci_dev *pci, const struct pci_device_id *id)
-{
- struct fm801_gp *gp;
- struct gameport *port;
- int error;
-
- gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
- port = gameport_allocate_port();
- if (!gp || !port) {
- printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
- error = -ENOMEM;
- goto err_out_free;
- }
-
- error = pci_enable_device(pci);
- if (error)
- goto err_out_free;
-
- port->open = fm801_gp_open;
-#ifdef HAVE_COOKED
- port->cooked_read = fm801_gp_cooked_read;
-#endif
- gameport_set_name(port, "FM801");
- gameport_set_phys(port, "pci%s/gameport0", pci_name(pci));
- port->dev.parent = &pci->dev;
- port->io = pci_resource_start(pci, 0);
-
- gp->gameport = port;
- gp->res_port = request_region(port->io, 0x10, "FM801 GP");
- if (!gp->res_port) {
- printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
- port->io, port->io + 0x0f);
- error = -EBUSY;
- goto err_out_disable_dev;
- }
-
- pci_set_drvdata(pci, gp);
-
- outb(0x60, port->io + 0x0d); /* enable joystick 1 and 2 */
- gameport_register_port(port);
-
- return 0;
-
- err_out_disable_dev:
- pci_disable_device(pci);
- err_out_free:
- gameport_free_port(port);
- kfree(gp);
- return error;
-}
-
-static void fm801_gp_remove(struct pci_dev *pci)
-{
- struct fm801_gp *gp = pci_get_drvdata(pci);
-
- gameport_unregister_port(gp->gameport);
- release_resource(gp->res_port);
- kfree(gp);
-
- pci_disable_device(pci);
-}
-
-static const struct pci_device_id fm801_gp_id_table[] = {
- { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
- { 0 }
-};
-MODULE_DEVICE_TABLE(pci, fm801_gp_id_table);
-
-static struct pci_driver fm801_gp_driver = {
- .name = "FM801_gameport",
- .id_table = fm801_gp_id_table,
- .probe = fm801_gp_probe,
- .remove = fm801_gp_remove,
-};
-
-module_pci_driver(fm801_gp_driver);
-
-MODULE_DESCRIPTION("FM801 gameport driver");
-MODULE_AUTHOR("Takashi Iwai <tiwai@xxxxxxx>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
deleted file mode 100644
index 24c41ba..0000000
--- a/drivers/input/gameport/gameport.c
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- * Generic gameport layer
- *
- * Copyright (c) 1999-2002 Vojtech Pavlik
- * Copyright (c) 2005 Dmitry Torokhov
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/stddef.h>
-#include <linux/module.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/gameport.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/workqueue.h>
-#include <linux/sched.h> /* HZ */
-#include <linux/mutex.h>
-
-/*#include <asm/io.h>*/
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION("Generic gameport layer");
-MODULE_LICENSE("GPL");
-
-/*
- * gameport_mutex protects entire gameport subsystem and is taken
- * every time gameport port or driver registrered or unregistered.
- */
-static DEFINE_MUTEX(gameport_mutex);
-
-static LIST_HEAD(gameport_list);
-
-static struct bus_type gameport_bus;
-
-static void gameport_add_port(struct gameport *gameport);
-static void gameport_attach_driver(struct gameport_driver *drv);
-static void gameport_reconnect_port(struct gameport *gameport);
-static void gameport_disconnect_port(struct gameport *gameport);
-
-#if defined(__i386__)
-
-#include <linux/i8253.h>
-
-#define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0))
-#define GET_TIME(x) do { x = get_time_pit(); } while (0)
-
-static unsigned int get_time_pit(void)
-{
- unsigned long flags;
- unsigned int count;
-
- raw_spin_lock_irqsave(&i8253_lock, flags);
- outb_p(0x00, 0x43);
- count = inb_p(0x40);
- count |= inb_p(0x40) << 8;
- raw_spin_unlock_irqrestore(&i8253_lock, flags);
-
- return count;
-}
-
-#endif
-
-
-
-/*
- * gameport_measure_speed() measures the gameport i/o speed.
- */
-
-static int gameport_measure_speed(struct gameport *gameport)
-{
-#if defined(__i386__)
-
- unsigned int i, t, t1, t2, t3, tx;
- unsigned long flags;
-
- if (gameport_open(gameport, NULL, GAMEPORT_MODE_RAW))
- return 0;
-
- tx = 1 << 30;
-
- for(i = 0; i < 50; i++) {
- local_irq_save(flags);
- GET_TIME(t1);
- for (t = 0; t < 50; t++) gameport_read(gameport);
- GET_TIME(t2);
- GET_TIME(t3);
- local_irq_restore(flags);
- udelay(i * 10);
- if ((t = DELTA(t2,t1) - DELTA(t3,t2)) < tx) tx = t;
- }
-
- gameport_close(gameport);
- return 59659 / (tx < 1 ? 1 : tx);
-
-#elif defined (__x86_64__)
-
- unsigned int i, t;
- unsigned long tx, t1, t2, flags;
-
- if (gameport_open(gameport, NULL, GAMEPORT_MODE_RAW))
- return 0;
-
- tx = 1 << 30;
-
- for(i = 0; i < 50; i++) {
- local_irq_save(flags);
- rdtscl(t1);
- for (t = 0; t < 50; t++) gameport_read(gameport);
- rdtscl(t2);
- local_irq_restore(flags);
- udelay(i * 10);
- if (t2 - t1 < tx) tx = t2 - t1;
- }
-
- gameport_close(gameport);
- return (this_cpu_read(cpu_info.loops_per_jiffy) *
- (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx);
-
-#else
-
- unsigned int j, t = 0;
-
- if (gameport_open(gameport, NULL, GAMEPORT_MODE_RAW))
- return 0;
-
- j = jiffies; while (j == jiffies);
- j = jiffies; while (j == jiffies) { t++; gameport_read(gameport); }
-
- gameport_close(gameport);
- return t * HZ / 1000;
-
-#endif
-}
-
-void gameport_start_polling(struct gameport *gameport)
-{
- spin_lock(&gameport->timer_lock);
-
- if (!gameport->poll_cnt++) {
- BUG_ON(!gameport->poll_handler);
- BUG_ON(!gameport->poll_interval);
- mod_timer(&gameport->poll_timer, jiffies + msecs_to_jiffies(gameport->poll_interval));
- }
-
- spin_unlock(&gameport->timer_lock);
-}
-EXPORT_SYMBOL(gameport_start_polling);
-
-void gameport_stop_polling(struct gameport *gameport)
-{
- spin_lock(&gameport->timer_lock);
-
- if (!--gameport->poll_cnt)
- del_timer(&gameport->poll_timer);
-
- spin_unlock(&gameport->timer_lock);
-}
-EXPORT_SYMBOL(gameport_stop_polling);
-
-static void gameport_run_poll_handler(unsigned long d)
-{
- struct gameport *gameport = (struct gameport *)d;
-
- gameport->poll_handler(gameport);
- if (gameport->poll_cnt)
- mod_timer(&gameport->poll_timer, jiffies + msecs_to_jiffies(gameport->poll_interval));
-}
-
-/*
- * Basic gameport -> driver core mappings
- */
-
-static int gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
-{
- int error;
-
- gameport->dev.driver = &drv->driver;
- if (drv->connect(gameport, drv)) {
- gameport->dev.driver = NULL;
- return -ENODEV;
- }
-
- error = device_bind_driver(&gameport->dev);
- if (error) {
- dev_warn(&gameport->dev,
- "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
- gameport->phys, gameport->name,
- drv->description, error);
- drv->disconnect(gameport);
- gameport->dev.driver = NULL;
- return error;
- }
-
- return 0;
-}
-
-static void gameport_find_driver(struct gameport *gameport)
-{
- int error;
-
- error = device_attach(&gameport->dev);
- if (error < 0)
- dev_warn(&gameport->dev,
- "device_attach() failed for %s (%s), error: %d\n",
- gameport->phys, gameport->name, error);
-}
-
-
-/*
- * Gameport event processing.
- */
-
-enum gameport_event_type {
- GAMEPORT_REGISTER_PORT,
- GAMEPORT_ATTACH_DRIVER,
-};
-
-struct gameport_event {
- enum gameport_event_type type;
- void *object;
- struct module *owner;
- struct list_head node;
-};
-
-static DEFINE_SPINLOCK(gameport_event_lock); /* protects gameport_event_list */
-static LIST_HEAD(gameport_event_list);
-
-static struct gameport_event *gameport_get_event(void)
-{
- struct gameport_event *event = NULL;
- unsigned long flags;
-
- spin_lock_irqsave(&gameport_event_lock, flags);
-
- if (!list_empty(&gameport_event_list)) {
- event = list_first_entry(&gameport_event_list,
- struct gameport_event, node);
- list_del_init(&event->node);
- }
-
- spin_unlock_irqrestore(&gameport_event_lock, flags);
- return event;
-}
-
-static void gameport_free_event(struct gameport_event *event)
-{
- module_put(event->owner);
- kfree(event);
-}
-
-static void gameport_remove_duplicate_events(struct gameport_event *event)
-{
- struct gameport_event *e, *next;
- unsigned long flags;
-
- spin_lock_irqsave(&gameport_event_lock, flags);
-
- list_for_each_entry_safe(e, next, &gameport_event_list, node) {
- if (event->object == e->object) {
- /*
- * If this event is of different type we should not
- * look further - we only suppress duplicate events
- * that were sent back-to-back.
- */
- if (event->type != e->type)
- break;
-
- list_del_init(&e->node);
- gameport_free_event(e);
- }
- }
-
- spin_unlock_irqrestore(&gameport_event_lock, flags);
-}
-
-
-static void gameport_handle_events(struct work_struct *work)
-{
- struct gameport_event *event;
-
- mutex_lock(&gameport_mutex);
-
- /*
- * Note that we handle only one event here to give swsusp
- * a chance to freeze kgameportd thread. Gameport events
- * should be pretty rare so we are not concerned about
- * taking performance hit.
- */
- if ((event = gameport_get_event())) {
-
- switch (event->type) {
-
- case GAMEPORT_REGISTER_PORT:
- gameport_add_port(event->object);
- break;
-
- case GAMEPORT_ATTACH_DRIVER:
- gameport_attach_driver(event->object);
- break;
- }
-
- gameport_remove_duplicate_events(event);
- gameport_free_event(event);
- }
-
- mutex_unlock(&gameport_mutex);
-}
-
-static DECLARE_WORK(gameport_event_work, gameport_handle_events);
-
-static int gameport_queue_event(void *object, struct module *owner,
- enum gameport_event_type event_type)
-{
- unsigned long flags;
- struct gameport_event *event;
- int retval = 0;
-
- spin_lock_irqsave(&gameport_event_lock, flags);
-
- /*
- * Scan event list for the other events for the same gameport port,
- * starting with the most recent one. If event is the same we
- * do not need add new one. If event is of different type we
- * need to add this event and should not look further because
- * we need to preserve sequence of distinct events.
- */
- list_for_each_entry_reverse(event, &gameport_event_list, node) {
- if (event->object == object) {
- if (event->type == event_type)
- goto out;
- break;
- }
- }
-
- event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC);
- if (!event) {
- pr_err("Not enough memory to queue event %d\n", event_type);
- retval = -ENOMEM;
- goto out;
- }
-
- if (!try_module_get(owner)) {
- pr_warning("Can't get module reference, dropping event %d\n",
- event_type);
- kfree(event);
- retval = -EINVAL;
- goto out;
- }
-
- event->type = event_type;
- event->object = object;
- event->owner = owner;
-
- list_add_tail(&event->node, &gameport_event_list);
- queue_work(system_long_wq, &gameport_event_work);
-
-out:
- spin_unlock_irqrestore(&gameport_event_lock, flags);
- return retval;
-}
-
-/*
- * Remove all events that have been submitted for a given object,
- * be it a gameport port or a driver.
- */
-static void gameport_remove_pending_events(void *object)
-{
- struct gameport_event *event, *next;
- unsigned long flags;
-
- spin_lock_irqsave(&gameport_event_lock, flags);
-
- list_for_each_entry_safe(event, next, &gameport_event_list, node) {
- if (event->object == object) {
- list_del_init(&event->node);
- gameport_free_event(event);
- }
- }
-
- spin_unlock_irqrestore(&gameport_event_lock, flags);
-}
-
-/*
- * Destroy child gameport port (if any) that has not been fully registered yet.
- *
- * Note that we rely on the fact that port can have only one child and therefore
- * only one child registration request can be pending. Additionally, children
- * are registered by driver's connect() handler so there can't be a grandchild
- * pending registration together with a child.
- */
-static struct gameport *gameport_get_pending_child(struct gameport *parent)
-{
- struct gameport_event *event;
- struct gameport *gameport, *child = NULL;
- unsigned long flags;
-
- spin_lock_irqsave(&gameport_event_lock, flags);
-
- list_for_each_entry(event, &gameport_event_list, node) {
- if (event->type == GAMEPORT_REGISTER_PORT) {
- gameport = event->object;
- if (gameport->parent == parent) {
- child = gameport;
- break;
- }
- }
- }
-
- spin_unlock_irqrestore(&gameport_event_lock, flags);
- return child;
-}
-
-/*
- * Gameport port operations
- */
-
-static ssize_t gameport_description_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct gameport *gameport = to_gameport_port(dev);
-
- return sprintf(buf, "%s\n", gameport->name);
-}
-static DEVICE_ATTR(description, S_IRUGO, gameport_description_show, NULL);
-
-static ssize_t drvctl_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
-{
- struct gameport *gameport = to_gameport_port(dev);
- struct device_driver *drv;
- int error;
-
- error = mutex_lock_interruptible(&gameport_mutex);
- if (error)
- return error;
-
- if (!strncmp(buf, "none", count)) {
- gameport_disconnect_port(gameport);
- } else if (!strncmp(buf, "reconnect", count)) {
- gameport_reconnect_port(gameport);
- } else if (!strncmp(buf, "rescan", count)) {
- gameport_disconnect_port(gameport);
- gameport_find_driver(gameport);
- } else if ((drv = driver_find(buf, &gameport_bus)) != NULL) {
- gameport_disconnect_port(gameport);
- error = gameport_bind_driver(gameport, to_gameport_driver(drv));
- } else {
- error = -EINVAL;
- }
-
- mutex_unlock(&gameport_mutex);
-
- return error ? error : count;
-}
-static DEVICE_ATTR_WO(drvctl);
-
-static struct attribute *gameport_device_attrs[] = {
- &dev_attr_description.attr,
- &dev_attr_drvctl.attr,
- NULL,
-};
-ATTRIBUTE_GROUPS(gameport_device);
-
-static void gameport_release_port(struct device *dev)
-{
- struct gameport *gameport = to_gameport_port(dev);
-
- kfree(gameport);
- module_put(THIS_MODULE);
-}
-
-void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- vsnprintf(gameport->phys, sizeof(gameport->phys), fmt, args);
- va_end(args);
-}
-EXPORT_SYMBOL(gameport_set_phys);
-
-/*
- * Prepare gameport port for registration.
- */
-static void gameport_init_port(struct gameport *gameport)
-{
- static atomic_t gameport_no = ATOMIC_INIT(0);
-
- __module_get(THIS_MODULE);
-
- mutex_init(&gameport->drv_mutex);
- device_initialize(&gameport->dev);
- dev_set_name(&gameport->dev, "gameport%lu",
- (unsigned long)atomic_inc_return(&gameport_no) - 1);
- gameport->dev.bus = &gameport_bus;
- gameport->dev.release = gameport_release_port;
- if (gameport->parent)
- gameport->dev.parent = &gameport->parent->dev;
-
- INIT_LIST_HEAD(&gameport->node);
- spin_lock_init(&gameport->timer_lock);
- init_timer(&gameport->poll_timer);
- gameport->poll_timer.function = gameport_run_poll_handler;
- gameport->poll_timer.data = (unsigned long)gameport;
-}
-
-/*
- * Complete gameport port registration.
- * Driver core will attempt to find appropriate driver for the port.
- */
-static void gameport_add_port(struct gameport *gameport)
-{
- int error;
-
- if (gameport->parent)
- gameport->parent->child = gameport;
-
- gameport->speed = gameport_measure_speed(gameport);
-
- list_add_tail(&gameport->node, &gameport_list);
-
- if (gameport->io)
- dev_info(&gameport->dev, "%s is %s, io %#x, speed %dkHz\n",
- gameport->name, gameport->phys, gameport->io, gameport->speed);
- else
- dev_info(&gameport->dev, "%s is %s, speed %dkHz\n",
- gameport->name, gameport->phys, gameport->speed);
-
- error = device_add(&gameport->dev);
- if (error)
- dev_err(&gameport->dev,
- "device_add() failed for %s (%s), error: %d\n",
- gameport->phys, gameport->name, error);
-}
-
-/*
- * gameport_destroy_port() completes deregistration process and removes
- * port from the system
- */
-static void gameport_destroy_port(struct gameport *gameport)
-{
- struct gameport *child;
-
- child = gameport_get_pending_child(gameport);
- if (child) {
- gameport_remove_pending_events(child);
- put_device(&child->dev);
- }
-
- if (gameport->parent) {
- gameport->parent->child = NULL;
- gameport->parent = NULL;
- }
-
- if (device_is_registered(&gameport->dev))
- device_del(&gameport->dev);
-
- list_del_init(&gameport->node);
-
- gameport_remove_pending_events(gameport);
- put_device(&gameport->dev);
-}
-
-/*
- * Reconnect gameport port and all its children (re-initialize attached devices)
- */
-static void gameport_reconnect_port(struct gameport *gameport)
-{
- do {
- if (!gameport->drv || !gameport->drv->reconnect || gameport->drv->reconnect(gameport)) {
- gameport_disconnect_port(gameport);
- gameport_find_driver(gameport);
- /* Ok, old children are now gone, we are done */
- break;
- }
- gameport = gameport->child;
- } while (gameport);
-}
-
-/*
- * gameport_disconnect_port() unbinds a port from its driver. As a side effect
- * all child ports are unbound and destroyed.
- */
-static void gameport_disconnect_port(struct gameport *gameport)
-{
- struct gameport *s, *parent;
-
- if (gameport->child) {
- /*
- * Children ports should be disconnected and destroyed
- * first, staring with the leaf one, since we don't want
- * to do recursion
- */
- for (s = gameport; s->child; s = s->child)
- /* empty */;
-
- do {
- parent = s->parent;
-
- device_release_driver(&s->dev);
- gameport_destroy_port(s);
- } while ((s = parent) != gameport);
- }
-
- /*
- * Ok, no children left, now disconnect this port
- */
- device_release_driver(&gameport->dev);
-}
-
-/*
- * Submits register request to kgameportd for subsequent execution.
- * Note that port registration is always asynchronous.
- */
-void __gameport_register_port(struct gameport *gameport, struct module *owner)
-{
- gameport_init_port(gameport);
- gameport_queue_event(gameport, owner, GAMEPORT_REGISTER_PORT);
-}
-EXPORT_SYMBOL(__gameport_register_port);
-
-/*
- * Synchronously unregisters gameport port.
- */
-void gameport_unregister_port(struct gameport *gameport)
-{
- mutex_lock(&gameport_mutex);
- gameport_disconnect_port(gameport);
- gameport_destroy_port(gameport);
- mutex_unlock(&gameport_mutex);
-}
-EXPORT_SYMBOL(gameport_unregister_port);
-
-
-/*
- * Gameport driver operations
- */
-
-static ssize_t description_show(struct device_driver *drv, char *buf)
-{
- struct gameport_driver *driver = to_gameport_driver(drv);
- return sprintf(buf, "%s\n", driver->description ? driver->description : "(none)");
-}
-static DRIVER_ATTR_RO(description);
-
-static struct attribute *gameport_driver_attrs[] = {
- &driver_attr_description.attr,
- NULL
-};
-ATTRIBUTE_GROUPS(gameport_driver);
-
-static int gameport_driver_probe(struct device *dev)
-{
- struct gameport *gameport = to_gameport_port(dev);
- struct gameport_driver *drv = to_gameport_driver(dev->driver);
-
- drv->connect(gameport, drv);
- return gameport->drv ? 0 : -ENODEV;
-}
-
-static int gameport_driver_remove(struct device *dev)
-{
- struct gameport *gameport = to_gameport_port(dev);
- struct gameport_driver *drv = to_gameport_driver(dev->driver);
-
- drv->disconnect(gameport);
- return 0;
-}
-
-static void gameport_attach_driver(struct gameport_driver *drv)
-{
- int error;
-
- error = driver_attach(&drv->driver);
- if (error)
- pr_err("driver_attach() failed for %s, error: %d\n",
- drv->driver.name, error);
-}
-
-int __gameport_register_driver(struct gameport_driver *drv, struct module *owner,
- const char *mod_name)
-{
- int error;
-
- drv->driver.bus = &gameport_bus;
- drv->driver.owner = owner;
- drv->driver.mod_name = mod_name;
-
- /*
- * Temporarily disable automatic binding because probing
- * takes long time and we are better off doing it in kgameportd
- */
- drv->ignore = true;
-
- error = driver_register(&drv->driver);
- if (error) {
- pr_err("driver_register() failed for %s, error: %d\n",
- drv->driver.name, error);
- return error;
- }
-
- /*
- * Reset ignore flag and let kgameportd bind the driver to free ports
- */
- drv->ignore = false;
- error = gameport_queue_event(drv, NULL, GAMEPORT_ATTACH_DRIVER);
- if (error) {
- driver_unregister(&drv->driver);
- return error;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(__gameport_register_driver);
-
-void gameport_unregister_driver(struct gameport_driver *drv)
-{
- struct gameport *gameport;
-
- mutex_lock(&gameport_mutex);
-
- drv->ignore = true; /* so gameport_find_driver ignores it */
- gameport_remove_pending_events(drv);
-
-start_over:
- list_for_each_entry(gameport, &gameport_list, node) {
- if (gameport->drv == drv) {
- gameport_disconnect_port(gameport);
- gameport_find_driver(gameport);
- /* we could've deleted some ports, restart */
- goto start_over;
- }
- }
-
- driver_unregister(&drv->driver);
-
- mutex_unlock(&gameport_mutex);
-}
-EXPORT_SYMBOL(gameport_unregister_driver);
-
-static int gameport_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct gameport_driver *gameport_drv = to_gameport_driver(drv);
-
- return !gameport_drv->ignore;
-}
-
-static struct bus_type gameport_bus = {
- .name = "gameport",
- .dev_groups = gameport_device_groups,
- .drv_groups = gameport_driver_groups,
- .match = gameport_bus_match,
- .probe = gameport_driver_probe,
- .remove = gameport_driver_remove,
-};
-
-static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv)
-{
- mutex_lock(&gameport->drv_mutex);
- gameport->drv = drv;
- mutex_unlock(&gameport->drv_mutex);
-}
-
-int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode)
-{
- if (gameport->open) {
- if (gameport->open(gameport, mode)) {
- return -1;
- }
- } else {
- if (mode != GAMEPORT_MODE_RAW)
- return -1;
- }
-
- gameport_set_drv(gameport, drv);
- return 0;
-}
-EXPORT_SYMBOL(gameport_open);
-
-void gameport_close(struct gameport *gameport)
-{
- del_timer_sync(&gameport->poll_timer);
- gameport->poll_handler = NULL;
- gameport->poll_interval = 0;
- gameport_set_drv(gameport, NULL);
- if (gameport->close)
- gameport->close(gameport);
-}
-EXPORT_SYMBOL(gameport_close);
-
-static int __init gameport_init(void)
-{
- int error;
-
- error = bus_register(&gameport_bus);
- if (error) {
- pr_err("failed to register gameport bus, error: %d\n", error);
- return error;
- }
-
-
- return 0;
-}
-
-static void __exit gameport_exit(void)
-{
- bus_unregister(&gameport_bus);
-
- /*
- * There should not be any outstanding events but work may
- * still be scheduled so simply cancel it.
- */
- cancel_work_sync(&gameport_event_work);
-}
-
-subsys_initcall(gameport_init);
-module_exit(gameport_exit);
diff --git a/drivers/input/gameport/lightning.c b/drivers/input/gameport/lightning.c
deleted file mode 100644
index 85d6ee0..0000000
--- a/drivers/input/gameport/lightning.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Vojtech Pavlik
- */
-
-/*
- * PDPI Lightning 4 gamecard driver for Linux.
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/gameport.h>
-
-#define L4_PORT 0x201
-#define L4_SELECT_ANALOG 0xa4
-#define L4_SELECT_DIGITAL 0xa5
-#define L4_SELECT_SECONDARY 0xa6
-#define L4_CMD_ID 0x80
-#define L4_CMD_GETCAL 0x92
-#define L4_CMD_SETCAL 0x93
-#define L4_ID 0x04
-#define L4_BUSY 0x01
-#define L4_TIMEOUT 80 /* 80 us */
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION("PDPI Lightning 4 gamecard driver");
-MODULE_LICENSE("GPL");
-
-struct l4 {
- struct gameport *gameport;
- unsigned char port;
-};
-
-static struct l4 l4_ports[8];
-
-/*
- * l4_wait_ready() waits for the L4 to become ready.
- */
-
-static int l4_wait_ready(void)
-{
- unsigned int t = L4_TIMEOUT;
-
- while ((inb(L4_PORT) & L4_BUSY) && t > 0) t--;
- return -(t <= 0);
-}
-
-/*
- * l4_cooked_read() reads data from the Lightning 4.
- */
-
-static int l4_cooked_read(struct gameport *gameport, int *axes, int *buttons)
-{
- struct l4 *l4 = gameport->port_data;
- unsigned char status;
- int i, result = -1;
-
- outb(L4_SELECT_ANALOG, L4_PORT);
- outb(L4_SELECT_DIGITAL + (l4->port >> 2), L4_PORT);
-
- if (inb(L4_PORT) & L4_BUSY) goto fail;
- outb(l4->port & 3, L4_PORT);
-
- if (l4_wait_ready()) goto fail;
- status = inb(L4_PORT);
-
- for (i = 0; i < 4; i++)
- if (status & (1 << i)) {
- if (l4_wait_ready()) goto fail;
- axes[i] = inb(L4_PORT);
- if (axes[i] > 252) axes[i] = -1;
- }
-
- if (status & 0x10) {
- if (l4_wait_ready()) goto fail;
- *buttons = inb(L4_PORT) & 0x0f;
- }
-
- result = 0;
-
-fail: outb(L4_SELECT_ANALOG, L4_PORT);
- return result;
-}
-
-static int l4_open(struct gameport *gameport, int mode)
-{
- struct l4 *l4 = gameport->port_data;
-
- if (l4->port != 0 && mode != GAMEPORT_MODE_COOKED)
- return -1;
- outb(L4_SELECT_ANALOG, L4_PORT);
- return 0;
-}
-
-/*
- * l4_getcal() reads the L4 with calibration values.
- */
-
-static int l4_getcal(int port, int *cal)
-{
- int i, result = -1;
-
- outb(L4_SELECT_ANALOG, L4_PORT);
- outb(L4_SELECT_DIGITAL + (port >> 2), L4_PORT);
- if (inb(L4_PORT) & L4_BUSY)
- goto out;
-
- outb(L4_CMD_GETCAL, L4_PORT);
- if (l4_wait_ready())
- goto out;
-
- if (inb(L4_PORT) != L4_SELECT_DIGITAL + (port >> 2))
- goto out;
-
- if (l4_wait_ready())
- goto out;
- outb(port & 3, L4_PORT);
-
- for (i = 0; i < 4; i++) {
- if (l4_wait_ready())
- goto out;
- cal[i] = inb(L4_PORT);
- }
-
- result = 0;
-
-out: outb(L4_SELECT_ANALOG, L4_PORT);
- return result;
-}
-
-/*
- * l4_setcal() programs the L4 with calibration values.
- */
-
-static int l4_setcal(int port, int *cal)
-{
- int i, result = -1;
-
- outb(L4_SELECT_ANALOG, L4_PORT);
- outb(L4_SELECT_DIGITAL + (port >> 2), L4_PORT);
- if (inb(L4_PORT) & L4_BUSY)
- goto out;
-
- outb(L4_CMD_SETCAL, L4_PORT);
- if (l4_wait_ready())
- goto out;
-
- if (inb(L4_PORT) != L4_SELECT_DIGITAL + (port >> 2))
- goto out;
-
- if (l4_wait_ready())
- goto out;
- outb(port & 3, L4_PORT);
-
- for (i = 0; i < 4; i++) {
- if (l4_wait_ready())
- goto out;
- outb(cal[i], L4_PORT);
- }
-
- result = 0;
-
-out: outb(L4_SELECT_ANALOG, L4_PORT);
- return result;
-}
-
-/*
- * l4_calibrate() calibrates the L4 for the attached device, so
- * that the device's resistance fits into the L4's 8-bit range.
- */
-
-static int l4_calibrate(struct gameport *gameport, int *axes, int *max)
-{
- int i, t;
- int cal[4];
- struct l4 *l4 = gameport->port_data;
-
- if (l4_getcal(l4->port, cal))
- return -1;
-
- for (i = 0; i < 4; i++) {
- t = (max[i] * cal[i]) / 200;
- t = (t < 1) ? 1 : ((t > 255) ? 255 : t);
- axes[i] = (axes[i] < 0) ? -1 : (axes[i] * cal[i]) / t;
- axes[i] = (axes[i] > 252) ? 252 : axes[i];
- cal[i] = t;
- }
-
- if (l4_setcal(l4->port, cal))
- return -1;
-
- return 0;
-}
-
-static int __init l4_create_ports(int card_no)
-{
- struct l4 *l4;
- struct gameport *port;
- int i, idx;
-
- for (i = 0; i < 4; i++) {
-
- idx = card_no * 4 + i;
- l4 = &l4_ports[idx];
-
- if (!(l4->gameport = port = gameport_allocate_port())) {
- printk(KERN_ERR "lightning: Memory allocation failed\n");
- while (--i >= 0) {
- gameport_free_port(l4->gameport);
- l4->gameport = NULL;
- }
- return -ENOMEM;
- }
- l4->port = idx;
-
- port->port_data = l4;
- port->open = l4_open;
- port->cooked_read = l4_cooked_read;
- port->calibrate = l4_calibrate;
-
- gameport_set_name(port, "PDPI Lightning 4");
- gameport_set_phys(port, "isa%04x/gameport%d", L4_PORT, idx);
-
- if (idx == 0)
- port->io = L4_PORT;
- }
-
- return 0;
-}
-
-static int __init l4_add_card(int card_no)
-{
- int cal[4] = { 255, 255, 255, 255 };
- int i, rev, result;
- struct l4 *l4;
-
- outb(L4_SELECT_ANALOG, L4_PORT);
- outb(L4_SELECT_DIGITAL + card_no, L4_PORT);
-
- if (inb(L4_PORT) & L4_BUSY)
- return -1;
- outb(L4_CMD_ID, L4_PORT);
-
- if (l4_wait_ready())
- return -1;
-
- if (inb(L4_PORT) != L4_SELECT_DIGITAL + card_no)
- return -1;
-
- if (l4_wait_ready())
- return -1;
- if (inb(L4_PORT) != L4_ID)
- return -1;
-
- if (l4_wait_ready())
- return -1;
- rev = inb(L4_PORT);
-
- if (!rev)
- return -1;
-
- result = l4_create_ports(card_no);
- if (result)
- return result;
-
- printk(KERN_INFO "gameport: PDPI Lightning 4 %s card v%d.%d at %#x\n",
- card_no ? "secondary" : "primary", rev >> 4, rev, L4_PORT);
-
- for (i = 0; i < 4; i++) {
- l4 = &l4_ports[card_no * 4 + i];
-
- if (rev > 0x28) /* on 2.9+ the setcal command works correctly */
- l4_setcal(l4->port, cal);
- gameport_register_port(l4->gameport);
- }
-
- return 0;
-}
-
-static int __init l4_init(void)
-{
- int i, cards = 0;
-
- if (!request_region(L4_PORT, 1, "lightning"))
- return -EBUSY;
-
- for (i = 0; i < 2; i++)
- if (l4_add_card(i) == 0)
- cards++;
-
- outb(L4_SELECT_ANALOG, L4_PORT);
-
- if (!cards) {
- release_region(L4_PORT, 1);
- return -ENODEV;
- }
-
- return 0;
-}
-
-static void __exit l4_exit(void)
-{
- int i;
- int cal[4] = { 59, 59, 59, 59 };
-
- for (i = 0; i < 8; i++)
- if (l4_ports[i].gameport) {
- l4_setcal(l4_ports[i].port, cal);
- gameport_unregister_port(l4_ports[i].gameport);
- }
-
- outb(L4_SELECT_ANALOG, L4_PORT);
- release_region(L4_PORT, 1);
-}
-
-module_init(l4_init);
-module_exit(l4_exit);
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
deleted file mode 100644
index 7c21784..0000000
--- a/drivers/input/gameport/ns558.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 1999-2001 Vojtech Pavlik
- * Copyright (c) 1999 Brian Gerst
- */
-
-/*
- * NS558 based standard IBM game port driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <asm/io.h>
-
-#include <linux/module.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/gameport.h>
-#include <linux/slab.h>
-#include <linux/pnp.h>
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION("Classic gameport (ISA/PnP) driver");
-MODULE_LICENSE("GPL");
-
-static int ns558_isa_portlist[] = { 0x201, 0x200, 0x202, 0x203, 0x204, 0x205, 0x207, 0x209,
- 0x20b, 0x20c, 0x20e, 0x20f, 0x211, 0x219, 0x101, 0 };
-
-struct ns558 {
- int type;
- int io;
- int size;
- struct pnp_dev *dev;
- struct gameport *gameport;
- struct list_head node;
-};
-
-static LIST_HEAD(ns558_list);
-
-/*
- * ns558_isa_probe() tries to find an isa gameport at the
- * specified address, and also checks for mirrors.
- * A joystick must be attached for this to work.
- */
-
-static int ns558_isa_probe(int io)
-{
- int i, j, b;
- unsigned char c, u, v;
- struct ns558 *ns558;
- struct gameport *port;
-
-/*
- * No one should be using this address.
- */
-
- if (!request_region(io, 1, "ns558-isa"))
- return -EBUSY;
-
-/*
- * We must not be able to write arbitrary values to the port.
- * The lower two axis bits must be 1 after a write.
- */
-
- c = inb(io);
- outb(~c & ~3, io);
- if (~(u = v = inb(io)) & 3) {
- outb(c, io);
- release_region(io, 1);
- return -ENODEV;
- }
-/*
- * After a trigger, there must be at least some bits changing.
- */
-
- for (i = 0; i < 1000; i++) v &= inb(io);
-
- if (u == v) {
- outb(c, io);
- release_region(io, 1);
- return -ENODEV;
- }
- msleep(3);
-/*
- * After some time (4ms) the axes shouldn't change anymore.
- */
-
- u = inb(io);
- for (i = 0; i < 1000; i++)
- if ((u ^ inb(io)) & 0xf) {
- outb(c, io);
- release_region(io, 1);
- return -ENODEV;
- }
-/*
- * And now find the number of mirrors of the port.
- */
-
- for (i = 1; i < 5; i++) {
-
- release_region(io & (-1 << (i - 1)), (1 << (i - 1)));
-
- if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
- break; /* Don't disturb anyone */
-
- outb(0xff, io & (-1 << i));
- for (j = b = 0; j < 1000; j++)
- if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
- msleep(3);
-
- if (b > 300) { /* We allow 30% difference */
- release_region(io & (-1 << i), (1 << i));
- break;
- }
- }
-
- i--;
-
- if (i != 4) {
- if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
- return -EBUSY;
- }
-
- ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL);
- port = gameport_allocate_port();
- if (!ns558 || !port) {
- printk(KERN_ERR "ns558: Memory allocation failed.\n");
- release_region(io & (-1 << i), (1 << i));
- kfree(ns558);
- gameport_free_port(port);
- return -ENOMEM;
- }
-
- ns558->io = io;
- ns558->size = 1 << i;
- ns558->gameport = port;
-
- port->io = io;
- gameport_set_name(port, "NS558 ISA Gameport");
- gameport_set_phys(port, "isa%04x/gameport0", io & (-1 << i));
-
- gameport_register_port(port);
-
- list_add(&ns558->node, &ns558_list);
-
- return 0;
-}
-
-#ifdef CONFIG_PNP
-
-static const struct pnp_device_id pnp_devids[] = {
- { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */
- { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */
- { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */
- { .id = "@P@2001", .driver_data = 0 }, /* ALS 120 */
- { .id = "ASB16fd", .driver_data = 0 }, /* AdLib NSC16 */
- { .id = "AZT3001", .driver_data = 0 }, /* AZT1008 */
- { .id = "CDC0001", .driver_data = 0 }, /* Opl3-SAx */
- { .id = "CSC0001", .driver_data = 0 }, /* CS4232 */
- { .id = "CSC000f", .driver_data = 0 }, /* CS4236 */
- { .id = "CSC0101", .driver_data = 0 }, /* CS4327 */
- { .id = "CTL7001", .driver_data = 0 }, /* SB16 */
- { .id = "CTL7002", .driver_data = 0 }, /* AWE64 */
- { .id = "CTL7005", .driver_data = 0 }, /* Vibra16 */
- { .id = "ENS2020", .driver_data = 0 }, /* SoundscapeVIVO */
- { .id = "ESS0001", .driver_data = 0 }, /* ES1869 */
- { .id = "ESS0005", .driver_data = 0 }, /* ES1878 */
- { .id = "ESS6880", .driver_data = 0 }, /* ES688 */
- { .id = "IBM0012", .driver_data = 0 }, /* CS4232 */
- { .id = "OPT0001", .driver_data = 0 }, /* OPTi Audio16 */
- { .id = "YMH0006", .driver_data = 0 }, /* Opl3-SA */
- { .id = "YMH0022", .driver_data = 0 }, /* Opl3-SAx */
- { .id = "PNPb02f", .driver_data = 0 }, /* Generic */
- { .id = "", },
-};
-
-MODULE_DEVICE_TABLE(pnp, pnp_devids);
-
-static int ns558_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
-{
- int ioport, iolen;
- struct ns558 *ns558;
- struct gameport *port;
-
- if (!pnp_port_valid(dev, 0)) {
- printk(KERN_WARNING "ns558: No i/o ports on a gameport? Weird\n");
- return -ENODEV;
- }
-
- ioport = pnp_port_start(dev, 0);
- iolen = pnp_port_len(dev, 0);
-
- if (!request_region(ioport, iolen, "ns558-pnp"))
- return -EBUSY;
-
- ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL);
- port = gameport_allocate_port();
- if (!ns558 || !port) {
- printk(KERN_ERR "ns558: Memory allocation failed\n");
- kfree(ns558);
- gameport_free_port(port);
- return -ENOMEM;
- }
-
- ns558->io = ioport;
- ns558->size = iolen;
- ns558->dev = dev;
- ns558->gameport = port;
-
- gameport_set_name(port, "NS558 PnP Gameport");
- gameport_set_phys(port, "pnp%s/gameport0", dev_name(&dev->dev));
- port->dev.parent = &dev->dev;
- port->io = ioport;
-
- gameport_register_port(port);
-
- list_add_tail(&ns558->node, &ns558_list);
- return 0;
-}
-
-static struct pnp_driver ns558_pnp_driver = {
- .name = "ns558",
- .id_table = pnp_devids,
- .probe = ns558_pnp_probe,
-};
-
-#else
-
-static struct pnp_driver ns558_pnp_driver;
-
-#endif
-
-static int __init ns558_init(void)
-{
- int i = 0;
- int error;
-
- error = pnp_register_driver(&ns558_pnp_driver);
- if (error && error != -ENODEV) /* should be ENOSYS really */
- return error;
-
-/*
- * Probe ISA ports after PnP, so that PnP ports that are already
- * enabled get detected as PnP. This may be suboptimal in multi-device
- * configurations, but saves hassle with simple setups.
- */
-
- while (ns558_isa_portlist[i])
- ns558_isa_probe(ns558_isa_portlist[i++]);
-
- return list_empty(&ns558_list) && error ? -ENODEV : 0;
-}
-
-static void __exit ns558_exit(void)
-{
- struct ns558 *ns558, *safe;
-
- list_for_each_entry_safe(ns558, safe, &ns558_list, node) {
- gameport_unregister_port(ns558->gameport);
- release_region(ns558->io & ~(ns558->size - 1), ns558->size);
- kfree(ns558);
- }
-
- pnp_unregister_driver(&ns558_pnp_driver);
-}
-
-module_init(ns558_init);
-module_exit(ns558_exit);
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index 56eb471..aca6e87 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -14,122 +14,6 @@ menuconfig INPUT_JOYSTICK

if INPUT_JOYSTICK

-config JOYSTICK_ANALOG
- tristate "Classic PC analog joysticks and gamepads"
- select GAMEPORT
- ---help---
- Say Y here if you have a joystick that connects to the PC
- gameport. In addition to the usual PC analog joystick, this driver
- supports many extensions, including joysticks with throttle control,
- with rudders, additional hats and buttons compatible with CH
- Flightstick Pro, ThrustMaster FCS, 6 and 8 button gamepads, or
- Saitek Cyborg joysticks.
-
- Please read the file <file:Documentation/input/joystick.txt> which
- contains more information.
-
- To compile this driver as a module, choose M here: the
- module will be called analog.
-
-config JOYSTICK_A3D
- tristate "Assassin 3D and MadCatz Panther devices"
- select GAMEPORT
- help
- Say Y here if you have an FPGaming or MadCatz controller using the
- A3D protocol over the PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called a3d.
-
-config JOYSTICK_ADI
- tristate "Logitech ADI digital joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a Logitech controller using the ADI
- protocol over the PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called adi.
-
-config JOYSTICK_COBRA
- tristate "Creative Labs Blaster Cobra gamepad"
- select GAMEPORT
- help
- Say Y here if you have a Creative Labs Blaster Cobra gamepad.
-
- To compile this driver as a module, choose M here: the
- module will be called cobra.
-
-config JOYSTICK_GF2K
- tristate "Genius Flight2000 Digital joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a Genius Flight2000 or MaxFighter digitally
- communicating joystick or gamepad.
-
- To compile this driver as a module, choose M here: the
- module will be called gf2k.
-
-config JOYSTICK_GRIP
- tristate "Gravis GrIP joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a Gravis controller using the GrIP protocol
- over the PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called grip.
-
-config JOYSTICK_GRIP_MP
- tristate "Gravis GrIP MultiPort"
- select GAMEPORT
- help
- Say Y here if you have the original Gravis GrIP MultiPort, a hub
- that connects to the gameport and you connect gamepads to it.
-
- To compile this driver as a module, choose M here: the
- module will be called grip_mp.
-
-config JOYSTICK_GUILLEMOT
- tristate "Guillemot joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a Guillemot joystick using a digital
- protocol over the PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called guillemot.
-
-config JOYSTICK_INTERACT
- tristate "InterAct digital joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have an InterAct gameport or joystick
- communicating digitally over the gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called interact.
-
-config JOYSTICK_SIDEWINDER
- tristate "Microsoft SideWinder digital joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a Microsoft controller using the Digital
- Overdrive protocol over PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called sidewinder.
-
-config JOYSTICK_TMDC
- tristate "ThrustMaster DirectConnect joysticks and gamepads"
- select GAMEPORT
- help
- Say Y here if you have a ThrustMaster controller using the
- DirectConnect (BSP) protocol over the PC gameport.
-
- To compile this driver as a module, choose M here: the
- module will be called tmdc.
-
source "drivers/input/joystick/iforce/Kconfig"

config JOYSTICK_WARRIOR
@@ -265,17 +149,6 @@ config JOYSTICK_AS5011
To compile this driver as a module, choose M here: the
module will be called as5011.

-config JOYSTICK_JOYDUMP
- tristate "Gameport data dumper"
- select GAMEPORT
- help
- Say Y here if you want to dump data from your joystick into the system
- log for debugging purposes. Say N if you are making a production
- configuration or aren't sure.
-
- To compile this driver as a module, choose M here: the
- module will be called joydump.
-
config JOYSTICK_XPAD
tristate "X-Box gamepad support"
depends on USB_ARCH_HAS_HCD
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
index 92dc0de..eb8e75a 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@ -4,28 +4,16 @@

# Each configuration option enables a list of files.

-obj-$(CONFIG_JOYSTICK_A3D) += a3d.o
-obj-$(CONFIG_JOYSTICK_ADI) += adi.o
obj-$(CONFIG_JOYSTICK_AMIGA) += amijoy.o
obj-$(CONFIG_JOYSTICK_AS5011) += as5011.o
-obj-$(CONFIG_JOYSTICK_ANALOG) += analog.o
-obj-$(CONFIG_JOYSTICK_COBRA) += cobra.o
obj-$(CONFIG_JOYSTICK_DB9) += db9.o
obj-$(CONFIG_JOYSTICK_GAMECON) += gamecon.o
-obj-$(CONFIG_JOYSTICK_GF2K) += gf2k.o
-obj-$(CONFIG_JOYSTICK_GRIP) += grip.o
-obj-$(CONFIG_JOYSTICK_GRIP_MP) += grip_mp.o
-obj-$(CONFIG_JOYSTICK_GUILLEMOT) += guillemot.o
obj-$(CONFIG_JOYSTICK_IFORCE) += iforce/
-obj-$(CONFIG_JOYSTICK_INTERACT) += interact.o
-obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o
obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o
obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o
-obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o
obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o
obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o
obj-$(CONFIG_JOYSTICK_STINGER) += stinger.o
-obj-$(CONFIG_JOYSTICK_TMDC) += tmdc.o
obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += turbografx.o
obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
deleted file mode 100644
index 55efdfc..0000000
--- a/drivers/input/joystick/a3d.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Vojtech Pavlik
- */
-
-/*
- * FP-Gaming Assassin 3D joystick driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "FP-Gaming Assassin 3D joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define A3D_MAX_START 600 /* 600 us */
-#define A3D_MAX_STROBE 80 /* 80 us */
-#define A3D_MAX_LENGTH 40 /* 40*3 bits */
-
-#define A3D_MODE_A3D 1 /* Assassin 3D */
-#define A3D_MODE_PAN 2 /* Panther */
-#define A3D_MODE_OEM 3 /* Panther OEM version */
-#define A3D_MODE_PXL 4 /* Panther XL */
-
-static char *a3d_names[] = { NULL, "FP-Gaming Assassin 3D", "MadCatz Panther", "OEM Panther",
- "MadCatz Panther XL", "MadCatz Panther XL w/ rudder" };
-
-struct a3d {
- struct gameport *gameport;
- struct gameport *adc;
- struct input_dev *dev;
- int axes[4];
- int buttons;
- int mode;
- int length;
- int reads;
- int bads;
- char phys[32];
-};
-
-/*
- * a3d_read_packet() reads an Assassin 3D packet.
- */
-
-static int a3d_read_packet(struct gameport *gameport, int length, char *data)
-{
- unsigned long flags;
- unsigned char u, v;
- unsigned int t, s;
- int i;
-
- i = 0;
- t = gameport_time(gameport, A3D_MAX_START);
- s = gameport_time(gameport, A3D_MAX_STROBE);
-
- local_irq_save(flags);
- gameport_trigger(gameport);
- v = gameport_read(gameport);
-
- while (t > 0 && i < length) {
- t--;
- u = v; v = gameport_read(gameport);
- if (~v & u & 0x10) {
- data[i++] = v >> 5;
- t = s;
- }
- }
-
- local_irq_restore(flags);
-
- return i;
-}
-
-/*
- * a3d_csum() computes checksum of triplet packet
- */
-
-static int a3d_csum(char *data, int count)
-{
- int i, csum = 0;
-
- for (i = 0; i < count - 2; i++)
- csum += data[i];
- return (csum & 0x3f) != ((data[count - 2] << 3) | data[count - 1]);
-}
-
-static void a3d_read(struct a3d *a3d, unsigned char *data)
-{
- struct input_dev *dev = a3d->dev;
-
- switch (a3d->mode) {
-
- case A3D_MODE_A3D:
- case A3D_MODE_OEM:
- case A3D_MODE_PAN:
-
- input_report_rel(dev, REL_X, ((data[5] << 6) | (data[6] << 3) | data[ 7]) - ((data[5] & 4) << 7));
- input_report_rel(dev, REL_Y, ((data[8] << 6) | (data[9] << 3) | data[10]) - ((data[8] & 4) << 7));
-
- input_report_key(dev, BTN_RIGHT, data[2] & 1);
- input_report_key(dev, BTN_LEFT, data[3] & 2);
- input_report_key(dev, BTN_MIDDLE, data[3] & 4);
-
- input_sync(dev);
-
- a3d->axes[0] = ((signed char)((data[11] << 6) | (data[12] << 3) | (data[13]))) + 128;
- a3d->axes[1] = ((signed char)((data[14] << 6) | (data[15] << 3) | (data[16]))) + 128;
- a3d->axes[2] = ((signed char)((data[17] << 6) | (data[18] << 3) | (data[19]))) + 128;
- a3d->axes[3] = ((signed char)((data[20] << 6) | (data[21] << 3) | (data[22]))) + 128;
-
- a3d->buttons = ((data[3] << 3) | data[4]) & 0xf;
-
- break;
-
- case A3D_MODE_PXL:
-
- input_report_rel(dev, REL_X, ((data[ 9] << 6) | (data[10] << 3) | data[11]) - ((data[ 9] & 4) << 7));
- input_report_rel(dev, REL_Y, ((data[12] << 6) | (data[13] << 3) | data[14]) - ((data[12] & 4) << 7));
-
- input_report_key(dev, BTN_RIGHT, data[2] & 1);
- input_report_key(dev, BTN_LEFT, data[3] & 2);
- input_report_key(dev, BTN_MIDDLE, data[3] & 4);
- input_report_key(dev, BTN_SIDE, data[7] & 2);
- input_report_key(dev, BTN_EXTRA, data[7] & 4);
-
- input_report_abs(dev, ABS_X, ((signed char)((data[15] << 6) | (data[16] << 3) | (data[17]))) + 128);
- input_report_abs(dev, ABS_Y, ((signed char)((data[18] << 6) | (data[19] << 3) | (data[20]))) + 128);
- input_report_abs(dev, ABS_RUDDER, ((signed char)((data[21] << 6) | (data[22] << 3) | (data[23]))) + 128);
- input_report_abs(dev, ABS_THROTTLE, ((signed char)((data[24] << 6) | (data[25] << 3) | (data[26]))) + 128);
-
- input_report_abs(dev, ABS_HAT0X, ( data[5] & 1) - ((data[5] >> 2) & 1));
- input_report_abs(dev, ABS_HAT0Y, ((data[5] >> 1) & 1) - ((data[6] >> 2) & 1));
- input_report_abs(dev, ABS_HAT1X, ((data[4] >> 1) & 1) - ( data[3] & 1));
- input_report_abs(dev, ABS_HAT1Y, ((data[4] >> 2) & 1) - ( data[4] & 1));
-
- input_report_key(dev, BTN_TRIGGER, data[8] & 1);
- input_report_key(dev, BTN_THUMB, data[8] & 2);
- input_report_key(dev, BTN_TOP, data[8] & 4);
- input_report_key(dev, BTN_PINKIE, data[7] & 1);
-
- input_sync(dev);
-
- break;
- }
-}
-
-
-/*
- * a3d_poll() reads and analyzes A3D joystick data.
- */
-
-static void a3d_poll(struct gameport *gameport)
-{
- struct a3d *a3d = gameport_get_drvdata(gameport);
- unsigned char data[A3D_MAX_LENGTH];
-
- a3d->reads++;
- if (a3d_read_packet(a3d->gameport, a3d->length, data) != a3d->length ||
- data[0] != a3d->mode || a3d_csum(data, a3d->length))
- a3d->bads++;
- else
- a3d_read(a3d, data);
-}
-
-/*
- * a3d_adc_cooked_read() copies the acis and button data to the
- * callers arrays. It could do the read itself, but the caller could
- * call this more than 50 times a second, which would use too much CPU.
- */
-
-static int a3d_adc_cooked_read(struct gameport *gameport, int *axes, int *buttons)
-{
- struct a3d *a3d = gameport->port_data;
- int i;
-
- for (i = 0; i < 4; i++)
- axes[i] = (a3d->axes[i] < 254) ? a3d->axes[i] : -1;
- *buttons = a3d->buttons;
- return 0;
-}
-
-/*
- * a3d_adc_open() is the gameport open routine. It refuses to serve
- * any but cooked data.
- */
-
-static int a3d_adc_open(struct gameport *gameport, int mode)
-{
- struct a3d *a3d = gameport->port_data;
-
- if (mode != GAMEPORT_MODE_COOKED)
- return -1;
-
- gameport_start_polling(a3d->gameport);
- return 0;
-}
-
-/*
- * a3d_adc_close() is a callback from the input close routine.
- */
-
-static void a3d_adc_close(struct gameport *gameport)
-{
- struct a3d *a3d = gameport->port_data;
-
- gameport_stop_polling(a3d->gameport);
-}
-
-/*
- * a3d_open() is a callback from the input open routine.
- */
-
-static int a3d_open(struct input_dev *dev)
-{
- struct a3d *a3d = input_get_drvdata(dev);
-
- gameport_start_polling(a3d->gameport);
- return 0;
-}
-
-/*
- * a3d_close() is a callback from the input close routine.
- */
-
-static void a3d_close(struct input_dev *dev)
-{
- struct a3d *a3d = input_get_drvdata(dev);
-
- gameport_stop_polling(a3d->gameport);
-}
-
-/*
- * a3d_connect() probes for A3D joysticks.
- */
-
-static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct a3d *a3d;
- struct input_dev *input_dev;
- struct gameport *adc;
- unsigned char data[A3D_MAX_LENGTH];
- int i;
- int err;
-
- a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!a3d || !input_dev) {
- err = -ENOMEM;
- goto fail1;
- }
-
- a3d->dev = input_dev;
- a3d->gameport = gameport;
-
- gameport_set_drvdata(gameport, a3d);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- i = a3d_read_packet(gameport, A3D_MAX_LENGTH, data);
-
- if (!i || a3d_csum(data, i)) {
- err = -ENODEV;
- goto fail2;
- }
-
- a3d->mode = data[0];
-
- if (!a3d->mode || a3d->mode > 5) {
- printk(KERN_WARNING "a3d.c: Unknown A3D device detected "
- "(%s, id=%d), contact <vojtech@xxxxxx>\n", gameport->phys, a3d->mode);
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, a3d_poll);
- gameport_set_poll_interval(gameport, 20);
-
- snprintf(a3d->phys, sizeof(a3d->phys), "%s/input0", gameport->phys);
-
- input_dev->name = a3d_names[a3d->mode];
- input_dev->phys = a3d->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ;
- input_dev->id.product = a3d->mode;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
- input_dev->open = a3d_open;
- input_dev->close = a3d_close;
-
- input_set_drvdata(input_dev, a3d);
-
- if (a3d->mode == A3D_MODE_PXL) {
-
- int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER };
-
- a3d->length = 33;
-
- input_dev->evbit[0] |= BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY) |
- BIT_MASK(EV_REL);
- input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
- input_dev->absbit[0] |= BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
- BIT_MASK(ABS_THROTTLE) | BIT_MASK(ABS_RUDDER) |
- BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) |
- BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y);
- input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) |
- BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) |
- BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
- input_dev->keybit[BIT_WORD(BTN_JOYSTICK)] |=
- BIT_MASK(BTN_TRIGGER) | BIT_MASK(BTN_THUMB) |
- BIT_MASK(BTN_TOP) | BIT_MASK(BTN_PINKIE);
-
- a3d_read(a3d, data);
-
- for (i = 0; i < 4; i++) {
- if (i < 2)
- input_set_abs_params(input_dev, axes[i],
- 48, input_abs_get_val(input_dev, axes[i]) * 2 - 48, 0, 8);
- else
- input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0);
- input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
- }
-
- } else {
- a3d->length = 29;
-
- input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
- input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
- input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) |
- BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE);
-
- a3d_read(a3d, data);
-
- if (!(a3d->adc = adc = gameport_allocate_port()))
- printk(KERN_ERR "a3d: Not enough memory for ADC port\n");
- else {
- adc->port_data = a3d;
- adc->open = a3d_adc_open;
- adc->close = a3d_adc_close;
- adc->cooked_read = a3d_adc_cooked_read;
- adc->fuzz = 1;
-
- gameport_set_name(adc, a3d_names[a3d->mode]);
- gameport_set_phys(adc, "%s/gameport0", gameport->phys);
- adc->dev.parent = &gameport->dev;
-
- gameport_register_port(adc);
- }
- }
-
- err = input_register_device(a3d->dev);
- if (err)
- goto fail3;
-
- return 0;
-
- fail3: if (a3d->adc)
- gameport_unregister_port(a3d->adc);
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- input_free_device(input_dev);
- kfree(a3d);
- return err;
-}
-
-static void a3d_disconnect(struct gameport *gameport)
-{
- struct a3d *a3d = gameport_get_drvdata(gameport);
-
- input_unregister_device(a3d->dev);
- if (a3d->adc)
- gameport_unregister_port(a3d->adc);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(a3d);
-}
-
-static struct gameport_driver a3d_drv = {
- .driver = {
- .name = "adc",
- .owner = THIS_MODULE,
- },
- .description = DRIVER_DESC,
- .connect = a3d_connect,
- .disconnect = a3d_disconnect,
-};
-
-module_gameport_driver(a3d_drv);
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
deleted file mode 100644
index b784257..0000000
--- a/drivers/input/joystick/adi.c
+++ /dev/null
@@ -1,568 +0,0 @@
-/*
- * Copyright (c) 1998-2005 Vojtech Pavlik
- */
-
-/*
- * Logitech ADI joystick family driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Logitech ADI joystick family driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-/*
- * Times, array sizes, flags, ids.
- */
-
-#define ADI_MAX_START 200 /* Trigger to packet timeout [200us] */
-#define ADI_MAX_STROBE 40 /* Single bit timeout [40us] */
-#define ADI_INIT_DELAY 10 /* Delay after init packet [10ms] */
-#define ADI_DATA_DELAY 4 /* Delay after data packet [4ms] */
-
-#define ADI_MAX_LENGTH 256
-#define ADI_MIN_LENGTH 8
-#define ADI_MIN_LEN_LENGTH 10
-#define ADI_MIN_ID_LENGTH 66
-#define ADI_MAX_NAME_LENGTH 64
-#define ADI_MAX_CNAME_LENGTH 16
-#define ADI_MAX_PHYS_LENGTH 64
-
-#define ADI_FLAG_HAT 0x04
-#define ADI_FLAG_10BIT 0x08
-
-#define ADI_ID_TPD 0x01
-#define ADI_ID_WGP 0x06
-#define ADI_ID_WGPE 0x08
-#define ADI_ID_MAX 0x0a
-
-/*
- * Names, buttons, axes ...
- */
-
-static char *adi_names[] = { "WingMan Extreme Digital", "ThunderPad Digital", "SideCar", "CyberMan 2",
- "WingMan Interceptor", "WingMan Formula", "WingMan GamePad",
- "WingMan Extreme Digital 3D", "WingMan GamePad Extreme",
- "WingMan GamePad USB", "Unknown Device %#x" };
-
-static char adi_wmgpe_abs[] = { ABS_X, ABS_Y, ABS_HAT0X, ABS_HAT0Y };
-static char adi_wmi_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
-static char adi_wmed3d_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RZ, ABS_HAT0X, ABS_HAT0Y };
-static char adi_cm2_abs[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
-static char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
-
-static short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT };
-static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA };
-static short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 };
-static short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 };
-
-static char* adi_abs[] = { adi_wmi_abs, adi_wmgpe_abs, adi_wmf_abs, adi_cm2_abs, adi_wmi_abs, adi_wmf_abs,
- adi_wmgpe_abs, adi_wmed3d_abs, adi_wmgpe_abs, adi_wmgpe_abs, adi_wmi_abs };
-
-static short* adi_key[] = { adi_wmi_key, adi_wmgpe_key, adi_cm2_key, adi_cm2_key, adi_wmi_key, adi_cm2_key,
- adi_wmgpe_key, adi_wmed3d_key, adi_wmgpe_key, adi_wmgpe_key, adi_wmi_key };
-
-/*
- * Hat to axis conversion arrays.
- */
-
-static struct {
- int x;
- int y;
-} adi_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
-
-/*
- * Per-port information.
- */
-
-struct adi {
- struct input_dev *dev;
- int length;
- int ret;
- int idx;
- unsigned char id;
- char buttons;
- char axes10;
- char axes8;
- signed char pad;
- char hats;
- char *abs;
- short *key;
- char name[ADI_MAX_NAME_LENGTH];
- char cname[ADI_MAX_CNAME_LENGTH];
- char phys[ADI_MAX_PHYS_LENGTH];
- unsigned char data[ADI_MAX_LENGTH];
-};
-
-struct adi_port {
- struct gameport *gameport;
- struct adi adi[2];
- int bad;
- int reads;
-};
-
-/*
- * adi_read_packet() reads a Logitech ADI packet.
- */
-
-static void adi_read_packet(struct adi_port *port)
-{
- struct adi *adi = port->adi;
- struct gameport *gameport = port->gameport;
- unsigned char u, v, w, x, z;
- int t[2], s[2], i;
- unsigned long flags;
-
- for (i = 0; i < 2; i++) {
- adi[i].ret = -1;
- t[i] = gameport_time(gameport, ADI_MAX_START);
- s[i] = 0;
- }
-
- local_irq_save(flags);
-
- gameport_trigger(gameport);
- v = z = gameport_read(gameport);
-
- do {
- u = v;
- w = u ^ (v = x = gameport_read(gameport));
- for (i = 0; i < 2; i++, w >>= 2, x >>= 2) {
- t[i]--;
- if ((w & 0x30) && s[i]) {
- if ((w & 0x30) < 0x30 && adi[i].ret < ADI_MAX_LENGTH && t[i] > 0) {
- adi[i].data[++adi[i].ret] = w;
- t[i] = gameport_time(gameport, ADI_MAX_STROBE);
- } else t[i] = 0;
- } else if (!(x & 0x30)) s[i] = 1;
- }
- } while (t[0] > 0 || t[1] > 0);
-
- local_irq_restore(flags);
-
- return;
-}
-
-/*
- * adi_move_bits() detects a possible 2-stream mode, and moves
- * the bits accordingly.
- */
-
-static void adi_move_bits(struct adi_port *port, int length)
-{
- int i;
- struct adi *adi = port->adi;
-
- adi[0].idx = adi[1].idx = 0;
-
- if (adi[0].ret <= 0 || adi[1].ret <= 0) return;
- if (adi[0].data[0] & 0x20 || ~adi[1].data[0] & 0x20) return;
-
- for (i = 1; i <= adi[1].ret; i++)
- adi[0].data[((length - 1) >> 1) + i + 1] = adi[1].data[i];
-
- adi[0].ret += adi[1].ret;
- adi[1].ret = -1;
-}
-
-/*
- * adi_get_bits() gathers bits from the data packet.
- */
-
-static inline int adi_get_bits(struct adi *adi, int count)
-{
- int bits = 0;
- int i;
- if ((adi->idx += count) > adi->ret) return 0;
- for (i = 0; i < count; i++)
- bits |= ((adi->data[adi->idx - i] >> 5) & 1) << i;
- return bits;
-}
-
-/*
- * adi_decode() decodes Logitech joystick data into input events.
- */
-
-static int adi_decode(struct adi *adi)
-{
- struct input_dev *dev = adi->dev;
- char *abs = adi->abs;
- short *key = adi->key;
- int i, t;
-
- if (adi->ret < adi->length || adi->id != (adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4)))
- return -1;
-
- for (i = 0; i < adi->axes10; i++)
- input_report_abs(dev, *abs++, adi_get_bits(adi, 10));
-
- for (i = 0; i < adi->axes8; i++)
- input_report_abs(dev, *abs++, adi_get_bits(adi, 8));
-
- for (i = 0; i < adi->buttons && i < 63; i++) {
- if (i == adi->pad) {
- t = adi_get_bits(adi, 4);
- input_report_abs(dev, *abs++, ((t >> 2) & 1) - ( t & 1));
- input_report_abs(dev, *abs++, ((t >> 1) & 1) - ((t >> 3) & 1));
- }
- input_report_key(dev, *key++, adi_get_bits(adi, 1));
- }
-
- for (i = 0; i < adi->hats; i++) {
- if ((t = adi_get_bits(adi, 4)) > 8) t = 0;
- input_report_abs(dev, *abs++, adi_hat_to_axis[t].x);
- input_report_abs(dev, *abs++, adi_hat_to_axis[t].y);
- }
-
- for (i = 63; i < adi->buttons; i++)
- input_report_key(dev, *key++, adi_get_bits(adi, 1));
-
- input_sync(dev);
-
- return 0;
-}
-
-/*
- * adi_read() reads the data packet and decodes it.
- */
-
-static int adi_read(struct adi_port *port)
-{
- int i;
- int result = 0;
-
- adi_read_packet(port);
- adi_move_bits(port, port->adi[0].length);
-
- for (i = 0; i < 2; i++)
- if (port->adi[i].length)
- result |= adi_decode(port->adi + i);
-
- return result;
-}
-
-/*
- * adi_poll() repeatedly polls the Logitech joysticks.
- */
-
-static void adi_poll(struct gameport *gameport)
-{
- struct adi_port *port = gameport_get_drvdata(gameport);
-
- port->bad -= adi_read(port);
- port->reads++;
-}
-
-/*
- * adi_open() is a callback from the input open routine.
- */
-
-static int adi_open(struct input_dev *dev)
-{
- struct adi_port *port = input_get_drvdata(dev);
-
- gameport_start_polling(port->gameport);
- return 0;
-}
-
-/*
- * adi_close() is a callback from the input close routine.
- */
-
-static void adi_close(struct input_dev *dev)
-{
- struct adi_port *port = input_get_drvdata(dev);
-
- gameport_stop_polling(port->gameport);
-}
-
-/*
- * adi_init_digital() sends a trigger & delay sequence
- * to reset and initialize a Logitech joystick into digital mode.
- */
-
-static void adi_init_digital(struct gameport *gameport)
-{
- int seq[] = { 4, -2, -3, 10, -6, -11, -7, -9, 11, 0 };
- int i;
-
- for (i = 0; seq[i]; i++) {
- gameport_trigger(gameport);
- if (seq[i] > 0)
- msleep(seq[i]);
- if (seq[i] < 0) {
- mdelay(-seq[i]);
- udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */
- }
- }
-}
-
-static void adi_id_decode(struct adi *adi, struct adi_port *port)
-{
- int i, t;
-
- if (adi->ret < ADI_MIN_ID_LENGTH) /* Minimum ID packet length */
- return;
-
- if (adi->ret < (t = adi_get_bits(adi, 10))) {
- printk(KERN_WARNING "adi: Short ID packet: reported: %d != read: %d\n", t, adi->ret);
- return;
- }
-
- adi->id = adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4);
-
- if ((t = adi_get_bits(adi, 4)) & ADI_FLAG_HAT) adi->hats++;
-
- adi->length = adi_get_bits(adi, 10);
-
- if (adi->length >= ADI_MAX_LENGTH || adi->length < ADI_MIN_LENGTH) {
- printk(KERN_WARNING "adi: Bad data packet length (%d).\n", adi->length);
- adi->length = 0;
- return;
- }
-
- adi->axes8 = adi_get_bits(adi, 4);
- adi->buttons = adi_get_bits(adi, 6);
-
- if (adi_get_bits(adi, 6) != 8 && adi->hats) {
- printk(KERN_WARNING "adi: Other than 8-dir POVs not supported yet.\n");
- adi->length = 0;
- return;
- }
-
- adi->buttons += adi_get_bits(adi, 6);
- adi->hats += adi_get_bits(adi, 4);
-
- i = adi_get_bits(adi, 4);
-
- if (t & ADI_FLAG_10BIT) {
- adi->axes10 = adi->axes8 - i;
- adi->axes8 = i;
- }
-
- t = adi_get_bits(adi, 4);
-
- for (i = 0; i < t; i++)
- adi->cname[i] = adi_get_bits(adi, 8);
- adi->cname[i] = 0;
-
- t = 8 + adi->buttons + adi->axes10 * 10 + adi->axes8 * 8 + adi->hats * 4;
- if (adi->length != t && adi->length != t + (t & 1)) {
- printk(KERN_WARNING "adi: Expected length %d != data length %d\n", t, adi->length);
- adi->length = 0;
- return;
- }
-
- switch (adi->id) {
- case ADI_ID_TPD:
- adi->pad = 4;
- adi->buttons -= 4;
- break;
- case ADI_ID_WGP:
- adi->pad = 0;
- adi->buttons -= 4;
- break;
- default:
- adi->pad = -1;
- break;
- }
-}
-
-static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
-{
- struct input_dev *input_dev;
- char buf[ADI_MAX_NAME_LENGTH];
- int i, t;
-
- adi->dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
-
- snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id);
- snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
- snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half);
-
- adi->abs = adi_abs[t];
- adi->key = adi_key[t];
-
- input_dev->name = adi->name;
- input_dev->phys = adi->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH;
- input_dev->id.product = adi->id;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &port->gameport->dev;
-
- input_set_drvdata(input_dev, port);
-
- input_dev->open = adi_open;
- input_dev->close = adi_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++)
- set_bit(adi->abs[i], input_dev->absbit);
-
- for (i = 0; i < adi->buttons; i++)
- set_bit(adi->key[i], input_dev->keybit);
-
- return 0;
-}
-
-static void adi_init_center(struct adi *adi)
-{
- int i, t, x;
-
- if (!adi->length)
- return;
-
- for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) {
-
- t = adi->abs[i];
- x = input_abs_get_val(adi->dev, t);
-
- if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE)
- x = i < adi->axes10 ? 512 : 128;
-
- if (i < adi->axes10)
- input_set_abs_params(adi->dev, t, 64, x * 2 - 64, 2, 16);
- else if (i < adi->axes10 + adi->axes8)
- input_set_abs_params(adi->dev, t, 48, x * 2 - 48, 1, 16);
- else
- input_set_abs_params(adi->dev, t, -1, 1, 0, 0);
- }
-}
-
-/*
- * adi_connect() probes for Logitech ADI joysticks.
- */
-
-static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct adi_port *port;
- int i;
- int err;
-
- port = kzalloc(sizeof(struct adi_port), GFP_KERNEL);
- if (!port)
- return -ENOMEM;
-
- port->gameport = gameport;
-
- gameport_set_drvdata(gameport, port);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- adi_init_digital(gameport);
- adi_read_packet(port);
-
- if (port->adi[0].ret >= ADI_MIN_LEN_LENGTH)
- adi_move_bits(port, adi_get_bits(port->adi, 10));
-
- for (i = 0; i < 2; i++) {
- adi_id_decode(port->adi + i, port);
-
- if (!port->adi[i].length)
- continue;
-
- err = adi_init_input(port->adi + i, port, i);
- if (err)
- goto fail2;
- }
-
- if (!port->adi[0].length && !port->adi[1].length) {
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, adi_poll);
- gameport_set_poll_interval(gameport, 20);
-
- msleep(ADI_INIT_DELAY);
- if (adi_read(port)) {
- msleep(ADI_DATA_DELAY);
- adi_read(port);
- }
-
- for (i = 0; i < 2; i++)
- if (port->adi[i].length > 0) {
- adi_init_center(port->adi + i);
- err = input_register_device(port->adi[i].dev);
- if (err)
- goto fail3;
- }
-
- return 0;
-
- fail3: while (--i >= 0) {
- if (port->adi[i].length > 0) {
- input_unregister_device(port->adi[i].dev);
- port->adi[i].dev = NULL;
- }
- }
- fail2: for (i = 0; i < 2; i++)
- if (port->adi[i].dev)
- input_free_device(port->adi[i].dev);
- gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(port);
- return err;
-}
-
-static void adi_disconnect(struct gameport *gameport)
-{
- int i;
- struct adi_port *port = gameport_get_drvdata(gameport);
-
- for (i = 0; i < 2; i++)
- if (port->adi[i].length > 0)
- input_unregister_device(port->adi[i].dev);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(port);
-}
-
-static struct gameport_driver adi_drv = {
- .driver = {
- .name = "adi",
- },
- .description = DRIVER_DESC,
- .connect = adi_connect,
- .disconnect = adi_disconnect,
-};
-
-module_gameport_driver(adi_drv);
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
deleted file mode 100644
index ab0fdcd..0000000
--- a/drivers/input/joystick/analog.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 1996-2001 Vojtech Pavlik
- */
-
-/*
- * Analog joystick and gamepad driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/bitops.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-#include <linux/jiffies.h>
-#include <linux/timex.h>
-
-#define DRIVER_DESC "Analog joystick and gamepad driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-/*
- * Option parsing.
- */
-
-#define ANALOG_PORTS 16
-
-static char *js[ANALOG_PORTS];
-static unsigned int js_nargs;
-static int analog_options[ANALOG_PORTS];
-module_param_array_named(map, js, charp, &js_nargs, 0);
-MODULE_PARM_DESC(map, "Describes analog joysticks type/capabilities");
-
-/*
- * Times, feature definitions.
- */
-
-#define ANALOG_RUDDER 0x00004
-#define ANALOG_THROTTLE 0x00008
-#define ANALOG_AXES_STD 0x0000f
-#define ANALOG_BTNS_STD 0x000f0
-
-#define ANALOG_BTNS_CHF 0x00100
-#define ANALOG_HAT1_CHF 0x00200
-#define ANALOG_HAT2_CHF 0x00400
-#define ANALOG_HAT_FCS 0x00800
-#define ANALOG_HATS_ALL 0x00e00
-#define ANALOG_BTN_TL 0x01000
-#define ANALOG_BTN_TR 0x02000
-#define ANALOG_BTN_TL2 0x04000
-#define ANALOG_BTN_TR2 0x08000
-#define ANALOG_BTNS_TLR 0x03000
-#define ANALOG_BTNS_TLR2 0x0c000
-#define ANALOG_BTNS_GAMEPAD 0x0f000
-
-#define ANALOG_HBTN_CHF 0x10000
-#define ANALOG_ANY_CHF 0x10700
-#define ANALOG_SAITEK 0x20000
-#define ANALOG_EXTENSIONS 0x7ff00
-#define ANALOG_GAMEPAD 0x80000
-
-#define ANALOG_MAX_TIME 3 /* 3 ms */
-#define ANALOG_LOOP_TIME 2000 /* 2 * loop */
-#define ANALOG_SAITEK_DELAY 200 /* 200 us */
-#define ANALOG_SAITEK_TIME 2000 /* 2000 us */
-#define ANALOG_AXIS_TIME 2 /* 2 * refresh */
-#define ANALOG_INIT_RETRIES 8 /* 8 times */
-#define ANALOG_FUZZ_BITS 2 /* 2 bit more */
-#define ANALOG_FUZZ_MAGIC 36 /* 36 u*ms/loop */
-
-#define ANALOG_MAX_NAME_LENGTH 128
-#define ANALOG_MAX_PHYS_LENGTH 32
-
-static short analog_axes[] = { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE };
-static short analog_hats[] = { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
-static short analog_pads[] = { BTN_Y, BTN_Z, BTN_TL, BTN_TR };
-static short analog_exts[] = { ANALOG_HAT1_CHF, ANALOG_HAT2_CHF, ANALOG_HAT_FCS };
-static short analog_pad_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_TL2, BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_BASE };
-static short analog_joy_btn[] = { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2,
- BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_BASE6 };
-
-static unsigned char analog_chf[] = { 0xf, 0x0, 0x1, 0x9, 0x2, 0x4, 0xc, 0x8, 0x3, 0x5, 0xb, 0x7, 0xd, 0xe, 0xa, 0x6 };
-
-struct analog {
- struct input_dev *dev;
- int mask;
- short *buttons;
- char name[ANALOG_MAX_NAME_LENGTH];
- char phys[ANALOG_MAX_PHYS_LENGTH];
-};
-
-struct analog_port {
- struct gameport *gameport;
- struct analog analog[2];
- unsigned char mask;
- char saitek;
- char cooked;
- int bads;
- int reads;
- int speed;
- int loop;
- int fuzz;
- int axes[4];
- int buttons;
- int initial[4];
- int axtime;
-};
-
-/*
- * Time macros.
- */
-
-#ifdef __i386__
-
-#include <linux/i8253.h>
-
-#define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
-#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TICK_RATE / HZ : 0)))
-#define TIME_NAME (cpu_has_tsc?"TSC":"PIT")
-static unsigned int get_time_pit(void)
-{
- unsigned long flags;
- unsigned int count;
-
- raw_spin_lock_irqsave(&i8253_lock, flags);
- outb_p(0x00, 0x43);
- count = inb_p(0x40);
- count |= inb_p(0x40) << 8;
- raw_spin_unlock_irqrestore(&i8253_lock, flags);
-
- return count;
-}
-#elif defined(__x86_64__)
-#define GET_TIME(x) rdtscl(x)
-#define DELTA(x,y) ((y)-(x))
-#define TIME_NAME "TSC"
-#elif defined(__alpha__) || defined(CONFIG_MN10300) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_TILE)
-#define GET_TIME(x) do { x = get_cycles(); } while (0)
-#define DELTA(x,y) ((y)-(x))
-#define TIME_NAME "get_cycles"
-#else
-#define FAKE_TIME
-static unsigned long analog_faketime = 0;
-#define GET_TIME(x) do { x = analog_faketime++; } while(0)
-#define DELTA(x,y) ((y)-(x))
-#define TIME_NAME "Unreliable"
-#warning Precise timer not defined for this architecture.
-#endif
-
-/*
- * analog_decode() decodes analog joystick data and reports input events.
- */
-
-static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons)
-{
- struct input_dev *dev = analog->dev;
- int i, j;
-
- if (analog->mask & ANALOG_HAT_FCS)
- for (i = 0; i < 4; i++)
- if (axes[3] < ((initial[3] * ((i << 1) + 1)) >> 3)) {
- buttons |= 1 << (i + 14);
- break;
- }
-
- for (i = j = 0; i < 6; i++)
- if (analog->mask & (0x10 << i))
- input_report_key(dev, analog->buttons[j++], (buttons >> i) & 1);
-
- if (analog->mask & ANALOG_HBTN_CHF)
- for (i = 0; i < 4; i++)
- input_report_key(dev, analog->buttons[j++], (buttons >> (i + 10)) & 1);
-
- if (analog->mask & ANALOG_BTN_TL)
- input_report_key(dev, analog_pads[0], axes[2] < (initial[2] >> 1));
- if (analog->mask & ANALOG_BTN_TR)
- input_report_key(dev, analog_pads[1], axes[3] < (initial[3] >> 1));
- if (analog->mask & ANALOG_BTN_TL2)
- input_report_key(dev, analog_pads[2], axes[2] > (initial[2] + (initial[2] >> 1)));
- if (analog->mask & ANALOG_BTN_TR2)
- input_report_key(dev, analog_pads[3], axes[3] > (initial[3] + (initial[3] >> 1)));
-
- for (i = j = 0; i < 4; i++)
- if (analog->mask & (1 << i))
- input_report_abs(dev, analog_axes[j++], axes[i]);
-
- for (i = j = 0; i < 3; i++)
- if (analog->mask & analog_exts[i]) {
- input_report_abs(dev, analog_hats[j++],
- ((buttons >> ((i << 2) + 7)) & 1) - ((buttons >> ((i << 2) + 9)) & 1));
- input_report_abs(dev, analog_hats[j++],
- ((buttons >> ((i << 2) + 8)) & 1) - ((buttons >> ((i << 2) + 6)) & 1));
- }
-
- input_sync(dev);
-}
-
-/*
- * analog_cooked_read() reads analog joystick data.
- */
-
-static int analog_cooked_read(struct analog_port *port)
-{
- struct gameport *gameport = port->gameport;
- unsigned int time[4], start, loop, now, loopout, timeout;
- unsigned char data[4], this, last;
- unsigned long flags;
- int i, j;
-
- loopout = (ANALOG_LOOP_TIME * port->loop) / 1000;
- timeout = ANALOG_MAX_TIME * port->speed;
-
- local_irq_save(flags);
- gameport_trigger(gameport);
- GET_TIME(now);
- local_irq_restore(flags);
-
- start = now;
- this = port->mask;
- i = 0;
-
- do {
- loop = now;
- last = this;
-
- local_irq_disable();
- this = gameport_read(gameport) & port->mask;
- GET_TIME(now);
- local_irq_restore(flags);
-
- if ((last ^ this) && (DELTA(loop, now) < loopout)) {
- data[i] = last ^ this;
- time[i] = now;
- i++;
- }
-
- } while (this && (i < 4) && (DELTA(start, now) < timeout));
-
- this <<= 4;
-
- for (--i; i >= 0; i--) {
- this |= data[i];
- for (j = 0; j < 4; j++)
- if (data[i] & (1 << j))
- port->axes[j] = (DELTA(start, time[i]) << ANALOG_FUZZ_BITS) / port->loop;
- }
-
- return -(this != port->mask);
-}
-
-static int analog_button_read(struct analog_port *port, char saitek, char chf)
-{
- unsigned char u;
- int t = 1, i = 0;
- int strobe = gameport_time(port->gameport, ANALOG_SAITEK_TIME);
-
- u = gameport_read(port->gameport);
-
- if (!chf) {
- port->buttons = (~u >> 4) & 0xf;
- return 0;
- }
-
- port->buttons = 0;
-
- while ((~u & 0xf0) && (i < 16) && t) {
- port->buttons |= 1 << analog_chf[(~u >> 4) & 0xf];
- if (!saitek) return 0;
- udelay(ANALOG_SAITEK_DELAY);
- t = strobe;
- gameport_trigger(port->gameport);
- while (((u = gameport_read(port->gameport)) & port->mask) && t) t--;
- i++;
- }
-
- return -(!t || (i == 16));
-}
-
-/*
- * analog_poll() repeatedly polls the Analog joysticks.
- */
-
-static void analog_poll(struct gameport *gameport)
-{
- struct analog_port *port = gameport_get_drvdata(gameport);
- int i;
-
- char saitek = !!(port->analog[0].mask & ANALOG_SAITEK);
- char chf = !!(port->analog[0].mask & ANALOG_ANY_CHF);
-
- if (port->cooked) {
- port->bads -= gameport_cooked_read(port->gameport, port->axes, &port->buttons);
- if (chf)
- port->buttons = port->buttons ? (1 << analog_chf[port->buttons]) : 0;
- port->reads++;
- } else {
- if (!port->axtime--) {
- port->bads -= analog_cooked_read(port);
- port->bads -= analog_button_read(port, saitek, chf);
- port->reads++;
- port->axtime = ANALOG_AXIS_TIME - 1;
- } else {
- if (!saitek)
- analog_button_read(port, saitek, chf);
- }
- }
-
- for (i = 0; i < 2; i++)
- if (port->analog[i].mask)
- analog_decode(port->analog + i, port->axes, port->initial, port->buttons);
-}
-
-/*
- * analog_open() is a callback from the input open routine.
- */
-
-static int analog_open(struct input_dev *dev)
-{
- struct analog_port *port = input_get_drvdata(dev);
-
- gameport_start_polling(port->gameport);
- return 0;
-}
-
-/*
- * analog_close() is a callback from the input close routine.
- */
-
-static void analog_close(struct input_dev *dev)
-{
- struct analog_port *port = input_get_drvdata(dev);
-
- gameport_stop_polling(port->gameport);
-}
-
-/*
- * analog_calibrate_timer() calibrates the timer and computes loop
- * and timeout values for a joystick port.
- */
-
-static void analog_calibrate_timer(struct analog_port *port)
-{
- struct gameport *gameport = port->gameport;
- unsigned int i, t, tx, t1, t2, t3;
- unsigned long flags;
-
- local_irq_save(flags);
- GET_TIME(t1);
-#ifdef FAKE_TIME
- analog_faketime += 830;
-#endif
- mdelay(1);
- GET_TIME(t2);
- GET_TIME(t3);
- local_irq_restore(flags);
-
- port->speed = DELTA(t1, t2) - DELTA(t2, t3);
-
- tx = ~0;
-
- for (i = 0; i < 50; i++) {
- local_irq_save(flags);
- GET_TIME(t1);
- for (t = 0; t < 50; t++) { gameport_read(gameport); GET_TIME(t2); }
- GET_TIME(t3);
- local_irq_restore(flags);
- udelay(i);
- t = DELTA(t1, t2) - DELTA(t2, t3);
- if (t < tx) tx = t;
- }
-
- port->loop = tx / 50;
-}
-
-/*
- * analog_name() constructs a name for an analog joystick.
- */
-
-static void analog_name(struct analog *analog)
-{
- snprintf(analog->name, sizeof(analog->name), "Analog %d-axis %d-button",
- hweight8(analog->mask & ANALOG_AXES_STD),
- hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 +
- hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4);
-
- if (analog->mask & ANALOG_HATS_ALL)
- snprintf(analog->name, sizeof(analog->name), "%s %d-hat",
- analog->name, hweight16(analog->mask & ANALOG_HATS_ALL));
-
- if (analog->mask & ANALOG_HAT_FCS)
- strlcat(analog->name, " FCS", sizeof(analog->name));
- if (analog->mask & ANALOG_ANY_CHF)
- strlcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF",
- sizeof(analog->name));
-
- strlcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick",
- sizeof(analog->name));
-}
-
-/*
- * analog_init_device()
- */
-
-static int analog_init_device(struct analog_port *port, struct analog *analog, int index)
-{
- struct input_dev *input_dev;
- int i, j, t, v, w, x, y, z;
- int error;
-
- analog_name(analog);
- snprintf(analog->phys, sizeof(analog->phys),
- "%s/input%d", port->gameport->phys, index);
- analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn;
-
- analog->dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- input_dev->name = analog->name;
- input_dev->phys = analog->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG;
- input_dev->id.product = analog->mask >> 4;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &port->gameport->dev;
-
- input_set_drvdata(input_dev, port);
-
- input_dev->open = analog_open;
- input_dev->close = analog_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = j = 0; i < 4; i++)
- if (analog->mask & (1 << i)) {
-
- t = analog_axes[j];
- x = port->axes[i];
- y = (port->axes[0] + port->axes[1]) >> 1;
- z = y - port->axes[i];
- z = z > 0 ? z : -z;
- v = (x >> 3);
- w = (x >> 3);
-
- if ((i == 2 || i == 3) && (j == 2 || j == 3) && (z > (y >> 3)))
- x = y;
-
- if (analog->mask & ANALOG_SAITEK) {
- if (i == 2) x = port->axes[i];
- v = x - (x >> 2);
- w = (x >> 4);
- }
-
- input_set_abs_params(input_dev, t, v, (x << 1) - v, port->fuzz, w);
- j++;
- }
-
- for (i = j = 0; i < 3; i++)
- if (analog->mask & analog_exts[i])
- for (x = 0; x < 2; x++) {
- t = analog_hats[j++];
- input_set_abs_params(input_dev, t, -1, 1, 0, 0);
- }
-
- for (i = j = 0; i < 4; i++)
- if (analog->mask & (0x10 << i))
- set_bit(analog->buttons[j++], input_dev->keybit);
-
- if (analog->mask & ANALOG_BTNS_CHF)
- for (i = 0; i < 2; i++)
- set_bit(analog->buttons[j++], input_dev->keybit);
-
- if (analog->mask & ANALOG_HBTN_CHF)
- for (i = 0; i < 4; i++)
- set_bit(analog->buttons[j++], input_dev->keybit);
-
- for (i = 0; i < 4; i++)
- if (analog->mask & (ANALOG_BTN_TL << i))
- set_bit(analog_pads[i], input_dev->keybit);
-
- analog_decode(analog, port->axes, port->initial, port->buttons);
-
- error = input_register_device(analog->dev);
- if (error) {
- input_free_device(analog->dev);
- return error;
- }
-
- return 0;
-}
-
-/*
- * analog_init_devices() sets up device-specific values and registers the input devices.
- */
-
-static int analog_init_masks(struct analog_port *port)
-{
- int i;
- struct analog *analog = port->analog;
- int max[4];
-
- if (!port->mask)
- return -1;
-
- if ((port->mask & 3) != 3 && port->mask != 0xc) {
- printk(KERN_WARNING "analog.c: Unknown joystick device found "
- "(data=%#x, %s), probably not analog joystick.\n",
- port->mask, port->gameport->phys);
- return -1;
- }
-
-
- i = analog_options[0]; /* FIXME !!! - need to specify options for different ports */
-
- analog[0].mask = i & 0xfffff;
-
- analog[0].mask &= ~(ANALOG_AXES_STD | ANALOG_HAT_FCS | ANALOG_BTNS_GAMEPAD)
- | port->mask | ((port->mask << 8) & ANALOG_HAT_FCS)
- | ((port->mask << 10) & ANALOG_BTNS_TLR) | ((port->mask << 12) & ANALOG_BTNS_TLR2);
-
- analog[0].mask &= ~(ANALOG_HAT2_CHF)
- | ((analog[0].mask & ANALOG_HBTN_CHF) ? 0 : ANALOG_HAT2_CHF);
-
- analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_BTN_TR | ANALOG_BTN_TR2)
- | ((~analog[0].mask & ANALOG_HAT_FCS) >> 8)
- | ((~analog[0].mask & ANALOG_HAT_FCS) << 2)
- | ((~analog[0].mask & ANALOG_HAT_FCS) << 4);
-
- analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_RUDDER)
- | (((~analog[0].mask & ANALOG_BTNS_TLR ) >> 10)
- & ((~analog[0].mask & ANALOG_BTNS_TLR2) >> 12));
-
- analog[1].mask = ((i >> 20) & 0xff) | ((i >> 12) & 0xf0000);
-
- analog[1].mask &= (analog[0].mask & ANALOG_EXTENSIONS) ? ANALOG_GAMEPAD
- : (((ANALOG_BTNS_STD | port->mask) & ~analog[0].mask) | ANALOG_GAMEPAD);
-
- if (port->cooked) {
-
- for (i = 0; i < 4; i++) max[i] = port->axes[i] << 1;
-
- if ((analog[0].mask & 0x7) == 0x7) max[2] = (max[0] + max[1]) >> 1;
- if ((analog[0].mask & 0xb) == 0xb) max[3] = (max[0] + max[1]) >> 1;
- if ((analog[0].mask & ANALOG_BTN_TL) && !(analog[0].mask & ANALOG_BTN_TL2)) max[2] >>= 1;
- if ((analog[0].mask & ANALOG_BTN_TR) && !(analog[0].mask & ANALOG_BTN_TR2)) max[3] >>= 1;
- if ((analog[0].mask & ANALOG_HAT_FCS)) max[3] >>= 1;
-
- gameport_calibrate(port->gameport, port->axes, max);
- }
-
- for (i = 0; i < 4; i++)
- port->initial[i] = port->axes[i];
-
- return -!(analog[0].mask || analog[1].mask);
-}
-
-static int analog_init_port(struct gameport *gameport, struct gameport_driver *drv, struct analog_port *port)
-{
- int i, t, u, v;
-
- port->gameport = gameport;
-
- gameport_set_drvdata(gameport, port);
-
- if (!gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {
-
- analog_calibrate_timer(port);
-
- gameport_trigger(gameport);
- t = gameport_read(gameport);
- msleep(ANALOG_MAX_TIME);
- port->mask = (gameport_read(gameport) ^ t) & t & 0xf;
- port->fuzz = (port->speed * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS;
-
- for (i = 0; i < ANALOG_INIT_RETRIES; i++) {
- if (!analog_cooked_read(port))
- break;
- msleep(ANALOG_MAX_TIME);
- }
-
- u = v = 0;
-
- msleep(ANALOG_MAX_TIME);
- t = gameport_time(gameport, ANALOG_MAX_TIME * 1000);
- gameport_trigger(gameport);
- while ((gameport_read(port->gameport) & port->mask) && (u < t))
- u++;
- udelay(ANALOG_SAITEK_DELAY);
- t = gameport_time(gameport, ANALOG_SAITEK_TIME);
- gameport_trigger(gameport);
- while ((gameport_read(port->gameport) & port->mask) && (v < t))
- v++;
-
- if (v < (u >> 1)) { /* FIXME - more than one port */
- analog_options[0] |= /* FIXME - more than one port */
- ANALOG_SAITEK | ANALOG_BTNS_CHF | ANALOG_HBTN_CHF | ANALOG_HAT1_CHF;
- return 0;
- }
-
- gameport_close(gameport);
- }
-
- if (!gameport_open(gameport, drv, GAMEPORT_MODE_COOKED)) {
-
- for (i = 0; i < ANALOG_INIT_RETRIES; i++)
- if (!gameport_cooked_read(gameport, port->axes, &port->buttons))
- break;
- for (i = 0; i < 4; i++)
- if (port->axes[i] != -1)
- port->mask |= 1 << i;
-
- port->fuzz = gameport->fuzz;
- port->cooked = 1;
- return 0;
- }
-
- return gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
-}
-
-static int analog_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct analog_port *port;
- int i;
- int err;
-
- if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL)))
- return - ENOMEM;
-
- err = analog_init_port(gameport, drv, port);
- if (err)
- goto fail1;
-
- err = analog_init_masks(port);
- if (err)
- goto fail2;
-
- gameport_set_poll_handler(gameport, analog_poll);
- gameport_set_poll_interval(gameport, 10);
-
- for (i = 0; i < 2; i++)
- if (port->analog[i].mask) {
- err = analog_init_device(port, port->analog + i, i);
- if (err)
- goto fail3;
- }
-
- return 0;
-
- fail3: while (--i >= 0)
- if (port->analog[i].mask)
- input_unregister_device(port->analog[i].dev);
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(port);
- return err;
-}
-
-static void analog_disconnect(struct gameport *gameport)
-{
- struct analog_port *port = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < 2; i++)
- if (port->analog[i].mask)
- input_unregister_device(port->analog[i].dev);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n",
- port->bads, port->reads, port->reads ? (port->bads * 100 / port->reads) : 0,
- port->gameport->phys);
- kfree(port);
-}
-
-struct analog_types {
- char *name;
- int value;
-};
-
-static struct analog_types analog_types[] = {
- { "none", 0x00000000 },
- { "auto", 0x000000ff },
- { "2btn", 0x0000003f },
- { "y-joy", 0x0cc00033 },
- { "y-pad", 0x8cc80033 },
- { "fcs", 0x000008f7 },
- { "chf", 0x000002ff },
- { "fullchf", 0x000007ff },
- { "gamepad", 0x000830f3 },
- { "gamepad8", 0x0008f0f3 },
- { NULL, 0 }
-};
-
-static void analog_parse_options(void)
-{
- int i, j;
- char *end;
-
- for (i = 0; i < js_nargs; i++) {
-
- for (j = 0; analog_types[j].name; j++)
- if (!strcmp(analog_types[j].name, js[i])) {
- analog_options[i] = analog_types[j].value;
- break;
- }
- if (analog_types[j].name) continue;
-
- analog_options[i] = simple_strtoul(js[i], &end, 0);
- if (end != js[i]) continue;
-
- analog_options[i] = 0xff;
- if (!strlen(js[i])) continue;
-
- printk(KERN_WARNING "analog.c: Bad config for port %d - \"%s\"\n", i, js[i]);
- }
-
- for (; i < ANALOG_PORTS; i++)
- analog_options[i] = 0xff;
-}
-
-/*
- * The gameport device structure.
- */
-
-static struct gameport_driver analog_drv = {
- .driver = {
- .name = "analog",
- },
- .description = DRIVER_DESC,
- .connect = analog_connect,
- .disconnect = analog_disconnect,
-};
-
-static int __init analog_init(void)
-{
- analog_parse_options();
- return gameport_register_driver(&analog_drv);
-}
-
-static void __exit analog_exit(void)
-{
- gameport_unregister_driver(&analog_drv);
-}
-
-module_init(analog_init);
-module_exit(analog_exit);
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
deleted file mode 100644
index ae3ee24..0000000
--- a/drivers/input/joystick/cobra.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1999-2001 Vojtech Pavlik
- */
-
-/*
- * Creative Labs Blaster GamePad Cobra driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Creative Labs Blaster GamePad Cobra driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define COBRA_MAX_STROBE 45 /* 45 us max wait for first strobe */
-#define COBRA_LENGTH 36
-
-static int cobra_btn[] = { BTN_START, BTN_SELECT, BTN_TL, BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL2, BTN_TR2, 0 };
-
-struct cobra {
- struct gameport *gameport;
- struct input_dev *dev[2];
- int reads;
- int bads;
- unsigned char exists;
- char phys[2][32];
-};
-
-static unsigned char cobra_read_packet(struct gameport *gameport, unsigned int *data)
-{
- unsigned long flags;
- unsigned char u, v, w;
- __u64 buf[2];
- int r[2], t[2];
- int i, j, ret;
-
- int strobe = gameport_time(gameport, COBRA_MAX_STROBE);
-
- for (i = 0; i < 2; i++) {
- r[i] = buf[i] = 0;
- t[i] = COBRA_MAX_STROBE;
- }
-
- local_irq_save(flags);
-
- u = gameport_read(gameport);
-
- do {
- t[0]--; t[1]--;
- v = gameport_read(gameport);
- for (i = 0, w = u ^ v; i < 2 && w; i++, w >>= 2)
- if (w & 0x30) {
- if ((w & 0x30) < 0x30 && r[i] < COBRA_LENGTH && t[i] > 0) {
- buf[i] |= (__u64)((w >> 5) & 1) << r[i]++;
- t[i] = strobe;
- u = v;
- } else t[i] = 0;
- }
- } while (t[0] > 0 || t[1] > 0);
-
- local_irq_restore(flags);
-
- ret = 0;
-
- for (i = 0; i < 2; i++) {
-
- if (r[i] != COBRA_LENGTH) continue;
-
- for (j = 0; j < COBRA_LENGTH && (buf[i] & 0x04104107f) ^ 0x041041040; j++)
- buf[i] = (buf[i] >> 1) | ((__u64)(buf[i] & 1) << (COBRA_LENGTH - 1));
-
- if (j < COBRA_LENGTH) ret |= (1 << i);
-
- data[i] = ((buf[i] >> 7) & 0x000001f) | ((buf[i] >> 8) & 0x00003e0)
- | ((buf[i] >> 9) & 0x0007c00) | ((buf[i] >> 10) & 0x00f8000)
- | ((buf[i] >> 11) & 0x1f00000);
-
- }
-
- return ret;
-}
-
-static void cobra_poll(struct gameport *gameport)
-{
- struct cobra *cobra = gameport_get_drvdata(gameport);
- struct input_dev *dev;
- unsigned int data[2];
- int i, j, r;
-
- cobra->reads++;
-
- if ((r = cobra_read_packet(gameport, data)) != cobra->exists) {
- cobra->bads++;
- return;
- }
-
- for (i = 0; i < 2; i++)
- if (cobra->exists & r & (1 << i)) {
-
- dev = cobra->dev[i];
-
- input_report_abs(dev, ABS_X, ((data[i] >> 4) & 1) - ((data[i] >> 3) & 1));
- input_report_abs(dev, ABS_Y, ((data[i] >> 2) & 1) - ((data[i] >> 1) & 1));
-
- for (j = 0; cobra_btn[j]; j++)
- input_report_key(dev, cobra_btn[j], data[i] & (0x20 << j));
-
- input_sync(dev);
-
- }
-}
-
-static int cobra_open(struct input_dev *dev)
-{
- struct cobra *cobra = input_get_drvdata(dev);
-
- gameport_start_polling(cobra->gameport);
- return 0;
-}
-
-static void cobra_close(struct input_dev *dev)
-{
- struct cobra *cobra = input_get_drvdata(dev);
-
- gameport_stop_polling(cobra->gameport);
-}
-
-static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct cobra *cobra;
- struct input_dev *input_dev;
- unsigned int data[2];
- int i, j;
- int err;
-
- cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL);
- if (!cobra)
- return -ENOMEM;
-
- cobra->gameport = gameport;
-
- gameport_set_drvdata(gameport, cobra);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- cobra->exists = cobra_read_packet(gameport, data);
-
- for (i = 0; i < 2; i++)
- if ((cobra->exists >> i) & data[i] & 1) {
- printk(KERN_WARNING "cobra.c: Device %d on %s has the Ext bit set. ID is: %d"
- " Contact vojtech@xxxxxx\n", i, gameport->phys, (data[i] >> 2) & 7);
- cobra->exists &= ~(1 << i);
- }
-
- if (!cobra->exists) {
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, cobra_poll);
- gameport_set_poll_interval(gameport, 20);
-
- for (i = 0; i < 2; i++) {
- if (~(cobra->exists >> i) & 1)
- continue;
-
- cobra->dev[i] = input_dev = input_allocate_device();
- if (!input_dev) {
- err = -ENOMEM;
- goto fail3;
- }
-
- snprintf(cobra->phys[i], sizeof(cobra->phys[i]),
- "%s/input%d", gameport->phys, i);
-
- input_dev->name = "Creative Labs Blaster GamePad Cobra";
- input_dev->phys = cobra->phys[i];
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_CREATIVE;
- input_dev->id.product = 0x0008;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, cobra);
-
- input_dev->open = cobra_open;
- input_dev->close = cobra_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
- input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0);
- input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0);
- for (j = 0; cobra_btn[j]; j++)
- set_bit(cobra_btn[j], input_dev->keybit);
-
- err = input_register_device(cobra->dev[i]);
- if (err)
- goto fail4;
- }
-
- return 0;
-
- fail4: input_free_device(cobra->dev[i]);
- fail3: while (--i >= 0)
- if (cobra->dev[i])
- input_unregister_device(cobra->dev[i]);
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(cobra);
- return err;
-}
-
-static void cobra_disconnect(struct gameport *gameport)
-{
- struct cobra *cobra = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < 2; i++)
- if ((cobra->exists >> i) & 1)
- input_unregister_device(cobra->dev[i]);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(cobra);
-}
-
-static struct gameport_driver cobra_drv = {
- .driver = {
- .name = "cobra",
- },
- .description = DRIVER_DESC,
- .connect = cobra_connect,
- .disconnect = cobra_disconnect,
-};
-
-module_gameport_driver(cobra_drv);
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
deleted file mode 100644
index 0f519db..0000000
--- a/drivers/input/joystick/gf2k.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Vojtech Pavlik
- */
-
-/*
- * Genius Flight 2000 joystick driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Genius Flight 2000 joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define GF2K_START 400 /* The time we wait for the first bit [400 us] */
-#define GF2K_STROBE 40 /* The time we wait for the first bit [40 us] */
-#define GF2K_TIMEOUT 4 /* Wait for everything to settle [4 ms] */
-#define GF2K_LENGTH 80 /* Max number of triplets in a packet */
-
-/*
- * Genius joystick ids ...
- */
-
-#define GF2K_ID_G09 1
-#define GF2K_ID_F30D 2
-#define GF2K_ID_F30 3
-#define GF2K_ID_F31D 4
-#define GF2K_ID_F305 5
-#define GF2K_ID_F23P 6
-#define GF2K_ID_F31 7
-#define GF2K_ID_MAX 7
-
-static char gf2k_length[] = { 40, 40, 40, 40, 40, 40, 40, 40 };
-static char gf2k_hat_to_axis[][2] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
-
-static char *gf2k_names[] = {"", "Genius G-09D", "Genius F-30D", "Genius F-30", "Genius MaxFighter F-31D",
- "Genius F-30-5", "Genius Flight2000 F-23", "Genius F-31"};
-static unsigned char gf2k_hats[] = { 0, 2, 0, 0, 2, 0, 2, 0 };
-static unsigned char gf2k_axes[] = { 0, 2, 0, 0, 4, 0, 4, 0 };
-static unsigned char gf2k_joys[] = { 0, 0, 0, 0,10, 0, 8, 0 };
-static unsigned char gf2k_pads[] = { 0, 6, 0, 0, 0, 0, 0, 0 };
-static unsigned char gf2k_lens[] = { 0,18, 0, 0,18, 0,18, 0 };
-
-static unsigned char gf2k_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER, ABS_GAS, ABS_BRAKE };
-static short gf2k_btn_joy[] = { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4 };
-static short gf2k_btn_pad[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_START, BTN_SELECT };
-
-
-static short gf2k_seq_reset[] = { 240, 340, 0 };
-static short gf2k_seq_digital[] = { 590, 320, 860, 0 };
-
-struct gf2k {
- struct gameport *gameport;
- struct input_dev *dev;
- int reads;
- int bads;
- unsigned char id;
- unsigned char length;
- char phys[32];
-};
-
-/*
- * gf2k_read_packet() reads a Genius Flight2000 packet.
- */
-
-static int gf2k_read_packet(struct gameport *gameport, int length, char *data)
-{
- unsigned char u, v;
- int i;
- unsigned int t, p;
- unsigned long flags;
-
- t = gameport_time(gameport, GF2K_START);
- p = gameport_time(gameport, GF2K_STROBE);
-
- i = 0;
-
- local_irq_save(flags);
-
- gameport_trigger(gameport);
- v = gameport_read(gameport);
-
- while (t > 0 && i < length) {
- t--; u = v;
- v = gameport_read(gameport);
- if (v & ~u & 0x10) {
- data[i++] = v >> 5;
- t = p;
- }
- }
-
- local_irq_restore(flags);
-
- return i;
-}
-
-/*
- * gf2k_trigger_seq() initializes a Genius Flight2000 joystick
- * into digital mode.
- */
-
-static void gf2k_trigger_seq(struct gameport *gameport, short *seq)
-{
-
- unsigned long flags;
- int i, t;
-
- local_irq_save(flags);
-
- i = 0;
- do {
- gameport_trigger(gameport);
- t = gameport_time(gameport, GF2K_TIMEOUT * 1000);
- while ((gameport_read(gameport) & 1) && t) t--;
- udelay(seq[i]);
- } while (seq[++i]);
-
- gameport_trigger(gameport);
-
- local_irq_restore(flags);
-}
-
-/*
- * js_sw_get_bits() composes bits from the triplet buffer into a __u64.
- * Parameter 'pos' is bit number inside packet where to start at, 'num' is number
- * of bits to be read, 'shift' is offset in the resulting __u64 to start at, bits
- * is number of bits per triplet.
- */
-
-#define GB(p,n,s) gf2k_get_bits(data, p, n, s)
-
-static int gf2k_get_bits(unsigned char *buf, int pos, int num, int shift)
-{
- __u64 data = 0;
- int i;
-
- for (i = 0; i < num / 3 + 2; i++)
- data |= buf[pos / 3 + i] << (i * 3);
- data >>= pos % 3;
- data &= (1 << num) - 1;
- data <<= shift;
-
- return data;
-}
-
-static void gf2k_read(struct gf2k *gf2k, unsigned char *data)
-{
- struct input_dev *dev = gf2k->dev;
- int i, t;
-
- for (i = 0; i < 4 && i < gf2k_axes[gf2k->id]; i++)
- input_report_abs(dev, gf2k_abs[i], GB(i<<3,8,0) | GB(i+46,1,8) | GB(i+50,1,9));
-
- for (i = 0; i < 2 && i < gf2k_axes[gf2k->id] - 4; i++)
- input_report_abs(dev, gf2k_abs[i], GB(i*9+60,8,0) | GB(i+54,1,9));
-
- t = GB(40,4,0);
-
- for (i = 0; i < gf2k_hats[gf2k->id]; i++)
- input_report_abs(dev, ABS_HAT0X + i, gf2k_hat_to_axis[t][i]);
-
- t = GB(44,2,0) | GB(32,8,2) | GB(78,2,10);
-
- for (i = 0; i < gf2k_joys[gf2k->id]; i++)
- input_report_key(dev, gf2k_btn_joy[i], (t >> i) & 1);
-
- for (i = 0; i < gf2k_pads[gf2k->id]; i++)
- input_report_key(dev, gf2k_btn_pad[i], (t >> i) & 1);
-
- input_sync(dev);
-}
-
-/*
- * gf2k_poll() reads and analyzes Genius joystick data.
- */
-
-static void gf2k_poll(struct gameport *gameport)
-{
- struct gf2k *gf2k = gameport_get_drvdata(gameport);
- unsigned char data[GF2K_LENGTH];
-
- gf2k->reads++;
-
- if (gf2k_read_packet(gf2k->gameport, gf2k_length[gf2k->id], data) < gf2k_length[gf2k->id])
- gf2k->bads++;
- else
- gf2k_read(gf2k, data);
-}
-
-static int gf2k_open(struct input_dev *dev)
-{
- struct gf2k *gf2k = input_get_drvdata(dev);
-
- gameport_start_polling(gf2k->gameport);
- return 0;
-}
-
-static void gf2k_close(struct input_dev *dev)
-{
- struct gf2k *gf2k = input_get_drvdata(dev);
-
- gameport_stop_polling(gf2k->gameport);
-}
-
-/*
- * gf2k_connect() probes for Genius id joysticks.
- */
-
-static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct gf2k *gf2k;
- struct input_dev *input_dev;
- unsigned char data[GF2K_LENGTH];
- int i, err;
-
- gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!gf2k || !input_dev) {
- err = -ENOMEM;
- goto fail1;
- }
-
- gf2k->gameport = gameport;
- gf2k->dev = input_dev;
-
- gameport_set_drvdata(gameport, gf2k);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- gf2k_trigger_seq(gameport, gf2k_seq_reset);
-
- msleep(GF2K_TIMEOUT);
-
- gf2k_trigger_seq(gameport, gf2k_seq_digital);
-
- msleep(GF2K_TIMEOUT);
-
- if (gf2k_read_packet(gameport, GF2K_LENGTH, data) < 12) {
- err = -ENODEV;
- goto fail2;
- }
-
- if (!(gf2k->id = GB(7,2,0) | GB(3,3,2) | GB(0,3,5))) {
- err = -ENODEV;
- goto fail2;
- }
-
-#ifdef RESET_WORKS
- if ((gf2k->id != (GB(19,2,0) | GB(15,3,2) | GB(12,3,5))) &&
- (gf2k->id != (GB(31,2,0) | GB(27,3,2) | GB(24,3,5)))) {
- err = -ENODEV;
- goto fail2;
- }
-#else
- gf2k->id = 6;
-#endif
-
- if (gf2k->id > GF2K_ID_MAX || !gf2k_axes[gf2k->id]) {
- printk(KERN_WARNING "gf2k.c: Not yet supported joystick on %s. [id: %d type:%s]\n",
- gameport->phys, gf2k->id, gf2k->id > GF2K_ID_MAX ? "Unknown" : gf2k_names[gf2k->id]);
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, gf2k_poll);
- gameport_set_poll_interval(gameport, 20);
-
- snprintf(gf2k->phys, sizeof(gf2k->phys), "%s/input0", gameport->phys);
-
- gf2k->length = gf2k_lens[gf2k->id];
-
- input_dev->name = gf2k_names[gf2k->id];
- input_dev->phys = gf2k->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
- input_dev->id.product = gf2k->id;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, gf2k);
-
- input_dev->open = gf2k_open;
- input_dev->close = gf2k_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = 0; i < gf2k_axes[gf2k->id]; i++)
- set_bit(gf2k_abs[i], input_dev->absbit);
-
- for (i = 0; i < gf2k_hats[gf2k->id]; i++)
- input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
-
- for (i = 0; i < gf2k_joys[gf2k->id]; i++)
- set_bit(gf2k_btn_joy[i], input_dev->keybit);
-
- for (i = 0; i < gf2k_pads[gf2k->id]; i++)
- set_bit(gf2k_btn_pad[i], input_dev->keybit);
-
- gf2k_read_packet(gameport, gf2k->length, data);
- gf2k_read(gf2k, data);
-
- for (i = 0; i < gf2k_axes[gf2k->id]; i++) {
- int max = i < 2 ?
- input_abs_get_val(input_dev, gf2k_abs[i]) * 2 :
- input_abs_get_val(input_dev, gf2k_abs[0]) +
- input_abs_get_val(input_dev, gf2k_abs[1]);
- int flat = i < 2 ? 24 : 0;
-
- input_set_abs_params(input_dev, gf2k_abs[i],
- 32, max - 32, 8, flat);
- }
-
- err = input_register_device(gf2k->dev);
- if (err)
- goto fail2;
-
- return 0;
-
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- input_free_device(input_dev);
- kfree(gf2k);
- return err;
-}
-
-static void gf2k_disconnect(struct gameport *gameport)
-{
- struct gf2k *gf2k = gameport_get_drvdata(gameport);
-
- input_unregister_device(gf2k->dev);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(gf2k);
-}
-
-static struct gameport_driver gf2k_drv = {
- .driver = {
- .name = "gf2k",
- },
- .description = DRIVER_DESC,
- .connect = gf2k_connect,
- .disconnect = gf2k_disconnect,
-};
-
-module_gameport_driver(gf2k_drv);
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
deleted file mode 100644
index eac9c5b..0000000
--- a/drivers/input/joystick/grip.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Vojtech Pavlik
- */
-
-/*
- * Gravis/Kensington GrIP protocol joystick and gamepad driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Gravis GrIP protocol joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define GRIP_MODE_GPP 1
-#define GRIP_MODE_BD 2
-#define GRIP_MODE_XT 3
-#define GRIP_MODE_DC 4
-
-#define GRIP_LENGTH_GPP 24
-#define GRIP_STROBE_GPP 200 /* 200 us */
-#define GRIP_LENGTH_XT 4
-#define GRIP_STROBE_XT 64 /* 64 us */
-#define GRIP_MAX_CHUNKS_XT 10
-#define GRIP_MAX_BITS_XT 30
-
-struct grip {
- struct gameport *gameport;
- struct input_dev *dev[2];
- unsigned char mode[2];
- int reads;
- int bads;
- char phys[2][32];
-};
-
-static int grip_btn_gpp[] = { BTN_START, BTN_SELECT, BTN_TR2, BTN_Y, 0, BTN_TL2, BTN_A, BTN_B, BTN_X, 0, BTN_TL, BTN_TR, -1 };
-static int grip_btn_bd[] = { BTN_THUMB, BTN_THUMB2, BTN_TRIGGER, BTN_TOP, BTN_BASE, -1 };
-static int grip_btn_xt[] = { BTN_TRIGGER, BTN_THUMB, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_SELECT, BTN_START, BTN_MODE, -1 };
-static int grip_btn_dc[] = { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, -1 };
-
-static int grip_abs_gpp[] = { ABS_X, ABS_Y, -1 };
-static int grip_abs_bd[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, -1 };
-static int grip_abs_xt[] = { ABS_X, ABS_Y, ABS_BRAKE, ABS_GAS, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, -1 };
-static int grip_abs_dc[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, -1 };
-
-static char *grip_name[] = { NULL, "Gravis GamePad Pro", "Gravis Blackhawk Digital",
- "Gravis Xterminator Digital", "Gravis Xterminator DualControl" };
-static int *grip_abs[] = { NULL, grip_abs_gpp, grip_abs_bd, grip_abs_xt, grip_abs_dc };
-static int *grip_btn[] = { NULL, grip_btn_gpp, grip_btn_bd, grip_btn_xt, grip_btn_dc };
-static char grip_anx[] = { 0, 0, 3, 5, 5 };
-static char grip_cen[] = { 0, 0, 2, 2, 4 };
-
-/*
- * grip_gpp_read_packet() reads a Gravis GamePad Pro packet.
- */
-
-static int grip_gpp_read_packet(struct gameport *gameport, int shift, unsigned int *data)
-{
- unsigned long flags;
- unsigned char u, v;
- unsigned int t;
- int i;
-
- int strobe = gameport_time(gameport, GRIP_STROBE_GPP);
-
- data[0] = 0;
- t = strobe;
- i = 0;
-
- local_irq_save(flags);
-
- v = gameport_read(gameport) >> shift;
-
- do {
- t--;
- u = v; v = (gameport_read(gameport) >> shift) & 3;
- if (~v & u & 1) {
- data[0] |= (v >> 1) << i++;
- t = strobe;
- }
- } while (i < GRIP_LENGTH_GPP && t > 0);
-
- local_irq_restore(flags);
-
- if (i < GRIP_LENGTH_GPP) return -1;
-
- for (i = 0; i < GRIP_LENGTH_GPP && (data[0] & 0xfe4210) ^ 0x7c0000; i++)
- data[0] = data[0] >> 1 | (data[0] & 1) << (GRIP_LENGTH_GPP - 1);
-
- return -(i == GRIP_LENGTH_GPP);
-}
-
-/*
- * grip_xt_read_packet() reads a Gravis Xterminator packet.
- */
-
-static int grip_xt_read_packet(struct gameport *gameport, int shift, unsigned int *data)
-{
- unsigned int i, j, buf, crc;
- unsigned char u, v, w;
- unsigned long flags;
- unsigned int t;
- char status;
-
- int strobe = gameport_time(gameport, GRIP_STROBE_XT);
-
- data[0] = data[1] = data[2] = data[3] = 0;
- status = buf = i = j = 0;
- t = strobe;
-
- local_irq_save(flags);
-
- v = w = (gameport_read(gameport) >> shift) & 3;
-
- do {
- t--;
- u = (gameport_read(gameport) >> shift) & 3;
-
- if (u ^ v) {
-
- if ((u ^ v) & 1) {
- buf = (buf << 1) | (u >> 1);
- t = strobe;
- i++;
- } else
-
- if ((((u ^ v) & (v ^ w)) >> 1) & ~(u | v | w) & 1) {
- if (i == 20) {
- crc = buf ^ (buf >> 7) ^ (buf >> 14);
- if (!((crc ^ (0x25cb9e70 >> ((crc >> 2) & 0x1c))) & 0xf)) {
- data[buf >> 18] = buf >> 4;
- status |= 1 << (buf >> 18);
- }
- j++;
- }
- t = strobe;
- buf = 0;
- i = 0;
- }
- w = v;
- v = u;
- }
-
- } while (status != 0xf && i < GRIP_MAX_BITS_XT && j < GRIP_MAX_CHUNKS_XT && t > 0);
-
- local_irq_restore(flags);
-
- return -(status != 0xf);
-}
-
-/*
- * grip_timer() repeatedly polls the joysticks and generates events.
- */
-
-static void grip_poll(struct gameport *gameport)
-{
- struct grip *grip = gameport_get_drvdata(gameport);
- unsigned int data[GRIP_LENGTH_XT];
- struct input_dev *dev;
- int i, j;
-
- for (i = 0; i < 2; i++) {
-
- dev = grip->dev[i];
- if (!dev)
- continue;
-
- grip->reads++;
-
- switch (grip->mode[i]) {
-
- case GRIP_MODE_GPP:
-
- if (grip_gpp_read_packet(grip->gameport, (i << 1) + 4, data)) {
- grip->bads++;
- break;
- }
-
- input_report_abs(dev, ABS_X, ((*data >> 15) & 1) - ((*data >> 16) & 1));
- input_report_abs(dev, ABS_Y, ((*data >> 13) & 1) - ((*data >> 12) & 1));
-
- for (j = 0; j < 12; j++)
- if (grip_btn_gpp[j])
- input_report_key(dev, grip_btn_gpp[j], (*data >> j) & 1);
-
- break;
-
- case GRIP_MODE_BD:
-
- if (grip_xt_read_packet(grip->gameport, (i << 1) + 4, data)) {
- grip->bads++;
- break;
- }
-
- input_report_abs(dev, ABS_X, (data[0] >> 2) & 0x3f);
- input_report_abs(dev, ABS_Y, 63 - ((data[0] >> 8) & 0x3f));
- input_report_abs(dev, ABS_THROTTLE, (data[2] >> 8) & 0x3f);
-
- input_report_abs(dev, ABS_HAT0X, ((data[2] >> 1) & 1) - ( data[2] & 1));
- input_report_abs(dev, ABS_HAT0Y, ((data[2] >> 2) & 1) - ((data[2] >> 3) & 1));
-
- for (j = 0; j < 5; j++)
- input_report_key(dev, grip_btn_bd[j], (data[3] >> (j + 4)) & 1);
-
- break;
-
- case GRIP_MODE_XT:
-
- if (grip_xt_read_packet(grip->gameport, (i << 1) + 4, data)) {
- grip->bads++;
- break;
- }
-
- input_report_abs(dev, ABS_X, (data[0] >> 2) & 0x3f);
- input_report_abs(dev, ABS_Y, 63 - ((data[0] >> 8) & 0x3f));
- input_report_abs(dev, ABS_BRAKE, (data[1] >> 2) & 0x3f);
- input_report_abs(dev, ABS_GAS, (data[1] >> 8) & 0x3f);
- input_report_abs(dev, ABS_THROTTLE, (data[2] >> 8) & 0x3f);
-
- input_report_abs(dev, ABS_HAT0X, ((data[2] >> 1) & 1) - ( data[2] & 1));
- input_report_abs(dev, ABS_HAT0Y, ((data[2] >> 2) & 1) - ((data[2] >> 3) & 1));
- input_report_abs(dev, ABS_HAT1X, ((data[2] >> 5) & 1) - ((data[2] >> 4) & 1));
- input_report_abs(dev, ABS_HAT1Y, ((data[2] >> 6) & 1) - ((data[2] >> 7) & 1));
-
- for (j = 0; j < 11; j++)
- input_report_key(dev, grip_btn_xt[j], (data[3] >> (j + 3)) & 1);
- break;
-
- case GRIP_MODE_DC:
-
- if (grip_xt_read_packet(grip->gameport, (i << 1) + 4, data)) {
- grip->bads++;
- break;
- }
-
- input_report_abs(dev, ABS_X, (data[0] >> 2) & 0x3f);
- input_report_abs(dev, ABS_Y, (data[0] >> 8) & 0x3f);
- input_report_abs(dev, ABS_RX, (data[1] >> 2) & 0x3f);
- input_report_abs(dev, ABS_RY, (data[1] >> 8) & 0x3f);
- input_report_abs(dev, ABS_THROTTLE, (data[2] >> 8) & 0x3f);
-
- input_report_abs(dev, ABS_HAT0X, ((data[2] >> 1) & 1) - ( data[2] & 1));
- input_report_abs(dev, ABS_HAT0Y, ((data[2] >> 2) & 1) - ((data[2] >> 3) & 1));
-
- for (j = 0; j < 9; j++)
- input_report_key(dev, grip_btn_dc[j], (data[3] >> (j + 3)) & 1);
- break;
-
-
- }
-
- input_sync(dev);
- }
-}
-
-static int grip_open(struct input_dev *dev)
-{
- struct grip *grip = input_get_drvdata(dev);
-
- gameport_start_polling(grip->gameport);
- return 0;
-}
-
-static void grip_close(struct input_dev *dev)
-{
- struct grip *grip = input_get_drvdata(dev);
-
- gameport_stop_polling(grip->gameport);
-}
-
-static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct grip *grip;
- struct input_dev *input_dev;
- unsigned int data[GRIP_LENGTH_XT];
- int i, j, t;
- int err;
-
- if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL)))
- return -ENOMEM;
-
- grip->gameport = gameport;
-
- gameport_set_drvdata(gameport, grip);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- for (i = 0; i < 2; i++) {
- if (!grip_gpp_read_packet(gameport, (i << 1) + 4, data)) {
- grip->mode[i] = GRIP_MODE_GPP;
- continue;
- }
- if (!grip_xt_read_packet(gameport, (i << 1) + 4, data)) {
- if (!(data[3] & 7)) {
- grip->mode[i] = GRIP_MODE_BD;
- continue;
- }
- if (!(data[2] & 0xf0)) {
- grip->mode[i] = GRIP_MODE_XT;
- continue;
- }
- grip->mode[i] = GRIP_MODE_DC;
- continue;
- }
- }
-
- if (!grip->mode[0] && !grip->mode[1]) {
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, grip_poll);
- gameport_set_poll_interval(gameport, 20);
-
- for (i = 0; i < 2; i++) {
- if (!grip->mode[i])
- continue;
-
- grip->dev[i] = input_dev = input_allocate_device();
- if (!input_dev) {
- err = -ENOMEM;
- goto fail3;
- }
-
- snprintf(grip->phys[i], sizeof(grip->phys[i]),
- "%s/input%d", gameport->phys, i);
-
- input_dev->name = grip_name[grip->mode[i]];
- input_dev->phys = grip->phys[i];
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
- input_dev->id.product = grip->mode[i];
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, grip);
-
- input_dev->open = grip_open;
- input_dev->close = grip_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) {
-
- if (j < grip_cen[grip->mode[i]])
- input_set_abs_params(input_dev, t, 14, 52, 1, 2);
- else if (j < grip_anx[grip->mode[i]])
- input_set_abs_params(input_dev, t, 3, 57, 1, 0);
- else
- input_set_abs_params(input_dev, t, -1, 1, 0, 0);
- }
-
- for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++)
- if (t > 0)
- set_bit(t, input_dev->keybit);
-
- err = input_register_device(grip->dev[i]);
- if (err)
- goto fail4;
- }
-
- return 0;
-
- fail4: input_free_device(grip->dev[i]);
- fail3: while (--i >= 0)
- if (grip->dev[i])
- input_unregister_device(grip->dev[i]);
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(grip);
- return err;
-}
-
-static void grip_disconnect(struct gameport *gameport)
-{
- struct grip *grip = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < 2; i++)
- if (grip->dev[i])
- input_unregister_device(grip->dev[i]);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(grip);
-}
-
-static struct gameport_driver grip_drv = {
- .driver = {
- .name = "grip",
- .owner = THIS_MODULE,
- },
- .description = DRIVER_DESC,
- .connect = grip_connect,
- .disconnect = grip_disconnect,
-};
-
-module_gameport_driver(grip_drv);
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
deleted file mode 100644
index 573191d..0000000
--- a/drivers/input/joystick/grip_mp.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- * Driver for the Gravis Grip Multiport, a gamepad "hub" that
- * connects up to four 9-pin digital gamepads/joysticks.
- * Driver tested on SMP and UP kernel versions 2.4.18-4 and 2.4.18-5.
- *
- * Thanks to Chris Gassib for helpful advice.
- *
- * Copyright (c) 2002 Brian Bonnlander, Bill Soudan
- * Copyright (c) 1998-2000 Vojtech Pavlik
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/delay.h>
-#include <linux/proc_fs.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Gravis Grip Multiport driver"
-
-MODULE_AUTHOR("Brian Bonnlander");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#ifdef GRIP_DEBUG
-#define dbg(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg)
-#else
-#define dbg(format, arg...) do {} while (0)
-#endif
-
-#define GRIP_MAX_PORTS 4
-/*
- * Grip multiport state
- */
-
-struct grip_port {
- struct input_dev *dev;
- int mode;
- int registered;
-
- /* individual gamepad states */
- int buttons;
- int xaxes;
- int yaxes;
- int dirty; /* has the state been updated? */
-};
-
-struct grip_mp {
- struct gameport *gameport;
- struct grip_port *port[GRIP_MAX_PORTS];
- int reads;
- int bads;
-};
-
-/*
- * Multiport packet interpretation
- */
-
-#define PACKET_FULL 0x80000000 /* packet is full */
-#define PACKET_IO_FAST 0x40000000 /* 3 bits per gameport read */
-#define PACKET_IO_SLOW 0x20000000 /* 1 bit per gameport read */
-#define PACKET_MP_MORE 0x04000000 /* multiport wants to send more */
-#define PACKET_MP_DONE 0x02000000 /* multiport done sending */
-
-/*
- * Packet status code interpretation
- */
-
-#define IO_GOT_PACKET 0x0100 /* Got a packet */
-#define IO_MODE_FAST 0x0200 /* Used 3 data bits per gameport read */
-#define IO_SLOT_CHANGE 0x0800 /* Multiport physical slot status changed */
-#define IO_DONE 0x1000 /* Multiport is done sending packets */
-#define IO_RETRY 0x4000 /* Try again later to get packet */
-#define IO_RESET 0x8000 /* Force multiport to resend all packets */
-
-/*
- * Gamepad configuration data. Other 9-pin digital joystick devices
- * may work with the multiport, so this may not be an exhaustive list!
- * Commodore 64 joystick remains untested.
- */
-
-#define GRIP_INIT_DELAY 2000 /* 2 ms */
-
-#define GRIP_MODE_NONE 0
-#define GRIP_MODE_RESET 1
-#define GRIP_MODE_GP 2
-#define GRIP_MODE_C64 3
-
-static const int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 };
-static const int grip_btn_c64[] = { BTN_JOYSTICK, -1 };
-
-static const int grip_abs_gp[] = { ABS_X, ABS_Y, -1 };
-static const int grip_abs_c64[] = { ABS_X, ABS_Y, -1 };
-
-static const int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 };
-static const int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 };
-
-static const char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" };
-
-static const int init_seq[] = {
- 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
- 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1,
- 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
- 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1 };
-
-/* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */
-
-static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 };
-
-static int register_slot(int i, struct grip_mp *grip);
-
-/*
- * Returns whether an odd or even number of bits are on in pkt.
- */
-
-static int bit_parity(u32 pkt)
-{
- int x = pkt ^ (pkt >> 16);
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x & 1;
-}
-
-/*
- * Poll gameport; return true if all bits set in 'onbits' are on and
- * all bits set in 'offbits' are off.
- */
-
-static inline int poll_until(u8 onbits, u8 offbits, int u_sec, struct gameport* gp, u8 *data)
-{
- int i, nloops;
-
- nloops = gameport_time(gp, u_sec);
- for (i = 0; i < nloops; i++) {
- *data = gameport_read(gp);
- if ((*data & onbits) == onbits &&
- (~(*data) & offbits) == offbits)
- return 1;
- }
- dbg("gameport timed out after %d microseconds.\n", u_sec);
- return 0;
-}
-
-/*
- * Gets a 28-bit packet from the multiport.
- *
- * After getting a packet successfully, commands encoded by sendcode may
- * be sent to the multiport.
- *
- * The multiport clock value is reflected in gameport bit B4.
- *
- * Returns a packet status code indicating whether packet is valid, the transfer
- * mode, and any error conditions.
- *
- * sendflags: current I/O status
- * sendcode: data to send to the multiport if sendflags is nonzero
- */
-
-static int mp_io(struct gameport* gameport, int sendflags, int sendcode, u32 *packet)
-{
- u8 raw_data; /* raw data from gameport */
- u8 data_mask; /* packet data bits from raw_data */
- u32 pkt; /* packet temporary storage */
- int bits_per_read; /* num packet bits per gameport read */
- int portvals = 0; /* used for port value sanity check */
- int i;
-
- /* Gameport bits B0, B4, B5 should first be off, then B4 should come on. */
-
- *packet = 0;
- raw_data = gameport_read(gameport);
- if (raw_data & 1)
- return IO_RETRY;
-
- for (i = 0; i < 64; i++) {
- raw_data = gameport_read(gameport);
- portvals |= 1 << ((raw_data >> 4) & 3); /* Demux B4, B5 */
- }
-
- if (portvals == 1) { /* B4, B5 off */
- raw_data = gameport_read(gameport);
- portvals = raw_data & 0xf0;
-
- if (raw_data & 0x31)
- return IO_RESET;
- gameport_trigger(gameport);
-
- if (!poll_until(0x10, 0, 308, gameport, &raw_data))
- return IO_RESET;
- } else
- return IO_RETRY;
-
- /* Determine packet transfer mode and prepare for packet construction. */
-
- if (raw_data & 0x20) { /* 3 data bits/read */
- portvals |= raw_data >> 4; /* Compare B4-B7 before & after trigger */
-
- if (portvals != 0xb)
- return 0;
- data_mask = 7;
- bits_per_read = 3;
- pkt = (PACKET_FULL | PACKET_IO_FAST) >> 28;
- } else { /* 1 data bit/read */
- data_mask = 1;
- bits_per_read = 1;
- pkt = (PACKET_FULL | PACKET_IO_SLOW) >> 28;
- }
-
- /* Construct a packet. Final data bits must be zero. */
-
- while (1) {
- if (!poll_until(0, 0x10, 77, gameport, &raw_data))
- return IO_RESET;
- raw_data = (raw_data >> 5) & data_mask;
-
- if (pkt & PACKET_FULL)
- break;
- pkt = (pkt << bits_per_read) | raw_data;
-
- if (!poll_until(0x10, 0, 77, gameport, &raw_data))
- return IO_RESET;
- }
-
- if (raw_data)
- return IO_RESET;
-
- /* If 3 bits/read used, drop from 30 bits to 28. */
-
- if (bits_per_read == 3) {
- pkt = (pkt & 0xffff0000) | ((pkt << 1) & 0xffff);
- pkt = (pkt >> 2) | 0xf0000000;
- }
-
- if (bit_parity(pkt) == 1)
- return IO_RESET;
-
- /* Acknowledge packet receipt */
-
- if (!poll_until(0x30, 0, 77, gameport, &raw_data))
- return IO_RESET;
-
- raw_data = gameport_read(gameport);
-
- if (raw_data & 1)
- return IO_RESET;
-
- gameport_trigger(gameport);
-
- if (!poll_until(0, 0x20, 77, gameport, &raw_data))
- return IO_RESET;
-
- /* Return if we just wanted the packet or multiport wants to send more */
-
- *packet = pkt;
- if ((sendflags == 0) || ((sendflags & IO_RETRY) && !(pkt & PACKET_MP_DONE)))
- return IO_GOT_PACKET;
-
- if (pkt & PACKET_MP_MORE)
- return IO_GOT_PACKET | IO_RETRY;
-
- /* Multiport is done sending packets and is ready to receive data */
-
- if (!poll_until(0x20, 0, 77, gameport, &raw_data))
- return IO_GOT_PACKET | IO_RESET;
-
- raw_data = gameport_read(gameport);
- if (raw_data & 1)
- return IO_GOT_PACKET | IO_RESET;
-
- /* Trigger gameport based on bits in sendcode */
-
- gameport_trigger(gameport);
- do {
- if (!poll_until(0x20, 0x10, 116, gameport, &raw_data))
- return IO_GOT_PACKET | IO_RESET;
-
- if (!poll_until(0x30, 0, 193, gameport, &raw_data))
- return IO_GOT_PACKET | IO_RESET;
-
- if (raw_data & 1)
- return IO_GOT_PACKET | IO_RESET;
-
- if (sendcode & 1)
- gameport_trigger(gameport);
-
- sendcode >>= 1;
- } while (sendcode);
-
- return IO_GOT_PACKET | IO_MODE_FAST;
-}
-
-/*
- * Disables and restores interrupts for mp_io(), which does the actual I/O.
- */
-
-static int multiport_io(struct gameport* gameport, int sendflags, int sendcode, u32 *packet)
-{
- int status;
- unsigned long flags;
-
- local_irq_save(flags);
- status = mp_io(gameport, sendflags, sendcode, packet);
- local_irq_restore(flags);
-
- return status;
-}
-
-/*
- * Puts multiport into digital mode. Multiport LED turns green.
- *
- * Returns true if a valid digital packet was received, false otherwise.
- */
-
-static int dig_mode_start(struct gameport *gameport, u32 *packet)
-{
- int i;
- int flags, tries = 0, bads = 0;
-
- for (i = 0; i < ARRAY_SIZE(init_seq); i++) { /* Send magic sequence */
- if (init_seq[i])
- gameport_trigger(gameport);
- udelay(GRIP_INIT_DELAY);
- }
-
- for (i = 0; i < 16; i++) /* Wait for multiport to settle */
- udelay(GRIP_INIT_DELAY);
-
- while (tries < 64 && bads < 8) { /* Reset multiport and try getting a packet */
-
- flags = multiport_io(gameport, IO_RESET, 0x27, packet);
-
- if (flags & IO_MODE_FAST)
- return 1;
-
- if (flags & IO_RETRY)
- tries++;
- else
- bads++;
- }
- return 0;
-}
-
-/*
- * Packet structure: B0-B15 => gamepad state
- * B16-B20 => gamepad device type
- * B21-B24 => multiport slot index (1-4)
- *
- * Known device types: 0x1f (grip pad), 0x0 (no device). Others may exist.
- *
- * Returns the packet status.
- */
-
-static int get_and_decode_packet(struct grip_mp *grip, int flags)
-{
- struct grip_port *port;
- u32 packet;
- int joytype = 0;
- int slot;
-
- /* Get a packet and check for validity */
-
- flags &= IO_RESET | IO_RETRY;
- flags = multiport_io(grip->gameport, flags, 0, &packet);
- grip->reads++;
-
- if (packet & PACKET_MP_DONE)
- flags |= IO_DONE;
-
- if (flags && !(flags & IO_GOT_PACKET)) {
- grip->bads++;
- return flags;
- }
-
- /* Ignore non-gamepad packets, e.g. multiport hardware version */
-
- slot = ((packet >> 21) & 0xf) - 1;
- if ((slot < 0) || (slot > 3))
- return flags;
-
- port = grip->port[slot];
-
- /*
- * Handle "reset" packets, which occur at startup, and when gamepads
- * are removed or plugged in. May contain configuration of a new gamepad.
- */
-
- joytype = (packet >> 16) & 0x1f;
- if (!joytype) {
-
- if (port->registered) {
- printk(KERN_INFO "grip_mp: removing %s, slot %d\n",
- grip_name[port->mode], slot);
- input_unregister_device(port->dev);
- port->registered = 0;
- }
- dbg("Reset: grip multiport slot %d\n", slot);
- port->mode = GRIP_MODE_RESET;
- flags |= IO_SLOT_CHANGE;
- return flags;
- }
-
- /* Interpret a grip pad packet */
-
- if (joytype == 0x1f) {
-
- int dir = (packet >> 8) & 0xf; /* eight way directional value */
- port->buttons = (~packet) & 0xff;
- port->yaxes = ((axis_map[dir] >> 2) & 3) - 1;
- port->xaxes = (axis_map[dir] & 3) - 1;
- port->dirty = 1;
-
- if (port->mode == GRIP_MODE_RESET)
- flags |= IO_SLOT_CHANGE;
-
- port->mode = GRIP_MODE_GP;
-
- if (!port->registered) {
- dbg("New Grip pad in multiport slot %d.\n", slot);
- if (register_slot(slot, grip)) {
- port->mode = GRIP_MODE_RESET;
- port->dirty = 0;
- }
- }
- return flags;
- }
-
- /* Handle non-grip device codes. For now, just print diagnostics. */
-
- {
- static int strange_code = 0;
- if (strange_code != joytype) {
- printk(KERN_INFO "Possible non-grip pad/joystick detected.\n");
- printk(KERN_INFO "Got joy type 0x%x and packet 0x%x.\n", joytype, packet);
- strange_code = joytype;
- }
- }
- return flags;
-}
-
-/*
- * Returns true if all multiport slot states appear valid.
- */
-
-static int slots_valid(struct grip_mp *grip)
-{
- int flags, slot, invalid = 0, active = 0;
-
- flags = get_and_decode_packet(grip, 0);
- if (!(flags & IO_GOT_PACKET))
- return 0;
-
- for (slot = 0; slot < 4; slot++) {
- if (grip->port[slot]->mode == GRIP_MODE_RESET)
- invalid = 1;
- if (grip->port[slot]->mode != GRIP_MODE_NONE)
- active = 1;
- }
-
- /* Return true if no active slot but multiport sent all its data */
- if (!active)
- return (flags & IO_DONE) ? 1 : 0;
-
- /* Return false if invalid device code received */
- return invalid ? 0 : 1;
-}
-
-/*
- * Returns whether the multiport was placed into digital mode and
- * able to communicate its state successfully.
- */
-
-static int multiport_init(struct grip_mp *grip)
-{
- int dig_mode, initialized = 0, tries = 0;
- u32 packet;
-
- dig_mode = dig_mode_start(grip->gameport, &packet);
- while (!dig_mode && tries < 4) {
- dig_mode = dig_mode_start(grip->gameport, &packet);
- tries++;
- }
-
- if (dig_mode)
- dbg("multiport_init(): digital mode activated.\n");
- else {
- dbg("multiport_init(): unable to activate digital mode.\n");
- return 0;
- }
-
- /* Get packets, store multiport state, and check state's validity */
- for (tries = 0; tries < 4096; tries++) {
- if (slots_valid(grip)) {
- initialized = 1;
- break;
- }
- }
- dbg("multiport_init(): initialized == %d\n", initialized);
- return initialized;
-}
-
-/*
- * Reports joystick state to the linux input layer.
- */
-
-static void report_slot(struct grip_mp *grip, int slot)
-{
- struct grip_port *port = grip->port[slot];
- int i;
-
- /* Store button states with linux input driver */
-
- for (i = 0; i < 8; i++)
- input_report_key(port->dev, grip_btn_gp[i], (port->buttons >> i) & 1);
-
- /* Store axis states with linux driver */
-
- input_report_abs(port->dev, ABS_X, port->xaxes);
- input_report_abs(port->dev, ABS_Y, port->yaxes);
-
- /* Tell the receiver of the events to process them */
-
- input_sync(port->dev);
-
- port->dirty = 0;
-}
-
-/*
- * Get the multiport state.
- */
-
-static void grip_poll(struct gameport *gameport)
-{
- struct grip_mp *grip = gameport_get_drvdata(gameport);
- int i, npkts, flags;
-
- for (npkts = 0; npkts < 4; npkts++) {
- flags = IO_RETRY;
- for (i = 0; i < 32; i++) {
- flags = get_and_decode_packet(grip, flags);
- if ((flags & IO_GOT_PACKET) || !(flags & IO_RETRY))
- break;
- }
- if (flags & IO_DONE)
- break;
- }
-
- for (i = 0; i < 4; i++)
- if (grip->port[i]->dirty)
- report_slot(grip, i);
-}
-
-/*
- * Called when a joystick device file is opened
- */
-
-static int grip_open(struct input_dev *dev)
-{
- struct grip_mp *grip = input_get_drvdata(dev);
-
- gameport_start_polling(grip->gameport);
- return 0;
-}
-
-/*
- * Called when a joystick device file is closed
- */
-
-static void grip_close(struct input_dev *dev)
-{
- struct grip_mp *grip = input_get_drvdata(dev);
-
- gameport_stop_polling(grip->gameport);
-}
-
-/*
- * Tell the linux input layer about a newly plugged-in gamepad.
- */
-
-static int register_slot(int slot, struct grip_mp *grip)
-{
- struct grip_port *port = grip->port[slot];
- struct input_dev *input_dev;
- int j, t;
- int err;
-
- port->dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- input_dev->name = grip_name[port->mode];
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
- input_dev->id.product = 0x0100 + port->mode;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &grip->gameport->dev;
-
- input_set_drvdata(input_dev, grip);
-
- input_dev->open = grip_open;
- input_dev->close = grip_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++)
- input_set_abs_params(input_dev, t, -1, 1, 0, 0);
-
- for (j = 0; (t = grip_btn[port->mode][j]) >= 0; j++)
- if (t > 0)
- set_bit(t, input_dev->keybit);
-
- err = input_register_device(port->dev);
- if (err) {
- input_free_device(port->dev);
- return err;
- }
-
- port->registered = 1;
-
- if (port->dirty) /* report initial state, if any */
- report_slot(grip, slot);
-
- return 0;
-}
-
-static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct grip_mp *grip;
- int err;
-
- if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL)))
- return -ENOMEM;
-
- grip->gameport = gameport;
-
- gameport_set_drvdata(gameport, grip);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- gameport_set_poll_handler(gameport, grip_poll);
- gameport_set_poll_interval(gameport, 20);
-
- if (!multiport_init(grip)) {
- err = -ENODEV;
- goto fail2;
- }
-
- if (!grip->port[0]->mode && !grip->port[1]->mode && !grip->port[2]->mode && !grip->port[3]->mode) {
- /* nothing plugged in */
- err = -ENODEV;
- goto fail2;
- }
-
- return 0;
-
-fail2: gameport_close(gameport);
-fail1: gameport_set_drvdata(gameport, NULL);
- kfree(grip);
- return err;
-}
-
-static void grip_disconnect(struct gameport *gameport)
-{
- struct grip_mp *grip = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < 4; i++)
- if (grip->port[i]->registered)
- input_unregister_device(grip->port[i]->dev);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(grip);
-}
-
-static struct gameport_driver grip_drv = {
- .driver = {
- .name = "grip_mp",
- },
- .description = DRIVER_DESC,
- .connect = grip_connect,
- .disconnect = grip_disconnect,
-};
-
-module_gameport_driver(grip_drv);
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
deleted file mode 100644
index a9ac2f9..0000000
--- a/drivers/input/joystick/guillemot.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (c) 2001 Vojtech Pavlik
- */
-
-/*
- * Guillemot Digital Interface Protocol driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Guillemot Digital joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define GUILLEMOT_MAX_START 600 /* 600 us */
-#define GUILLEMOT_MAX_STROBE 60 /* 60 us */
-#define GUILLEMOT_MAX_LENGTH 17 /* 17 bytes */
-
-static short guillemot_abs_pad[] =
- { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER, -1 };
-
-static short guillemot_btn_pad[] =
- { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_MODE, BTN_SELECT, -1 };
-
-static struct {
- int x;
- int y;
-} guillemot_hat_to_axis[16] = {{ 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
-
-struct guillemot_type {
- unsigned char id;
- short *abs;
- short *btn;
- int hat;
- char *name;
-};
-
-struct guillemot {
- struct gameport *gameport;
- struct input_dev *dev;
- int bads;
- int reads;
- struct guillemot_type *type;
- unsigned char length;
- char phys[32];
-};
-
-static struct guillemot_type guillemot_type[] = {
- { 0x00, guillemot_abs_pad, guillemot_btn_pad, 1, "Guillemot Pad" },
- { 0 }};
-
-/*
- * guillemot_read_packet() reads Guillemot joystick data.
- */
-
-static int guillemot_read_packet(struct gameport *gameport, u8 *data)
-{
- unsigned long flags;
- unsigned char u, v;
- unsigned int t, s;
- int i;
-
- for (i = 0; i < GUILLEMOT_MAX_LENGTH; i++)
- data[i] = 0;
-
- i = 0;
- t = gameport_time(gameport, GUILLEMOT_MAX_START);
- s = gameport_time(gameport, GUILLEMOT_MAX_STROBE);
-
- local_irq_save(flags);
- gameport_trigger(gameport);
- v = gameport_read(gameport);
-
- while (t > 0 && i < GUILLEMOT_MAX_LENGTH * 8) {
- t--;
- u = v; v = gameport_read(gameport);
- if (v & ~u & 0x10) {
- data[i >> 3] |= ((v >> 5) & 1) << (i & 7);
- i++;
- t = s;
- }
- }
-
- local_irq_restore(flags);
-
- return i;
-}
-
-/*
- * guillemot_poll() reads and analyzes Guillemot joystick data.
- */
-
-static void guillemot_poll(struct gameport *gameport)
-{
- struct guillemot *guillemot = gameport_get_drvdata(gameport);
- struct input_dev *dev = guillemot->dev;
- u8 data[GUILLEMOT_MAX_LENGTH];
- int i;
-
- guillemot->reads++;
-
- if (guillemot_read_packet(guillemot->gameport, data) != GUILLEMOT_MAX_LENGTH * 8 ||
- data[0] != 0x55 || data[16] != 0xaa) {
- guillemot->bads++;
- } else {
-
- for (i = 0; i < 6 && guillemot->type->abs[i] >= 0; i++)
- input_report_abs(dev, guillemot->type->abs[i], data[i + 5]);
-
- if (guillemot->type->hat) {
- input_report_abs(dev, ABS_HAT0X, guillemot_hat_to_axis[data[4] >> 4].x);
- input_report_abs(dev, ABS_HAT0Y, guillemot_hat_to_axis[data[4] >> 4].y);
- }
-
- for (i = 0; i < 16 && guillemot->type->btn[i] >= 0; i++)
- input_report_key(dev, guillemot->type->btn[i], (data[2 + (i >> 3)] >> (i & 7)) & 1);
- }
-
- input_sync(dev);
-}
-
-/*
- * guillemot_open() is a callback from the input open routine.
- */
-
-static int guillemot_open(struct input_dev *dev)
-{
- struct guillemot *guillemot = input_get_drvdata(dev);
-
- gameport_start_polling(guillemot->gameport);
- return 0;
-}
-
-/*
- * guillemot_close() is a callback from the input close routine.
- */
-
-static void guillemot_close(struct input_dev *dev)
-{
- struct guillemot *guillemot = input_get_drvdata(dev);
-
- gameport_stop_polling(guillemot->gameport);
-}
-
-/*
- * guillemot_connect() probes for Guillemot joysticks.
- */
-
-static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct guillemot *guillemot;
- struct input_dev *input_dev;
- u8 data[GUILLEMOT_MAX_LENGTH];
- int i, t;
- int err;
-
- guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!guillemot || !input_dev) {
- err = -ENOMEM;
- goto fail1;
- }
-
- guillemot->gameport = gameport;
- guillemot->dev = input_dev;
-
- gameport_set_drvdata(gameport, guillemot);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- i = guillemot_read_packet(gameport, data);
-
- if (i != GUILLEMOT_MAX_LENGTH * 8 || data[0] != 0x55 || data[16] != 0xaa) {
- err = -ENODEV;
- goto fail2;
- }
-
- for (i = 0; guillemot_type[i].name; i++)
- if (guillemot_type[i].id == data[11])
- break;
-
- if (!guillemot_type[i].name) {
- printk(KERN_WARNING "guillemot.c: Unknown joystick on %s. [ %02x%02x:%04x, ver %d.%02d ]\n",
- gameport->phys, data[12], data[13], data[11], data[14], data[15]);
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, guillemot_poll);
- gameport_set_poll_interval(gameport, 20);
-
- snprintf(guillemot->phys, sizeof(guillemot->phys), "%s/input0", gameport->phys);
- guillemot->type = guillemot_type + i;
-
- input_dev->name = guillemot_type[i].name;
- input_dev->phys = guillemot->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
- input_dev->id.product = guillemot_type[i].id;
- input_dev->id.version = (int)data[14] << 8 | data[15];
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, guillemot);
-
- input_dev->open = guillemot_open;
- input_dev->close = guillemot_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++)
- input_set_abs_params(input_dev, t, 0, 255, 0, 0);
-
- if (guillemot->type->hat) {
- input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
- input_set_abs_params(input_dev, ABS_HAT0Y, -1, 1, 0, 0);
- }
-
- for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
- set_bit(t, input_dev->keybit);
-
- err = input_register_device(guillemot->dev);
- if (err)
- goto fail2;
-
- return 0;
-
-fail2: gameport_close(gameport);
-fail1: gameport_set_drvdata(gameport, NULL);
- input_free_device(input_dev);
- kfree(guillemot);
- return err;
-}
-
-static void guillemot_disconnect(struct gameport *gameport)
-{
- struct guillemot *guillemot = gameport_get_drvdata(gameport);
-
- printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys);
- input_unregister_device(guillemot->dev);
- gameport_close(gameport);
- kfree(guillemot);
-}
-
-static struct gameport_driver guillemot_drv = {
- .driver = {
- .name = "guillemot",
- },
- .description = DRIVER_DESC,
- .connect = guillemot_connect,
- .disconnect = guillemot_disconnect,
-};
-
-module_gameport_driver(guillemot_drv);
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
deleted file mode 100644
index 17c2c80..0000000
--- a/drivers/input/joystick/interact.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2001 Vojtech Pavlik
- *
- * Based on the work of:
- * Toby Deshane
- */
-
-/*
- * InterAct digital gamepad/joystick driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "InterAct digital joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define INTERACT_MAX_START 600 /* 400 us */
-#define INTERACT_MAX_STROBE 60 /* 40 us */
-#define INTERACT_MAX_LENGTH 32 /* 32 bits */
-
-#define INTERACT_TYPE_HHFX 0 /* HammerHead/FX */
-#define INTERACT_TYPE_PP8D 1 /* ProPad 8 */
-
-struct interact {
- struct gameport *gameport;
- struct input_dev *dev;
- int bads;
- int reads;
- unsigned char type;
- unsigned char length;
- char phys[32];
-};
-
-static short interact_abs_hhfx[] =
- { ABS_RX, ABS_RY, ABS_X, ABS_Y, ABS_HAT0X, ABS_HAT0Y, -1 };
-static short interact_abs_pp8d[] =
- { ABS_X, ABS_Y, -1 };
-
-static short interact_btn_hhfx[] =
- { BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL, BTN_TL2, BTN_TR2, BTN_MODE, BTN_SELECT, -1 };
-static short interact_btn_pp8d[] =
- { BTN_C, BTN_TL, BTN_TR, BTN_A, BTN_B, BTN_Y, BTN_Z, BTN_X, -1 };
-
-struct interact_type {
- int id;
- short *abs;
- short *btn;
- char *name;
- unsigned char length;
- unsigned char b8;
-};
-
-static struct interact_type interact_type[] = {
- { 0x6202, interact_abs_hhfx, interact_btn_hhfx, "InterAct HammerHead/FX", 32, 4 },
- { 0x53f8, interact_abs_pp8d, interact_btn_pp8d, "InterAct ProPad 8 Digital", 16, 0 },
- { 0 }};
-
-/*
- * interact_read_packet() reads and InterAct joystick data.
- */
-
-static int interact_read_packet(struct gameport *gameport, int length, u32 *data)
-{
- unsigned long flags;
- unsigned char u, v;
- unsigned int t, s;
- int i;
-
- i = 0;
- data[0] = data[1] = data[2] = 0;
- t = gameport_time(gameport, INTERACT_MAX_START);
- s = gameport_time(gameport, INTERACT_MAX_STROBE);
-
- local_irq_save(flags);
- gameport_trigger(gameport);
- v = gameport_read(gameport);
-
- while (t > 0 && i < length) {
- t--;
- u = v; v = gameport_read(gameport);
- if (v & ~u & 0x40) {
- data[0] = (data[0] << 1) | ((v >> 4) & 1);
- data[1] = (data[1] << 1) | ((v >> 5) & 1);
- data[2] = (data[2] << 1) | ((v >> 7) & 1);
- i++;
- t = s;
- }
- }
-
- local_irq_restore(flags);
-
- return i;
-}
-
-/*
- * interact_poll() reads and analyzes InterAct joystick data.
- */
-
-static void interact_poll(struct gameport *gameport)
-{
- struct interact *interact = gameport_get_drvdata(gameport);
- struct input_dev *dev = interact->dev;
- u32 data[3];
- int i;
-
- interact->reads++;
-
- if (interact_read_packet(interact->gameport, interact->length, data) < interact->length) {
- interact->bads++;
- } else {
-
- for (i = 0; i < 3; i++)
- data[i] <<= INTERACT_MAX_LENGTH - interact->length;
-
- switch (interact->type) {
-
- case INTERACT_TYPE_HHFX:
-
- for (i = 0; i < 4; i++)
- input_report_abs(dev, interact_abs_hhfx[i], (data[i & 1] >> ((i >> 1) << 3)) & 0xff);
-
- for (i = 0; i < 2; i++)
- input_report_abs(dev, ABS_HAT0Y - i,
- ((data[1] >> ((i << 1) + 17)) & 1) - ((data[1] >> ((i << 1) + 16)) & 1));
-
- for (i = 0; i < 8; i++)
- input_report_key(dev, interact_btn_hhfx[i], (data[0] >> (i + 16)) & 1);
-
- for (i = 0; i < 4; i++)
- input_report_key(dev, interact_btn_hhfx[i + 8], (data[1] >> (i + 20)) & 1);
-
- break;
-
- case INTERACT_TYPE_PP8D:
-
- for (i = 0; i < 2; i++)
- input_report_abs(dev, interact_abs_pp8d[i],
- ((data[0] >> ((i << 1) + 20)) & 1) - ((data[0] >> ((i << 1) + 21)) & 1));
-
- for (i = 0; i < 8; i++)
- input_report_key(dev, interact_btn_pp8d[i], (data[1] >> (i + 16)) & 1);
-
- break;
- }
- }
-
- input_sync(dev);
-}
-
-/*
- * interact_open() is a callback from the input open routine.
- */
-
-static int interact_open(struct input_dev *dev)
-{
- struct interact *interact = input_get_drvdata(dev);
-
- gameport_start_polling(interact->gameport);
- return 0;
-}
-
-/*
- * interact_close() is a callback from the input close routine.
- */
-
-static void interact_close(struct input_dev *dev)
-{
- struct interact *interact = input_get_drvdata(dev);
-
- gameport_stop_polling(interact->gameport);
-}
-
-/*
- * interact_connect() probes for InterAct joysticks.
- */
-
-static int interact_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct interact *interact;
- struct input_dev *input_dev;
- __u32 data[3];
- int i, t;
- int err;
-
- interact = kzalloc(sizeof(struct interact), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!interact || !input_dev) {
- err = -ENOMEM;
- goto fail1;
- }
-
- interact->gameport = gameport;
- interact->dev = input_dev;
-
- gameport_set_drvdata(gameport, interact);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- i = interact_read_packet(gameport, INTERACT_MAX_LENGTH * 2, data);
-
- if (i != 32 || (data[0] >> 24) != 0x0c || (data[1] >> 24) != 0x02) {
- err = -ENODEV;
- goto fail2;
- }
-
- for (i = 0; interact_type[i].length; i++)
- if (interact_type[i].id == (data[2] >> 16))
- break;
-
- if (!interact_type[i].length) {
- printk(KERN_WARNING "interact.c: Unknown joystick on %s. [len %d d0 %08x d1 %08x i2 %08x]\n",
- gameport->phys, i, data[0], data[1], data[2]);
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, interact_poll);
- gameport_set_poll_interval(gameport, 20);
-
- snprintf(interact->phys, sizeof(interact->phys), "%s/input0", gameport->phys);
-
- interact->type = i;
- interact->length = interact_type[i].length;
-
- input_dev->name = interact_type[i].name;
- input_dev->phys = interact->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
- input_dev->id.product = interact_type[i].id;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, interact);
-
- input_dev->open = interact_open;
- input_dev->close = interact_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) {
- if (i < interact_type[interact->type].b8)
- input_set_abs_params(input_dev, t, 0, 255, 0, 0);
- else
- input_set_abs_params(input_dev, t, -1, 1, 0, 0);
- }
-
- for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
- __set_bit(t, input_dev->keybit);
-
- err = input_register_device(interact->dev);
- if (err)
- goto fail2;
-
- return 0;
-
-fail2: gameport_close(gameport);
-fail1: gameport_set_drvdata(gameport, NULL);
- input_free_device(input_dev);
- kfree(interact);
- return err;
-}
-
-static void interact_disconnect(struct gameport *gameport)
-{
- struct interact *interact = gameport_get_drvdata(gameport);
-
- input_unregister_device(interact->dev);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(interact);
-}
-
-static struct gameport_driver interact_drv = {
- .driver = {
- .name = "interact",
- },
- .description = DRIVER_DESC,
- .connect = interact_connect,
- .disconnect = interact_disconnect,
-};
-
-module_gameport_driver(interact_drv);
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
deleted file mode 100644
index d1c6e48..0000000
--- a/drivers/input/joystick/joydump.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1996-2001 Vojtech Pavlik
- */
-
-/*
- * This is just a very simple driver that can dump the data
- * out of the joystick port into the syslog ...
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/module.h>
-#include <linux/gameport.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-
-#define DRIVER_DESC "Gameport data dumper module"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define BUF_SIZE 256
-
-struct joydump {
- unsigned int time;
- unsigned char data;
-};
-
-static int joydump_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct joydump *buf; /* all entries */
- struct joydump *dump, *prev; /* one entry each */
- int axes[4], buttons;
- int i, j, t, timeout;
- unsigned long flags;
- unsigned char u;
-
- printk(KERN_INFO "joydump: ,------------------ START ----------------.\n");
- printk(KERN_INFO "joydump: | Dumping: %30s |\n", gameport->phys);
- printk(KERN_INFO "joydump: | Speed: %28d kHz |\n", gameport->speed);
-
- if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {
-
- printk(KERN_INFO "joydump: | Raw mode not available - trying cooked. |\n");
-
- if (gameport_open(gameport, drv, GAMEPORT_MODE_COOKED)) {
-
- printk(KERN_INFO "joydump: | Cooked not available either. Failing. |\n");
- printk(KERN_INFO "joydump: `------------------- END -----------------'\n");
- return -ENODEV;
- }
-
- gameport_cooked_read(gameport, axes, &buttons);
-
- for (i = 0; i < 4; i++)
- printk(KERN_INFO "joydump: | Axis %d: %4d. |\n", i, axes[i]);
- printk(KERN_INFO "joydump: | Buttons %02x. |\n", buttons);
- printk(KERN_INFO "joydump: `------------------- END -----------------'\n");
- }
-
- timeout = gameport_time(gameport, 10000); /* 10 ms */
-
- buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
- if (!buf) {
- printk(KERN_INFO "joydump: no memory for testing\n");
- goto jd_end;
- }
- dump = buf;
- t = 0;
- i = 1;
-
- local_irq_save(flags);
-
- u = gameport_read(gameport);
-
- dump->data = u;
- dump->time = t;
- dump++;
-
- gameport_trigger(gameport);
-
- while (i < BUF_SIZE && t < timeout) {
-
- dump->data = gameport_read(gameport);
-
- if (dump->data ^ u) {
- u = dump->data;
- dump->time = t;
- i++;
- dump++;
- }
- t++;
- }
-
- local_irq_restore(flags);
-
-/*
- * Dump data.
- */
-
- t = i;
- dump = buf;
- prev = dump;
-
- printk(KERN_INFO "joydump: >------------------ DATA -----------------<\n");
- printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ", 0, 0);
- for (j = 7; j >= 0; j--)
- printk("%d", (dump->data >> j) & 1);
- printk(" |\n");
- dump++;
-
- for (i = 1; i < t; i++, dump++, prev++) {
- printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ",
- i, dump->time - prev->time);
- for (j = 7; j >= 0; j--)
- printk("%d", (dump->data >> j) & 1);
- printk(" |\n");
- }
- kfree(buf);
-
-jd_end:
- printk(KERN_INFO "joydump: `------------------- END -----------------'\n");
-
- return 0;
-}
-
-static void joydump_disconnect(struct gameport *gameport)
-{
- gameport_close(gameport);
-}
-
-static struct gameport_driver joydump_drv = {
- .driver = {
- .name = "joydump",
- },
- .description = DRIVER_DESC,
- .connect = joydump_connect,
- .disconnect = joydump_disconnect,
-};
-
-module_gameport_driver(joydump_drv);
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
deleted file mode 100644
index 4a95b22..0000000
--- a/drivers/input/joystick/sidewinder.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/*
- * Copyright (c) 1998-2005 Vojtech Pavlik
- */
-
-/*
- * Microsoft SideWinder joystick family driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "Microsoft SideWinder joystick family driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-/*
- * These are really magic values. Changing them can make a problem go away,
- * as well as break everything.
- */
-
-#undef SW_DEBUG
-#undef SW_DEBUG_DATA
-
-#define SW_START 600 /* The time we wait for the first bit [600 us] */
-#define SW_STROBE 60 /* Max time per bit [60 us] */
-#define SW_TIMEOUT 6 /* Wait for everything to settle [6 ms] */
-#define SW_KICK 45 /* Wait after A0 fall till kick [45 us] */
-#define SW_END 8 /* Number of bits before end of packet to kick */
-#define SW_FAIL 16 /* Number of packet read errors to fail and reinitialize */
-#define SW_BAD 2 /* Number of packet read errors to switch off 3d Pro optimization */
-#define SW_OK 64 /* Number of packet read successes to switch optimization back on */
-#define SW_LENGTH 512 /* Max number of bits in a packet */
-
-#ifdef SW_DEBUG
-#define dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg)
-#else
-#define dbg(format, arg...) do {} while (0)
-#endif
-
-/*
- * SideWinder joystick types ...
- */
-
-#define SW_ID_3DP 0
-#define SW_ID_GP 1
-#define SW_ID_PP 2
-#define SW_ID_FFP 3
-#define SW_ID_FSP 4
-#define SW_ID_FFW 5
-
-/*
- * Names, buttons, axes ...
- */
-
-static char *sw_name[] = { "3D Pro", "GamePad", "Precision Pro", "Force Feedback Pro", "FreeStyle Pro",
- "Force Feedback Wheel" };
-
-static char sw_abs[][7] = {
- { ABS_X, ABS_Y, ABS_RZ, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y },
- { ABS_X, ABS_Y },
- { ABS_X, ABS_Y, ABS_RZ, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y },
- { ABS_X, ABS_Y, ABS_RZ, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y },
- { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y },
- { ABS_RX, ABS_RUDDER, ABS_THROTTLE }};
-
-static char sw_bit[][7] = {
- { 10, 10, 9, 10, 1, 1 },
- { 1, 1 },
- { 10, 10, 6, 7, 1, 1 },
- { 10, 10, 6, 7, 1, 1 },
- { 10, 10, 6, 1, 1 },
- { 10, 7, 7, 1, 1 }};
-
-static short sw_btn[][12] = {
- { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_THUMB2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_MODE },
- { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE },
- { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_SELECT },
- { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_SELECT },
- { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT },
- { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_THUMB2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4 }};
-
-static struct {
- int x;
- int y;
-} sw_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
-
-struct sw {
- struct gameport *gameport;
- struct input_dev *dev[4];
- char name[64];
- char phys[4][32];
- int length;
- int type;
- int bits;
- int number;
- int fail;
- int ok;
- int reads;
- int bads;
-};
-
-/*
- * sw_read_packet() is a function which reads either a data packet, or an
- * identification packet from a SideWinder joystick. The protocol is very,
- * very, very braindamaged. Microsoft patented it in US patent #5628686.
- */
-
-static int sw_read_packet(struct gameport *gameport, unsigned char *buf, int length, int id)
-{
- unsigned long flags;
- int timeout, bitout, sched, i, kick, start, strobe;
- unsigned char pending, u, v;
-
- i = -id; /* Don't care about data, only want ID */
- timeout = id ? gameport_time(gameport, SW_TIMEOUT * 1000) : 0; /* Set up global timeout for ID packet */
- kick = id ? gameport_time(gameport, SW_KICK) : 0; /* Set up kick timeout for ID packet */
- start = gameport_time(gameport, SW_START);
- strobe = gameport_time(gameport, SW_STROBE);
- bitout = start;
- pending = 0;
- sched = 0;
-
- local_irq_save(flags); /* Quiet, please */
-
- gameport_trigger(gameport); /* Trigger */
- v = gameport_read(gameport);
-
- do {
- bitout--;
- u = v;
- v = gameport_read(gameport);
- } while (!(~v & u & 0x10) && (bitout > 0)); /* Wait for first falling edge on clock */
-
- if (bitout > 0)
- bitout = strobe; /* Extend time if not timed out */
-
- while ((timeout > 0 || bitout > 0) && (i < length)) {
-
- timeout--;
- bitout--; /* Decrement timers */
- sched--;
-
- u = v;
- v = gameport_read(gameport);
-
- if ((~u & v & 0x10) && (bitout > 0)) { /* Rising edge on clock - data bit */
- if (i >= 0) /* Want this data */
- buf[i] = v >> 5; /* Store it */
- i++; /* Advance index */
- bitout = strobe; /* Extend timeout for next bit */
- }
-
- if (kick && (~v & u & 0x01)) { /* Falling edge on axis 0 */
- sched = kick; /* Schedule second trigger */
- kick = 0; /* Don't schedule next time on falling edge */
- pending = 1; /* Mark schedule */
- }
-
- if (pending && sched < 0 && (i > -SW_END)) { /* Second trigger time */
- gameport_trigger(gameport); /* Trigger */
- bitout = start; /* Long bit timeout */
- pending = 0; /* Unmark schedule */
- timeout = 0; /* Switch from global to bit timeouts */
- }
- }
-
- local_irq_restore(flags); /* Done - relax */
-
-#ifdef SW_DEBUG_DATA
- {
- int j;
- printk(KERN_DEBUG "sidewinder.c: Read %d triplets. [", i);
- for (j = 0; j < i; j++) printk("%d", buf[j]);
- printk("]\n");
- }
-#endif
-
- return i;
-}
-
-/*
- * sw_get_bits() and GB() compose bits from the triplet buffer into a __u64.
- * Parameter 'pos' is bit number inside packet where to start at, 'num' is number
- * of bits to be read, 'shift' is offset in the resulting __u64 to start at, bits
- * is number of bits per triplet.
- */
-
-#define GB(pos,num) sw_get_bits(buf, pos, num, sw->bits)
-
-static __u64 sw_get_bits(unsigned char *buf, int pos, int num, char bits)
-{
- __u64 data = 0;
- int tri = pos % bits; /* Start position */
- int i = pos / bits;
- int bit = 0;
-
- while (num--) {
- data |= (__u64)((buf[i] >> tri++) & 1) << bit++; /* Transfer bit */
- if (tri == bits) {
- i++; /* Next triplet */
- tri = 0;
- }
- }
-
- return data;
-}
-
-/*
- * sw_init_digital() initializes a SideWinder 3D Pro joystick
- * into digital mode.
- */
-
-static void sw_init_digital(struct gameport *gameport)
-{
- int seq[] = { 140, 140+725, 140+300, 0 };
- unsigned long flags;
- int i, t;
-
- local_irq_save(flags);
-
- i = 0;
- do {
- gameport_trigger(gameport); /* Trigger */
- t = gameport_time(gameport, SW_TIMEOUT * 1000);
- while ((gameport_read(gameport) & 1) && t) t--; /* Wait for axis to fall back to 0 */
- udelay(seq[i]); /* Delay magic time */
- } while (seq[++i]);
-
- gameport_trigger(gameport); /* Last trigger */
-
- local_irq_restore(flags);
-}
-
-/*
- * sw_parity() computes parity of __u64
- */
-
-static int sw_parity(__u64 t)
-{
- int x = t ^ (t >> 32);
-
- x ^= x >> 16;
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x & 1;
-}
-
-/*
- * sw_ccheck() checks synchronization bits and computes checksum of nibbles.
- */
-
-static int sw_check(__u64 t)
-{
- unsigned char sum = 0;
-
- if ((t & 0x8080808080808080ULL) ^ 0x80) /* Sync */
- return -1;
-
- while (t) { /* Sum */
- sum += t & 0xf;
- t >>= 4;
- }
-
- return sum & 0xf;
-}
-
-/*
- * sw_parse() analyzes SideWinder joystick data, and writes the results into
- * the axes and buttons arrays.
- */
-
-static int sw_parse(unsigned char *buf, struct sw *sw)
-{
- int hat, i, j;
- struct input_dev *dev;
-
- switch (sw->type) {
-
- case SW_ID_3DP:
-
- if (sw_check(GB(0,64)) || (hat = (GB(6,1) << 3) | GB(60,3)) > 8)
- return -1;
-
- dev = sw->dev[0];
-
- input_report_abs(dev, ABS_X, (GB( 3,3) << 7) | GB(16,7));
- input_report_abs(dev, ABS_Y, (GB( 0,3) << 7) | GB(24,7));
- input_report_abs(dev, ABS_RZ, (GB(35,2) << 7) | GB(40,7));
- input_report_abs(dev, ABS_THROTTLE, (GB(32,3) << 7) | GB(48,7));
-
- input_report_abs(dev, ABS_HAT0X, sw_hat_to_axis[hat].x);
- input_report_abs(dev, ABS_HAT0Y, sw_hat_to_axis[hat].y);
-
- for (j = 0; j < 7; j++)
- input_report_key(dev, sw_btn[SW_ID_3DP][j], !GB(j+8,1));
-
- input_report_key(dev, BTN_BASE4, !GB(38,1));
- input_report_key(dev, BTN_BASE5, !GB(37,1));
-
- input_sync(dev);
-
- return 0;
-
- case SW_ID_GP:
-
- for (i = 0; i < sw->number; i ++) {
-
- if (sw_parity(GB(i*15,15)))
- return -1;
-
- input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1));
- input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1));
-
- for (j = 0; j < 10; j++)
- input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1));
-
- input_sync(sw->dev[i]);
- }
-
- return 0;
-
- case SW_ID_PP:
- case SW_ID_FFP:
-
- if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8)
- return -1;
-
- dev = sw->dev[0];
- input_report_abs(dev, ABS_X, GB( 9,10));
- input_report_abs(dev, ABS_Y, GB(19,10));
- input_report_abs(dev, ABS_RZ, GB(36, 6));
- input_report_abs(dev, ABS_THROTTLE, GB(29, 7));
-
- input_report_abs(dev, ABS_HAT0X, sw_hat_to_axis[hat].x);
- input_report_abs(dev, ABS_HAT0Y, sw_hat_to_axis[hat].y);
-
- for (j = 0; j < 9; j++)
- input_report_key(dev, sw_btn[SW_ID_PP][j], !GB(j,1));
-
- input_sync(dev);
-
- return 0;
-
- case SW_ID_FSP:
-
- if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8)
- return -1;
-
- dev = sw->dev[0];
- input_report_abs(dev, ABS_X, GB( 0,10));
- input_report_abs(dev, ABS_Y, GB(16,10));
- input_report_abs(dev, ABS_THROTTLE, GB(32, 6));
-
- input_report_abs(dev, ABS_HAT0X, sw_hat_to_axis[hat].x);
- input_report_abs(dev, ABS_HAT0Y, sw_hat_to_axis[hat].y);
-
- for (j = 0; j < 6; j++)
- input_report_key(dev, sw_btn[SW_ID_FSP][j], !GB(j+10,1));
-
- input_report_key(dev, BTN_TR, !GB(26,1));
- input_report_key(dev, BTN_START, !GB(27,1));
- input_report_key(dev, BTN_MODE, !GB(38,1));
- input_report_key(dev, BTN_SELECT, !GB(39,1));
-
- input_sync(dev);
-
- return 0;
-
- case SW_ID_FFW:
-
- if (!sw_parity(GB(0,33)))
- return -1;
-
- dev = sw->dev[0];
- input_report_abs(dev, ABS_RX, GB( 0,10));
- input_report_abs(dev, ABS_RUDDER, GB(10, 6));
- input_report_abs(dev, ABS_THROTTLE, GB(16, 6));
-
- for (j = 0; j < 8; j++)
- input_report_key(dev, sw_btn[SW_ID_FFW][j], !GB(j+22,1));
-
- input_sync(dev);
-
- return 0;
- }
-
- return -1;
-}
-
-/*
- * sw_read() reads SideWinder joystick data, and reinitializes
- * the joystick in case of persistent problems. This is the function that is
- * called from the generic code to poll the joystick.
- */
-
-static int sw_read(struct sw *sw)
-{
- unsigned char buf[SW_LENGTH];
- int i;
-
- i = sw_read_packet(sw->gameport, buf, sw->length, 0);
-
- if (sw->type == SW_ID_3DP && sw->length == 66 && i != 66) { /* Broken packet, try to fix */
-
- if (i == 64 && !sw_check(sw_get_bits(buf,0,64,1))) { /* Last init failed, 1 bit mode */
- printk(KERN_WARNING "sidewinder.c: Joystick in wrong mode on %s"
- " - going to reinitialize.\n", sw->gameport->phys);
- sw->fail = SW_FAIL; /* Reinitialize */
- i = 128; /* Bogus value */
- }
-
- if (i < 66 && GB(0,64) == GB(i*3-66,64)) /* 1 == 3 */
- i = 66; /* Everything is fine */
-
- if (i < 66 && GB(0,64) == GB(66,64)) /* 1 == 2 */
- i = 66; /* Everything is fine */
-
- if (i < 66 && GB(i*3-132,64) == GB(i*3-66,64)) { /* 2 == 3 */
- memmove(buf, buf + i - 22, 22); /* Move data */
- i = 66; /* Carry on */
- }
- }
-
- if (i == sw->length && !sw_parse(buf, sw)) { /* Parse data */
-
- sw->fail = 0;
- sw->ok++;
-
- if (sw->type == SW_ID_3DP && sw->length == 66 /* Many packets OK */
- && sw->ok > SW_OK) {
-
- printk(KERN_INFO "sidewinder.c: No more trouble on %s"
- " - enabling optimization again.\n", sw->gameport->phys);
- sw->length = 22;
- }
-
- return 0;
- }
-
- sw->ok = 0;
- sw->fail++;
-
- if (sw->type == SW_ID_3DP && sw->length == 22 && sw->fail > SW_BAD) { /* Consecutive bad packets */
-
- printk(KERN_INFO "sidewinder.c: Many bit errors on %s"
- " - disabling optimization.\n", sw->gameport->phys);
- sw->length = 66;
- }
-
- if (sw->fail < SW_FAIL)
- return -1; /* Not enough, don't reinitialize yet */
-
- printk(KERN_WARNING "sidewinder.c: Too many bit errors on %s"
- " - reinitializing joystick.\n", sw->gameport->phys);
-
- if (!i && sw->type == SW_ID_3DP) { /* 3D Pro can be in analog mode */
- mdelay(3 * SW_TIMEOUT);
- sw_init_digital(sw->gameport);
- }
-
- mdelay(SW_TIMEOUT);
- i = sw_read_packet(sw->gameport, buf, SW_LENGTH, 0); /* Read normal data packet */
- mdelay(SW_TIMEOUT);
- sw_read_packet(sw->gameport, buf, SW_LENGTH, i); /* Read ID packet, this initializes the stick */
-
- sw->fail = SW_FAIL;
-
- return -1;
-}
-
-static void sw_poll(struct gameport *gameport)
-{
- struct sw *sw = gameport_get_drvdata(gameport);
-
- sw->reads++;
- if (sw_read(sw))
- sw->bads++;
-}
-
-static int sw_open(struct input_dev *dev)
-{
- struct sw *sw = input_get_drvdata(dev);
-
- gameport_start_polling(sw->gameport);
- return 0;
-}
-
-static void sw_close(struct input_dev *dev)
-{
- struct sw *sw = input_get_drvdata(dev);
-
- gameport_stop_polling(sw->gameport);
-}
-
-/*
- * sw_print_packet() prints the contents of a SideWinder packet.
- */
-
-static void sw_print_packet(char *name, int length, unsigned char *buf, char bits)
-{
- int i;
-
- printk(KERN_INFO "sidewinder.c: %s packet, %d bits. [", name, length);
- for (i = (((length + 3) >> 2) - 1); i >= 0; i--)
- printk("%x", (int)sw_get_bits(buf, i << 2, 4, bits));
- printk("]\n");
-}
-
-/*
- * sw_3dp_id() translates the 3DP id into a human legible string.
- * Unfortunately I don't know how to do this for the other SW types.
- */
-
-static void sw_3dp_id(unsigned char *buf, char *comment, size_t size)
-{
- int i;
- char pnp[8], rev[9];
-
- for (i = 0; i < 7; i++) /* ASCII PnP ID */
- pnp[i] = sw_get_bits(buf, 24+8*i, 8, 1);
-
- for (i = 0; i < 8; i++) /* ASCII firmware revision */
- rev[i] = sw_get_bits(buf, 88+8*i, 8, 1);
-
- pnp[7] = rev[8] = 0;
-
- snprintf(comment, size, " [PnP %d.%02d id %s rev %s]",
- (int) ((sw_get_bits(buf, 8, 6, 1) << 6) | /* Two 6-bit values */
- sw_get_bits(buf, 16, 6, 1)) / 100,
- (int) ((sw_get_bits(buf, 8, 6, 1) << 6) |
- sw_get_bits(buf, 16, 6, 1)) % 100,
- pnp, rev);
-}
-
-/*
- * sw_guess_mode() checks the upper two button bits for toggling -
- * indication of that the joystick is in 3-bit mode. This is documented
- * behavior for 3DP ID packet, and for example the FSP does this in
- * normal packets instead. Fun ...
- */
-
-static int sw_guess_mode(unsigned char *buf, int len)
-{
- int i;
- unsigned char xor = 0;
-
- for (i = 1; i < len; i++)
- xor |= (buf[i - 1] ^ buf[i]) & 6;
-
- return !!xor * 2 + 1;
-}
-
-/*
- * sw_connect() probes for SideWinder type joysticks.
- */
-
-static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- struct sw *sw;
- struct input_dev *input_dev;
- int i, j, k, l;
- int err = 0;
- unsigned char *buf = NULL; /* [SW_LENGTH] */
- unsigned char *idbuf = NULL; /* [SW_LENGTH] */
- unsigned char m = 1;
- char comment[40];
-
- comment[0] = 0;
-
- sw = kzalloc(sizeof(struct sw), GFP_KERNEL);
- buf = kmalloc(SW_LENGTH, GFP_KERNEL);
- idbuf = kmalloc(SW_LENGTH, GFP_KERNEL);
- if (!sw || !buf || !idbuf) {
- err = -ENOMEM;
- goto fail1;
- }
-
- sw->gameport = gameport;
-
- gameport_set_drvdata(gameport, sw);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- dbg("Init 0: Opened %s, io %#x, speed %d",
- gameport->phys, gameport->io, gameport->speed);
-
- i = sw_read_packet(gameport, buf, SW_LENGTH, 0); /* Read normal packet */
- msleep(SW_TIMEOUT);
- dbg("Init 1: Mode %d. Length %d.", m , i);
-
- if (!i) { /* No data. 3d Pro analog mode? */
- sw_init_digital(gameport); /* Switch to digital */
- msleep(SW_TIMEOUT);
- i = sw_read_packet(gameport, buf, SW_LENGTH, 0); /* Retry reading packet */
- msleep(SW_TIMEOUT);
- dbg("Init 1b: Length %d.", i);
- if (!i) { /* No data -> FAIL */
- err = -ENODEV;
- goto fail2;
- }
- }
-
- j = sw_read_packet(gameport, idbuf, SW_LENGTH, i); /* Read ID. This initializes the stick */
- m |= sw_guess_mode(idbuf, j); /* ID packet should carry mode info [3DP] */
- dbg("Init 2: Mode %d. ID Length %d.", m, j);
-
- if (j <= 0) { /* Read ID failed. Happens in 1-bit mode on PP */
- msleep(SW_TIMEOUT);
- i = sw_read_packet(gameport, buf, SW_LENGTH, 0); /* Retry reading packet */
- m |= sw_guess_mode(buf, i);
- dbg("Init 2b: Mode %d. Length %d.", m, i);
- if (!i) {
- err = -ENODEV;
- goto fail2;
- }
- msleep(SW_TIMEOUT);
- j = sw_read_packet(gameport, idbuf, SW_LENGTH, i); /* Retry reading ID */
- dbg("Init 2c: ID Length %d.", j);
- }
-
- sw->type = -1;
- k = SW_FAIL; /* Try SW_FAIL times */
- l = 0;
-
- do {
- k--;
- msleep(SW_TIMEOUT);
- i = sw_read_packet(gameport, buf, SW_LENGTH, 0); /* Read data packet */
- dbg("Init 3: Mode %d. Length %d. Last %d. Tries %d.", m, i, l, k);
-
- if (i > l) { /* Longer? As we can only lose bits, it makes */
- /* no sense to try detection for a packet shorter */
- l = i; /* than the previous one */
-
- sw->number = 1;
- sw->gameport = gameport;
- sw->length = i;
- sw->bits = m;
-
- dbg("Init 3a: Case %d.\n", i * m);
-
- switch (i * m) {
- case 60:
- sw->number++;
- case 45: /* Ambiguous packet length */
- if (j <= 40) { /* ID length less or eq 40 -> FSP */
- case 43:
- sw->type = SW_ID_FSP;
- break;
- }
- sw->number++;
- case 30:
- sw->number++;
- case 15:
- sw->type = SW_ID_GP;
- break;
- case 33:
- case 31:
- sw->type = SW_ID_FFW;
- break;
- case 48: /* Ambiguous */
- if (j == 14) { /* ID length 14*3 -> FFP */
- sw->type = SW_ID_FFP;
- sprintf(comment, " [AC %s]", sw_get_bits(idbuf,38,1,3) ? "off" : "on");
- } else
- sw->type = SW_ID_PP;
- break;
- case 66:
- sw->bits = 3;
- case 198:
- sw->length = 22;
- case 64:
- sw->type = SW_ID_3DP;
- if (j == 160)
- sw_3dp_id(idbuf, comment, sizeof(comment));
- break;
- }
- }
-
- } while (k && sw->type == -1);
-
- if (sw->type == -1) {
- printk(KERN_WARNING "sidewinder.c: unknown joystick device detected "
- "on %s, contact <vojtech@xxxxxx>\n", gameport->phys);
- sw_print_packet("ID", j * 3, idbuf, 3);
- sw_print_packet("Data", i * m, buf, m);
- err = -ENODEV;
- goto fail2;
- }
-
-#ifdef SW_DEBUG
- sw_print_packet("ID", j * 3, idbuf, 3);
- sw_print_packet("Data", i * m, buf, m);
-#endif
-
- gameport_set_poll_handler(gameport, sw_poll);
- gameport_set_poll_interval(gameport, 20);
-
- k = i;
- l = j;
-
- for (i = 0; i < sw->number; i++) {
- int bits, code;
-
- snprintf(sw->name, sizeof(sw->name),
- "Microsoft SideWinder %s", sw_name[sw->type]);
- snprintf(sw->phys[i], sizeof(sw->phys[i]),
- "%s/input%d", gameport->phys, i);
-
- sw->dev[i] = input_dev = input_allocate_device();
- if (!input_dev) {
- err = -ENOMEM;
- goto fail3;
- }
-
- input_dev->name = sw->name;
- input_dev->phys = sw->phys[i];
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT;
- input_dev->id.product = sw->type;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &gameport->dev;
-
- input_set_drvdata(input_dev, sw);
-
- input_dev->open = sw_open;
- input_dev->close = sw_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (j = 0; (bits = sw_bit[sw->type][j]); j++) {
- int min, max, fuzz, flat;
-
- code = sw_abs[sw->type][j];
- min = bits == 1 ? -1 : 0;
- max = (1 << bits) - 1;
- fuzz = (bits >> 1) >= 2 ? 1 << ((bits >> 1) - 2) : 0;
- flat = code == ABS_THROTTLE || bits < 5 ?
- 0 : 1 << (bits - 5);
-
- input_set_abs_params(input_dev, code,
- min, max, fuzz, flat);
- }
-
- for (j = 0; (code = sw_btn[sw->type][j]); j++)
- __set_bit(code, input_dev->keybit);
-
- dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k);
-
- err = input_register_device(sw->dev[i]);
- if (err)
- goto fail4;
- }
-
- out: kfree(buf);
- kfree(idbuf);
-
- return err;
-
- fail4: input_free_device(sw->dev[i]);
- fail3: while (--i >= 0)
- input_unregister_device(sw->dev[i]);
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(sw);
- goto out;
-}
-
-static void sw_disconnect(struct gameport *gameport)
-{
- struct sw *sw = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < sw->number; i++)
- input_unregister_device(sw->dev[i]);
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(sw);
-}
-
-static struct gameport_driver sw_drv = {
- .driver = {
- .name = "sidewinder",
- .owner = THIS_MODULE,
- },
- .description = DRIVER_DESC,
- .connect = sw_connect,
- .disconnect = sw_disconnect,
-};
-
-module_gameport_driver(sw_drv);
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
deleted file mode 100644
index 7e17cde..0000000
--- a/drivers/input/joystick/tmdc.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Vojtech Pavlik
- *
- * Based on the work of:
- * Trystan Larey-Williams
- */
-
-/*
- * ThrustMaster DirectConnect (BSP) joystick family driver for Linux
- */
-
-/*
- * 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
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@xxxxxx>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-#include <linux/jiffies.h>
-
-#define DRIVER_DESC "ThrustMaster DirectConnect joystick driver"
-
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@xxxxxx>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-#define TMDC_MAX_START 600 /* 600 us */
-#define TMDC_MAX_STROBE 60 /* 60 us */
-#define TMDC_MAX_LENGTH 13
-
-#define TMDC_MODE_M3DI 1
-#define TMDC_MODE_3DRP 3
-#define TMDC_MODE_AT 4
-#define TMDC_MODE_FM 8
-#define TMDC_MODE_FGP 163
-
-#define TMDC_BYTE_ID 10
-#define TMDC_BYTE_REV 11
-#define TMDC_BYTE_DEF 12
-
-#define TMDC_ABS 7
-#define TMDC_ABS_HAT 4
-#define TMDC_BTN 16
-
-static const unsigned char tmdc_byte_a[16] = { 0, 1, 3, 4, 6, 7 };
-static const unsigned char tmdc_byte_d[16] = { 2, 5, 8, 9 };
-
-static const signed char tmdc_abs[TMDC_ABS] =
- { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE, ABS_RX, ABS_RY, ABS_RZ };
-static const signed char tmdc_abs_hat[TMDC_ABS_HAT] =
- { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y };
-static const signed char tmdc_abs_at[TMDC_ABS] =
- { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE };
-static const signed char tmdc_abs_fm[TMDC_ABS] =
- { ABS_RX, ABS_RY, ABS_X, ABS_Y };
-
-static const short tmdc_btn_pad[TMDC_BTN] =
- { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR };
-static const short tmdc_btn_joy[TMDC_BTN] =
- { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE,
- BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z };
-static const short tmdc_btn_fm[TMDC_BTN] =
- { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 };
-static const short tmdc_btn_at[TMDC_BTN] =
- { BTN_TRIGGER, BTN_THUMB2, BTN_PINKIE, BTN_THUMB, BTN_BASE6, BTN_BASE5, BTN_BASE4,
- BTN_BASE3, BTN_BASE2, BTN_BASE };
-
-static const struct {
- int x;
- int y;
-} tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}};
-
-static const struct tmdc_model {
- unsigned char id;
- const char *name;
- char abs;
- char hats;
- char btnc[4];
- char btno[4];
- const signed char *axes;
- const short *buttons;
-} tmdc_models[] = {
- { 1, "ThrustMaster Millenium 3D Inceptor", 6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy },
- { 3, "ThrustMaster Rage 3D Gamepad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
- { 4, "ThrustMaster Attack Throttle", 5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at },
- { 8, "ThrustMaster FragMaster", 4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm },
- { 163, "Thrustmaster Fusion GamePad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
- { 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy }
-};
-
-
-struct tmdc_port {
- struct input_dev *dev;
- char name[64];
- char phys[32];
- int mode;
- const signed char *abs;
- const short *btn;
- unsigned char absc;
- unsigned char btnc[4];
- unsigned char btno[4];
-};
-
-struct tmdc {
- struct gameport *gameport;
- struct tmdc_port *port[2];
-#if 0
- struct input_dev *dev[2];
- char name[2][64];
- char phys[2][32];
- int mode[2];
- signed char *abs[2];
- short *btn[2];
- unsigned char absc[2];
- unsigned char btnc[2][4];
- unsigned char btno[2][4];
-#endif
- int reads;
- int bads;
- unsigned char exists;
-};
-
-/*
- * tmdc_read_packet() reads a ThrustMaster packet.
- */
-
-static int tmdc_read_packet(struct gameport *gameport, unsigned char data[2][TMDC_MAX_LENGTH])
-{
- unsigned char u, v, w, x;
- unsigned long flags;
- int i[2], j[2], t[2], p, k;
-
- p = gameport_time(gameport, TMDC_MAX_STROBE);
-
- for (k = 0; k < 2; k++) {
- t[k] = gameport_time(gameport, TMDC_MAX_START);
- i[k] = j[k] = 0;
- }
-
- local_irq_save(flags);
- gameport_trigger(gameport);
-
- w = gameport_read(gameport) >> 4;
-
- do {
- x = w;
- w = gameport_read(gameport) >> 4;
-
- for (k = 0, v = w, u = x; k < 2; k++, v >>= 2, u >>= 2) {
- if (~v & u & 2) {
- if (t[k] <= 0 || i[k] >= TMDC_MAX_LENGTH) continue;
- t[k] = p;
- if (j[k] == 0) { /* Start bit */
- if (~v & 1) t[k] = 0;
- data[k][i[k]] = 0; j[k]++; continue;
- }
- if (j[k] == 9) { /* Stop bit */
- if (v & 1) t[k] = 0;
- j[k] = 0; i[k]++; continue;
- }
- data[k][i[k]] |= (~v & 1) << (j[k]++ - 1); /* Data bit */
- }
- t[k]--;
- }
- } while (t[0] > 0 || t[1] > 0);
-
- local_irq_restore(flags);
-
- return (i[0] == TMDC_MAX_LENGTH) | ((i[1] == TMDC_MAX_LENGTH) << 1);
-}
-
-static int tmdc_parse_packet(struct tmdc_port *port, unsigned char *data)
-{
- int i, k, l;
-
- if (data[TMDC_BYTE_ID] != port->mode)
- return -1;
-
- for (i = 0; i < port->absc; i++) {
- if (port->abs[i] < 0)
- return 0;
-
- input_report_abs(port->dev, port->abs[i], data[tmdc_byte_a[i]]);
- }
-
- switch (port->mode) {
-
- case TMDC_MODE_M3DI:
-
- i = tmdc_byte_d[0];
- input_report_abs(port->dev, ABS_HAT0X, ((data[i] >> 3) & 1) - ((data[i] >> 1) & 1));
- input_report_abs(port->dev, ABS_HAT0Y, ((data[i] >> 2) & 1) - ( data[i] & 1));
- break;
-
- case TMDC_MODE_AT:
-
- i = tmdc_byte_a[3];
- input_report_abs(port->dev, ABS_HAT0X, tmdc_hat_to_axis[(data[i] - 141) / 25].x);
- input_report_abs(port->dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[i] - 141) / 25].y);
- break;
-
- }
-
- for (k = l = 0; k < 4; k++) {
- for (i = 0; i < port->btnc[k]; i++)
- input_report_key(port->dev, port->btn[i + l],
- ((data[tmdc_byte_d[k]] >> (i + port->btno[k])) & 1));
- l += port->btnc[k];
- }
-
- input_sync(port->dev);
-
- return 0;
-}
-
-/*
- * tmdc_poll() reads and analyzes ThrustMaster joystick data.
- */
-
-static void tmdc_poll(struct gameport *gameport)
-{
- unsigned char data[2][TMDC_MAX_LENGTH];
- struct tmdc *tmdc = gameport_get_drvdata(gameport);
- unsigned char r, bad = 0;
- int i;
-
- tmdc->reads++;
-
- if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists)
- bad = 1;
- else {
- for (i = 0; i < 2; i++) {
- if (r & (1 << i) & tmdc->exists) {
-
- if (tmdc_parse_packet(tmdc->port[i], data[i]))
- bad = 1;
- }
- }
- }
-
- tmdc->bads += bad;
-}
-
-static int tmdc_open(struct input_dev *dev)
-{
- struct tmdc *tmdc = input_get_drvdata(dev);
-
- gameport_start_polling(tmdc->gameport);
- return 0;
-}
-
-static void tmdc_close(struct input_dev *dev)
-{
- struct tmdc *tmdc = input_get_drvdata(dev);
-
- gameport_stop_polling(tmdc->gameport);
-}
-
-static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
-{
- const struct tmdc_model *model;
- struct tmdc_port *port;
- struct input_dev *input_dev;
- int i, j, b = 0;
- int err;
-
- tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!port || !input_dev) {
- err = -ENOMEM;
- goto fail;
- }
-
- port->mode = data[TMDC_BYTE_ID];
-
- for (model = tmdc_models; model->id && model->id != port->mode; model++)
- /* empty */;
-
- port->abs = model->axes;
- port->btn = model->buttons;
-
- if (!model->id) {
- port->absc = data[TMDC_BYTE_DEF] >> 4;
- for (i = 0; i < 4; i++)
- port->btnc[i] = i < (data[TMDC_BYTE_DEF] & 0xf) ? 8 : 0;
- } else {
- port->absc = model->abs;
- for (i = 0; i < 4; i++)
- port->btnc[i] = model->btnc[i];
- }
-
- for (i = 0; i < 4; i++)
- port->btno[i] = model->btno[i];
-
- snprintf(port->name, sizeof(port->name), model->name,
- port->absc, (data[TMDC_BYTE_DEF] & 0xf) << 3, port->mode);
- snprintf(port->phys, sizeof(port->phys), "%s/input%d", tmdc->gameport->phys, i);
-
- port->dev = input_dev;
-
- input_dev->name = port->name;
- input_dev->phys = port->phys;
- input_dev->id.bustype = BUS_GAMEPORT;
- input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER;
- input_dev->id.product = model->id;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &tmdc->gameport->dev;
-
- input_set_drvdata(input_dev, tmdc);
-
- input_dev->open = tmdc_open;
- input_dev->close = tmdc_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-
- for (i = 0; i < port->absc && i < TMDC_ABS; i++)
- if (port->abs[i] >= 0)
- input_set_abs_params(input_dev, port->abs[i], 8, 248, 2, 4);
-
- for (i = 0; i < model->hats && i < TMDC_ABS_HAT; i++)
- input_set_abs_params(input_dev, tmdc_abs_hat[i], -1, 1, 0, 0);
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < port->btnc[i] && j < TMDC_BTN; j++)
- set_bit(port->btn[j + b], input_dev->keybit);
- b += port->btnc[i];
- }
-
- err = input_register_device(port->dev);
- if (err)
- goto fail;
-
- return 0;
-
- fail: input_free_device(input_dev);
- kfree(port);
- return err;
-}
-
-/*
- * tmdc_probe() probes for ThrustMaster type joysticks.
- */
-
-static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
-{
- unsigned char data[2][TMDC_MAX_LENGTH];
- struct tmdc *tmdc;
- int i;
- int err;
-
- if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL)))
- return -ENOMEM;
-
- tmdc->gameport = gameport;
-
- gameport_set_drvdata(gameport, tmdc);
-
- err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
- if (err)
- goto fail1;
-
- if (!(tmdc->exists = tmdc_read_packet(gameport, data))) {
- err = -ENODEV;
- goto fail2;
- }
-
- gameport_set_poll_handler(gameport, tmdc_poll);
- gameport_set_poll_interval(gameport, 20);
-
- for (i = 0; i < 2; i++) {
- if (tmdc->exists & (1 << i)) {
-
- err = tmdc_setup_port(tmdc, i, data[i]);
- if (err)
- goto fail3;
- }
- }
-
- return 0;
-
- fail3: while (--i >= 0) {
- if (tmdc->port[i]) {
- input_unregister_device(tmdc->port[i]->dev);
- kfree(tmdc->port[i]);
- }
- }
- fail2: gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
- kfree(tmdc);
- return err;
-}
-
-static void tmdc_disconnect(struct gameport *gameport)
-{
- struct tmdc *tmdc = gameport_get_drvdata(gameport);
- int i;
-
- for (i = 0; i < 2; i++) {
- if (tmdc->port[i]) {
- input_unregister_device(tmdc->port[i]->dev);
- kfree(tmdc->port[i]);
- }
- }
- gameport_close(gameport);
- gameport_set_drvdata(gameport, NULL);
- kfree(tmdc);
-}
-
-static struct gameport_driver tmdc_drv = {
- .driver = {
- .name = "tmdc",
- .owner = THIS_MODULE,
- },
- .description = DRIVER_DESC,
- .connect = tmdc_connect,
- .disconnect = tmdc_disconnect,
-};
-
-module_gameport_driver(tmdc_drv);
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
deleted file mode 100644
index bb7de09..0000000
--- a/include/linux/gameport.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 1999-2002 Vojtech Pavlik
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-#ifndef _GAMEPORT_H
-#define _GAMEPORT_H
-
-#include <asm/io.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <uapi/linux/gameport.h>
-
-struct gameport {
-
- void *port_data; /* Private pointer for gameport drivers */
- char name[32];
- char phys[32];
-
- int io;
- int speed;
- int fuzz;
-
- void (*trigger)(struct gameport *);
- unsigned char (*read)(struct gameport *);
- int (*cooked_read)(struct gameport *, int *, int *);
- int (*calibrate)(struct gameport *, int *, int *);
- int (*open)(struct gameport *, int);
- void (*close)(struct gameport *);
-
- struct timer_list poll_timer;
- unsigned int poll_interval; /* in msecs */
- spinlock_t timer_lock;
- unsigned int poll_cnt;
- void (*poll_handler)(struct gameport *);
-
- struct gameport *parent, *child;
-
- struct gameport_driver *drv;
- struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
-
- struct device dev;
-
- struct list_head node;
-};
-#define to_gameport_port(d) container_of(d, struct gameport, dev)
-
-struct gameport_driver {
- const char *description;
-
- int (*connect)(struct gameport *, struct gameport_driver *drv);
- int (*reconnect)(struct gameport *);
- void (*disconnect)(struct gameport *);
-
- struct device_driver driver;
-
- bool ignore;
-};
-#define to_gameport_driver(d) container_of(d, struct gameport_driver, driver)
-
-int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode);
-void gameport_close(struct gameport *gameport);
-
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
-
-void __gameport_register_port(struct gameport *gameport, struct module *owner);
-/* use a define to avoid include chaining to get THIS_MODULE */
-#define gameport_register_port(gameport) \
- __gameport_register_port(gameport, THIS_MODULE)
-
-void gameport_unregister_port(struct gameport *gameport);
-
-__printf(2, 3)
-void gameport_set_phys(struct gameport *gameport, const char *fmt, ...);
-
-#else
-
-static inline void gameport_register_port(struct gameport *gameport)
-{
- return;
-}
-
-static inline void gameport_unregister_port(struct gameport *gameport)
-{
- return;
-}
-
-static inline __printf(2, 3)
-void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
-{
- return;
-}
-
-#endif
-
-static inline struct gameport *gameport_allocate_port(void)
-{
- struct gameport *gameport = kzalloc(sizeof(struct gameport), GFP_KERNEL);
-
- return gameport;
-}
-
-static inline void gameport_free_port(struct gameport *gameport)
-{
- kfree(gameport);
-}
-
-static inline void gameport_set_name(struct gameport *gameport, const char *name)
-{
- strlcpy(gameport->name, name, sizeof(gameport->name));
-}
-
-/*
- * Use the following functions to manipulate gameport's per-port
- * driver-specific data.
- */
-static inline void *gameport_get_drvdata(struct gameport *gameport)
-{
- return dev_get_drvdata(&gameport->dev);
-}
-
-static inline void gameport_set_drvdata(struct gameport *gameport, void *data)
-{
- dev_set_drvdata(&gameport->dev, data);
-}
-
-/*
- * Use the following functions to pin gameport's driver in process context
- */
-static inline int gameport_pin_driver(struct gameport *gameport)
-{
- return mutex_lock_interruptible(&gameport->drv_mutex);
-}
-
-static inline void gameport_unpin_driver(struct gameport *gameport)
-{
- mutex_unlock(&gameport->drv_mutex);
-}
-
-int __must_check __gameport_register_driver(struct gameport_driver *drv,
- struct module *owner, const char *mod_name);
-
-/* use a define to avoid include chaining to get THIS_MODULE & friends */
-#define gameport_register_driver(drv) \
- __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
-
-void gameport_unregister_driver(struct gameport_driver *drv);
-
-/**
- * module_gameport_driver() - Helper macro for registering a gameport driver
- * @__gameport_driver: gameport_driver struct
- *
- * Helper macro for gameport drivers which do not do anything special in
- * module init/exit. This eliminates a lot of boilerplate. Each module may
- * only use this macro once, and calling it replaces module_init() and
- * module_exit().
- */
-#define module_gameport_driver(__gameport_driver) \
- module_driver(__gameport_driver, gameport_register_driver, \
- gameport_unregister_driver)
-
-
-static inline void gameport_trigger(struct gameport *gameport)
-{
- if (gameport->trigger)
- gameport->trigger(gameport);
- else
- outb(0xff, gameport->io);
-}
-
-static inline unsigned char gameport_read(struct gameport *gameport)
-{
- if (gameport->read)
- return gameport->read(gameport);
- else
- return inb(gameport->io);
-}
-
-static inline int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
-{
- if (gameport->cooked_read)
- return gameport->cooked_read(gameport, axes, buttons);
- else
- return -1;
-}
-
-static inline int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
-{
- if (gameport->calibrate)
- return gameport->calibrate(gameport, axes, max);
- else
- return -1;
-}
-
-static inline int gameport_time(struct gameport *gameport, int time)
-{
- return (time * gameport->speed) / 1000;
-}
-
-static inline void gameport_set_poll_handler(struct gameport *gameport, void (*handler)(struct gameport *))
-{
- gameport->poll_handler = handler;
-}
-
-static inline void gameport_set_poll_interval(struct gameport *gameport, unsigned int msecs)
-{
- gameport->poll_interval = msecs;
-}
-
-void gameport_start_polling(struct gameport *gameport);
-void gameport_stop_polling(struct gameport *gameport);
-
-#endif
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 24e9033..5482e82 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -127,7 +127,6 @@ header-y += fs.h
header-y += fsl_hypervisor.h
header-y += fuse.h
header-y += futex.h
-header-y += gameport.h
header-y += gen_stats.h
header-y += genetlink.h
header-y += gfs2_ondisk.h
diff --git a/include/uapi/linux/gameport.h b/include/uapi/linux/gameport.h
deleted file mode 100644
index 49b29b0..0000000
--- a/include/uapi/linux/gameport.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1999-2002 Vojtech Pavlik
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-#ifndef _UAPI_GAMEPORT_H
-#define _UAPI_GAMEPORT_H
-
-
-
-#define GAMEPORT_MODE_DISABLED 0
-#define GAMEPORT_MODE_RAW 1
-#define GAMEPORT_MODE_COOKED 2
-
-#define GAMEPORT_ID_VENDOR_ANALOG 0x0001
-#define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
-#define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
-#define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
-#define GAMEPORT_ID_VENDOR_GENIUS 0x0005
-#define GAMEPORT_ID_VENDOR_INTERACT 0x0006
-#define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
-#define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
-#define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
-#define GAMEPORT_ID_VENDOR_GUILLEMOT 0x000a
-
-#endif /* _UAPI_GAMEPORT_H */
--
2.1.0.rc2.206.gedb03e5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/