diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/pci/au88x0/au88x0_game.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/pci/au88x0/au88x0_game.c')
-rw-r--r-- | sound/pci/au88x0/au88x0_game.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/sound/pci/au88x0/au88x0_game.c b/sound/pci/au88x0/au88x0_game.c new file mode 100644 index 000000000000..a07d1deba322 --- /dev/null +++ b/sound/pci/au88x0/au88x0_game.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * $Id: au88x0_game.c,v 1.9 2003/09/22 03:51:28 mjander Exp $ | ||
3 | * | ||
4 | * Manuel Jander. | ||
5 | * | ||
6 | * Based on the work of: | ||
7 | * Vojtech Pavlik | ||
8 | * Raymond Ingles | ||
9 | * | ||
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. | ||
14 | * | ||
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. | ||
19 | * | ||
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 | ||
23 | * | ||
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 | ||
27 | * | ||
28 | * Based 90% on Vojtech Pavlik pcigame driver. | ||
29 | * Merged and modified by Manuel Jander, for the OpenVortex | ||
30 | * driver. (email: mjander@embedded.cl). | ||
31 | */ | ||
32 | |||
33 | #include <sound/driver.h> | ||
34 | #include <linux/time.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <linux/init.h> | ||
37 | #include <sound/core.h> | ||
38 | #include "au88x0.h" | ||
39 | #include <linux/gameport.h> | ||
40 | |||
41 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
42 | |||
43 | #define VORTEX_GAME_DWAIT 20 /* 20 ms */ | ||
44 | |||
45 | static unsigned char vortex_game_read(struct gameport *gameport) | ||
46 | { | ||
47 | vortex_t *vortex = gameport_get_port_data(gameport); | ||
48 | return hwread(vortex->mmio, VORTEX_GAME_LEGACY); | ||
49 | } | ||
50 | |||
51 | static void vortex_game_trigger(struct gameport *gameport) | ||
52 | { | ||
53 | vortex_t *vortex = gameport_get_port_data(gameport); | ||
54 | hwwrite(vortex->mmio, VORTEX_GAME_LEGACY, 0xff); | ||
55 | } | ||
56 | |||
57 | static int | ||
58 | vortex_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) | ||
59 | { | ||
60 | vortex_t *vortex = gameport_get_port_data(gameport); | ||
61 | int i; | ||
62 | |||
63 | *buttons = (~hwread(vortex->mmio, VORTEX_GAME_LEGACY) >> 4) & 0xf; | ||
64 | |||
65 | for (i = 0; i < 4; i++) { | ||
66 | axes[i] = | ||
67 | hwread(vortex->mmio, VORTEX_GAME_AXIS + (i * AXIS_SIZE)); | ||
68 | if (axes[i] == AXIS_RANGE) | ||
69 | axes[i] = -1; | ||
70 | } | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int vortex_game_open(struct gameport *gameport, int mode) | ||
75 | { | ||
76 | vortex_t *vortex = gameport_get_port_data(gameport); | ||
77 | |||
78 | switch (mode) { | ||
79 | case GAMEPORT_MODE_COOKED: | ||
80 | hwwrite(vortex->mmio, VORTEX_CTRL2, | ||
81 | hwread(vortex->mmio, | ||
82 | VORTEX_CTRL2) | CTRL2_GAME_ADCMODE); | ||
83 | msleep(VORTEX_GAME_DWAIT); | ||
84 | return 0; | ||
85 | case GAMEPORT_MODE_RAW: | ||
86 | hwwrite(vortex->mmio, VORTEX_CTRL2, | ||
87 | hwread(vortex->mmio, | ||
88 | VORTEX_CTRL2) & ~CTRL2_GAME_ADCMODE); | ||
89 | return 0; | ||
90 | default: | ||
91 | return -1; | ||
92 | } | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static int __devinit vortex_gameport_register(vortex_t * vortex) | ||
98 | { | ||
99 | struct gameport *gp; | ||
100 | |||
101 | vortex->gameport = gp = gameport_allocate_port(); | ||
102 | if (!gp) { | ||
103 | printk(KERN_ERR "vortex: cannot allocate memory for gameport\n"); | ||
104 | return -ENOMEM; | ||
105 | }; | ||
106 | |||
107 | gameport_set_name(gp, "AU88x0 Gameport"); | ||
108 | gameport_set_phys(gp, "pci%s/gameport0", pci_name(vortex->pci_dev)); | ||
109 | gameport_set_dev_parent(gp, &vortex->pci_dev->dev); | ||
110 | |||
111 | gp->read = vortex_game_read; | ||
112 | gp->trigger = vortex_game_trigger; | ||
113 | gp->cooked_read = vortex_game_cooked_read; | ||
114 | gp->open = vortex_game_open; | ||
115 | |||
116 | gameport_set_port_data(gp, vortex); | ||
117 | gp->fuzz = 64; | ||
118 | |||
119 | gameport_register_port(gp); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static void vortex_gameport_unregister(vortex_t * vortex) | ||
125 | { | ||
126 | if (vortex->gameport) { | ||
127 | gameport_unregister_port(vortex->gameport); | ||
128 | vortex->gameport = NULL; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | #else | ||
133 | static inline int vortex_gameport_register(vortex_t * vortex) { return -ENOSYS; } | ||
134 | static inline void vortex_gameport_unregister(vortex_t * vortex) { } | ||
135 | #endif | ||