]>
Commit | Line | Data |
---|---|---|
affae2bf WD |
1 | /* |
2 | * (C) Copyright 2001 | |
3 | * Denis Peter, MPL AG Switzerland | |
4 | * | |
5 | * Part of this source has been derived from the Linux USB | |
6 | * project. | |
7 | * | |
8 | * See file CREDITS for list of people who contributed to this | |
9 | * project. | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU General Public License as | |
13 | * published by the Free Software Foundation; either version 2 of | |
14 | * the License, or (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
24 | * MA 02111-1307 USA | |
25 | * | |
26 | */ | |
27 | #include <common.h> | |
9a8c72a6 | 28 | #include <malloc.h> |
52cb4d4f | 29 | #include <stdio_dev.h> |
c918261c | 30 | #include <asm/byteorder.h> |
affae2bf | 31 | |
affae2bf WD |
32 | #include <usb.h> |
33 | ||
9a8c72a6 MV |
34 | #ifdef USB_KBD_DEBUG |
35 | #define USB_KBD_PRINTF(fmt, args...) printf(fmt, ##args) | |
36 | #else | |
37 | #define USB_KBD_PRINTF(fmt, args...) | |
38 | #endif | |
39 | ||
affae2bf | 40 | /* |
00b7d6ec | 41 | * If overwrite_console returns 1, the stdin, stderr and stdout |
affae2bf WD |
42 | * are switched to the serial port, else the settings in the |
43 | * environment are used | |
44 | */ | |
6d0f6bcf | 45 | #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE |
00b7d6ec | 46 | extern int overwrite_console(void); |
affae2bf | 47 | #else |
00b7d6ec | 48 | int overwrite_console(void) |
affae2bf | 49 | { |
00b7d6ec | 50 | return 0; |
affae2bf WD |
51 | } |
52 | #endif | |
53 | ||
9a8c72a6 MV |
54 | /* Keyboard sampling rate */ |
55 | #define REPEAT_RATE (40 / 4) /* 40msec -> 25cps */ | |
56 | #define REPEAT_DELAY 10 /* 10 x REPEAT_RATE = 400msec */ | |
affae2bf WD |
57 | |
58 | #define NUM_LOCK 0x53 | |
00b7d6ec MV |
59 | #define CAPS_LOCK 0x39 |
60 | #define SCROLL_LOCK 0x47 | |
affae2bf | 61 | |
affae2bf | 62 | /* Modifier bits */ |
9a8c72a6 MV |
63 | #define LEFT_CNTR (1 << 0) |
64 | #define LEFT_SHIFT (1 << 1) | |
65 | #define LEFT_ALT (1 << 2) | |
66 | #define LEFT_GUI (1 << 3) | |
67 | #define RIGHT_CNTR (1 << 4) | |
68 | #define RIGHT_SHIFT (1 << 5) | |
69 | #define RIGHT_ALT (1 << 6) | |
70 | #define RIGHT_GUI (1 << 7) | |
71 | ||
72 | /* Size of the keyboard buffer */ | |
73 | #define USB_KBD_BUFFER_LEN 0x20 | |
74 | ||
75 | /* Device name */ | |
00b7d6ec | 76 | #define DEVNAME "usbkbd" |
affae2bf | 77 | |
9a8c72a6 MV |
78 | /* Keyboard maps */ |
79 | static const unsigned char usb_kbd_numkey[] = { | |
00b7d6ec MV |
80 | '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', |
81 | '\r', 0x1b, '\b', '\t', ' ', '-', '=', '[', ']', | |
82 | '\\', '#', ';', '\'', '`', ',', '.', '/' | |
affae2bf | 83 | }; |
9a8c72a6 | 84 | static const unsigned char usb_kbd_numkey_shifted[] = { |
00b7d6ec MV |
85 | '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', |
86 | '\r', 0x1b, '\b', '\t', ' ', '_', '+', '{', '}', | |
87 | '|', '~', ':', '"', '~', '<', '>', '?' | |
affae2bf WD |
88 | }; |
89 | ||
9a8c72a6 MV |
90 | /* |
91 | * NOTE: It's important for the NUM, CAPS, SCROLL-lock bits to be in this | |
92 | * order. See usb_kbd_setled() function! | |
93 | */ | |
94 | #define USB_KBD_NUMLOCK (1 << 0) | |
95 | #define USB_KBD_CAPSLOCK (1 << 1) | |
96 | #define USB_KBD_SCROLLLOCK (1 << 2) | |
97 | #define USB_KBD_CTRL (1 << 3) | |
48c8073e | 98 | |
9a8c72a6 MV |
99 | #define USB_KBD_LEDMASK \ |
100 | (USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK) | |
48c8073e | 101 | |
9a8c72a6 MV |
102 | struct usb_kbd_pdata { |
103 | uint32_t repeat_delay; | |
affae2bf | 104 | |
9a8c72a6 MV |
105 | uint32_t usb_in_pointer; |
106 | uint32_t usb_out_pointer; | |
107 | uint8_t usb_kbd_buffer[USB_KBD_BUFFER_LEN]; | |
48c8073e | 108 | |
9a8c72a6 MV |
109 | uint8_t new[8]; |
110 | uint8_t old[8]; | |
48c8073e | 111 | |
9a8c72a6 MV |
112 | uint8_t flags; |
113 | }; | |
48c8073e | 114 | |
9a8c72a6 MV |
115 | /* Generic keyboard event polling. */ |
116 | void usb_kbd_generic_poll(void) | |
affae2bf | 117 | { |
48c8073e MV |
118 | struct stdio_dev *dev; |
119 | struct usb_device *usb_kbd_dev; | |
9a8c72a6 MV |
120 | struct usb_kbd_pdata *data; |
121 | struct usb_interface *iface; | |
122 | struct usb_endpoint_descriptor *ep; | |
123 | int pipe; | |
124 | int maxp; | |
48c8073e | 125 | |
9a8c72a6 MV |
126 | /* Get the pointer to USB Keyboard device pointer */ |
127 | dev = stdio_get_by_name(DEVNAME); | |
48c8073e | 128 | usb_kbd_dev = (struct usb_device *)dev->priv; |
9a8c72a6 MV |
129 | data = usb_kbd_dev->privptr; |
130 | iface = &usb_kbd_dev->config.if_desc[0]; | |
131 | ep = &iface->ep_desc[0]; | |
132 | pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress); | |
48c8073e | 133 | |
9a8c72a6 MV |
134 | /* Submit a interrupt transfer request */ |
135 | maxp = usb_maxpacket(usb_kbd_dev, pipe); | |
136 | usb_submit_int_msg(usb_kbd_dev, pipe, data->new, | |
137 | maxp > 8 ? 8 : maxp, ep->bInterval); | |
affae2bf WD |
138 | } |
139 | ||
9a8c72a6 MV |
140 | /* Puts character in the queue and sets up the in and out pointer. */ |
141 | static void usb_kbd_put_queue(struct usb_kbd_pdata *data, char c) | |
affae2bf | 142 | { |
9a8c72a6 MV |
143 | if (data->usb_in_pointer == USB_KBD_BUFFER_LEN - 1) { |
144 | /* Check for buffer full. */ | |
145 | if (data->usb_out_pointer == 0) | |
146 | return; | |
affae2bf | 147 | |
9a8c72a6 MV |
148 | data->usb_in_pointer = 0; |
149 | } else { | |
150 | /* Check for buffer full. */ | |
151 | if (data->usb_in_pointer == data->usb_out_pointer - 1) | |
152 | return; | |
affae2bf | 153 | |
9a8c72a6 MV |
154 | data->usb_in_pointer++; |
155 | } | |
affae2bf | 156 | |
9a8c72a6 | 157 | data->usb_kbd_buffer[data->usb_in_pointer] = c; |
affae2bf WD |
158 | } |
159 | ||
9a8c72a6 MV |
160 | /* |
161 | * Set the LEDs. Since this is used in the irq routine, the control job is | |
162 | * issued with a timeout of 0. This means, that the job is queued without | |
163 | * waiting for job completion. | |
affae2bf | 164 | */ |
affae2bf WD |
165 | static void usb_kbd_setled(struct usb_device *dev) |
166 | { | |
9a8c72a6 MV |
167 | struct usb_interface *iface = &dev->config.if_desc[0]; |
168 | struct usb_kbd_pdata *data = dev->privptr; | |
169 | uint32_t leds = data->flags & USB_KBD_LEDMASK; | |
170 | ||
affae2bf WD |
171 | usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
172 | USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE, | |
8f8bd565 | 173 | 0x200, iface->desc.bInterfaceNumber, (void *)&leds, 1, 0); |
affae2bf WD |
174 | } |
175 | ||
9a8c72a6 | 176 | #define CAPITAL_MASK 0x20 |
affae2bf | 177 | /* Translate the scancode in ASCII */ |
9a8c72a6 MV |
178 | static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode, |
179 | unsigned char modifier, int pressed) | |
affae2bf | 180 | { |
9a8c72a6 | 181 | uint8_t keycode = 0; |
affae2bf | 182 | |
9a8c72a6 | 183 | /* Key released */ |
00b7d6ec | 184 | if (pressed == 0) { |
9a8c72a6 | 185 | data->repeat_delay = 0; |
affae2bf WD |
186 | return 0; |
187 | } | |
9a8c72a6 | 188 | |
00b7d6ec | 189 | if (pressed == 2) { |
9a8c72a6 MV |
190 | data->repeat_delay++; |
191 | if (data->repeat_delay < REPEAT_DELAY) | |
affae2bf | 192 | return 0; |
9a8c72a6 MV |
193 | |
194 | data->repeat_delay = REPEAT_DELAY; | |
affae2bf | 195 | } |
9a8c72a6 MV |
196 | |
197 | /* Alphanumeric values */ | |
198 | if ((scancode > 3) && (scancode <= 0x1d)) { | |
199 | keycode = scancode - 4 + 'a'; | |
200 | ||
201 | if (data->flags & USB_KBD_CAPSLOCK) | |
00b7d6ec | 202 | keycode &= ~CAPITAL_MASK; |
9a8c72a6 MV |
203 | |
204 | if (modifier & (LEFT_SHIFT | RIGHT_SHIFT)) { | |
205 | /* Handle CAPSLock + Shift pressed simultaneously */ | |
00b7d6ec | 206 | if (keycode & CAPITAL_MASK) |
00b7d6ec | 207 | keycode &= ~CAPITAL_MASK; |
affae2bf | 208 | else |
00b7d6ec | 209 | keycode |= CAPITAL_MASK; |
affae2bf WD |
210 | } |
211 | } | |
9a8c72a6 MV |
212 | |
213 | if ((scancode > 0x1d) && (scancode < 0x3a)) { | |
214 | /* Shift pressed */ | |
215 | if (modifier & (LEFT_SHIFT | RIGHT_SHIFT)) | |
216 | keycode = usb_kbd_numkey_shifted[scancode - 0x1e]; | |
217 | else | |
218 | keycode = usb_kbd_numkey[scancode - 0x1e]; | |
affae2bf | 219 | } |
4785a694 | 220 | |
9a8c72a6 | 221 | if (data->flags & USB_KBD_CTRL) |
4785a694 ZW |
222 | keycode = scancode - 0x3; |
223 | ||
00b7d6ec MV |
224 | if (pressed == 1) { |
225 | if (scancode == NUM_LOCK) { | |
9a8c72a6 | 226 | data->flags ^= USB_KBD_NUMLOCK; |
affae2bf WD |
227 | return 1; |
228 | } | |
9a8c72a6 | 229 | |
00b7d6ec | 230 | if (scancode == CAPS_LOCK) { |
9a8c72a6 | 231 | data->flags ^= USB_KBD_CAPSLOCK; |
affae2bf WD |
232 | return 1; |
233 | } | |
00b7d6ec | 234 | if (scancode == SCROLL_LOCK) { |
9a8c72a6 | 235 | data->flags ^= USB_KBD_SCROLLLOCK; |
affae2bf WD |
236 | return 1; |
237 | } | |
238 | } | |
9a8c72a6 MV |
239 | |
240 | /* Report keycode if any */ | |
241 | if (keycode) { | |
00b7d6ec | 242 | USB_KBD_PRINTF("%c", keycode); |
9a8c72a6 | 243 | usb_kbd_put_queue(data, keycode); |
affae2bf | 244 | } |
9a8c72a6 | 245 | |
affae2bf WD |
246 | return 0; |
247 | } | |
248 | ||
9a8c72a6 MV |
249 | static uint32_t usb_kbd_service_key(struct usb_device *dev, int i, int up) |
250 | { | |
251 | uint32_t res = 0; | |
252 | struct usb_kbd_pdata *data = dev->privptr; | |
253 | uint8_t *new; | |
254 | uint8_t *old; | |
255 | ||
256 | if (up) { | |
257 | new = data->old; | |
258 | old = data->new; | |
259 | } else { | |
260 | new = data->new; | |
261 | old = data->old; | |
262 | } | |
263 | ||
264 | if ((old[i] > 3) && (memscan(new + 2, old[i], 6) == new + 8)) | |
265 | res |= usb_kbd_translate(data, old[i], data->new[0], up); | |
266 | ||
267 | return res; | |
268 | } | |
269 | ||
affae2bf | 270 | /* Interrupt service routine */ |
48c8073e | 271 | static int usb_kbd_irq_worker(struct usb_device *dev) |
affae2bf | 272 | { |
9a8c72a6 MV |
273 | struct usb_kbd_pdata *data = dev->privptr; |
274 | int i, res = 0; | |
4785a694 | 275 | |
9a8c72a6 MV |
276 | /* No combo key pressed */ |
277 | if (data->new[0] == 0x00) | |
278 | data->flags &= ~USB_KBD_CTRL; | |
279 | /* Left or Right Ctrl pressed */ | |
280 | else if ((data->new[0] == LEFT_CNTR) || (data->new[0] == RIGHT_CNTR)) | |
281 | data->flags |= USB_KBD_CTRL; | |
00b7d6ec | 282 | |
9a8c72a6 MV |
283 | for (i = 2; i < 8; i++) { |
284 | res |= usb_kbd_service_key(dev, i, 0); | |
285 | res |= usb_kbd_service_key(dev, i, 1); | |
affae2bf | 286 | } |
00b7d6ec | 287 | |
9a8c72a6 MV |
288 | /* Key is still pressed */ |
289 | if ((data->new[2] > 3) && (data->old[2] == data->new[2])) | |
290 | res |= usb_kbd_translate(data, data->new[2], data->new[0], 2); | |
291 | ||
00b7d6ec | 292 | if (res == 1) |
affae2bf | 293 | usb_kbd_setled(dev); |
00b7d6ec | 294 | |
9a8c72a6 | 295 | memcpy(data->old, data->new, 8); |
00b7d6ec | 296 | |
9a8c72a6 | 297 | return 1; |
affae2bf WD |
298 | } |
299 | ||
9a8c72a6 | 300 | /* Keyboard interrupt handler */ |
48c8073e MV |
301 | static int usb_kbd_irq(struct usb_device *dev) |
302 | { | |
303 | if ((dev->irq_status != 0) || (dev->irq_act_len != 8)) { | |
9a8c72a6 | 304 | USB_KBD_PRINTF("USB KBD: Error %lX, len %d\n", |
48c8073e MV |
305 | dev->irq_status, dev->irq_act_len); |
306 | return 1; | |
307 | } | |
308 | ||
309 | return usb_kbd_irq_worker(dev); | |
310 | } | |
311 | ||
9a8c72a6 MV |
312 | /* Interrupt polling */ |
313 | static inline void usb_kbd_poll_for_event(struct usb_device *dev) | |
314 | { | |
315 | #if defined(CONFIG_SYS_USB_EVENT_POLL) | |
316 | usb_event_poll(); | |
317 | usb_kbd_irq_worker(dev); | |
318 | #elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) | |
319 | struct usb_interface *iface; | |
320 | struct usb_kbd_pdata *data = dev->privptr; | |
321 | iface = &dev->config.if_desc[0]; | |
322 | usb_get_report(dev, iface->desc.bInterfaceNumber, | |
323 | 1, 1, data->new, sizeof(data->new)); | |
324 | if (memcmp(data->old, data->new, sizeof(data->new))) | |
325 | usb_kbd_irq_worker(dev); | |
326 | #endif | |
327 | } | |
328 | ||
329 | /* test if a character is in the queue */ | |
330 | static int usb_kbd_testc(void) | |
331 | { | |
332 | struct stdio_dev *dev; | |
333 | struct usb_device *usb_kbd_dev; | |
334 | struct usb_kbd_pdata *data; | |
335 | ||
336 | dev = stdio_get_by_name(DEVNAME); | |
337 | usb_kbd_dev = (struct usb_device *)dev->priv; | |
338 | data = usb_kbd_dev->privptr; | |
339 | ||
340 | usb_kbd_poll_for_event(usb_kbd_dev); | |
341 | ||
342 | return !(data->usb_in_pointer == data->usb_out_pointer); | |
343 | } | |
344 | ||
345 | /* gets the character from the queue */ | |
346 | static int usb_kbd_getc(void) | |
347 | { | |
348 | struct stdio_dev *dev; | |
349 | struct usb_device *usb_kbd_dev; | |
350 | struct usb_kbd_pdata *data; | |
351 | ||
352 | dev = stdio_get_by_name(DEVNAME); | |
353 | usb_kbd_dev = (struct usb_device *)dev->priv; | |
354 | data = usb_kbd_dev->privptr; | |
355 | ||
356 | while (data->usb_in_pointer == data->usb_out_pointer) | |
357 | usb_kbd_poll_for_event(usb_kbd_dev); | |
358 | ||
359 | if (data->usb_out_pointer == USB_KBD_BUFFER_LEN - 1) | |
360 | data->usb_out_pointer = 0; | |
361 | else | |
362 | data->usb_out_pointer++; | |
363 | ||
364 | return data->usb_kbd_buffer[data->usb_out_pointer]; | |
365 | } | |
366 | ||
367 | /* probes the USB device dev for keyboard type. */ | |
affae2bf WD |
368 | static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum) |
369 | { | |
8f8bd565 | 370 | struct usb_interface *iface; |
affae2bf | 371 | struct usb_endpoint_descriptor *ep; |
9a8c72a6 | 372 | struct usb_kbd_pdata *data; |
00b7d6ec | 373 | int pipe, maxp; |
affae2bf | 374 | |
00b7d6ec MV |
375 | if (dev->descriptor.bNumConfigurations != 1) |
376 | return 0; | |
9a8c72a6 | 377 | |
affae2bf WD |
378 | iface = &dev->config.if_desc[ifnum]; |
379 | ||
8f8bd565 TR |
380 | if (iface->desc.bInterfaceClass != 3) |
381 | return 0; | |
9a8c72a6 | 382 | |
8f8bd565 TR |
383 | if (iface->desc.bInterfaceSubClass != 1) |
384 | return 0; | |
9a8c72a6 | 385 | |
8f8bd565 TR |
386 | if (iface->desc.bInterfaceProtocol != 1) |
387 | return 0; | |
9a8c72a6 | 388 | |
8f8bd565 TR |
389 | if (iface->desc.bNumEndpoints != 1) |
390 | return 0; | |
affae2bf WD |
391 | |
392 | ep = &iface->ep_desc[0]; | |
393 | ||
9a8c72a6 | 394 | /* Check if endpoint 1 is interrupt endpoint */ |
00b7d6ec MV |
395 | if (!(ep->bEndpointAddress & 0x80)) |
396 | return 0; | |
9a8c72a6 | 397 | |
00b7d6ec MV |
398 | if ((ep->bmAttributes & 3) != 3) |
399 | return 0; | |
9a8c72a6 MV |
400 | |
401 | USB_KBD_PRINTF("USB KBD: found set protocol...\n"); | |
402 | ||
403 | data = malloc(sizeof(struct usb_kbd_pdata)); | |
404 | if (!data) { | |
405 | printf("USB KBD: Error allocating private data\n"); | |
406 | return 0; | |
407 | } | |
408 | ||
409 | /* Clear private data */ | |
410 | memset(data, 0, sizeof(struct usb_kbd_pdata)); | |
411 | ||
412 | /* Insert private data into USB device structure */ | |
413 | dev->privptr = data; | |
414 | ||
415 | /* Set IRQ handler */ | |
416 | dev->irq_handle = usb_kbd_irq; | |
417 | ||
affae2bf WD |
418 | pipe = usb_rcvintpipe(dev, ep->bEndpointAddress); |
419 | maxp = usb_maxpacket(dev, pipe); | |
9a8c72a6 MV |
420 | |
421 | /* We found a USB Keyboard, install it. */ | |
422 | usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0); | |
423 | ||
424 | USB_KBD_PRINTF("USB KBD: found set idle...\n"); | |
425 | usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0); | |
426 | ||
427 | USB_KBD_PRINTF("USB KBD: enable interrupt pipe...\n"); | |
428 | usb_submit_int_msg(dev, pipe, data->new, maxp > 8 ? 8 : maxp, | |
00b7d6ec | 429 | ep->bInterval); |
9a8c72a6 MV |
430 | |
431 | /* Success. */ | |
affae2bf WD |
432 | return 1; |
433 | } | |
434 | ||
9a8c72a6 MV |
435 | /* Search for keyboard and register it if found. */ |
436 | int drv_usb_kbd_init(void) | |
437 | { | |
438 | struct stdio_dev usb_kbd_dev, *old_dev; | |
439 | struct usb_device *dev; | |
440 | char *stdinname = getenv("stdin"); | |
441 | int error, i; | |
442 | ||
443 | /* Scan all USB Devices */ | |
444 | for (i = 0; i < USB_MAX_DEVICE; i++) { | |
445 | /* Get USB device. */ | |
446 | dev = usb_get_dev_index(i); | |
447 | if (!dev) | |
448 | return -1; | |
449 | ||
450 | if (dev->devnum == -1) | |
451 | continue; | |
452 | ||
453 | /* Try probing the keyboard */ | |
454 | if (usb_kbd_probe(dev, 0) != 1) | |
455 | continue; | |
456 | ||
457 | /* We found a keyboard, check if it is already registered. */ | |
458 | USB_KBD_PRINTF("USB KBD: found set up device.\n"); | |
459 | old_dev = stdio_get_by_name(DEVNAME); | |
460 | if (old_dev) { | |
461 | /* Already registered, just return ok. */ | |
462 | USB_KBD_PRINTF("USB KBD: is already registered.\n"); | |
463 | return 1; | |
464 | } | |
465 | ||
466 | /* Register the keyboard */ | |
467 | USB_KBD_PRINTF("USB KBD: register.\n"); | |
468 | memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev)); | |
469 | strcpy(usb_kbd_dev.name, DEVNAME); | |
470 | usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; | |
471 | usb_kbd_dev.putc = NULL; | |
472 | usb_kbd_dev.puts = NULL; | |
473 | usb_kbd_dev.getc = usb_kbd_getc; | |
474 | usb_kbd_dev.tstc = usb_kbd_testc; | |
475 | usb_kbd_dev.priv = (void *)dev; | |
476 | error = stdio_register(&usb_kbd_dev); | |
477 | if (error) | |
478 | return error; | |
479 | ||
480 | /* Check if this is the standard input device. */ | |
481 | if (strcmp(stdinname, DEVNAME)) | |
482 | return 1; | |
483 | ||
484 | /* Reassign the console */ | |
485 | if (overwrite_console()) | |
486 | return 1; | |
487 | ||
488 | error = console_assign(stdin, DEVNAME); | |
489 | if (error) | |
490 | return error; | |
491 | ||
492 | return 1; | |
493 | } | |
494 | ||
495 | /* No USB Keyboard found */ | |
496 | return -1; | |
497 | } | |
498 | ||
499 | /* Deregister the keyboard. */ | |
500 | int usb_kbd_deregister(void) | |
501 | { | |
502 | #ifdef CONFIG_SYS_STDIO_DEREGISTER | |
503 | return stdio_deregister(DEVNAME); | |
504 | #else | |
505 | return 1; | |
506 | #endif | |
507 | } |