diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 1998-04-01 20:21:01 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 1998-04-01 20:21:01 +0000 |
commit | 6bc3e22bb4487fa3a2e30138ae737e836f24d215 (patch) | |
tree | 7ba29a147fb74c271d877190b9b935142023ab94 /sys | |
parent | 5d9febdb3830863198c6fb23051d34e5259c4cd7 (diff) |
Add a write function and make the raw mode real raw in the PS/2 driver
to support extended PS/2 protocol under XFree86.
From NetBSD port-i386/5130 by Lennart Augustsson <augustss@cs.chalmers.se>,
adapted to OpenBSD by myself.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/isa/pms.c | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/sys/arch/i386/isa/pms.c b/sys/arch/i386/isa/pms.c index acaaf291f4a..1b7b3fa013e 100644 --- a/sys/arch/i386/isa/pms.c +++ b/sys/arch/i386/isa/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.17 1997/08/29 22:49:06 kstailey Exp $ */ +/* $OpenBSD: pms.c,v 1.18 1998/04/01 20:21:00 matthieu Exp $ */ /* $NetBSD: pms.c,v 1.29 1996/05/12 23:12:42 mycroft Exp $ */ /*- @@ -364,6 +364,36 @@ pmsread(dev, uio, flag) } int +pmswrite(dev, uio, flag) + dev_t dev; + struct uio *uio; + int flag; +{ + struct pms_softc *sc = pms_cd.cd_devs[PMSUNIT(dev)]; + int i, n; + int error; + int s; + u_char wrbuf[32]; + + + if (!(sc->sc_flags & PMS_RAW)) + return ENODEV; + + error = 0; + /* Only allow a small number of bytes per write. */ + n = min(sizeof(wrbuf), uio->uio_resid); + error = uiomove(wrbuf, n, uio); + if (error) + return error; + s = spltty(); + for(i = 0; i < n; i++) + pms_dev_cmd(wrbuf[i]); + splx(s); + + return error; +} + +int pmsioctl(dev, cmd, addr, flag, p) dev_t dev; u_long cmd; @@ -505,53 +535,9 @@ pmsintr(arg) #endif } } else { - /* read data port */ buffer[0] = inb(PMS_DATA); - - /* emulate old state machine for the ioctl's sake. */ - switch (state) { - case 0: - buttons = buffer[0]; - if ((buttons & 0xc0) == 0) - ++state; - break; - case 1: - dx = buffer[0]; - /* Bounding at -127 avoids a bug in XFree86. */ - dx = (dx == -128) ? -127 : dx; - ++state; - break; - case 2: - dy = buffer[0]; - dy = (dy == -128) ? -127 : dy; -#ifdef INTELLIMOUSE - ++state; -#else - state = 0; -#endif - - buttons = ((buttons & PS2LBUTMASK) << 2) | - ((buttons & (PS2RBUTMASK | PS2MBUTMASK)) >> 1); - changed = ((buttons ^ sc->sc_status) & BUTSTATMASK) << 3; - sc->sc_status = buttons | - (sc->sc_status & ~BUTSTATMASK) | changed; - - if (dx || dy || changed) { - /* Update accumulated movements. */ - sc->sc_x += dx; - sc->sc_y += dy; - } - break; -#ifdef INTELLIMOUSE /* discard fourth "wheel" byte */ - case 3: - state = 0; - return 0; /* XXX 0? -1? */ -#endif - } - - /* add raw data to the queue. */ (void) b_to_q(buffer, 1, &sc->sc_q); - + if (sc->sc_state & PMS_ASLP) { sc->sc_state &= ~PMS_ASLP; wakeup((caddr_t)sc); |