Import 2.4.0-test2pre7
[davej-history.git] / include / linux / gameport.h
blob972dd0bfb727fa9e7c8218d5885a485405c4f625
1 #ifndef _GAMEPORT_H
2 #define _GAMEPORT_H
4 /*
5 * $Id: gameport.h,v 1.8 2000/06/03 20:18:52 vojtech Exp $
7 * Copyright (c) 1999-2000 Vojtech Pavlik
9 * Sponsored by SuSE
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
32 #include <asm/io.h>
34 struct gameport;
36 struct gameport {
38 void *private;
39 void *driver;
41 int number;
43 int io;
44 int size;
45 int speed;
46 int fuzz;
47 int type;
48 struct pci_dev *pci;
50 void (*trigger)(struct gameport *);
51 unsigned char (*read)(struct gameport *);
52 int (*cooked_read)(struct gameport *, int *, int *);
53 int (*calibrate)(struct gameport *, int *, int *);
54 int (*open)(struct gameport *, int);
55 void (*close)(struct gameport *);
57 struct gameport_dev *dev;
59 struct gameport *next;
62 struct gameport_dev {
64 void *private;
66 void (*connect)(struct gameport *, struct gameport_dev *dev);
67 void (*disconnect)(struct gameport *);
69 struct gameport_dev *next;
72 int gameport_open(struct gameport *gameport, struct gameport_dev *dev, int mode);
73 void gameport_close(struct gameport *gameport);
74 void gameport_rescan(struct gameport *gameport);
76 void gameport_register_port(struct gameport *gameport);
77 void gameport_unregister_port(struct gameport *gameport);
78 void gameport_register_device(struct gameport_dev *dev);
79 void gameport_unregister_device(struct gameport_dev *dev);
81 #define GAMEPORT_MODE_DISABLED 0
82 #define GAMEPORT_MODE_RAW 1
83 #define GAMEPORT_MODE_COOKED 2
85 #define GAMEPORT_ISA 0
86 #define GAMEPORT_PNP 1
87 #define GAMEPORT_EXT 2
89 #define GAMEPORT_ID_VENDOR_ANALOG 0x0001
90 #define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
91 #define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
92 #define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
93 #define GAMEPORT_ID_VENDOR_GENIUS 0x0005
94 #define GAMEPORT_ID_VENDOR_INTERACT 0x0006
95 #define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
96 #define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
97 #define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
99 static __inline__ void gameport_trigger(struct gameport *gameport)
101 if (gameport->trigger)
102 gameport->trigger(gameport);
103 else
104 outb(0xff, gameport->io);
107 static __inline__ unsigned char gameport_read(struct gameport *gameport)
109 if (gameport->read)
110 return gameport->read(gameport);
111 else
112 return inb(gameport->io);
115 static __inline__ int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
117 if (gameport->cooked_read)
118 return gameport->cooked_read(gameport, axes, buttons);
119 else
120 return -1;
123 static __inline__ int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
125 if (gameport->calibrate)
126 return gameport->calibrate(gameport, axes, max);
127 else
128 return -1;
131 static __inline__ int gameport_time(struct gameport *gameport, int time)
133 return (time * gameport->speed) / 1000;
136 static __inline__ void wait_ms(unsigned int ms)
138 current->state = TASK_UNINTERRUPTIBLE;
139 schedule_timeout(1 + ms * HZ / 1000);
142 #endif