1 /*#include <linux/sched.h>
2    #include <linux/errno.h>
3    #include <linux/major.h>
4    #include <asm/io.h>
5    #include <asm/segment.h>
6    #include <asm/system.h>
7    #include <linux/module.h> */
8 
9 #define JS_RETURN sizeof(struct JS_DATA_TYPE)	/*number of bytes returned by js_read */
10 #define JS_TRUE 1
11 #define JS_FALSE 0
12 #define JS_PORT 0x201		/*io port for joystick operations */
13 #define JS_DEF_TIMEOUT 0x1300	/*default timeout value for js_read() */
14 #define JS_DEF_CORR	0	/*default correction factor */
15 #define JS_DEF_TIMELIMIT 10L	/*default data valid time =10 jiffies == 100ms */
16 #define JS_X_0	0x01		/*bit mask for x-axis js0 */
17 #define JS_Y_0	0x02		/*bit mask for y-axis js0 */
18 #define JS_X_1	0x04		/*bit mask for x-axis js1 */
19 #define JS_Y_1	0x08		/*bit mask for y-axis js1 */
20 #define JS_MAX 2		/*Max number of joysticks */
21 #define PIT_MODE 0x43		/*io port for timer 0 */
22 #define PIT_COUNTER_0 0x40	/*io port for timer 0 */
23 #define JS_SET_CAL 0x01		/*ioctl cmd to set joystick correction factor */
24 #define JS_GET_CAL 0x02		/*ioctl cmd to get joystick correction factor */
25 #define JS_SET_TIMEOUT 0x03	/*ioctl cmd to set maximum number of iterations
26 				   to wait for a timeout */
27 #define JS_GET_TIMEOUT		0x04	/*as above, to get */
28 #define JS_SET_TIMELIMIT	0x05	/*set data retention time */
29 #define JS_GET_TIMELIMIT	0x06	/*get data retention time */
30 #define JS_GET_ALL		0x07	/*get the whole JS_DATA[minor] struct */
31 #define JS_SET_ALL		0x08	/*set the whole JS_DATA[minor] struct
32 					   except JS_BUSY! */
33 
34 /*This union is used for the ioctl to set the scaling factor and to return
35    the current values for a joystick. 'buttons' is ignored on the ioctl call */
36 
37 struct JS_DATA_TYPE
38   {
39     int             buttons;
40     int             x;
41     int             y;
42   };
43 
44 /* This struct is used for misc data about the joystick */
45 struct JS_DATA_SAVE_TYPE
46   {
47     int             JS_TIMEOUT;	/*timeout */
48     int             BUSY;	/*joystick is in use */
49     long            JS_EXPIRETIME;	/*Time when stick after which stick must be re-read */
50     long            JS_TIMELIMIT;	/*Max time before data is invalid */
51     struct JS_DATA_TYPE JS_SAVE;	/*last read data */
52     struct JS_DATA_TYPE JS_CORR;	/*correction factor */
53   };
54 
55 #define LATCH (1193180L/HZ)	/*initial timer 0 value */
56 #define DELTA_TIME(X,Y) ((X)-(Y)+(((X)>=(Y))?0:LATCH))
57 #define CURRENT_JIFFIES (jiffies)
58 
59 #define JOYSTICK_MAJOR		15
60