2 * $Id: au88x0_game.c,v 1.9 2003/09/22 03:51:28 mjander Exp $
6 * Based on the work of:
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
26 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
28 * Based 90% on Vojtech Pavlik pcigame driver.
29 * Merged and modified by Manuel Jander, for the OpenVortex
30 * driver. (email: mjander@embedded.cl).
33 #include <sound/driver.h>
34 #include <linux/time.h>
35 #include <linux/init.h>
36 #include <sound/core.h>
38 #include <linux/gameport.h>
40 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
42 #define VORTEX_GAME_DWAIT 20 /* 20 ms */
44 static struct gameport gameport;
46 static unsigned char vortex_game_read(struct gameport *gameport)
48 vortex_t *vortex = gameport->driver;
49 return hwread(vortex->mmio, VORTEX_GAME_LEGACY);
52 static void vortex_game_trigger(struct gameport *gameport)
54 vortex_t *vortex = gameport->driver;
55 hwwrite(vortex->mmio, VORTEX_GAME_LEGACY, 0xff);
59 vortex_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
61 vortex_t *vortex = gameport->driver;
64 *buttons = (~hwread(vortex->mmio, VORTEX_GAME_LEGACY) >> 4) & 0xf;
66 for (i = 0; i < 4; i++) {
68 hwread(vortex->mmio, VORTEX_GAME_AXIS + (i * AXIS_SIZE));
69 if (axes[i] == AXIS_RANGE)
75 static int vortex_game_open(struct gameport *gameport, int mode)
77 vortex_t *vortex = gameport->driver;
80 case GAMEPORT_MODE_COOKED:
81 hwwrite(vortex->mmio, VORTEX_CTRL2,
83 VORTEX_CTRL2) | CTRL2_GAME_ADCMODE);
84 wait_ms(VORTEX_GAME_DWAIT);
86 case GAMEPORT_MODE_RAW:
87 hwwrite(vortex->mmio, VORTEX_CTRL2,
89 VORTEX_CTRL2) & ~CTRL2_GAME_ADCMODE);
98 static int vortex_gameport_register(vortex_t * vortex)
100 vortex->gameport = &gameport;
102 vortex->gameport->driver = vortex;
103 vortex->gameport->fuzz = 64;
105 vortex->gameport->read = vortex_game_read;
106 vortex->gameport->trigger = vortex_game_trigger;
107 vortex->gameport->cooked_read = vortex_game_cooked_read;
108 vortex->gameport->open = vortex_game_open;
110 gameport_register_port((struct gameport *)vortex->gameport);
112 /* printk(KERN_INFO "gameport%d: %s at speed %d kHz\n",
113 vortex->gameport->number, vortex->pci_dev->name, vortex->gameport->speed);
118 static int vortex_gameport_unregister(vortex_t * vortex)
120 if (vortex->gameport != NULL)
121 gameport_unregister_port(vortex->gameport);
127 static inline int vortex_gameport_register(vortex_t * vortex) { return 0; }
128 static inline int vortex_gameport_unregister(vortex_t * vortex) { return 0; }