initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / linux / gameport.h
blob322a7f73297b9b8a73cd681391ac4eebeaafebf6
1 #ifndef _GAMEPORT_H
2 #define _GAMEPORT_H
4 /*
5 * Copyright (c) 1999-2002 Vojtech Pavlik
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
12 #include <asm/io.h>
13 #include <linux/input.h>
14 #include <linux/list.h>
16 struct gameport;
18 struct gameport {
20 void *private; /* Private pointer for joystick drivers */
21 void *driver; /* Private pointer for gameport drivers */
22 char *name;
23 char *phys;
25 struct input_id id;
27 int io;
28 int speed;
29 int fuzz;
31 void (*trigger)(struct gameport *);
32 unsigned char (*read)(struct gameport *);
33 int (*cooked_read)(struct gameport *, int *, int *);
34 int (*calibrate)(struct gameport *, int *, int *);
35 int (*open)(struct gameport *, int);
36 void (*close)(struct gameport *);
38 struct gameport_dev *dev;
40 struct list_head node;
43 struct gameport_dev {
45 void *private;
46 char *name;
48 void (*connect)(struct gameport *, struct gameport_dev *dev);
49 void (*disconnect)(struct gameport *);
51 struct list_head node;
54 int gameport_open(struct gameport *gameport, struct gameport_dev *dev, int mode);
55 void gameport_close(struct gameport *gameport);
56 void gameport_rescan(struct gameport *gameport);
58 #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
59 void gameport_register_port(struct gameport *gameport);
60 void gameport_unregister_port(struct gameport *gameport);
61 #else
62 static inline void gameport_register_port(struct gameport *gameport) { return; }
63 static inline void gameport_unregister_port(struct gameport *gameport) { return; }
64 #endif
66 void gameport_register_device(struct gameport_dev *dev);
67 void gameport_unregister_device(struct gameport_dev *dev);
69 #define GAMEPORT_MODE_DISABLED 0
70 #define GAMEPORT_MODE_RAW 1
71 #define GAMEPORT_MODE_COOKED 2
73 #define GAMEPORT_ID_VENDOR_ANALOG 0x0001
74 #define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
75 #define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
76 #define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
77 #define GAMEPORT_ID_VENDOR_GENIUS 0x0005
78 #define GAMEPORT_ID_VENDOR_INTERACT 0x0006
79 #define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
80 #define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
81 #define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
82 #define GAMEPORT_ID_VENDOR_GUILLEMOT 0x000a
84 static __inline__ void gameport_trigger(struct gameport *gameport)
86 if (gameport->trigger)
87 gameport->trigger(gameport);
88 else
89 outb(0xff, gameport->io);
92 static __inline__ unsigned char gameport_read(struct gameport *gameport)
94 if (gameport->read)
95 return gameport->read(gameport);
96 else
97 return inb(gameport->io);
100 static __inline__ int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
102 if (gameport->cooked_read)
103 return gameport->cooked_read(gameport, axes, buttons);
104 else
105 return -1;
108 static __inline__ int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
110 if (gameport->calibrate)
111 return gameport->calibrate(gameport, axes, max);
112 else
113 return -1;
116 static __inline__ int gameport_time(struct gameport *gameport, int time)
118 return (time * gameport->speed) / 1000;
121 #endif