~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/gameport.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _GAMEPORT_H
  2 #define _GAMEPORT_H
  3 
  4 /*
  5  * $Id: gameport.h,v 1.8 2000/06/03 20:18:52 vojtech Exp $
  6  *
  7  *  Copyright (c) 1999-2000 Vojtech Pavlik
  8  *
  9  *  Sponsored by SuSE
 10  */
 11 
 12 /*
 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.
 17  * 
 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.
 22  * 
 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
 26  * 
 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
 30  */
 31 
 32 #include <linux/sched.h>
 33 #include <asm/io.h>
 34 
 35 struct gameport;
 36 
 37 struct gameport {
 38 
 39         void *private;
 40         void *driver;
 41 
 42         int number;
 43 
 44         int io;
 45         int size;
 46         int speed;
 47         int fuzz;
 48         int type;
 49         struct pci_dev *pci;
 50 
 51         void (*trigger)(struct gameport *);
 52         unsigned char (*read)(struct gameport *);
 53         int (*cooked_read)(struct gameport *, int *, int *);    
 54         int (*calibrate)(struct gameport *, int *, int *); 
 55         int (*open)(struct gameport *, int);
 56         void (*close)(struct gameport *);
 57 
 58         struct gameport_dev *dev;
 59 
 60         struct gameport *next;
 61 };
 62 
 63 struct gameport_dev {
 64 
 65         void *private;
 66 
 67         void (*connect)(struct gameport *, struct gameport_dev *dev);
 68         void (*disconnect)(struct gameport *);
 69 
 70         struct gameport_dev *next;
 71 };
 72 
 73 int gameport_open(struct gameport *gameport, struct gameport_dev *dev, int mode);
 74 void gameport_close(struct gameport *gameport);
 75 void gameport_rescan(struct gameport *gameport);
 76 
 77 void gameport_register_port(struct gameport *gameport);
 78 void gameport_unregister_port(struct gameport *gameport);
 79 void gameport_register_device(struct gameport_dev *dev);
 80 void gameport_unregister_device(struct gameport_dev *dev);
 81 
 82 #define GAMEPORT_MODE_DISABLED          0
 83 #define GAMEPORT_MODE_RAW               1
 84 #define GAMEPORT_MODE_COOKED            2
 85 
 86 #define GAMEPORT_ISA       0
 87 #define GAMEPORT_PNP       1
 88 #define GAMEPORT_EXT       2
 89 
 90 #define GAMEPORT_ID_VENDOR_ANALOG       0x0001
 91 #define GAMEPORT_ID_VENDOR_MADCATZ      0x0002
 92 #define GAMEPORT_ID_VENDOR_LOGITECH     0x0003
 93 #define GAMEPORT_ID_VENDOR_CREATIVE     0x0004
 94 #define GAMEPORT_ID_VENDOR_GENIUS       0x0005
 95 #define GAMEPORT_ID_VENDOR_INTERACT     0x0006
 96 #define GAMEPORT_ID_VENDOR_MICROSOFT    0x0007
 97 #define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
 98 #define GAMEPORT_ID_VENDOR_GRAVIS       0x0009
 99 
100 static __inline__ void gameport_trigger(struct gameport *gameport)
101 {
102         if (gameport->trigger)
103                 gameport->trigger(gameport);
104         else
105                 outb(0xff, gameport->io);
106 }
107 
108 static __inline__ unsigned char gameport_read(struct gameport *gameport)
109 {
110         if (gameport->read)
111                 return gameport->read(gameport);
112         else
113                 return inb(gameport->io);
114 }
115 
116 static __inline__ int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
117 {
118         if (gameport->cooked_read)
119                 return gameport->cooked_read(gameport, axes, buttons);
120         else
121                 return -1;
122 }
123 
124 static __inline__ int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
125 {
126         if (gameport->calibrate)
127                 return gameport->calibrate(gameport, axes, max);
128         else
129                 return -1;
130 }
131 
132 static __inline__ int gameport_time(struct gameport *gameport, int time)
133 {
134         return (time * gameport->speed) / 1000;
135 }
136 
137 static __inline__ void wait_ms(unsigned int ms)
138 {
139         current->state = TASK_UNINTERRUPTIBLE;
140         schedule_timeout(1 + ms * HZ / 1000);
141 }
142 
143 #endif
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.