Portability cleanup as required by Linus.
[linux-2.6/linux-mips.git] / drivers / char / dn_keyb.c
blob8d8766b85a7fc951cf5ec9dab50e4db9d7f3d1c0
1 #include <linux/sched.h>
2 #include <linux/interrupt.h>
3 #include <linux/errno.h>
4 #include <linux/keyboard.h>
5 #include <linux/delay.h>
6 #include <linux/timer.h>
7 #include <linux/kd.h>
8 #include <linux/random.h>
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/poll.h>
12 #include <linux/miscdevice.h>
13 #include <linux/init.h>
15 #include <asm/setup.h>
16 #include <asm/irq.h>
17 #include <asm/apollohw.h>
18 #include <asm/uaccess.h>
20 #include "busmouse.h"
22 /* extern void handle_scancode(unsigned char,int ); */
24 #define DNKEY_CAPS 0x7e
25 #define BREAK_FLAG 0x80
26 #define DNKEY_REPEAT_DELAY 50
27 #define DNKEY_CTRL 0x43
28 #define DNKEY_LSHIFT 0x5e
29 #define DNKEY_RSHIFT 0x6a
30 #define DNKEY_REPT 0x5d
31 #define DNKEY_REPEAT 0x7f
32 #define DNKEY_LALT 0x75
33 #define DNKEY_RALT 0x77
35 #define APOLLO_KEYB_CMD_ENTRIES 16
36 #define APOLLO_KBD_MODE_KEYB 0x01
37 #define APOLLO_KBD_MODE_MOUSE 0x02
38 #define APOLLO_KBD_MODE_CHANGE 0xff
40 static u_char keyb_cmds[APOLLO_KEYB_CMD_ENTRIES];
41 static short keyb_cmd_read=0, keyb_cmd_write=0;
42 static int keyb_cmd_transmit=0;
43 static int msedev;
45 static unsigned int kbd_mode=APOLLO_KBD_MODE_KEYB;
47 #if 0
48 static void debug_keyb_timer_handler(unsigned long ignored);
49 static u_char debug_buf1[4096],debug_buf2[4096],*debug_buf=&debug_buf1[0];
50 static u_char *shadow_buf=&debug_buf2[0];
51 static short debug_buf_count=0;
52 static int debug_buf_overrun=0,debug_timer_running=0;
53 static unsigned long debug_buffer_updated=0;
54 static struct timer_list debug_keyb_timer = { NULL, NULL, 0, 0,
55 debug_keyb_timer_handler };
56 #endif
58 static u_short dnplain_map[NR_KEYS] __initdata = {
59 /* ins del del F1 F2 F3 F4
60 mark line char */
61 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
62 /* F5 F6 F7 F8 F9 F0 Again Read */
63 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
64 /* Edit Exit Hold Copy Paste Grow ESC */
65 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
66 /* 1 2 3 4 5 6 7 8 */
67 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038,
68 /* 9 0 - = ` Back |<--
69 Space */
70 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf060, 0xf07f, 0xf200, 0xf200,
71 /* Shell -->| Tab q w e
72 Cmd */
73 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xfb71, 0xfb77, 0xfb65,
74 /* r t y u i o p [ */
75 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b,
76 /* ] Del 7 8 9 + */
77 0xf05d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
78 /* [<--] Up [-->] Ctrl a s */
79 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb61, 0xfb73,
80 /* d f g h j k l ; */
81 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
82 /* ' Return \ 4 5 6 */
83 0xf027, 0xf200, 0xf201, 0xf05c, 0xf200, 0xf304, 0xf305, 0xf306,
84 /* - <-- Next --> Rept Shift
85 Window */
86 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf700, 0xf200,
87 /* z x c v b n m , */
88 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c,
89 /* . / Shift Pop 1 2 */
90 0xf02e, 0xf02f, 0xf700, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
91 /* 3 PgUp Down PgDn Alt Space Alt */
92 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
93 /* 0 . Enter */
94 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf700, 0xf200,
97 static u_short dnshift_map[NR_KEYS] __initdata = {
98 /* ins del del F1 F2 F3 F4
99 mark line char */
100 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
101 /* F5 F6 F7 F8 F9 F0 Again Read */
102 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
103 /* Save Abort Help Cut Undo Grow ESC */
104 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
105 /* ! @ # $ % ^ & * */
106 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a,
107 /* ( ) _ + ~ Back |<--
108 Space */
109 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07e, 0xf07f, 0xf200, 0xf200,
110 /* Shell -->| Tab Q W E
111 Cmd */
112 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xfb51, 0xfb57, 0xfb45,
113 /* R T Y U I O P { */
114 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b,
115 /* } Del 7 8 9 + */
116 0xf07d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
117 /* [<--] Up [-->] Ctrl A S */
118 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb41, 0xfb53,
119 /* D F G H J K L : */
120 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a,
121 /* " Return | 4 5 6 */
122 0xf022, 0xf200, 0xf201, 0xf07c, 0xf200, 0xf304, 0xf305, 0xf306,
123 /* - <-- Next --> Rept Shift
124 Window */
125 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf700, 0xf200,
126 /* Z X C V B N M < */
127 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c,
128 /* > ? Shift Pop 1 2 */
129 0xf03e, 0xf03f, 0xf700, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
130 /* 3 PgUp Down PgDn Alt Space Alt */
131 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
132 /* 0 . Enter */
133 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf708, 0xf200,
136 static u_short dnctrl_map[NR_KEYS] __initdata = {
137 /* ins del del F1 F2 F3 F4
138 mark line char */
139 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
140 /* F5 F6 F7 F8 F9 F0 Again Read */
141 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
142 /* Save Abort Help Cut Undo Grow ESC */
143 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
144 /* ! @ # $ % ^ & * */
145 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e, 0xf01f, 0xf07f,
146 /* ( ) _ + ~ Back |<--
147 Space */
148 0xf200, 0xf200, 0xf01f, 0xf200, 0xf01c, 0xf200, 0xf200, 0xf200,
149 /* Shell -->| Tab Q W E
150 Cmd */
151 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xf011, 0xf017, 0xf005,
152 /* R T Y U I O P { */
153 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b,
154 /* } Del 7 8 9 + */
155 0xf01d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
156 /* [<--] Up [-->] Ctrl A S */
157 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb01, 0xfb53,
158 /* D F G H J K L : */
159 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
160 /* " Return | 4 5 6 */
161 0xf200, 0xf200, 0xf201, 0xf01c, 0xf200, 0xf304, 0xf305, 0xf306,
162 /* - <-- Next --> Rept Shift
163 Window */
164 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf704, 0xf200,
165 /* Z X C V B N M < */
166 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf01d, 0xf03c,
167 /* > ? Shift Pop 1 2 */
168 0xf03e, 0xf03f, 0xf705, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
169 /* 3 PgUp Down PgDn Alt Space Alt */
170 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
171 /* 0 . Enter */
172 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf200, 0xf200,
175 static u_short dnalt_map[NR_KEYS] __initdata = {
176 /* ins del del F1 F2 F3 F4
177 mark line char */
178 0xf200, 0xf200, 0xf200, 0xf200, 0xf500, 0xf501, 0xf502, 0xf503,
179 /* F5 F6 F7 F8 F9 F0 Again Read */
180 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf200, 0xf200,
181 /* Edit Exit Hold Copy Paste Grow ESC */
182 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
183 /* 1 2 3 4 5 6 7 8 */
184 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838,
185 /* 9 0 - = ` Back |<--
186 Space */
187 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf860, 0xf87f, 0xf200, 0xf200,
188 /* Shell -->| Tab q w e
189 Cmd */
190 0xf200, 0xf200, 0xf200, 0xf200, 0xf809, 0xf871, 0xf877, 0xf865,
191 /* r t y u i o p [ */
192 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b,
193 /* ] Del 7 8 9 + */
194 0xf05d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
195 /* [<--] Up [-->] Ctrl a s */
196 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xf861, 0xf873,
197 /* d f g h j k l ; */
198 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf03b,
199 /* ' Return \ 4 5 6 */
200 0xf027, 0xf200, 0xf201, 0xf05c, 0xf200, 0xf304, 0xf305, 0xf306,
201 /* - <-- Next --> Rept Shift
202 Window */
203 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf704, 0xf200,
204 /* z x c v b n m , */
205 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c,
206 /* . / Shift Pop 1 2 */
207 0xf82e, 0xf82f, 0xf705, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
208 /* 3 PgUp Down PgDn Alt Space Alt */
209 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf820, 0xf701,
210 /* 0 . Enter */
211 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf200, 0xf200,
214 static u_short dnaltgr_map[NR_KEYS] __initdata = {
215 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
216 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
217 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
218 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
219 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
220 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
221 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
222 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
223 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
224 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
225 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
226 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
227 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
228 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
229 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
230 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
233 static u_short dnshift_ctrl_map[NR_KEYS] __initdata = {
234 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
235 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
236 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
237 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
238 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
239 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
240 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
241 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
242 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
243 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
244 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
245 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
246 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
247 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
248 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
249 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
252 static u_short dnctrl_alt_map[NR_KEYS] __initdata = {
253 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
254 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
255 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
256 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
257 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
258 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
259 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
260 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
261 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
262 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
263 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
264 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
265 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
266 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
267 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
268 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
271 #if 0
272 static void debug_keyb_timer_handler(unsigned long ignored) {
274 unsigned long flags;
275 u_char *swap;
276 short length,i;
278 if (time_after(jiffies, debug_buffer_updated + 100)) {
279 save_flags(flags);
280 cli();
281 length=debug_buf_count;
282 swap=debug_buf;
283 debug_buf=shadow_buf;
284 shadow_buf=swap;
285 debug_buf_count=0;
286 debug_timer_running=0;
287 restore_flags(flags);
288 for(i=1;length;length--,i++)
289 printk("%02x%c",*(swap++), (i % 25) ? ' ' : '\n');
290 printk("\n");
292 else {
293 debug_keyb_timer.expires=jiffies+10;
294 add_timer(&debug_keyb_timer);
297 #endif
299 static void dn_keyb_process_key_event(unsigned char scancode) {
301 static unsigned char lastscancode;
302 unsigned char prev_scancode=lastscancode;
303 static unsigned int lastkeypress;
305 lastscancode=scancode;
307 /* printk("scan: %02x, lastscan: %02X, prev_scancode: %02X\n",scancode,lastscancode,prev_scancode); */
309 if(prev_scancode==APOLLO_KBD_MODE_CHANGE) {
310 kbd_mode=scancode;
311 /* printk("modechange: %d\n",scancode); */
313 else if((scancode & (~BREAK_FLAG)) == DNKEY_CAPS) {
314 /* printk("handle_scancode: %02x\n",DNKEY_CAPS); */
315 handle_scancode(DNKEY_CAPS, 1);
316 /* printk("handle_scancode: %02x\n",BREAK_FLAG | DNKEY_CAPS); */
317 handle_scancode(DNKEY_CAPS, 0);
319 else if( (scancode == DNKEY_REPEAT) && (prev_scancode < 0x7e) &&
320 !(prev_scancode==DNKEY_CTRL || prev_scancode==DNKEY_LSHIFT ||
321 prev_scancode==DNKEY_RSHIFT || prev_scancode==DNKEY_REPT ||
322 prev_scancode==DNKEY_LALT || prev_scancode==DNKEY_RALT)) {
323 if (time_after(jiffies, lastkeypress + DNKEY_REPEAT_DELAY)) {
324 /* printk("handle_scancode: %02x\n",prev_scancode); */
325 handle_scancode(prev_scancode, 1);
327 lastscancode=prev_scancode;
329 else {
330 /* printk("handle_scancode: %02x\n",scancode); */
331 handle_scancode(scancode & ~BREAK_FLAG, !(scancode & BREAK_FLAG));
332 lastkeypress=jiffies;
336 static void dn_keyb_process_mouse_event(unsigned char mouse_data) {
338 static short mouse_byte_count=0;
339 static u_char mouse_packet[3];
340 short mouse_buttons;
342 mouse_packet[mouse_byte_count++]=mouse_data;
344 if(mouse_byte_count==3) {
345 if(mouse_packet[0]==APOLLO_KBD_MODE_CHANGE) {
346 kbd_mode=mouse_packet[1];
347 mouse_byte_count=0;
348 /* printk("modechange: %d\n",mouse_packet[1]); */
349 if(kbd_mode==APOLLO_KBD_MODE_KEYB)
350 dn_keyb_process_key_event(mouse_packet[2]);
352 if((mouse_packet[0] & 0x8f) == 0x80) {
353 if(mouse_update_allowed) {
354 mouse_ready=1;
355 mouse_buttons=(mouse_packet[0] >> 4) & 0x7;
356 mouse_dx+=mouse_packet[1] == 0xff ? 0 : (signed char)mouse_packet[1];
357 mouse_dy+=mouse_packet[2] == 0xff ? 0 : (signed char)mouse_packet[2];
358 wake_up_interruptible(&mouse_wait);
359 if (mouse_dx < -2048)
360 mouse_dx = -2048;
361 else if (mouse_dx > 2048)
362 mouse_dx = 2048;
363 if (mouse_dy < -2048)
364 mouse_dy = -2048;
365 else if (mouse_dy > 2048)
366 mouse_dy = 2048;
367 kill_fasync(&mouse_fasyncptr, SIGIO, POLL_IN);
369 mouse_byte_count=0;
370 /* printk("mouse: %d, %d, %x\n",mouse_x,mouse_y,buttons); */
375 static void dn_keyb_int(int irq, void *dummy, struct pt_regs *fp) {
377 unsigned char data;
378 unsigned long flags;
379 int scn2681_ints;
381 do {
382 scn2681_ints=sio01.isr_imr & 3;
383 if(scn2681_ints & 2) {
384 data=sio01.rhra_thra;
385 #if 0
386 if(debug_buf_count<4096) {
387 debug_buf[debug_buf_count++]=data;
388 debug_buffer_updated=jiffies;
389 if(!debug_timer_running) {
390 debug_keyb_timer.expires=jiffies+10;
391 add_timer(&debug_keyb_timer);
392 debug_timer_running=1;
395 else
396 debug_buf_overrun=1;
397 #endif
398 if(sio01.sra_csra & 0x10) {
399 printk("whaa overrun !\n");
400 continue;
403 if(kbd_mode==APOLLO_KBD_MODE_KEYB)
404 dn_keyb_process_key_event(data);
405 else
406 dn_keyb_process_mouse_event(data);
409 if(scn2681_ints & 1) {
410 save_flags(flags);
411 cli();
412 if(keyb_cmd_write!=keyb_cmd_read) {
413 sio01.rhra_thra=keyb_cmds[keyb_cmd_read++];
414 if(keyb_cmd_read==APOLLO_KEYB_CMD_ENTRIES)
415 keyb_cmd_read=0;
416 keyb_cmd_transmit=1;
418 else {
419 keyb_cmd_transmit=0;
420 sio01.BRGtest_cra=9;
422 restore_flags(flags);
424 } while(scn2681_ints) ;
427 void write_keyb_cmd(u_short length, u_char *cmd) {
429 unsigned long flags;
431 if((keyb_cmd_write==keyb_cmd_read) && keyb_cmd_transmit)
432 return;
434 save_flags(flags);
435 cli();
436 for(;length;length--) {
437 keyb_cmds[keyb_cmd_write++]=*(cmd++);
438 if(keyb_cmd_write==keyb_cmd_read)
439 return;
440 if(keyb_cmd_write==APOLLO_KEYB_CMD_ENTRIES)
441 keyb_cmd_write=0;
443 if(!keyb_cmd_transmit) {
444 sio01.BRGtest_cra=5;
446 restore_flags(flags);
450 static struct busmouse apollo_mouse = {
451 APOLLO_MOUSE_MINOR, "apollomouse", THIS_MODULE, NULL, NULL, 7
454 int __init dn_keyb_init(void){
456 /* printk("dn_keyb_init\n"); */
458 memcpy(key_maps[0], dnplain_map, sizeof(plain_map));
459 memcpy(key_maps[1], dnshift_map, sizeof(plain_map));
460 memcpy(key_maps[2], dnaltgr_map, sizeof(plain_map));
461 memcpy(key_maps[4], dnctrl_map, sizeof(plain_map));
462 memcpy(key_maps[5], dnshift_ctrl_map, sizeof(plain_map));
463 memcpy(key_maps[8], dnalt_map, sizeof(plain_map));
464 memcpy(key_maps[12], dnctrl_alt_map, sizeof(plain_map));
467 msedev=register_busmouse(&apollo_mouse);
468 if (msedev < 0)
469 printk(KERN_WARNING "Unable to install Apollo mouse driver.\n");
470 else
471 printk(KERN_INFO "Apollo mouse installed.\n");
473 /* program UpDownMode */
475 while(!(sio01.sra_csra & 0x4));
476 sio01.rhra_thra=0xff;
478 while(!(sio01.sra_csra & 0x4));
479 sio01.rhra_thra=0x1;
481 request_irq(1, dn_keyb_int,0,NULL,NULL);
483 /* enable receive int on DUART */
484 sio01.isr_imr=3;
486 return 0;
490 int dn_dummy_kbdrate(struct kbd_repeat *k) {
492 printk("dn_dummy_kbdrate\n");
494 return 0;