Make the self-test logic match zsms, removing a 300ms delay on open.

This commit is contained in:
ad 2002-09-24 12:53:30 +00:00
parent 7f44855294
commit f8ec17dbbc
1 changed files with 22 additions and 37 deletions

View File

@ -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->sc_enabled == 0) {
if (sc->sc_selftest > 0) {
sc->sc_selftest -= 1;
if (sc->sc_selftest == 0)
wakeup(dzms_enable);
}
if (sc->self_test == 3) {
if ((data & 0x0f) != 0x2) {
printf("We don't have a mouse!!!\n");
sc->self_test = -1;
}
}
/* Interrupts are not expected. Discard the byte. */
return(1);
return (1);
}
#define WSMS_BUTTON1 0x01