diff options
-rw-r--r-- | distrib/notes/sparc64/hardware | 4 | ||||
-rw-r--r-- | share/man/man4/Makefile | 3 | ||||
-rw-r--r-- | share/man/man4/man4.i386/lms.4 | 5 | ||||
-rw-r--r-- | share/man/man4/man4.i386/mms.4 | 5 | ||||
-rw-r--r-- | share/man/man4/pckbc.4 | 6 | ||||
-rw-r--r-- | share/man/man4/pms.4 | 18 | ||||
-rw-r--r-- | sys/arch/alpha/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/loongson/conf/GENERIC | 6 | ||||
-rw-r--r-- | sys/arch/loongson/conf/RAMDISK | 6 | ||||
-rw-r--r-- | sys/arch/mvmeppc/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/mvmeppc/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/sparc64/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/dev/pckbc/files.pckbc | 6 | ||||
-rw-r--r-- | sys/dev/pckbc/pms.c | 55 | ||||
-rw-r--r-- | sys/dev/pckbc/pms_intelli.c | 405 |
17 files changed, 76 insertions, 465 deletions
diff --git a/distrib/notes/sparc64/hardware b/distrib/notes/sparc64/hardware index 95e56c4e048..726439cc277 100644 --- a/distrib/notes/sparc64/hardware +++ b/distrib/notes/sparc64/hardware @@ -1,4 +1,4 @@ -dnl $OpenBSD: hardware,v 1.151 2009/04/09 16:02:24 jsg Exp $ +dnl $OpenBSD: hardware,v 1.152 2010/09/26 20:39:06 miod Exp $ OpenBSD/MACHINE OSREV runs on the following classes of machines: Ultra 1/1E Ultra 2 @@ -490,7 +490,7 @@ Supported devices {:-include-:}: Sun mice on Zilog serial ports (zstty) Sun mice on NS16550 serial ports (com) USB mice (ums) - PS/2 mice (pms or pmsi) + PS/2 mice (pms) Framebuffers SBUS framebuffers: diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index e5c69e10a5c..2bff7da34dc 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.515 2010/09/23 14:35:13 yuo Exp $ +# $OpenBSD: Makefile,v 1.516 2010/09/26 20:39:08 miod Exp $ MAN= aac.4 ac97.4 acphy.4 \ acpi.4 acpiac.4 acpiasus.4 acpibat.4 acpibtn.4 acpicpu.4 acpidock.4 \ @@ -79,7 +79,6 @@ MLINKS+=isa.4 isadma.4 MLINKS+=isapnp.4 pnp.4 MLINKS+=netintro.4 networking.4 MLINKS+=pcmcia.4 pcic.4 -MLINKS+=pms.4 pmsi.4 MLINKS+=pty.4 ptm.4 MLINKS+=random.4 arandom.4 MLINKS+=random.4 srandom.4 random.4 urandom.4 diff --git a/share/man/man4/man4.i386/lms.4 b/share/man/man4/man4.i386/lms.4 index 6d197d3af72..e3fdd59b3ca 100644 --- a/share/man/man4/man4.i386/lms.4 +++ b/share/man/man4/man4.i386/lms.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: lms.4,v 1.10 2007/05/31 19:19:55 jmc Exp $ +.\" $OpenBSD: lms.4,v 1.11 2010/09/26 20:39:08 miod Exp $ .\" $NetBSD: lms.4,v 1.13 2000/07/05 16:13:48 msaitoh Exp $ .\" .\" Copyright (c) 1993 Christopher G. Demetriou @@ -33,7 +33,7 @@ .\" .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>> .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: September 26 2010 $ .Dt LMS 4 i386 .Os .Sh NAME @@ -53,6 +53,5 @@ devices. .Xr isa 4 , .Xr mms 4 , .Xr pms 4 , -.Xr pmsi 4 , .Xr ums 4 , .Xr wsmouse 4 diff --git a/share/man/man4/man4.i386/mms.4 b/share/man/man4/man4.i386/mms.4 index bed1af30511..5389a9963bf 100644 --- a/share/man/man4/man4.i386/mms.4 +++ b/share/man/man4/man4.i386/mms.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mms.4,v 1.9 2007/05/31 19:19:55 jmc Exp $ +.\" $OpenBSD: mms.4,v 1.10 2010/09/26 20:39:08 miod Exp $ .\" $NetBSD: mms.4,v 1.13 2000/07/05 16:13:49 msaitoh Exp $ .\" .\" Copyright (c) 1993 Christopher G. Demetriou @@ -33,7 +33,7 @@ .\" .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>> .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: September 26 2010 $ .Dt MMS 4 i386 .Os .Sh NAME @@ -53,6 +53,5 @@ devices. .Xr isa 4 , .Xr lms 4 , .Xr pms 4 , -.Xr pmsi 4 , .Xr ums 4 , .Xr wsmouse 4 diff --git a/share/man/man4/pckbc.4 b/share/man/man4/pckbc.4 index bea6e25f168..92e77007d48 100644 --- a/share/man/man4/pckbc.4 +++ b/share/man/man4/pckbc.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pckbc.4,v 1.17 2010/07/22 07:41:59 jmc Exp $ +.\" $OpenBSD: pckbc.4,v 1.18 2010/09/26 20:39:08 miod Exp $ .\" $NetBSD: pckbc.4,v 1.2 2000/06/16 06:42:31 augustss Exp $ .\" .\" Copyright (c) 1999 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: July 22 2010 $ +.Dd $Mdocdate: September 26 2010 $ .Dt PCKBC 4 .Os .Sh NAME @@ -36,7 +36,6 @@ .Cd "pckbc* at ebus? " Pq "sparc64" .Cd "pckbd* at pckbc?" .Cd "pms* at pckbc?" -.Cd "pmsi* at pckbc?" .Sh DESCRIPTION The .Nm @@ -69,5 +68,4 @@ device flags to 1. .Xr isa 4 , .Xr pckbd 4 , .Xr pms 4 , -.Xr pmsi 4 , .Xr boot_config 8 diff --git a/share/man/man4/pms.4 b/share/man/man4/pms.4 index d7c80239566..ba92566e06b 100644 --- a/share/man/man4/pms.4 +++ b/share/man/man4/pms.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pms.4,v 1.11 2007/10/19 06:29:36 jmc Exp $ +.\" $OpenBSD: pms.4,v 1.12 2010/09/26 20:39:08 miod Exp $ .\" $NetBSD: pms.4,v 1.4 2000/07/05 15:45:34 msaitoh Exp $ .\" .\" Copyright (c) 1993 Christopher G. Demetriou @@ -33,20 +33,17 @@ .\" .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>> .\" -.Dd $Mdocdate: October 19 2007 $ +.Dd $Mdocdate: September 26 2010 $ .Dt PMS 4 .Os .Sh NAME -.Nm pms , -.Nm pmsi +.Nm pms .Nd PS/2 auxiliary port mouse driver .Sh SYNOPSIS .Cd "pms* at pckbc?" .Cd "pms* at gsckbc?" Pq "hppa" .Cd "pms* at mkbc?" Pq "sgi" -.Cd "pmsi* at pckbc?" .Cd "wsmouse* at pms? mux 0" -.Cd "wsmouse* at pmsi? mux 0" .Sh DESCRIPTION The .Nm pms @@ -60,12 +57,11 @@ the PS/2 input port controller found on hppa machines, or .Xr pckbc 4 , the standard PC keyboard controller found on most other machines. .Dq pms -is a generic driver which supports 2 coordinate axes and 3 buttons. -The -.Dq pmsi -variant provides specific support for wheel mice of the +is a generic driver which supports mice using common variants of the PS/2 +protocol, including wheel mice of the .Dq IntelliMouse -breed; wheel movements are mapped to a third (z-) axis. +breed. +Wheel movements are mapped to a third (z-) axis. Mouse related data are accessed by .Xr wsmouse 4 devices. diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC index 16177890f6b..54892511815 100644 --- a/sys/arch/alpha/conf/GENERIC +++ b/sys/arch/alpha/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.216 2010/09/23 16:21:46 yuo Exp $ +# $OpenBSD: GENERIC,v 1.217 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -335,7 +335,6 @@ spkr0 at pcppi? # IBM BASIC emulation pckbc* at isa? # PC keyboard controller pckbd* at pckbc? # PC keyboard (kbd port) pms* at pckbc? # PS/2-style mouse (aux port) -pmsi* at pckbc? # PS/2 "Intelli"mouse com* at isa? port 0x3f8 irq 4 # standard serial ports com* at isa? port 0x2f8 irq 3 lpt* at isa? port 0x3bc irq 7 # standard parallel port @@ -429,7 +428,6 @@ wsdisplay* at vga? wsdisplay* at tga? wskbd* at pckbd? mux 1 wsmouse* at pms? mux 0 -wsmouse* at pmsi? mux 0 # crypto support hifn* at pci? # Hi/fn 7751 crypto card diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 46751755757..e2dfb7caae3 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.303 2010/09/23 16:21:46 yuo Exp $ +# $OpenBSD: GENERIC,v 1.304 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -279,14 +279,12 @@ option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11 pckbc0 at isa? flags 0x00 # PC keyboard controller pckbd* at pckbc? # PC keyboard pms* at pckbc? # PS/2 mouse for wsmouse -pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse vga0 at isa? option X86EMU # to POST video cards vga* at pci? wsdisplay* at vga? wskbd* at pckbd? mux 1 wsmouse* at pms? mux 0 -wsmouse* at pmsi? mux 0 intagp* at vga? # intel integrated graphics agp* at intagp? diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 0d3bdfdfd59..ebf348f944b 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.697 2010/09/23 16:21:46 yuo Exp $ +# $OpenBSD: GENERIC,v 1.698 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -342,7 +342,6 @@ option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11 pckbc0 at isa? flags 0x00 # PC keyboard controller pckbd* at pckbc? # PC keyboard pms* at pckbc? # PS/2 mouse for wsmouse -pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse vga0 at isa? option X86EMU # to POST video cards vga* at pci? @@ -351,7 +350,6 @@ wsdisplay* at vga? wsdisplay* at pcdisplay? wskbd* at pckbd? mux 1 wsmouse* at pms? mux 0 -wsmouse* at pmsi? mux 0 intagp* at vga? # intel integrated graphics agp aliagp* at pchb? diff --git a/sys/arch/loongson/conf/GENERIC b/sys/arch/loongson/conf/GENERIC index 670936256e0..12de741abd6 100644 --- a/sys/arch/loongson/conf/GENERIC +++ b/sys/arch/loongson/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.25 2010/09/23 16:21:46 yuo Exp $ +# $OpenBSD: GENERIC,v 1.26 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -44,8 +44,8 @@ mcclock0 at isa? port 0x70 pckbc0 at isa? # Yeeloong only pckbd* at pckbc? # Yeeloong only wskbd* at pckbd? mux 1 # Yeeloong only -pmsi* at pckbc? # Yeeloong only -wsmouse* at pmsi? mux 0 # Yeeloong only +pms* at pckbc? # Yeeloong only +wsmouse* at pms? mux 0 # Yeeloong only ykbec0 at isa? port 0x381 # Yeeloong only com0 at isa? port 0x2f8 irq 3 # Fuloong 2F only com1 at isa? port 0x3f8 irq 4 # Fuloong 2F only (IR port) diff --git a/sys/arch/loongson/conf/RAMDISK b/sys/arch/loongson/conf/RAMDISK index d0d6c924957..030a84fa599 100644 --- a/sys/arch/loongson/conf/RAMDISK +++ b/sys/arch/loongson/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.13 2010/07/03 03:59:16 krw Exp $ +# $OpenBSD: RAMDISK,v 1.14 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -54,8 +54,8 @@ mcclock0 at isa? port 0x70 pckbc0 at isa? # Yeeloong only pckbd* at pckbc? # Yeeloong only wskbd* at pckbd? mux 1 # Yeeloong only -pmsi* at pckbc? # Yeeloong only -wsmouse* at pmsi? mux 0 # Yeeloong only +pms* at pckbc? # Yeeloong only +wsmouse* at pms? mux 0 # Yeeloong only com0 at isa? port 0x2f8 irq 3 # Fuloong 2F only pciide* at pci? wd* at pciide? flags 0x0000 diff --git a/sys/arch/mvmeppc/conf/GENERIC b/sys/arch/mvmeppc/conf/GENERIC index 90108234e3b..8aec953ebfc 100644 --- a/sys/arch/mvmeppc/conf/GENERIC +++ b/sys/arch/mvmeppc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.11 2010/07/03 03:59:17 krw Exp $ +# $OpenBSD: GENERIC,v 1.12 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -53,7 +53,6 @@ isa* at pcib? #pckbc0 at isa? # PC keyboard controller #pckbd* at pckbc? # PC keyboard #pms* at pckbc? # PS/2 mouse for wsmouse -#pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse #vga0 at isa? #vga* at pci? #com* at isa? port 0x3f8 irq 4 # standard serial ports diff --git a/sys/arch/mvmeppc/conf/RAMDISK b/sys/arch/mvmeppc/conf/RAMDISK index 4372c76699f..e2d18eeb903 100644 --- a/sys/arch/mvmeppc/conf/RAMDISK +++ b/sys/arch/mvmeppc/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.12 2010/07/03 03:59:17 krw Exp $ +# $OpenBSD: RAMDISK,v 1.13 2010/09/26 20:39:08 miod Exp $ # # MVMEPPC GENERIC config file # @@ -49,7 +49,6 @@ isa* at pcib? #pckbc0 at isa? # PC keyboard controller #pckbd* at pckbc? # PC keyboard #pms* at pckbc? # PS/2 mouse for wsmouse -#pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse #vga0 at isa? #vga* at pci? #com* at isa? port 0x3f8 irq 4 # standard serial ports diff --git a/sys/arch/sparc64/conf/GENERIC b/sys/arch/sparc64/conf/GENERIC index 458661d65d0..ba108e7a778 100644 --- a/sys/arch/sparc64/conf/GENERIC +++ b/sys/arch/sparc64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.257 2010/09/24 07:23:00 dlg Exp $ +# $OpenBSD: GENERIC,v 1.258 2010/09/26 20:39:08 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -300,8 +300,6 @@ pckbd* at pckbc? # ps2 keyboard wskbd* at pckbd? mux 1 # generic keyboard layer pms* at pckbc? # ps2 mouse wsmouse* at pms? mux 0 # generic mouse -pmsi* at pckbc? # ps2 "intelli"mouse -wsmouse* at pmsi? mux 0 # generic mouse audioce* at ebus? # ebus cs4231 diff --git a/sys/dev/pckbc/files.pckbc b/sys/dev/pckbc/files.pckbc index 560b4e2357c..8b3d4e04dd9 100644 --- a/sys/dev/pckbc/files.pckbc +++ b/sys/dev/pckbc/files.pckbc @@ -1,4 +1,4 @@ -# $OpenBSD: files.pckbc,v 1.8 2007/10/18 17:39:54 miod Exp $ +# $OpenBSD: files.pckbc,v 1.9 2010/09/26 20:39:08 miod Exp $ # $NetBSD: files.pckbc,v 1.6 1999/01/23 16:05:56 drochner Exp $ # devices attached at pckbc, for use with wscons @@ -10,7 +10,3 @@ file dev/pckbc/wskbdmap_mfii.c pckbd device pms: wsmousedev attach pms at pckbcslot file dev/pckbc/pms.c pms - -device pmsi: wsmousedev -attach pmsi at pckbcslot -file dev/pckbc/pms_intelli.c pmsi diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index e0e7026d873..fea15ba5416 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.3 2010/07/22 14:25:41 deraadt Exp $ */ +/* $OpenBSD: pms.c,v 1.4 2010/09/26 20:39:08 miod Exp $ */ /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -48,9 +48,11 @@ struct pms_softc { /* driver status information */ #define PMS_STATE_DISABLED 0 #define PMS_STATE_ENABLED 1 #define PMS_STATE_SUSPENDED 2 + + int intelli; int inputstate; u_int buttons, oldbuttons; /* mouse button status */ - signed char dx; + signed char dx, dy; struct device *sc_wsmousedev; }; @@ -70,6 +72,8 @@ int pms_ioctl(void *, u_long, caddr_t, int, struct proc *); int pms_enable(void *); void pms_disable(void *); +int pms_setintellimode(pckbc_tag_t, pckbc_slot_t); + const struct wsmouse_accessops pms_accessops = { pms_enable, pms_ioctl, @@ -77,6 +81,29 @@ const struct wsmouse_accessops pms_accessops = { }; int +pms_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot) +{ + u_char cmd[2], resp[1]; + int i, res; + static const u_char rates[] = {200, 100, 80}; + + cmd[0] = PMS_SET_SAMPLE; + for (i = 0; i < 3; i++) { + cmd[1] = rates[i]; + res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL); + if (res) + return (0); + } + + cmd[0] = PMS_SEND_DEV_ID; + res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 0, resp); + if (res || resp[0] != 3) + return (0); + + return (1); +} + +int pmsprobe(parent, match, aux) struct device *parent; void *match; @@ -204,6 +231,8 @@ pms_change_state(struct pms_softc *sc, int newstate) pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1); + sc->intelli = pms_setintellimode(sc->sc_kbctag, sc->sc_kbcslot); + cmd[0] = PMS_DEV_ENABLE; res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0); @@ -320,7 +349,7 @@ void *vsc; int data; { struct pms_softc *sc = vsc; - signed char dy; + signed char dz = 0; u_int changed; if (sc->sc_state != PMS_STATE_ENABLED) { @@ -347,18 +376,28 @@ int data; break; case 2: - dy = data; - dy = (dy == -128) ? -127 : dy; + sc->dy = data; + sc->dy = (sc->dy == -128) ? -127 : sc->dy; + ++sc->inputstate; + break; + + case 3: + dz = data; + dz = (dz == -128) ? -127 : dz; + ++sc->inputstate; + break; + } + + if ((sc->inputstate == 3 && sc->intelli == 0) || sc->inputstate == 4) { sc->inputstate = 0; changed = (sc->buttons ^ sc->oldbuttons); sc->oldbuttons = sc->buttons; - if (sc->dx || dy || changed) + if (sc->dx || sc->dy || dz || changed) wsmouse_input(sc->sc_wsmousedev, - sc->buttons, sc->dx, dy, 0, 0, + sc->buttons, sc->dx, sc->dy, dz, 0, WSMOUSE_INPUT_DELTA); - break; } return; diff --git a/sys/dev/pckbc/pms_intelli.c b/sys/dev/pckbc/pms_intelli.c deleted file mode 100644 index 8e14798c036..00000000000 --- a/sys/dev/pckbc/pms_intelli.c +++ /dev/null @@ -1,405 +0,0 @@ -/* $OpenBSD: pms_intelli.c,v 1.5 2010/07/30 17:15:14 krw Exp $ */ -/* $NetBSD: psm_intelli.c,v 1.8 2000/06/05 22:20:57 sommerfeld Exp $ */ - -/*- - * Copyright (c) 1994 Charles M. Hannum. - * Copyright (c) 1992, 1993 Erik Forsberg. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/ioctl.h> - -#include <machine/bus.h> - -#include <dev/ic/pckbcvar.h> - -#include <dev/pckbc/pmsreg.h> - -#include <dev/wscons/wsconsio.h> -#include <dev/wscons/wsmousevar.h> - -struct pmsi_softc { /* driver status information */ - struct device sc_dev; - - pckbc_tag_t sc_kbctag; - int sc_kbcslot; - - int sc_state; -#define PMSI_STATE_DISABLED 0 -#define PMSI_STATE_ENABLED 1 -#define PMSI_STATE_SUSPENDED 2 - - int inputstate; - u_int buttons, oldbuttons; /* mouse button status */ - signed char dx, dy; - - struct device *sc_wsmousedev; -}; - -int pmsiprobe(struct device *, void *, void *); -void pmsiattach(struct device *, struct device *, void *); -int pmsiactivate(struct device *, int); -void pmsiinput(void *, int); - -struct cfattach pmsi_ca = { - sizeof(struct pmsi_softc), pmsiprobe, pmsiattach, NULL, - pmsiactivate -}; - -int pmsi_change_state(struct pmsi_softc *, int); -int pmsi_ioctl(void *, u_long, caddr_t, int, struct proc *); -int pmsi_enable(void *); -void pmsi_disable(void *); - -const struct wsmouse_accessops pmsi_accessops = { - pmsi_enable, - pmsi_ioctl, - pmsi_disable, -}; - -int pmsi_setintellimode(pckbc_tag_t, pckbc_slot_t, int); - -int -pmsi_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot, int poll) -{ - u_char cmd[2], resp[1]; - int i, res; - static const u_char rates[] = {200, 100, 80}; - - cmd[0] = PMS_SET_SAMPLE; - for (i = 0; i < 3; i++) { - cmd[1] = rates[i]; - if (poll) - res = pckbc_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0); - else - res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL); - if (res) - return (res); - } - - cmd[0] = PMS_SEND_DEV_ID; - if (poll) - res = pckbc_poll_cmd(tag, slot, cmd, 1, 1, resp, 0); - else - res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 0, resp); - if (res) - return (res); - if (resp[0] != 3) - return (ENXIO); - - return (0); -} - -int -pmsiprobe(parent, match, aux) - struct device *parent; - void *match; - void *aux; -{ - struct pckbc_attach_args *pa = aux; - u_char cmd[1], resp[2]; - int res; - - if (pa->pa_slot != PCKBC_AUX_SLOT) - return (0); - - /* Flush any garbage. */ - pckbc_flush(pa->pa_tag, pa->pa_slot); - - /* reset the device */ - cmd[0] = PMS_RESET; - res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1); - if (res) { -#ifdef DEBUG - printf("pmsiprobe: reset error %d\n", res); -#endif - return (0); - } - if (resp[0] != PMS_RSTDONE) { - printf("pmsiprobe: reset response 0x%x\n", resp[0]); - return (0); - } - - /* get type number (0 = mouse) */ - if (resp[1] != 0) { -#ifdef DEBUG - printf("pmsiprobe: type 0x%x\n", resp[1]); -#endif - return (0); - } - - if ((res = pmsi_setintellimode(pa->pa_tag, pa->pa_slot, 1))) { -#ifdef DEBUG - printf("pmsiprobe: intellimode -> %d\n", res); -#endif - return (0); - } - - return (20); -} - -void -pmsiattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct pmsi_softc *sc = (void *)self; - struct pckbc_attach_args *pa = aux; - struct wsmousedev_attach_args a; - u_char cmd[1], resp[2]; - int res; - - sc->sc_kbctag = pa->pa_tag; - sc->sc_kbcslot = pa->pa_slot; - - printf("\n"); - - /* Flush any garbage. */ - pckbc_flush(pa->pa_tag, pa->pa_slot); - - /* reset the device */ - cmd[0] = PMS_RESET; - res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1); -#ifdef DEBUG - if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) { - printf("pmsiattach: reset error\n"); - return; - } -#endif - res = pmsi_setintellimode(pa->pa_tag, pa->pa_slot, 1); -#ifdef DEBUG - if (res) { - printf("pmsiattach: error setting intelli mode\n"); - return; - } -#endif - - /* Other initialization was done by pmsiprobe. */ - sc->inputstate = 0; - sc->oldbuttons = 0; - - pckbc_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot, - pmsiinput, sc, sc->sc_dev.dv_xname); - - a.accessops = &pmsi_accessops; - a.accesscookie = sc; - - /* - * Attach the wsmouse, saving a handle to it. - * Note that we don't need to check this pointer against NULL - * here or in pmsintr, because if this fails pmsi_enable() will - * never be called, so pmsiinput() will never be called. - */ - sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); - - /* no interrupts until enabled */ - cmd[0] = PMS_DEV_DISABLE; - res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, NULL, 0); - if (res) - printf("pmsiattach: disable error\n"); - pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0); -} - -int -pmsiactivate(struct device *self, int act) -{ - struct pmsi_softc *sc = (struct pmsi_softc *)self; - - switch (act) { - case DVACT_SUSPEND: - if (sc->sc_state == PMSI_STATE_ENABLED) - pmsi_change_state(sc, PMSI_STATE_SUSPENDED); - break; - case DVACT_RESUME: - if (sc->sc_state == PMSI_STATE_SUSPENDED) - pmsi_change_state(sc, PMSI_STATE_ENABLED); - break; - } - return (0); -} - -int -pmsi_change_state(struct pmsi_softc *sc, int newstate) -{ - u_char cmd[1]; - int res; - - switch (newstate) { - case PMSI_STATE_ENABLED: - if (sc->sc_state == PMSI_STATE_ENABLED) - return EBUSY; - sc->inputstate = 0; - sc->oldbuttons = 0; - - pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1); - - pckbc_flush(sc->sc_kbctag, sc->sc_kbcslot); - res = pmsi_setintellimode(sc->sc_kbctag, sc->sc_kbcslot, 0); -#ifdef DEBUG - if (res) { - printf("pmsi_change_state: error setting intelli mode\n"); - } -#endif - - cmd[0] = PMS_DEV_ENABLE; - res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, - cmd, 1, 0, 1, 0); - if (res) - printf("pmsi_change_state: command error\n"); - sc->sc_state = newstate; - break; - case PMSI_STATE_DISABLED: - /* FALLTHROUGH */ - case PMSI_STATE_SUSPENDED: - cmd[0] = PMS_DEV_DISABLE; - res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, - cmd, 1, 0, 1, 0); - if (res) - printf("pmsi_change_state: command error\n"); - pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0); - sc->sc_state = newstate; - break; - } - return 0; -} - -int -pmsi_enable(void *v) -{ - struct pmsi_softc *sc = v; - - return pmsi_change_state(sc, PMSI_STATE_ENABLED); -} - - -void -pmsi_disable(void *v) -{ - struct pmsi_softc *sc = v; - - pmsi_change_state(sc, PMSI_STATE_DISABLED); -} - -int -pmsi_ioctl(v, cmd, data, flag, p) - void *v; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - struct pmsi_softc *sc = v; - u_char kbcmd[2]; - int i; - - switch (cmd) { - case WSMOUSEIO_GTYPE: - *(u_int *)data = WSMOUSE_TYPE_PS2; - break; - - case WSMOUSEIO_SRES: - i = ((int) *(u_int *)data - 12) / 25; - /* valid values are {0,1,2,3} */ - if (i < 0) - i = 0; - if (i > 3) - i = 3; - - kbcmd[0] = PMS_SET_RES; - kbcmd[1] = (unsigned char) i; - i = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, kbcmd, - 2, 0, 1, 0); - - if (i) - printf("pmsi_ioctl: SET_RES command error\n"); - break; - - default: - return (-1); - } - return (0); -} - -/* Masks for the first byte of a packet */ -#define PS2LBUTMASK 0x01 -#define PS2RBUTMASK 0x02 -#define PS2MBUTMASK 0x04 - -void pmsiinput(vsc, data) -void *vsc; -int data; -{ - struct pmsi_softc *sc = vsc; - signed char dz; - u_int changed; - - if (sc->sc_state != PMSI_STATE_ENABLED) { - /* Interrupts are not expected. Discard the byte. */ - return; - } - - switch (sc->inputstate) { - - case 0: - if ((data & 0xc0) == 0) { /* no ovfl, bit 3 == 1 too? */ - sc->buttons = ((data & PS2LBUTMASK) ? 0x1 : 0) | - ((data & PS2MBUTMASK) ? 0x2 : 0) | - ((data & PS2RBUTMASK) ? 0x4 : 0); - ++sc->inputstate; - } - break; - - case 1: - sc->dx = data; - /* Bounding at -127 avoids a bug in XFree86. */ - sc->dx = (sc->dx == -128) ? -127 : sc->dx; - ++sc->inputstate; - break; - - case 2: - sc->dy = data; - sc->dy = (sc->dy == -128) ? -127 : sc->dy; - ++sc->inputstate; - break; - - case 3: - dz = data; - dz = (dz == -128) ? -127 : dz; - sc->inputstate = 0; - - changed = (sc->buttons ^ sc->oldbuttons); - sc->oldbuttons = sc->buttons; - - if (sc->dx || sc->dy || dz || changed) - wsmouse_input(sc->sc_wsmousedev, - sc->buttons, sc->dx, sc->dy, dz, 0, - WSMOUSE_INPUT_DELTA); - break; - } - - return; -} - -struct cfdriver pmsi_cd = { - NULL, "pmsi", DV_DULL -}; |