Deleted Added
sdiff udiff text old ( 185724 ) new ( 186906 )
full compact
1/*-
2 * Copyright (C) 2008 Nathan Whitehorn
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/dev/adb/adb_kbd.c 185724 2008-12-06 23:26:02Z nwhitehorn $
26 */
27
28#include <sys/cdefs.h>
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33#include <sys/conf.h>

--- 33 unchanged lines hidden (view full) ---

67 struct cv sc_cv;
68
69 int sc_mode;
70 int sc_state;
71
72 int have_led_control;
73
74 uint8_t buffer[8];
75 volatile int buffers;
76
77 struct callout sc_repeater;
78 int sc_repeatstart;
79 int sc_repeatcontinue;
80 uint8_t last_press;
81};
82

--- 17 unchanged lines hidden (view full) ---

100 adb_kbd_methods,
101 sizeof(struct adb_kbd_softc),
102};
103
104static devclass_t adb_kbd_devclass;
105
106DRIVER_MODULE(akbd, adb, adb_kbd_driver, adb_kbd_devclass, 0, 0);
107
108static const uint8_t adb_to_at_scancode_map[128] = { 30, 31, 32, 33, 35, 34,
109 44, 45, 46, 47, 0, 48, 16, 17, 18, 19, 21, 20, 2, 3, 4, 5, 7, 6, 13,
110 10, 8, 12, 9, 11, 27, 24, 22, 26, 23, 25, 28, 38, 36, 40, 37, 39, 43,
111 51, 53, 49, 50, 52, 15, 57, 41, 14, 0, 1, 29, 0, 42, 58, 56, 97, 98,
112 100, 95, 0, 0, 83, 0, 55, 0, 78, 0, 69, 0, 0, 0, 91, 89, 0, 74, 13, 0,
113 0, 82, 79, 80, 81, 75, 76, 77, 71, 0, 72, 73, 0, 0, 0, 63, 64, 65, 61,
114 66, 67, 0, 87, 0, 105, 0, 70, 0, 68, 0, 88, 0, 107, 102, 94, 96, 103,
115 62, 99, 60, 101, 59, 54, 93, 90, 0, 0 };
116
117/* keyboard driver declaration */
118static int akbd_configure(int flags);
119static kbd_probe_t akbd_probe;
120static kbd_init_t akbd_init;
121static kbd_term_t akbd_term;
122static kbd_intr_t akbd_interrupt;
123static kbd_test_if_t akbd_test_if;
124static kbd_enable_t akbd_enable;

--- 338 unchanged lines hidden (view full) ---

463 struct adb_kbd_softc *sc;
464
465 if (!KBD_IS_ACTIVE(kbd))
466 return (FALSE);
467
468 sc = (struct adb_kbd_softc *)(kbd);
469
470 mtx_lock(&sc->sc_mutex);
471 if (sc->buffers > 0) {
472 mtx_unlock(&sc->sc_mutex);
473 return (TRUE);
474 }
475 mtx_unlock(&sc->sc_mutex);
476
477 return (FALSE);
478}
479
480static u_int
481akbd_read_char(keyboard_t *kbd, int wait)
482{
483 struct adb_kbd_softc *sc;
484 uint8_t adb_code, final_scancode;
485 int i;
486
487 sc = (struct adb_kbd_softc *)(kbd);
488
489 mtx_lock(&sc->sc_mutex);
490 if (!sc->buffers && wait)
491 cv_wait(&sc->sc_cv,&sc->sc_mutex);
492
493 if (!sc->buffers) {
494 mtx_unlock(&sc->sc_mutex);
495 return (0);
496 }
497
498 adb_code = sc->buffer[0];
499
500 for (i = 1; i < sc->buffers; i++)
501 sc->buffer[i-1] = sc->buffer[i];
502
503 sc->buffers--;
504 mtx_unlock(&sc->sc_mutex);
505
506 #ifdef AKBD_EMULATE_ATKBD
507 final_scancode = adb_to_at_scancode_map[adb_code & 0x7f];
508 final_scancode |= adb_code & 0x80;
509 #else
510 final_scancode = adb_code;
511 #endif
512
513 return (final_scancode);
514}
515
516static int
517akbd_check_char(keyboard_t *kbd)
518{
519 if (!KBD_IS_ACTIVE(kbd))
520 return (FALSE);
521

--- 121 unchanged lines hidden (view full) ---

643
644static int akbd_lock(keyboard_t *kbd, int lock)
645{
646 return (0);
647}
648
649static void akbd_clear_state(keyboard_t *kbd)
650{
651}
652
653static int akbd_get_state(keyboard_t *kbd, void *buf, size_t len)
654{
655 return (0);
656}
657
658static int akbd_set_state(keyboard_t *kbd, void *buf, size_t len)

--- 30 unchanged lines hidden ---