summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-01-11 15:53:59 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-01-11 15:53:59 +0000
commite0da449a4c028352b876410600579b9836e82522 (patch)
treed6de0657015fbfe385d67c3cc7eb87494bf6269e
parent891ebaa99d35c349cc9a96ece0b9f25654289ab4 (diff)
Factor a bit more sunkbd common parts; paves the way for upcoming
WSDISPLAY_COMPAT_RAWKBD support.
-rw-r--r--sys/arch/sparc/dev/z8530kbd.c19
-rw-r--r--sys/arch/sparc64/dev/comkbd_ebus.c12
-rw-r--r--sys/arch/sparc64/dev/z8530kbd.c19
-rw-r--r--sys/dev/sun/sunkbd.c22
-rw-r--r--sys/dev/sun/sunkbdvar.h4
5 files changed, 55 insertions, 21 deletions
diff --git a/sys/arch/sparc/dev/z8530kbd.c b/sys/arch/sparc/dev/z8530kbd.c
index 0f275b93c75..07f768ceeca 100644
--- a/sys/arch/sparc/dev/z8530kbd.c
+++ b/sys/arch/sparc/dev/z8530kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: z8530kbd.c,v 1.10 2008/10/15 19:12:19 blambert Exp $ */
+/* $OpenBSD: z8530kbd.c,v 1.11 2009/01/11 15:53:56 miod Exp $ */
/* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */
/*-
@@ -427,7 +427,7 @@ zskbd_attach(parent, self, aux)
if (console)
wskbd_cnattach(&zskbd_consops, zst, a.keymap);
- ss->sc_wskbddev = config_found(self, &a, wskbddevprint);
+ sunkbd_attach(ss, &a);
}
int
@@ -937,10 +937,11 @@ zskbd_rxsoft(zst)
struct sunkbd_softc *ss = (void *)zst;
struct zs_chanstate *cs = zst->zst_cs;
u_char *get, *end;
- u_int cc, scc, type;
+ u_int cc, scc;
u_char rr1;
- int code, value;
+ int code;
int s;
+ u_int8_t cbuf[64], *c;
end = zst->zst_ebuf;
get = zst->zst_rbget;
@@ -952,6 +953,7 @@ zskbd_rxsoft(zst)
timeout_add_sec(&zst->zst_diag_ch, 60);
}
+ c = cbuf;
while (cc) {
code = get[0];
rr1 = get[1];
@@ -967,14 +969,19 @@ zskbd_rxsoft(zst)
SET(code, TTY_PE);
}
- sunkbd_decode(code, &type, &value);
- wskbd_input(ss->sc_wskbddev, type, value);
+ *c++ = code;
+ if (c - cbuf == sizeof cbuf) {
+ sunkbd_input(ss, cbuf, c - cbuf);
+ c = cbuf;
+ }
get += 2;
if (get >= end)
get = zst->zst_rbuf;
cc--;
}
+ if (c != cbuf)
+ sunkbd_input(ss, cbuf, c - cbuf);
if (cc != scc) {
zst->zst_rbget = get;
diff --git a/sys/arch/sparc64/dev/comkbd_ebus.c b/sys/arch/sparc64/dev/comkbd_ebus.c
index bde4a3d4295..67177de29ed 100644
--- a/sys/arch/sparc64/dev/comkbd_ebus.c
+++ b/sys/arch/sparc64/dev/comkbd_ebus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: comkbd_ebus.c,v 1.18 2005/11/11 16:44:51 miod Exp $ */
+/* $OpenBSD: comkbd_ebus.c,v 1.19 2009/01/11 15:53:58 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -255,7 +255,7 @@ comkbd_attach(parent, self, aux)
COM_WRITE(sc, com_mcr, MCR_IENABLE | MCR_DTR | MCR_RTS);
}
- ss->sc_wskbddev = config_found(self, &a, wskbddevprint);
+ sunkbd_attach(ss, &a);
}
void
@@ -354,17 +354,15 @@ comkbd_soft(vsc)
{
struct comkbd_softc *sc = vsc;
struct sunkbd_softc *ss = (void *)sc;
- u_int type;
- int value;
+ u_int8_t cbuf[COMK_RX_RING], *cptr = cbuf;
u_int8_t c;
while (sc->sc_rxcnt) {
- c = *sc->sc_rxget;
+ *cptr++ = *sc->sc_rxget;
if (++sc->sc_rxget == sc->sc_rxend)
sc->sc_rxget = sc->sc_rxbeg;
sc->sc_rxcnt--;
- sunkbd_decode(c, &type, &value);
- wskbd_input(ss->sc_wskbddev, type, value);
+ sunkbd_input(ss, cbuf, cptr - cbuf);
}
if (sc->sc_txcnt) {
diff --git a/sys/arch/sparc64/dev/z8530kbd.c b/sys/arch/sparc64/dev/z8530kbd.c
index 5610131842a..cfb6f74f30c 100644
--- a/sys/arch/sparc64/dev/z8530kbd.c
+++ b/sys/arch/sparc64/dev/z8530kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: z8530kbd.c,v 1.20 2008/10/15 19:12:19 blambert Exp $ */
+/* $OpenBSD: z8530kbd.c,v 1.21 2009/01/11 15:53:58 miod Exp $ */
/* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */
/*-
@@ -413,7 +413,7 @@ zskbd_attach(parent, self, aux)
if (console)
wskbd_cnattach(&zskbd_consops, zst, a.keymap);
- ss->sc_wskbddev = config_found(self, &a, wskbddevprint);
+ sunkbd_attach(ss, &a);
}
int
@@ -920,10 +920,11 @@ zskbd_rxsoft(zst)
struct sunkbd_softc *ss = (void *)zst;
struct zs_chanstate *cs = zst->zst_cs;
u_char *get, *end;
- u_int cc, scc, type;
+ u_int cc, scc;
u_char rr1;
- int code, value;
+ int code;
int s;
+ u_int8_t cbuf[64], *c;
end = zst->zst_ebuf;
get = zst->zst_rbget;
@@ -935,6 +936,7 @@ zskbd_rxsoft(zst)
timeout_add_sec(&zst->zst_diag_ch, 60);
}
+ c = cbuf;
while (cc) {
code = get[0];
rr1 = get[1];
@@ -950,14 +952,19 @@ zskbd_rxsoft(zst)
SET(code, TTY_PE);
}
- sunkbd_decode(code, &type, &value);
- wskbd_input(ss->sc_wskbddev, type, value);
+ *c++ = code;
+ if (c - cbuf == sizeof cbuf) {
+ sunkbd_input(ss, cbuf, c - cbuf);
+ c = cbuf;
+ }
get += 2;
if (get >= end)
get = zst->zst_rbuf;
cc--;
}
+ if (c != cbuf)
+ sunkbd_input(ss, cbuf, c - cbuf);
if (cc != scc) {
zst->zst_rbget = get;
diff --git a/sys/dev/sun/sunkbd.c b/sys/dev/sun/sunkbd.c
index 572db74e998..4ad9e80bc9e 100644
--- a/sys/dev/sun/sunkbd.c
+++ b/sys/dev/sun/sunkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunkbd.c,v 1.21 2005/11/11 16:44:51 miod Exp $ */
+/* $OpenBSD: sunkbd.c,v 1.22 2009/01/11 15:53:58 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -57,6 +57,7 @@ void sunkbd_bell(struct sunkbd_softc *, u_int, u_int, u_int);
int sunkbd_enable(void *, int);
int sunkbd_getleds(struct sunkbd_softc *);
int sunkbd_ioctl(void *, u_long, caddr_t, int, struct proc *);
+void sunkbd_rawrepeat(void *);
void sunkbd_setleds(void *, int);
struct wskbd_accessops sunkbd_accessops = {
@@ -66,6 +67,13 @@ struct wskbd_accessops sunkbd_accessops = {
};
void
+sunkbd_attach(struct sunkbd_softc *sc, struct wskbddev_attach_args *waa)
+{
+ sc->sc_wskbddev = config_found((struct device *)sc, waa,
+ wskbddevprint);
+}
+
+void
sunkbd_bell(struct sunkbd_softc *sc, u_int period, u_int pitch, u_int volume)
{
int ticks, s;
@@ -142,6 +150,18 @@ sunkbd_getleds(struct sunkbd_softc *sc)
return (sc->sc_leds);
}
+void
+sunkbd_input(struct sunkbd_softc *sc, u_int8_t *buf, u_int buflen)
+{
+ u_int type;
+ int value;
+
+ while (buflen-- != 0) {
+ sunkbd_decode(*buf++, &type, &value);
+ wskbd_input(sc->sc_wskbddev, type, value);
+ }
+}
+
int
sunkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
diff --git a/sys/dev/sun/sunkbdvar.h b/sys/dev/sun/sunkbdvar.h
index e904f7a1707..912d276ac40 100644
--- a/sys/dev/sun/sunkbdvar.h
+++ b/sys/dev/sun/sunkbdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunkbdvar.h,v 1.10 2005/11/11 16:44:51 miod Exp $ */
+/* $OpenBSD: sunkbdvar.h,v 1.11 2009/01/11 15:53:58 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -50,8 +50,10 @@ struct sunkbd_softc {
extern struct wskbd_accessops sunkbd_accessops;
+void sunkbd_attach(struct sunkbd_softc *, struct wskbddev_attach_args *);
void sunkbd_bellstop(void *);
void sunkbd_decode(u_int8_t, u_int *, int *);
+void sunkbd_input(struct sunkbd_softc *, u_int8_t *, u_int);
void sunkbd_raw(struct sunkbd_softc *, u_int8_t);
int sunkbd_setclick(struct sunkbd_softc *, int);