|
From: Christoph H. <hc...@ca...> - 2000-08-20 18:55:22
|
> Well, OK. This will get really ugly when adbhid.c gets added with one of the
> next PPC merges and and drivers/usb has to be entered for
> CONFIG_ADB/CONFIG_INPUT_ADBHID too. Well, if that's the final word for
> 2.4.0... Can we schedule the move for 2.4.1 then?
>
> Who will send the joystick Makefile/Config.in patch to Linus? Please send it
> ASAP, I'll do the hackery for CONFIG_INPUT_ADBHID after that then.
Me. Here's a patch for -test7pre5.
NOTE (for Linus): beside the Changes to the makefiles and {C,c}onfig.ins
this is the same as moving drivers/joystick/*.c and drivers/usb/{evdev.c,
hid-debug.h, hid.c, hid.h, iforce.c, input.c, keybdev.c, mousedev.c, usbkbd.c,
usbmouse.c, wacom.c } to drivers/input
Christoph
--
Always remember that you are unique. Just like everyone else.
diff -uNr --exclude-from=exclude linux.orig/Makefile linux/Makefile
--- linux.orig/Makefile Tue Aug 15 12:29:44 2000
+++ linux/Makefile Thu Aug 17 16:14:13 2000
@@ -169,6 +169,7 @@
DRIVERS-$(CONFIG_HAMRADIO) += drivers/net/hamradio/hamradio.o
DRIVERS-$(CONFIG_TC) += drivers/tc/tc.a
DRIVERS-$(CONFIG_USB) += drivers/usb/usbdrv.o
+DRIVERS-$(CONFIG_INPUT) += drivers/input/inputdrv.o
DRIVERS-$(CONFIG_I2O) += drivers/i2o/i2o.o
DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o
DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o
diff -uNr --exclude-from=exclude linux.orig/arch/alpha/config.in linux/arch/alpha/config.in
--- linux.orig/arch/alpha/config.in Wed Jul 19 07:58:27 2000
+++ linux/arch/alpha/config.in Thu Aug 17 16:14:14 2000
@@ -334,6 +334,7 @@
endmenu
source drivers/usb/Config.in
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/arm/config.in linux/arch/arm/config.in
--- linux.orig/arch/arm/config.in Tue Aug 15 12:29:44 2000
+++ linux/arch/arm/config.in Thu Aug 17 16:14:14 2000
@@ -352,7 +352,7 @@
fi
source drivers/usb/Config.in
-
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/i386/config.in linux/arch/i386/config.in
--- linux.orig/arch/i386/config.in Tue Aug 1 04:36:10 2000
+++ linux/arch/i386/config.in Thu Aug 17 16:14:14 2000
@@ -339,6 +339,7 @@
endmenu
source drivers/usb/Config.in
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/ia64/config.in linux/arch/ia64/config.in
--- linux.orig/arch/ia64/config.in Tue Aug 15 12:29:45 2000
+++ linux/arch/ia64/config.in Thu Aug 17 16:14:14 2000
@@ -189,6 +189,7 @@
endmenu
source drivers/usb/Config.in
+source drivers/input/Config.in
fi # !HP_SIM
diff -uNr --exclude-from=exclude linux.orig/arch/m68k/config.in linux/arch/m68k/config.in
--- linux.orig/arch/m68k/config.in Thu Jul 13 00:12:11 2000
+++ linux/arch/m68k/config.in Thu Aug 17 17:04:55 2000
@@ -504,6 +504,8 @@
endmenu
fi
+source drivers/input/Config.in
+
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/mips/config.in linux/arch/mips/config.in
--- linux.orig/arch/mips/config.in Fri Jul 28 03:36:54 2000
+++ linux/arch/mips/config.in Thu Aug 17 16:14:14 2000
@@ -376,6 +376,7 @@
fi
source drivers/usb/Config.in
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/mips64/config.in linux/arch/mips64/config.in
--- linux.orig/arch/mips64/config.in Fri Jul 28 03:36:54 2000
+++ linux/arch/mips64/config.in Thu Aug 17 16:14:14 2000
@@ -247,6 +247,7 @@
fi
source drivers/usb/Config.in
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/ppc/config.in linux/arch/ppc/config.in
--- linux.orig/arch/ppc/config.in Thu Jul 13 18:42:50 2000
+++ linux/arch/ppc/config.in Thu Aug 17 16:14:14 2000
@@ -284,6 +284,7 @@
fi
source drivers/usb/Config.in
+source drivers/input/Config.in
mainmenu_option next_comment
comment 'Kernel hacking'
diff -uNr --exclude-from=exclude linux.orig/arch/sparc/config.in linux/arch/sparc/config.in
--- linux.orig/arch/sparc/config.in Tue Aug 15 12:29:46 2000
+++ linux/arch/sparc/config.in Thu Aug 17 17:05:26 2000
@@ -253,6 +253,8 @@
source fs/Config.in
+source drivers/input/Config.in
+
mainmenu_option next_comment
comment 'Watchdog'
diff -uNr --exclude-from=exclude linux.orig/arch/sparc64/config.in linux/arch/sparc64/config.in
--- linux.orig/arch/sparc64/config.in Tue Aug 15 12:29:46 2000
+++ linux/arch/sparc64/config.in Thu Aug 17 17:05:52 2000
@@ -331,6 +331,8 @@
source fs/Config.in
+source drivers/input/Config.in
+
mainmenu_option next_comment
comment 'Watchdog'
diff -uNr --exclude-from=exclude linux.orig/drivers/char/Config.in linux/drivers/char/Config.in
--- linux.orig/drivers/char/Config.in Tue Aug 15 12:29:47 2000
+++ linux/drivers/char/Config.in Thu Aug 17 16:15:03 2000
@@ -103,8 +103,6 @@
fi
endmenu
-source drivers/char/joystick/Config.in
-
tristate 'QIC-02 tape support' CONFIG_QIC02_TAPE
if [ "$CONFIG_QIC02_TAPE" != "n" ]; then
bool ' Do you want runtime configuration for QIC-02' CONFIG_QIC02_DYNCONF
diff -uNr --exclude-from=exclude linux.orig/drivers/char/Makefile linux/drivers/char/Makefile
--- linux.orig/drivers/char/Makefile Tue Aug 15 12:29:47 2000
+++ linux/drivers/char/Makefile Thu Aug 17 16:15:19 2000
@@ -23,7 +23,7 @@
SUB_DIRS :=
MOD_SUB_DIRS := $(SUB_DIRS)
-ALL_SUB_DIRS := $(SUB_DIRS) ftape joystick pcmcia rio drm agp
+ALL_SUB_DIRS := $(SUB_DIRS) ftape pcmcia rio drm agp
#
# This file contains the font map for the default (hardware) font
@@ -142,17 +142,6 @@
obj-$(CONFIG_ATIXL_BUSMOUSE) += atixlmouse.o
obj-$(CONFIG_LOGIBUSMOUSE) += logibusmouse.o
obj-$(CONFIG_PRINTER) += lp.o
-
-ifeq ($(CONFIG_JOYSTICK),y)
-obj-y += joystick/js.o
-SUB_DIRS += joystick
-MOD_SUB_DIRS += joystick
-else
- ifeq ($(CONFIG_JOYSTICK),m)
- MOD_SUB_DIRS += joystick
- endif
-endif
-
obj-$(CONFIG_BUSMOUSE) += busmouse.o
obj-$(CONFIG_DTLK) += dtlk.o
obj-$(CONFIG_R3964) += n_r3964.o
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/Config.in linux/drivers/char/joystick/Config.in
--- linux.orig/drivers/char/joystick/Config.in Tue Aug 15 12:29:47 2000
+++ linux/drivers/char/joystick/Config.in Thu Jan 1 01:00:00 1970
@@ -1,54 +0,0 @@
-#
-# Joystick driver configuration
-#
-
-mainmenu_option next_comment
-comment 'Joysticks'
-
-tristate 'Joystick support' CONFIG_JOYSTICK
-if [ "$CONFIG_JOYSTICK" != "n" ]; then
- define_tristate CONFIG_INPUT_JOYDEV $CONFIG_JOYSTICK
-
- comment 'Game port support'
- dep_tristate ' ns558 gameports' CONFIG_INPUT_NS558 $CONFIG_JOYSTICK
- dep_tristate ' PDPI Lightning 4 gamecard' CONFIG_INPUT_LIGHTNING $CONFIG_JOYSTICK
- dep_tristate ' Aureal Vortex and Trident 4DWave gameports' CONFIG_INPUT_PCIGAME $CONFIG_JOYSTICK
-
- comment 'Gameport joysticks'
- dep_tristate ' Classic PC analog joysticks and gamepads' CONFIG_INPUT_ANALOG $CONFIG_JOYSTICK
- dep_tristate ' Assasin 3D and MadCatz Panther devices' CONFIG_INPUT_A3D $CONFIG_JOYSTICK
- dep_tristate ' Logitech ADI digital joysticks and gamepads' CONFIG_INPUT_ADI $CONFIG_JOYSTICK
- dep_tristate ' Creative Labs Blaster Cobra gamepad' CONFIG_INPUT_COBRA $CONFIG_JOYSTICK
- dep_tristate ' Genius Flight2000 Digital joysticks and gamepads' CONFIG_INPUT_GF2K $CONFIG_JOYSTICK
- dep_tristate ' Gravis GrIP joysticks and gamepads' CONFIG_INPUT_GRIP $CONFIG_JOYSTICK
- dep_tristate ' InterAct digital joysticks and gamepads' CONFIG_INPUT_INTERACT $CONFIG_JOYSTICK
- dep_tristate ' ThrustMaster DirectConnect joysticks and gamepads' CONFIG_INPUT_TMDC $CONFIG_JOYSTICK
- dep_tristate ' Microsoft SideWinder digital joysticks and gamepads' CONFIG_INPUT_SIDEWINDER $CONFIG_JOYSTICK
-
- comment 'Serial port support'
- dep_tristate ' Serial port input line discipline' CONFIG_INPUT_SERPORT $CONFIG_JOYSTICK
-
- comment 'Serial port joysticks'
- dep_tristate ' Logitech WingMan Warrior joystick' CONFIG_INPUT_WARRIOR $CONFIG_JOYSTICK
- dep_tristate ' LogiCad3d Magellan/SpaceMouse 6dof controller' CONFIG_INPUT_MAGELLAN $CONFIG_JOYSTICK
- dep_tristate ' SpaceTec SpaceOrb/Avenger 6dof controller' CONFIG_INPUT_SPACEORB $CONFIG_JOYSTICK
- dep_tristate ' SpaceTec SpaceBall 4000 FLX 6dof controller' CONFIG_INPUT_SPACEBALL $CONFIG_JOYSTICK
- dep_tristate ' I-Force joysticks/wheels' CONFIG_INPUT_IFORCE_232 $CONFIG_JOYSTICK
- if [ "$CONFIG_INPUT_IFORCE_232" != "n" ]; then
- define_tristate CONFIG_INPUT_IFORCE $CONFIG_INPUT_IFORCE_232
- fi
-
- if [ "$CONFIG_PARPORT" != "n" ]; then
- comment 'Parallel port joysticks'
- dep_tristate ' Multisystem, Sega Genesis, Saturn joysticks and gamepads' CONFIG_INPUT_DB9 $CONFIG_JOYSTICK $CONFIG_PARPORT
- dep_tristate ' Multisystem, NES, SNES, N64, PSX joysticks and gamepads' CONFIG_INPUT_GAMECON $CONFIG_JOYSTICK $CONFIG_PARPORT
- dep_tristate ' Multisystem joysticks via TurboGraFX device' CONFIG_INPUT_TURBOGRAFX $CONFIG_JOYSTICK $CONFIG_PARPORT
- fi
-
- if [ "$CONFIG_AMIGA" = "y" ]; then
- comment 'System joysticks'
- dep_tristate ' Amiga joysticks' CONFIG_INPUT_AMIJOY $CONFIG_JOYSTICK
- fi
-fi
-
-endmenu
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/Makefile linux/drivers/char/joystick/Makefile
--- linux.orig/drivers/char/joystick/Makefile Sun Aug 6 20:23:40 2000
+++ linux/drivers/char/joystick/Makefile Thu Jan 1 01:00:00 1970
@@ -1,73 +0,0 @@
-#
-# Makefile for the joystick drivers.
-#
-
-# Subdirs.
-
-SUB_DIRS :=
-MOD_SUB_DIRS := $(SUB_DIRS)
-MOD_IN_SUB_DIRS := $(SUB_DIRS)
-ALL_SUB_DIRS := $(SUB_DIRS)
-
-# The target object and module list name.
-
-O_TARGET := js.o
-M_OBJS :=
-O_OBJS :=
-
-# Objects that export symbols.
-
-export-objs := serio.o gameport.o
-
-# Object file lists.
-
-obj-y :=
-obj-m :=
-obj-n :=
-obj- :=
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_INPUT_SERPORT) += serport.o serio.o
-
-obj-$(CONFIG_INPUT_NS558) += ns558.o gameport.o
-obj-$(CONFIG_INPUT_LIGHTNING) += lightning.o gameport.o
-obj-$(CONFIG_INPUT_PCIGAME) += pcigame.o gameport.o
-
-obj-$(CONFIG_INPUT_WARRIOR) += warrior.o serio.o
-obj-$(CONFIG_INPUT_MAGELLAN) += magellan.o serio.o
-obj-$(CONFIG_INPUT_SPACEORB) += spaceorb.o serio.o
-obj-$(CONFIG_INPUT_SPACEBALL) += spaceball.o serio.o
-obj-$(CONFIG_INPUT_IFORCE_232) += serio.o
-
-obj-$(CONFIG_INPUT_ANALOG) += analog.o gameport.o
-obj-$(CONFIG_INPUT_A3D) += a3d.o gameport.o
-obj-$(CONFIG_INPUT_ADI) += adi.o gameport.o
-obj-$(CONFIG_INPUT_COBRA) += cobra.o gameport.o
-obj-$(CONFIG_INPUT_GF2K) += gf2k.o gameport.o
-obj-$(CONFIG_INPUT_GRIP) += grip.o gameport.o
-obj-$(CONFIG_INPUT_INTERACT) += interact.o gameport.o
-obj-$(CONFIG_INPUT_TMDC) += tmdc.o gameport.o
-obj-$(CONFIG_INPUT_SIDEWINDER) += sidewinder.o gameport.o
-
-obj-$(CONFIG_INPUT_DB9) += db9.o
-obj-$(CONFIG_INPUT_GAMECON) += gamecon.o
-obj-$(CONFIG_INPUT_TURBOGRAFX) += turbografx.o
-
-obj-$(CONFIG_INPUT_AMIJOY) += amijoy.o
-
-# Files that are both resident and modular: remove from modular.
-
-obj-m := $(filter-out $(obj-y), $(obj-m))
-int-m := $(filter-out $(int-y), $(int-m))
-
-# Translate to Rules.make lists.
-
-O_OBJS := $(sort $(filter-out $(export-objs), $(obj-y)))
-OX_OBJS := $(sort $(filter $(export-objs), $(obj-y)))
-M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m)))
-MX_OBJS := $(sort $(filter $(export-objs), $(obj-m)))
-
-# The global Rules.make.
-
-include $(TOPDIR)/Rules.make
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/a3d.c linux/drivers/char/joystick/a3d.c
--- linux.orig/drivers/char/joystick/a3d.c Thu Jun 22 15:59:58 2000
+++ linux/drivers/char/joystick/a3d.c Thu Jan 1 01:00:00 1970
@@ -1,387 +0,0 @@
-/*
- * $Id: a3d.c,v 1.10 2000/05/29 11:19:50 vojtech Exp $
- *
- * Copyright (c) 1998-2000 Vojtech Pavlik
- *
- * Sponsored by SuSE
- */
-
-/*
- * FP-Gaming Assasin 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 <vo...@su...>, or by paper mail:
- * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/malloc.h>
-#include <linux/init.h>
-#include <linux/gameport.h>
-#include <linux/input.h>
-
-#define A3D_MAX_START 400 /* 400 us */
-#define A3D_MAX_STROBE 60 /* 40 us */
-#define A3D_DELAY_READ 3 /* 3 ms */
-#define A3D_MAX_LENGTH 40 /* 40*3 bits */
-#define A3D_REFRESH_TIME HZ/50 /* 20 ms */
-
-#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 */
-
-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;
- struct timer_list timer;
- int axes[4];
- int buttons;
- int mode;
- int length;
- int used;
- int reads;
- int bads;
-};
-
-/*
- * 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);
-
- __save_flags(flags);
- __cli();
- 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;
- }
- }
-
- __restore_flags(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);
-
- 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;
-
- return;
-
- 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);
-
- return;
- }
-}
-
-
-/*
- * a3d_timer() reads and analyzes A3D joystick data.
- */
-
-static void a3d_timer(unsigned long private)
-{
- struct a3d *a3d = (void *) private;
- 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);
- mod_timer(&a3d->timer, jiffies + A3D_REFRESH_TIME);
-}
-
-/*
- * 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.
- */
-
-int a3d_adc_cooked_read(struct gameport *gameport, int *axes, int *buttons)
-{
- struct a3d *a3d = gameport->driver;
- 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.
- */
-
-int a3d_adc_open(struct gameport *gameport, int mode)
-{
- struct a3d *a3d = gameport->driver;
- if (mode != GAMEPORT_MODE_COOKED)
- return -1;
- if (!a3d->used++)
- mod_timer(&a3d->timer, jiffies + A3D_REFRESH_TIME);
- 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->driver;
- if (!--a3d->used)
- del_timer(&a3d->timer);
-}
-
-/*
- * a3d_open() is a callback from the input open routine.
- */
-
-static int a3d_open(struct input_dev *dev)
-{
- struct a3d *a3d = dev->private;
- if (!a3d->used++)
- mod_timer(&a3d->timer, jiffies + A3D_REFRESH_TIME);
- return 0;
-}
-
-/*
- * a3d_close() is a callback from the input close routine.
- */
-
-static void a3d_close(struct input_dev *dev)
-{
- struct a3d *a3d = dev->private;
- if (!--a3d->used)
- del_timer(&a3d->timer);
-}
-
-/*
- * a3d_connect() probes for A3D joysticks.
- */
-
-static void a3d_connect(struct gameport *gameport, struct gameport_dev *dev)
-{
- struct a3d *a3d;
- unsigned char data[A3D_MAX_LENGTH];
- int i;
-
- if (!(a3d = kmalloc(sizeof(struct a3d), GFP_KERNEL)))
- return;
- memset(a3d, 0, sizeof(struct a3d));
-
- gameport->private = a3d;
-
- a3d->gameport = gameport;
- init_timer(&a3d->timer);
- a3d->timer.data = (long) a3d;
- a3d->timer.function = a3d_timer;
-
- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
- goto fail1;
-
- i = a3d_read_packet(gameport, A3D_MAX_LENGTH, data);
-
- if (!i || a3d_csum(data, i))
- goto fail2;
-
- a3d->mode = data[0];
-
- if (!a3d->mode || a3d->mode > 5) {
- printk(KERN_WARNING "a3d.c: Unknown A3D device detected "
- "(gameport%d, id=%d), contact <vo...@su...>\n", gameport->number, a3d->mode);
- goto fail2;
- }
-
-
- if (a3d->mode == A3D_MODE_PXL) {
-
- int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER };
-
- a3d->length = 33;
-
- a3d->dev.evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
- a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
- a3d->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER)
- | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y);
-
- a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE)
- | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
-
- a3d->dev.keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_PINKIE);
-
- a3d_read(a3d, data);
-
- for (i = 0; i < 4; i++) {
- if (i < 2) {
- a3d->dev.absmin[axes[i]] = 48;
- a3d->dev.absmax[axes[i]] = a3d->dev.abs[axes[i]] * 2 - 48;
- a3d->dev.absflat[axes[i]] = 8;
- } else {
- a3d->dev.absmin[axes[i]] = 2;
- a3d->dev.absmax[axes[i]] = 253;
- }
- a3d->dev.absmin[ABS_HAT0X + i] = -1;
- a3d->dev.absmax[ABS_HAT0X + i] = 1;
- }
-
- } else {
- a3d->length = 29;
-
- a3d->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_REL);
- a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
- a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);
-
- a3d->adc.driver = a3d;
- a3d->adc.open = a3d_adc_open;
- a3d->adc.close = a3d_adc_close;
- a3d->adc.cooked_read = a3d_adc_cooked_read;
- a3d->adc.fuzz = 1;
- a3d->adc.type = GAMEPORT_EXT;
-
- a3d_read(a3d, data);
-
- gameport_register_port(&a3d->adc);
- printk(KERN_INFO "gameport%d: %s on gameport%d.0\n",
- a3d->adc.number, a3d_names[a3d->mode], gameport->number);
- }
-
- a3d->dev.private = a3d;
- a3d->dev.open = a3d_open;
- a3d->dev.close = a3d_close;
-
- a3d->dev.name = a3d_names[a3d->mode];
- a3d->dev.idbus = BUS_GAMEPORT;
- a3d->dev.idvendor = GAMEPORT_ID_VENDOR_MADCATZ;
- a3d->dev.idproduct = a3d->mode;
- a3d->dev.idversion = 0x0100;
-
- input_register_device(&a3d->dev);
- printk(KERN_INFO "input%d: %s on gameport%d.0\n",
- a3d->dev.number, a3d_names[a3d->mode], gameport->number);
-
- return;
-fail2: gameport_close(gameport);
-fail1: kfree(a3d);
-}
-
-static void a3d_disconnect(struct gameport *gameport)
-{
-
- struct a3d *a3d = gameport->private;
- input_unregister_device(&a3d->dev);
- if (a3d->mode < A3D_MODE_PXL)
- gameport_unregister_port(&a3d->adc);
- gameport_close(gameport);
- kfree(a3d);
-}
-
-static struct gameport_dev a3d_dev = {
- connect: a3d_connect,
- disconnect: a3d_disconnect,
-};
-
-int __init a3d_init(void)
-{
- gameport_register_device(&a3d_dev);
- return 0;
-}
-
-void __exit a3d_exit(void)
-{
- gameport_unregister_device(&a3d_dev);
-}
-
-module_init(a3d_init);
-module_exit(a3d_exit);
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/adi.c linux/drivers/char/joystick/adi.c
--- linux.orig/drivers/char/joystick/adi.c Thu Jun 22 15:59:58 2000
+++ linux/drivers/char/joystick/adi.c Thu Jan 1 01:00:00 1970
@@ -1,554 +0,0 @@
-/*
- * $Id: adi.c,v 1.12 2000/06/03 20:18:52 vojtech Exp $
- *
- * Copyright (c) 1998-2000 Vojtech Pavlik
- *
- * Sponsored by SuSE
- */
-
-/*
- * 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 <vo...@su...>, or by paper mail:
- * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/malloc.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-#include <linux/init.h>
-
-/*
- * 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_REFRESH_TIME HZ/50 /* How often to poll the joystick [20 ms] */
-#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 48
-#define ADI_MAX_CNAME_LENGTH 16
-
-#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];
- unsigned char data[ADI_MAX_LENGTH];
-};
-
-struct adi_port {
- struct gameport *gameport;
- struct timer_list timer;
- struct adi adi[2];
- int bad;
- int reads;
- int used;
-};
-
-/*
- * 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;
- }
-
- __save_flags(flags);
- __cli();
-
- 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);
-
- __restore_flags(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));
-
- 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_timer() repeatedly polls the Logitech joysticks.
- */
-
-static void adi_timer(unsigned long data)
-{
- struct adi_port *port = (void *) data;
- port->bad -= adi_read(port);
- port->reads++;
- mod_timer(&port->timer, jiffies + ADI_REFRESH_TIME);
-}
-
-/*
- * adi_open() is a callback from the input open routine.
- */
-
-static int adi_open(struct input_dev *dev)
-{
- struct adi_port *port = dev->private;
- if (!port->used++)
- mod_timer(&port->timer, jiffies + ADI_REFRESH_TIME);
- return 0;
-}
-
-/*
- * adi_close() is a callback from the input close routine.
- */
-
-static void adi_close(struct input_dev *dev)
-{
- struct adi_port *port = dev->private;
- if (!--port->used)
- del_timer(&port->timer);
-}
-
-/*
- * 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[] = { 3, -2, -3, 10, -6, -11, -7, -9, 11, 0 };
- int i;
-
- for (i = 0; seq[i]; i++) {
- gameport_trigger(gameport);
- if (seq[i] > 0) wait_ms(seq[i]);
- if (seq[i] < 0) mdelay(-seq[i]);
- }
-}
-
-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;
-
- if (adi->length != (t = 8 + adi->buttons + adi->axes10 * 10 + adi->axes8 * 8 + adi->hats * 4)) {
- 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 void adi_init_input(struct adi *adi, struct adi_port *port)
-{
- int i, t;
- char buf[ADI_MAX_NAME_LENGTH];
-
- if (!adi->length) return;
-
- t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
-
- sprintf(buf, adi_names[t], adi->id);
- sprintf(adi->name, "Logitech %s", buf);
-
- adi->abs = adi_abs[t];
- adi->key = adi_key[t];
-
- adi->dev.open = adi_open;
- adi->dev.close = adi_close;
-
- adi->dev.name = adi->name;
- adi->dev.idbus = BUS_GAMEPORT;
- adi->dev.idvendor = GAMEPORT_ID_VENDOR_LOGITECH;
- adi->dev.idproduct = adi->id;
- adi->dev.idversion = 0x0100;
-
- adi->dev.private = port;
- adi->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-
- for (i = 0; i < adi->axes10 + adi->axes8 + adi->hats * 2; i++)
- set_bit(adi->abs[i], &adi->dev.absbit);
-
- for (i = 0; i < adi->buttons; i++)
- set_bit(adi->key[i], &adi->dev.keybit);
-}
-
-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 * 2; i++) {
-
- t = adi->abs[i];
- x = adi->dev.abs[t];
-
- if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) {
- if (i < adi->axes10) x = 512; else x = 128;
- }
-
- if (i < adi->axes10) {
- adi->dev.absmax[t] = x * 2 - 64;
- adi->dev.absmin[t] = 64;
- adi->dev.absfuzz[t] = 2;
- adi->dev.absflat[t] = 16;
- continue;
- }
-
- if (i < adi->axes10 + adi->axes8) {
- adi->dev.absmax[t] = x * 2 - 48;
- adi->dev.absmin[t] = 48;
- adi->dev.absfuzz[t] = 1;
- adi->dev.absflat[t] = 16;
- continue;
- }
-
- adi->dev.absmax[t] = 1;
- adi->dev.absmin[t] = -1;
- }
-}
-
-/*
- * adi_connect() probes for Logitech ADI joysticks.
- */
-
-static void adi_connect(struct gameport *gameport, struct gameport_dev *dev)
-{
- struct adi_port *port;
- int i;
-
- if (!(port = kmalloc(sizeof(struct adi_port), GFP_KERNEL)))
- return;
- memset(port, 0, sizeof(struct adi_port));
-
- gameport->private = port;
-
- port->gameport = gameport;
- init_timer(&port->timer);
- port->timer.data = (long) port;
- port->timer.function = adi_timer;
-
- if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW)) {
- kfree(port);
- return;
- }
-
- 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);
- adi_init_input(port->adi + i, port);
- }
-
- if (!port->adi[0].length && !port->adi[1].length) {
- gameport_close(gameport);
- kfree(port);
- return;
- }
-
- wait_ms(ADI_INIT_DELAY);
- if (adi_read(port)) {
- wait_ms(ADI_DATA_DELAY);
- adi_read(port);
- }
-
- for (i = 0; i < 2; i++)
- if (port->adi[i].length > 0) {
- adi_init_center(port->adi + i);
- input_register_device(&port->adi[i].dev);
- printk(KERN_INFO "input%d: %s [%s] on gameport%d.%d\n",
- port->adi[i].dev.number, port->adi[i].name, port->adi[i].cname, gameport->number, i);
- }
-}
-
-static void adi_disconnect(struct gameport *gameport)
-{
- int i;
-
- struct adi_port *port = gameport->private;
- for (i = 0; i < 2; i++)
- if (port->adi[i].length > 0)
- input_unregister_device(&port->adi[i].dev);
- gameport_close(gameport);
- kfree(port);
-}
-
-/*
- * The gameport device structure.
- */
-
-static struct gameport_dev adi_dev = {
- connect: adi_connect,
- disconnect: adi_disconnect,
-};
-
-int __init adi_init(void)
-{
- gameport_register_device(&adi_dev);
- return 0;
-}
-
-void __exit adi_exit(void)
-{
- gameport_unregister_device(&adi_dev);
-}
-
-module_init(adi_init);
-module_exit(adi_exit);
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/amijoy.c linux/drivers/char/joystick/amijoy.c
--- linux.orig/drivers/char/joystick/amijoy.c Wed Jun 21 17:22:21 2000
+++ linux/drivers/char/joystick/amijoy.c Thu Jan 1 01:00:00 1970
@@ -1,149 +0,0 @@
-/*
- * $Id: amijoy.c,v 1.4 2000/05/29 10:39:54 vojtech Exp $
- *
- * Copyright (c) 1998-2000 Vojtech Pavlik
- *
- * Sponsored by SuSE
- */
-
-/*
- * Driver for Amiga joysticks for Linux/m68k
- */
-
-/*
- * 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 <vo...@su...>, or by paper mail:
- * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input.h>
-
-#include <asm/system.h>
-#include <asm/amigahw.h>
-
-MODULE_AUTHOR("Vojtech Pavlik <vo...@su...>");
-MODULE_PARM(amijoy, "1-2i");
-
-static int amijoy[2] = { 0, 1 };
-static int amijoy_used[2] = { 0, 0 };
-static struct input_dev amijoy_dev[2];
-
-static char *amijoy_name = "Amiga joystick";
-
-static void amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp)
-{
- int i, data = 0, button = 0;
-
- for (i = 0; i < 2; i++)
- if (amijoy[i]) {
-
- switch (i) {
- case 0: data = ~custom.joy0dat; button = (~ciaa.pra >> 6) & 1; break;
- case 1: data = ~custom.joy1dat; button = (~ciaa.pra >> 7) & 1; break;
- }
-
- input_report_key(amijoy_dev + i, BTN_TRIGGER, button);
-
- input_report_abs(amijoy_dev + i, ABS_X, ((data >> 1) & 1) - ((data >> 9) & 1);
- data = ~(data ^ (data << 1));
- input_report_abs(amijoy_dev + i, ABS_Y, ((data >> 1) & 1) - ((data >> 9) & 1);
- }
-}
-
-static int amijoy_open(struct input_dev *dev)
-{
- int *used = dev->private;
-
- if ((*used)++)
- return 0;
-
- if (request_irq(IRQ_AMIGA_VERTB, amijoy_interrupt, 0, "amijoy", NULL)) {
- amijoy_used--;
- printk(KERN_ERR "amijoy.c: Can't allocate irq %d\n", amijoy_irq);
- return -EBUSY;
- }
-
- return 0;
-}
-
-static void amijoy_close(struct input_dev *dev)
-{
- int *used = dev->private;
-
- if (!--(*port->used))
- free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt);
-}
-
-static int __init amijoy_setup(char *str)
-{
- int i;
- int ints[4]
- str = get_options(str, ARRAY_SIZE(ints), ints);
- for (i = 0; i <= ints[0] && i < 2; i++) amijoy[i] = ints[i+1];
- return 1;
-}
-__setup("amijoy=", amijoy_setup);
-
-static int __init amijoy_init(void)
-{
- int i, j;
-
- init_timer(amijoy_timer);
- port->timer.function = amijoy_timer;
-
- for (i = 0; i < 2; i++)
- if (amijoy[i]) {
-
- amijoy_dev[i].open = amijoy_open;
- amijoy_dev[i].close = amijoy_close;
- amijoy_dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- amijoy_dev[i].absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
- amijoy_dev[i].keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
- for (j = 0; j < 2; j++)
- amijoy_dev[i].absmin[ABS_X + j] = -1;
- amijoy_dev[i].absmax[ABS_X + j] = 1;
- }
-
- amijoy->dev[i].name = amijoy_name;
- amijoy->dev[i].idbus = BUS_AMIGA;
- amijoy->dev[i].idvendor = 0x0001;
- amijoy->dev[i].idproduct = 0x0003;
- amijoy->dev[i].version = 0x0100;
-
- amijoy_dev[i].private = amijoy_used + i;
-
- input_register_device(amijoy_dev + i);
- printk(KERN_INFO "input%d: %s at joy%ddat\n", amijoy_dev[i].number, amijoy_name, i);
- }
-}
-
-static void _exit amijoy_exit(void)
-{
- int i;
-
- for (i = 0; i < 2; i++)
- if (amijoy[i])
- input_unregister_device(amijoy_dev + i);
-}
-
-module_init(amijoy_init);
-module_exit(amijoy_exit);
diff -uNr --exclude-from=exclude linux.orig/drivers/char/joystick/analog.c linux/drivers/char/joystick/analog.c
--- linux.orig/drivers/char/joystick/analog.c Thu Jun 22 15:59:58 2000
+++ linux/drivers/char/joystick/analog.c Thu Jan 1 01:00:00 1970
@@ -1,758 +0,0 @@
-/*
- * $Id: analog.c,v 1.52 2000/06/07 13:07:06 vojtech Exp $
- *
- * Copyright (c) 1996-2000 Vojtech Pavlik
- *
- * Sponsored by SuSE
- */
-
-/*
- * 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 <vo...@su...>, or by paper mail:
- * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
- */
-
-#include <linux/config.h>
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/malloc.h>
-#include <linux/bitops.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/gameport.h>
-
-MODULE_AUTHOR("Vojtech Pavlik <vo...@su...>");
-
-/*
- * Option parsing.
- */
-
-MODULE_PARM(js,"1-16s");
-
-#define ANALOG_PORTS 16
-
-static char *js[ANALOG_PORTS];
-static int analog_options[ANALOG_PORTS];
-
-/*
- * 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_REFRESH_TIME HZ/100 /* 10 ms */
-#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
-
-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];
-};
-
-struct analog_port {
- struct gameport *gameport;
- struct timer_list timer;
- 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 used;
- int axtime;
-};
-
-/*
- * Time macros.
- */
-
-#ifdef __i386__
-#ifdef CONFIG_X86_TSC
-#define GET_TIME(x) __asm__ __volatile__ ( "rdtsc" : "=a" (x) : : "dx" )
-#define DELTA(x,y) ((y)-(x))
-#define TIME_NAME "TSC"
-#else
-#define GET_TIME(x) do { outb(0, 0x43); x = inb(0x40); x |= inb(0x40) << 8; } while (0)
-#define DELTA(x,y) ((x)-(y)+((x)<(y)?1193180L/HZ:0))
-#define TIME_NAME "PIT"
-#endif
-#elif __alpha__
-#define GET_TIME(x) __asm__ __volatile__ ( "rpcc %0" : "=r" (x) )
-#define DELTA(x,y) ((y)-(x))
-#define TIME_NAME "PCC"
-#endif
-
-#ifndef GET_TIME
-#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"
-#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));
- }
-}
-
-/*
- * 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;
-
- __save_flags(flags);
- __cli();
- gameport_trigger(gameport);
- GET_TIME(now);
- __restore_flags(flags);
-
- start = now;
- this = port->mask;
- i = 0;
-
- do {
- loop = now;
- last = this;
-
- __cli();
- this = gameport_read(gameport) & port->mask;
- GET_TIME(now);
- __restore_flags(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_timer() repeatedly polls the Analog joysticks.
- */
-
-static void analog_timer(unsigned long data)
-{
- struct analog_port *port = (void *) data;
- 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);
-
- mod_timer(&port->timer, jiffies + ANALOG_REFRESH_TIME);
-}
-
-/*
- * analog_open() is a callback from the input open routine.
- */
-
-static int analog_open(struct input_dev *dev)
-{
- struct analog_port *port = dev->private;
- if (!port->used++)
- mod_timer(&port->timer, jiffies + ANALOG_REFRESH_TIME);
- return 0;
-}
-
-/*
- * analog_close() is a callback from the input close routine.
- */
-
-static void analog_close(struct input_dev *dev)
-{
- struct analog_port *port = dev->private;
- if (!--port->used)
- del_timer(&port->timer);
-}
-
-/*
- * 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;
-
- save_flags(flags);
- cli();
- GET_TIME(t1);
-#ifdef FAKE_TIME
- analog_faketime += 830;
-#endif
- udelay(1000);
- GET_TIME(t2);
- GET_TIME(t3);
- restore_flags(flags);
-
- port->speed = DELTA(t1, t2) - DELTA(t2, t3);
-
- tx = ~0;
-
- for (i = 0; i < 50; i++) {
- save_flags(flags);
- cli();
- GET_TIME(t1);
- for (t = 0; t < 50; t++) { gameport_read(gameport); GET_TIME(t2); }
- GET_TIME(t3);
- restore_flags(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)
-{
- sprintf(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)
- sprintf(analog->name, "%s %d-hat",
- analog->name, hweight16(analog->mask & ANALOG_HATS_ALL));
-
- if (analog->mask & ANALOG_HAT_FCS)
- strcat(analog->name, " FCS");
- if (analog->mask & ANALOG_ANY_CHF)
- strcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF");
-
- strcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick");
-}
-
-/*
- * analog_init_device()
- */
-
-static void analog_init_device(struct analog_port *port, struct analog *analog, int index)
-{
- int i, j, t, v, w, x, y, z;
-
- analog_name(analog);
-
- analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn;
-
- analog->dev.name = analog->name;
- analog->dev.idbus = BUS_GAMEPORT;
- analog->dev.idvendor = GAMEPORT_ID_VENDOR_ANALOG;
- analog->dev.idproduct = analog->mask >> 4;
- analog->dev.idversion = 0x0100;
-
- analog->dev.open = analog_open;
- analog->dev.close = analog_close;
- analog->dev.private = port;
- analog->dev.evbit[0] = BIT(EV_KEY) | BIT(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);
-
- set_bit(t, analog->dev.absbit);
-
- 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);
- }
-
- analog->dev.absmax[t] = (x << 1) - v;
- analog->dev.absmin[t] = v;
- analog->dev.absfuzz[t] = port->fuzz;
- analog->dev.absflat[t] = 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++];
- set_bit(t, analog->dev.absbit);
- analog->dev.absmax[t] = 1;
- analog->dev.absmin[t] = -1;
- }
-
- for (i = j = 0; i < 4; i++)
- if (analog->mask & (0x10 << i))
- set_bit(analog->buttons[j++], analog->dev.keybit);
-
- if (analog->mask & ANALOG_BTNS_CHF)
- for (i = 0; i < 2; i++)
- set_bit(analog->buttons[j++], analog->dev.keybit);
-
- if (analog->mask & ANALOG_HBTN_CHF)
- for (i = 0; i < 4; i++)
- set_bit(analog->buttons[j++], analog->dev.keybit);
-
- for (i = 0; i < 4; i++)
- if (analog->mask & (ANALOG_BTN_TL << i))
- set_bit(analog_pads[i], analog->dev.keybit);
-
- analog_decode(analog, port->axes, port->initial, port->buttons);
-
- input_register_device(&analog->dev);
-
- printk(KERN_INFO "input%d: %s at gameport%d.%d",
- analog->dev.number, analog->name, port->gameport->number, index);
-
- if (port->cooked)
- printk(" [ADC port]\n");
- else
- printk(" ["TIME_NAME" timer, %d %sHz clock, %d ns res]\n",
- port->speed > 10000 ? (port->speed + 800) / 1000 : port->speed,
- port->speed > 10000 ? "M" : "k", (port->loop * 1000000) / port->speed);
-}
-
-/*
- * 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, gameport%d), probably not analog joystick.\n",
- port->mask, port->gameport->number);
- return -1;
- }
-
- i = port->gameport->number < ANALOG_PORTS ? analog_options[port->gameport->number] : 0xff;
-
- 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_dev *dev, struct analog_port *port)
-{
- int i, t, u, v;
-
- gameport->private = port;
- port->gameport = gameport;
- init_timer(&port->timer);
- port->timer.data = (long) port;
- port->timer.function = analog_timer;
-
- if (!gameport_open(gameport, dev, GAMEPORT_MODE_RAW)) {
-
- analog_calibrate_timer(port);
-
- gameport_trigger(gameport);
- t = gameport_read(gameport);
- wait_ms(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;
- wait_ms(ANALOG_MAX_TIME);
- }
-
- u = v = 0;
-
- wait_ms(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) && port->gameport->number < ANALOG_PORTS) {
- analog_options[port->gameport->number] |=
- ANALOG_SAITEK | ANALOG_BTNS_CHF | ANALOG_HBTN_CHF | ANALOG_HAT1_CHF;
- return 0;
- }
-
- gameport_close(gameport);
- }
-
- if (!gameport_open(gameport, dev, 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;
- }
-
- if (!gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
- return 0;
-
- return -1;
-}
-
-static void analog_connect(struct gameport *gameport, struct gameport_dev *dev)
-{
- struct analog_port *port;
- int i;
-
- if (!(port = kmalloc(sizeof(struct analog_port), GFP_KERNEL)))
- return;
- memset(port, 0, sizeof(struct analog_port));
-
- if (analog_init_port(gameport, dev, port)) {
- kfree(port);
- return;
- }
-
- if (analog_init_masks(port)) {
- gameport_close(gameport);
- kfree(port);
- return;
- }
-
- for (i = 0; i < 2; i++)
- if (port->analog[i].mask)
- analog_init_device(port, port->analog + i, i);
-}
-
-static void analog_disconnect(struct gameport *gameport)
-{
- int i;
-
- struct analog_port *port = gameport->private;
- for (i = 0; i < 2; i++)
- if (port->analog[i].mask)
- input_unregister_device(&port->analog[i].dev);
- gameport_close(gameport);
- printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on gameport%d failed\n",
- port->bads, port->reads, port->reads ? (port->bads * 100 / port->reads) : 0,
- port->gameport->number);
- kfree(port);
-}
-
-struct analog_types {
- char *name;
- int value;
-};
-
-struct analog_types analog_types[] = {
- { "none", 0x00000000 },
- { "auto",...
[truncated message content] |