diff options
| author | ad <ad@NetBSD.org> | 2002-09-24 12:53:30 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2002-09-24 12:53:30 +0000 |
| commit | f8ec17dbbc18f9033008459d5febbd6cec973c23 (patch) | |
| tree | efd466815683323561a88493fb0210adf09413a5 /sys/dev/dec | |
| parent | 7f4485529466c9e61789248b7fda83a97da2d09a (diff) | |
Make the self-test logic match zsms, removing a 300ms delay on open.
Diffstat (limited to 'sys/dev/dec')
| -rw-r--r-- | sys/dev/dec/dzms.c | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/sys/dev/dec/dzms.c b/sys/dev/dec/dzms.c index 9e253f86a11..d5d09e5d295 100644 --- a/sys/dev/dec/dzms.c +++ b/sys/dev/dec/dzms.c @@ -1,4 +1,4 @@ -/* $NetBSD: dzms.c,v 1.5 2002/03/26 13:59:10 fredette Exp $ */ +/* $NetBSD: dzms.c,v 1.6 2002/09/24 12:53:30 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,13 +49,16 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dzms.c,v 1.5 2002/03/26 13:59:10 fredette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dzms.c,v 1.6 2002/09/24 12:53:30 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> #include <sys/ioctl.h> #include <sys/syslog.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/tty.h> #include <machine/bus.h> @@ -74,12 +77,11 @@ struct dzms_softc { /* driver status information */ struct dz_linestate *dzms_ls; int sc_enabled; /* input enabled? */ - int self_test; + int sc_selftest; int inputstate; u_int buttons; - signed char dx; - signed char dy; + int dx, dy; struct device *sc_wsmousedev; }; @@ -143,7 +145,7 @@ dzms_attach(parent, self, aux) a.accesscookie = dzms; dzms->sc_enabled = 0; - dzms->self_test = 0; + dzms->sc_selftest = 0; dzms->sc_wsmousedev = config_found(self, &a, wsmousedevprint); } @@ -156,23 +158,17 @@ dzms_enable(v) if (sc->sc_enabled) return EBUSY; - /* XXX mice presence test should be done in match/attach context XXX */ - sc->self_test = 1; + sc->sc_selftest = 4; /* wait for 4 byte reply upto 1/2 sec */ dzputc(sc->dzms_ls, MOUSE_SELF_TEST); - DELAY(100000); - DELAY(100000); - DELAY(100000); - if (sc->self_test < 0) { - sc->self_test = 0; - return EBUSY; - } else if (sc->self_test == 5) { - sc->self_test = 0; - sc->sc_enabled = 1; + (void)tsleep(dzms_enable, TTIPRI, "dzmsopen", hz / 2); + if (sc->sc_selftest != 0) { + sc->sc_selftest = 0; + return ENXIO; } - sc->inputstate = 0; - + DELAY(150); dzputc(sc->dzms_ls, MOUSE_INCREMENTAL); - + sc->sc_enabled = 1; + sc->inputstate = 0; return 0; } @@ -207,24 +203,13 @@ dzms_input(vsc, data) { struct dzms_softc *sc = vsc; - /* XXX mice presence test should be done in match/attach context XXX */ - if (!sc->sc_enabled) { - if (sc->self_test > 0) { - if (data < 0) { - printf("Timeout on 1st byte of mouse self-test report\n"); - sc->self_test = -1; - } else { - sc->self_test++; - } - } - if (sc->self_test == 3) { - if ((data & 0x0f) != 0x2) { - printf("We don't have a mouse!!!\n"); - sc->self_test = -1; - } + if (sc->sc_enabled == 0) { + if (sc->sc_selftest > 0) { + sc->sc_selftest -= 1; + if (sc->sc_selftest == 0) + wakeup(dzms_enable); } - /* Interrupts are not expected. Discard the byte. */ - return(1); + return (1); } #define WSMS_BUTTON1 0x01 |
