/[openvortex]/alsa/pci/au88x0/au88x0_game.c
ViewVC logotype

Diff of /alsa/pci/au88x0/au88x0_game.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mjander, Thu Aug 7 01:58:51 2003 UTC revision 1.7 by vizard, Sun Aug 10 20:00:34 2003 UTC
# Line 1  Line 1 
1  #define __NO_VERSION__  /*
2  #include "../../alsa-kernel/pci/au88x0/au88x0_game.c"   * $Id$
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/init.h>
36    #include <sound/core.h>
37    #include "au88x0.h"
38    #include <linux/gameport.h>
39    
40    #define VORTEX_GAME_DWAIT       20      /* 20 ms */
41    
42    static struct gameport gameport;
43    
44    static unsigned char vortex_game_read(struct gameport *gameport) {
45            vortex_t *vortex = gameport->driver;
46            return hwread(vortex->mmio, VORTEX_GAME_LEGACY);
47    }
48    
49    static void vortex_game_trigger(struct gameport *gameport) {
50            vortex_t *vortex = gameport->driver;
51            hwwrite(vortex->mmio, VORTEX_GAME_LEGACY, 0xff);
52    }
53    
54    static int vortex_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) {
55            vortex_t *vortex = gameport->driver;
56            int i;
57    
58            *buttons = (~hwread(vortex->mmio, VORTEX_GAME_LEGACY) >> 4) & 0xf;
59    
60            for (i = 0; i < 4; i++) {
61                    axes[i] = hwread(vortex->mmio, VORTEX_GAME_AXIS + (i * AXIS_SIZE));
62                    if (axes[i] == AXIS_RANGE) axes[i] = -1;
63            }
64            return 0;
65    }
66    
67    static int vortex_game_open(struct gameport *gameport, int mode) {
68            vortex_t *vortex = gameport->driver;
69    
70            switch (mode) {
71                    case GAMEPORT_MODE_COOKED:
72                            hwwrite(vortex->mmio, VORTEX_CTRL2, hwread(vortex->mmio, VORTEX_CTRL2) | CTRL2_GAME_ADCMODE);
73                            wait_ms(VORTEX_GAME_DWAIT);
74                            return 0;
75                    case GAMEPORT_MODE_RAW:
76                            hwwrite(vortex->mmio, VORTEX_CTRL2, hwread(vortex->mmio, VORTEX_CTRL2) & ~CTRL2_GAME_ADCMODE);
77                            return 0;
78                    default:
79                            return -1;
80            }
81    
82            return 0;
83    }
84    
85    int vortex_gameport_register(vortex_t *vortex) {
86            vortex->gameport = &gameport;
87    
88            vortex->gameport->driver = vortex;
89            vortex->gameport->fuzz = 64;
90    
91            vortex->gameport->read = vortex_game_read;
92            vortex->gameport->trigger = vortex_game_trigger;
93            vortex->gameport->cooked_read = vortex_game_cooked_read;
94            vortex->gameport->open = vortex_game_open;
95    
96            gameport_register_port((struct gameport *)vortex->gameport);
97    
98    /*      printk(KERN_INFO "gameport%d: %s at speed %d kHz\n",
99                    vortex->gameport->number, vortex->pci_dev->name, vortex->gameport->speed);
100    */
101            return 0;
102    }
103    
104    int vortex_gameport_unregister(vortex_t *vortex) {
105            if (vortex->gameport != NULL)
106                    gameport_unregister_port(vortex->gameport);
107            return 0;
108    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26