Deleted Added
full compact
uart_kbd_sun.c (163890) uart_kbd_sun.c (166100)
1/*-
2 * Copyright (c) 2003 Jake Burkholder.
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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Jake Burkholder.
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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_kbd_sun.c 163890 2006-11-02 00:01:15Z marius $");
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_kbd_sun.c 166100 2007-01-18 22:01:19Z marius $");
29
30#include "opt_compat.h"
31#include "opt_kbd.h"
32#include "opt_sunkbd.h"
33
34#if (defined(SUNKBD_EMULATE_ATKBD) && defined(SUNKBD_DFLT_KEYMAP)) || \
35 !defined(SUNKBD_EMULATE_ATKBD)
36#define KBD_DFLT_KEYMAP

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

67
68#define TODO printf("%s: unimplemented", __func__)
69
70struct sunkbd_softc {
71 keyboard_t sc_kbd;
72 struct uart_softc *sc_uart;
73 struct uart_devinfo *sc_sysdev;
74
29
30#include "opt_compat.h"
31#include "opt_kbd.h"
32#include "opt_sunkbd.h"
33
34#if (defined(SUNKBD_EMULATE_ATKBD) && defined(SUNKBD_DFLT_KEYMAP)) || \
35 !defined(SUNKBD_EMULATE_ATKBD)
36#define KBD_DFLT_KEYMAP

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

67
68#define TODO printf("%s: unimplemented", __func__)
69
70struct sunkbd_softc {
71 keyboard_t sc_kbd;
72 struct uart_softc *sc_uart;
73 struct uart_devinfo *sc_sysdev;
74
75 int sc_checked_key;
76
77 struct callout sc_repeat_callout;
78 int sc_repeat_key;
79
80 int sc_accents;
81 int sc_composed_char;
82 int sc_flags;
83#define KPCOMPOSE (1 << 0)
84 int sc_mode;

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

398
399 if (sc->sc_repeating)
400 return (TRUE);
401
402 if (sc->sc_uart != NULL && !uart_rx_empty(sc->sc_uart))
403 return (TRUE);
404
405 if (sc->sc_polling != 0 && sc->sc_sysdev != NULL &&
75 struct callout sc_repeat_callout;
76 int sc_repeat_key;
77
78 int sc_accents;
79 int sc_composed_char;
80 int sc_flags;
81#define KPCOMPOSE (1 << 0)
82 int sc_mode;

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

396
397 if (sc->sc_repeating)
398 return (TRUE);
399
400 if (sc->sc_uart != NULL && !uart_rx_empty(sc->sc_uart))
401 return (TRUE);
402
403 if (sc->sc_polling != 0 && sc->sc_sysdev != NULL &&
406 (sc->sc_checked_key = uart_poll(sc->sc_sysdev)) != -1)
404 uart_rxready(sc->sc_sysdev))
407 return (TRUE);
408
409 return (FALSE);
410}
411
412static u_int
413sunkbd_read_char(keyboard_t *kbd, int wait)
414{

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

436 repeated = 1;
437 sc->sc_repeating = 0;
438 callout_reset(&sc->sc_repeat_callout, hz / 10,
439 sunkbd_repeat, sc);
440 suncode = sc->sc_repeat_key;
441 goto process_code;
442 }
443
405 return (TRUE);
406
407 return (FALSE);
408}
409
410static u_int
411sunkbd_read_char(keyboard_t *kbd, int wait)
412{

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

434 repeated = 1;
435 sc->sc_repeating = 0;
436 callout_reset(&sc->sc_repeat_callout, hz / 10,
437 sunkbd_repeat, sc);
438 suncode = sc->sc_repeat_key;
439 goto process_code;
440 }
441
444 if (sc->sc_checked_key != -1) {
445 suncode = sc->sc_checked_key;
446 sc->sc_checked_key = -1;
447 goto process_code;
448 }
449
450 for (;;) {
451 next_code:
452 if (!(sc->sc_flags & KPCOMPOSE) && (sc->sc_composed_char > 0)) {
453 key = sc->sc_composed_char;
454 sc->sc_composed_char = 0;
455 if (key > UCHAR_MAX)
456 return (ERRKEY);
457 return (key);

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

467 } else {
468 return (NOKEY);
469 }
470
471 switch (suncode) {
472 case SKBD_RSP_IDLE:
473 break;
474 default:
442 for (;;) {
443 next_code:
444 if (!(sc->sc_flags & KPCOMPOSE) && (sc->sc_composed_char > 0)) {
445 key = sc->sc_composed_char;
446 sc->sc_composed_char = 0;
447 if (key > UCHAR_MAX)
448 return (ERRKEY);
449 return (key);

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

459 } else {
460 return (NOKEY);
461 }
462
463 switch (suncode) {
464 case SKBD_RSP_IDLE:
465 break;
466 default:
475
476 process_code:
477 ++kbd->kb_count;
478 key = SKBD_KEY_CHAR(suncode);
479 release = suncode & SKBD_KEY_RELEASE;
480 if (!repeated) {
481 if (release == 0) {
482 callout_reset(&sc->sc_repeat_callout,
483 hz / 2, sunkbd_repeat, sc);

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

560#endif
561
562#if defined(SUNKBD_EMULATE_ATKBD)
563 if (key == 0x38) { /* left alt (KP compose key) */
564#else
565 if (key == 0x13) { /* left alt (KP compose key) */
566#endif
567 if (release != 0) {
467 process_code:
468 ++kbd->kb_count;
469 key = SKBD_KEY_CHAR(suncode);
470 release = suncode & SKBD_KEY_RELEASE;
471 if (!repeated) {
472 if (release == 0) {
473 callout_reset(&sc->sc_repeat_callout,
474 hz / 2, sunkbd_repeat, sc);

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

551#endif
552
553#if defined(SUNKBD_EMULATE_ATKBD)
554 if (key == 0x38) { /* left alt (KP compose key) */
555#else
556 if (key == 0x13) { /* left alt (KP compose key) */
557#endif
558 if (release != 0) {
568 if (sc->sc_flags & KPCOMPOSE) {
569 sc->sc_flags &= ~KPCOMPOSE;
570 if (sc->sc_composed_char > UCHAR_MAX)
571 sc->sc_composed_char = 0;
559 if (sc->sc_flags & KPCOMPOSE) {
560 sc->sc_flags &= ~KPCOMPOSE;
561 if (sc->sc_composed_char >
562 UCHAR_MAX)
563 sc->sc_composed_char =
564 0;
572 }
573 } else {
574 if (!(sc->sc_flags & KPCOMPOSE)) {
575 sc->sc_flags |= KPCOMPOSE;
576 sc->sc_composed_char = 0;
577 }
578 }
579 }

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

763}
764
765static void
766sunkbd_clear_state(keyboard_t *kbd)
767{
768 struct sunkbd_softc *sc;
769
770 sc = (struct sunkbd_softc *)kbd;
565 }
566 } else {
567 if (!(sc->sc_flags & KPCOMPOSE)) {
568 sc->sc_flags |= KPCOMPOSE;
569 sc->sc_composed_char = 0;
570 }
571 }
572 }

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

756}
757
758static void
759sunkbd_clear_state(keyboard_t *kbd)
760{
761 struct sunkbd_softc *sc;
762
763 sc = (struct sunkbd_softc *)kbd;
771 sc->sc_checked_key = -1;
772 sc->sc_repeat_key = -1;
773 sc->sc_accents = 0;
774 sc->sc_composed_char = 0;
775 sc->sc_flags = 0;
776 sc->sc_polling = 0;
777 sc->sc_repeating = 0;
778 sc->sc_state &= LOCK_MASK; /* Preserve locking key state. */
779

--- 97 unchanged lines hidden ---
764 sc->sc_repeat_key = -1;
765 sc->sc_accents = 0;
766 sc->sc_composed_char = 0;
767 sc->sc_flags = 0;
768 sc->sc_polling = 0;
769 sc->sc_repeating = 0;
770 sc->sc_state &= LOCK_MASK; /* Preserve locking key state. */
771

--- 97 unchanged lines hidden ---