import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / include / linux / pc_keyb.h
1 /*
2  *      include/linux/pc_keyb.h
3  *
4  *      PC Keyboard And Keyboard Controller
5  *
6  *      (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7  */
8
9 /*
10  *      Configuration Switches
11  */
12
13 #undef KBD_REPORT_ERR                   /* Report keyboard errors */
14 #define KBD_REPORT_UNKN                 /* Report unknown scan codes */
15 #define KBD_REPORT_TIMEOUTS             /* Report keyboard timeouts */
16 #undef KBD_IS_FOCUS_9000                /* We have the brain-damaged FOCUS-9000 keyboard */
17 #undef INITIALIZE_MOUSE                 /* Define if your PS/2 mouse needs initialization. */
18
19
20
21 #define KBD_INIT_TIMEOUT 1000           /* Timeout in ms for initializing the keyboard */
22 #define KBC_TIMEOUT 250                 /* Timeout in ms for sending to keyboard controller */
23 #define KBD_TIMEOUT 1000                /* Timeout in ms for keyboard command acknowledge */
24
25 /*
26  *      Internal variables of the driver
27  */
28
29 extern unsigned char pckbd_read_mask;
30 extern unsigned char aux_device_present;
31
32 /*
33  *      Keyboard Controller Registers on normal PCs.
34  */
35
36 #define KBD_STATUS_REG          0x64    /* Status register (R) */
37 #define KBD_CNTL_REG            0x64    /* Controller command register (W) */
38 #define KBD_DATA_REG            0x60    /* Keyboard data register (R/W) */
39
40 /*
41  *      Keyboard Controller Commands
42  */
43
44 #define KBD_CCMD_READ_MODE      0x20    /* Read mode bits */
45 #define KBD_CCMD_WRITE_MODE     0x60    /* Write mode bits */
46 #define KBD_CCMD_GET_VERSION    0xA1    /* Get controller version */
47 #define KBD_CCMD_MOUSE_DISABLE  0xA7    /* Disable mouse interface */
48 #define KBD_CCMD_MOUSE_ENABLE   0xA8    /* Enable mouse interface */
49 #define KBD_CCMD_TEST_MOUSE     0xA9    /* Mouse interface test */
50 #define KBD_CCMD_SELF_TEST      0xAA    /* Controller self test */
51 #define KBD_CCMD_KBD_TEST       0xAB    /* Keyboard interface test */
52 #define KBD_CCMD_KBD_DISABLE    0xAD    /* Keyboard interface disable */
53 #define KBD_CCMD_KBD_ENABLE     0xAE    /* Keyboard interface enable */
54 #define KBD_CCMD_WRITE_AUX_OBUF 0xD3    /* Write to output buffer as if
55                                            initiated by the auxiliary device */
56 #define KBD_CCMD_WRITE_MOUSE    0xD4    /* Write the following byte to the mouse */
57
58 /*
59  *      Keyboard Commands
60  */
61
62 #define KBD_CMD_SET_LEDS        0xED    /* Set keyboard leds */
63 #define KBD_CMD_SET_RATE        0xF3    /* Set typematic rate */
64 #define KBD_CMD_ENABLE          0xF4    /* Enable scanning */
65 #define KBD_CMD_DISABLE         0xF5    /* Disable scanning */
66 #define KBD_CMD_RESET           0xFF    /* Reset */
67
68 /*
69  *      Keyboard Replies
70  */
71
72 #define KBD_REPLY_POR           0xAA    /* Power on reset */
73 #define KBD_REPLY_ACK           0xFA    /* Command ACK */
74 #define KBD_REPLY_RESEND        0xFE    /* Command NACK, send the cmd again */
75
76 /*
77  *      Status Register Bits
78  */
79
80 #define KBD_STAT_OBF            0x01    /* Keyboard output buffer full */
81 #define KBD_STAT_IBF            0x02    /* Keyboard input buffer full */
82 #define KBD_STAT_SELFTEST       0x04    /* Self test successful */
83 #define KBD_STAT_CMD            0x08    /* Last write was a command write (0=data) */
84 #define KBD_STAT_UNLOCKED       0x10    /* Zero if keyboard locked */
85 #define KBD_STAT_MOUSE_OBF      0x20    /* Mouse output buffer full */
86 #define KBD_STAT_GTO            0x40    /* General receive/xmit timeout */
87 #define KBD_STAT_PERR           0x80    /* Parity error */
88
89 #define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
90
91 /*
92  *      Controller Mode Register Bits
93  */
94
95 #define KBD_MODE_KBD_INT        0x01    /* Keyboard data generate IRQ1 */
96 #define KBD_MODE_MOUSE_INT      0x02    /* Mouse data generate IRQ12 */
97 #define KBD_MODE_SYS            0x04    /* The system flag (?) */
98 #define KBD_MODE_NO_KEYLOCK     0x08    /* The keylock doesn't affect the keyboard if set */
99 #define KBD_MODE_DISABLE_KBD    0x10    /* Disable keyboard interface */
100 #define KBD_MODE_DISABLE_MOUSE  0x20    /* Disable mouse interface */
101 #define KBD_MODE_KCC            0x40    /* Scan code conversion to PC format */
102 #define KBD_MODE_RFU            0x80
103
104 /*
105  *      Mouse Commands
106  */
107
108 #define AUX_SET_RES             0xE8    /* Set resolution */
109 #define AUX_SET_SCALE11         0xE6    /* Set 1:1 scaling */
110 #define AUX_SET_SCALE21         0xE7    /* Set 2:1 scaling */
111 #define AUX_GET_SCALE           0xE9    /* Get scaling factor */
112 #define AUX_SET_STREAM          0xEA    /* Set stream mode */
113 #define AUX_SET_SAMPLE          0xF3    /* Set sample rate */
114 #define AUX_ENABLE_DEV          0xF4    /* Enable aux device */
115 #define AUX_DISABLE_DEV         0xF5    /* Disable aux device */
116 #define AUX_RESET               0xFF    /* Reset aux device */
117 #define AUX_ACK                 0xFA    /* Command byte ACK. */
118
119 #define AUX_BUF_SIZE            2048    /* This might be better divisible by
120                                            three to make overruns stay in sync
121                                            but then the read function would need
122                                            a lock etc - ick */
123
124 struct aux_queue {
125         unsigned long head;
126         unsigned long tail;
127         wait_queue_head_t proc_list;
128         struct fasync_struct *fasync;
129         unsigned char buf[AUX_BUF_SIZE];
130 };