Sorry, forgot to fix previous diff. Attached correct diff
Index: distrib/notes/sparc64/hardware
===================================================================
RCS file: /cvs/src/distrib/notes/sparc64/hardware,v
retrieving revision 1.151
diff -u -p -r1.151 hardware
--- distrib/notes/sparc64/hardware      9 Apr 2009 16:02:24 -0000       1.151
+++ distrib/notes/sparc64/hardware      21 Sep 2010 18:02:06 -0000
@@ -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:
Index: distrib/sets/lists/man/mi
===================================================================
RCS file: /cvs/src/distrib/sets/lists/man/mi,v
retrieving revision 1.1061
diff -u -p -r1.1061 mi
--- distrib/sets/lists/man/mi   25 Aug 2010 19:21:26 -0000      1.1061
+++ distrib/sets/lists/man/mi   21 Sep 2010 18:02:07 -0000
@@ -2002,7 +2002,6 @@
 ./usr/share/man/cat4/piixpm.0
 ./usr/share/man/cat4/pim.0
 ./usr/share/man/cat4/pms.0
-./usr/share/man/cat4/pmsi.0
 ./usr/share/man/cat4/pnp.0
 ./usr/share/man/cat4/ppb.0
 ./usr/share/man/cat4/ppp.0
Index: share/man/man4/Makefile
===================================================================
RCS file: /cvs/src/share/man/man4/Makefile,v
retrieving revision 1.514
diff -u -p -r1.514 Makefile
--- share/man/man4/Makefile     19 Aug 2010 15:45:35 -0000      1.514
+++ share/man/man4/Makefile     21 Sep 2010 18:03:27 -0000
@@ -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
Index: share/man/man4/pckbc.4
===================================================================
RCS file: /cvs/src/share/man/man4/pckbc.4,v
retrieving revision 1.17
diff -u -p -r1.17 pckbc.4
--- share/man/man4/pckbc.4      22 Jul 2010 07:41:59 -0000      1.17
+++ share/man/man4/pckbc.4      21 Sep 2010 18:03:27 -0000
@@ -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
Index: share/man/man4/pms.4
===================================================================
RCS file: /cvs/src/share/man/man4/pms.4,v
retrieving revision 1.11
diff -u -p -r1.11 pms.4
--- share/man/man4/pms.4        19 Oct 2007 06:29:36 -0000      1.11
+++ share/man/man4/pms.4        21 Sep 2010 18:03:28 -0000
@@ -37,16 +37,13 @@
 .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,13 @@ the PS/2 input port controller found on 
 .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.
+The driver is
+believed to work with both 3-button and 5-button mice with scroll wheels.
 Mouse related data are accessed by
 .Xr wsmouse 4
 devices.
Index: share/man/man4/man4.i386/lms.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.i386/lms.4,v
retrieving revision 1.10
diff -u -p -r1.10 lms.4
--- share/man/man4/man4.i386/lms.4      31 May 2007 19:19:55 -0000      1.10
+++ share/man/man4/man4.i386/lms.4      21 Sep 2010 18:03:28 -0000
@@ -53,6 +53,5 @@ devices.
 .Xr isa 4 ,
 .Xr mms 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr ums 4 ,
 .Xr wsmouse 4
Index: share/man/man4/man4.i386/mms.4
===================================================================
RCS file: /cvs/src/share/man/man4/man4.i386/mms.4,v
retrieving revision 1.9
diff -u -p -r1.9 mms.4
--- share/man/man4/man4.i386/mms.4      31 May 2007 19:19:55 -0000      1.9
+++ share/man/man4/man4.i386/mms.4      21 Sep 2010 18:03:28 -0000
@@ -53,6 +53,5 @@ devices.
 .Xr isa 4 ,
 .Xr lms 4 ,
 .Xr pms 4 ,
-.Xr pmsi 4 ,
 .Xr ums 4 ,
 .Xr wsmouse 4
Index: sys/arch/alpha/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/alpha/conf/GENERIC,v
retrieving revision 1.215
diff -u -p -r1.215 GENERIC
--- sys/arch/alpha/conf/GENERIC 2 Aug 2010 14:13:23 -0000       1.215
+++ sys/arch/alpha/conf/GENERIC 21 Sep 2010 18:03:32 -0000
@@ -334,7 +334,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
@@ -428,7 +427,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
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.302
diff -u -p -r1.302 GENERIC
--- sys/arch/amd64/conf/GENERIC 8 Sep 2010 16:04:35 -0000       1.302
+++ sys/arch/amd64/conf/GENERIC 21 Sep 2010 18:03:33 -0000
@@ -278,14 +278,12 @@ option    WSDISPLAY_COMPAT_PCVT           # emulate 
 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?
Index: sys/arch/i386/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.696
diff -u -p -r1.696 GENERIC
--- sys/arch/i386/conf/GENERIC  8 Sep 2010 16:04:35 -0000       1.696
+++ sys/arch/i386/conf/GENERIC  21 Sep 2010 18:03:36 -0000
@@ -341,7 +341,6 @@ option      WSDISPLAY_COMPAT_PCVT           # emulate 
 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?
@@ -350,7 +349,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?
Index: sys/arch/loongson/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/loongson/conf/GENERIC,v
retrieving revision 1.24
diff -u -p -r1.24 GENERIC
--- sys/arch/loongson/conf/GENERIC      21 Sep 2010 02:46:33 -0000      1.24
+++ sys/arch/loongson/conf/GENERIC      21 Sep 2010 18:03:37 -0000
@@ -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)
Index: sys/arch/loongson/conf/RAMDISK
===================================================================
RCS file: /cvs/src/sys/arch/loongson/conf/RAMDISK,v
retrieving revision 1.13
diff -u -p -r1.13 RAMDISK
--- sys/arch/loongson/conf/RAMDISK      3 Jul 2010 03:59:16 -0000       1.13
+++ sys/arch/loongson/conf/RAMDISK      21 Sep 2010 18:03:37 -0000
@@ -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
Index: sys/arch/mvmeppc/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/mvmeppc/conf/GENERIC,v
retrieving revision 1.11
diff -u -p -r1.11 GENERIC
--- sys/arch/mvmeppc/conf/GENERIC       3 Jul 2010 03:59:17 -0000       1.11
+++ sys/arch/mvmeppc/conf/GENERIC       21 Sep 2010 18:03:42 -0000
@@ -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
Index: sys/arch/mvmeppc/conf/RAMDISK
===================================================================
RCS file: /cvs/src/sys/arch/mvmeppc/conf/RAMDISK,v
retrieving revision 1.12
diff -u -p -r1.12 RAMDISK
--- sys/arch/mvmeppc/conf/RAMDISK       3 Jul 2010 03:59:17 -0000       1.12
+++ sys/arch/mvmeppc/conf/RAMDISK       21 Sep 2010 18:03:42 -0000
@@ -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
Index: sys/arch/sparc64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/conf/GENERIC,v
retrieving revision 1.255
diff -u -p -r1.255 GENERIC
--- sys/arch/sparc64/conf/GENERIC       13 Aug 2010 09:30:11 -0000      1.255
+++ sys/arch/sparc64/conf/GENERIC       21 Sep 2010 18:03:44 -0000
@@ -299,8 +299,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
 
Index: sys/dev/pckbc/files.pckbc
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/files.pckbc,v
retrieving revision 1.8
diff -u -p -r1.8 files.pckbc
--- sys/dev/pckbc/files.pckbc   18 Oct 2007 17:39:54 -0000      1.8
+++ sys/dev/pckbc/files.pckbc   21 Sep 2010 18:03:48 -0000
@@ -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
Index: sys/dev/pckbc/pms.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.3
diff -u -p -r1.3 pms.c
--- sys/dev/pckbc/pms.c 22 Jul 2010 14:25:41 -0000      1.3
+++ sys/dev/pckbc/pms.c 21 Sep 2010 18:03:49 -0000
@@ -38,6 +38,59 @@
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsmousevar.h>
 
+#ifdef PMS_DEBUG
+#define DPRINTF(...) do { if (pmsdebug) printf(__VA_ARGS__); } while(0)
+#define DPRINTFN(n, ...) do { if (pmsdebug > (n)) printf(__VA_ARGS__); } 
while(0)
+int pmsdebug = 1;
+#else
+#define DPRINTF(...)
+#define DPRINTFN(n, ...)
+#endif
+#define DEVNAME(sc) ((sc)->sc_dev.dv_xname)
+
+/* PS/2 mouse data packet */
+#define PMS_PS2_BUTTONSMASK    0x07
+#define PMS_PS2_BUTTON1                0x01    /* left */
+#define PMS_PS2_BUTTON2                0x04    /* middle */
+#define PMS_PS2_BUTTON3                0x02    /* right */
+#define PMS_PS2_XNEG           0x10
+#define PMS_PS2_YNEG           0x20
+
+/* MS IntelliMouse Explorer data packet */
+#define PMS_EXPLORER_ZNEG      0x08
+#define PMS_EXPLORER_BUTTON4   0x10
+#define PMS_EXPLORER_BUTTON5   0x20
+
+/* Genius NetMouse data packet */
+#define PMS_NETMOUSE_BUTTON4   0x40
+#define PMS_NETMOUSE_BUTTON5   0x80
+
+/* Genius NetScroll data packet */
+#define PMS_NETSCROLL_BUTTON4  0x01
+#define PMS_NETSCROLL_BUTTON5  0x02
+#define PMS_NETSCROLL_ZNEG     0x10
+
+#define PMS_BUTTON1DOWN                0x01    /* left */
+#define PMS_BUTTON2DOWN                0x02    /* middle */
+#define PMS_BUTTON3DOWN                0x04    /* right */
+#define PMS_BUTTON4DOWN                0x08
+#define PMS_BUTTON5DOWN                0x10
+
+struct pms_softc;
+
+struct pms_protocol {
+       int type;
+#define PMS_STANDARD   0
+#define PMS_INTELLI    1
+#define PMS_EXPLORER   2
+#define PMS_NETMOUSE   3
+#define PMS_NETSCROLL  4
+       int packetsize;
+       int syncmask;
+       int sync;
+       int (*enable)(struct pms_softc *);
+};
+
 struct pms_softc {             /* driver status information */
        struct device sc_dev;
 
@@ -48,27 +101,45 @@ struct pms_softc {         /* driver status inf
 #define PMS_STATE_DISABLED     0
 #define PMS_STATE_ENABLED      1
 #define PMS_STATE_SUSPENDED    2
+
+       struct pms_protocol protocol;
+       unsigned char packet[8];
+
        int inputstate;
-       u_int buttons, oldbuttons;      /* mouse button status */
-       signed char dx;
+       u_int buttons;  /* mouse button status */
 
        struct device *sc_wsmousedev;
 };
 
-int pmsprobe(struct device *, void *, void *);
+int  pmsmatch(struct device *, void *, void *);
 void pmsattach(struct device *, struct device *, void *);
-int pmsactivate(struct device *, int);
+int  pmsactivate(struct device *, int);
+
 void pmsinput(void *, int);
 
+int  pms_change_state(struct pms_softc *, int);
+int  pms_ioctl(void *, u_long, caddr_t, int, struct proc *);
+int  pms_enable(void *);
+void pms_disable(void *);
+
+int  pms_get_devid(struct pms_softc *, u_char *);
+int  pms_get_status(struct pms_softc *, u_char *);
+int  pms_set_rate(struct pms_softc *, int);
+int  pms_set_resolution(struct pms_softc *, int);
+int  pms_set_scaling(struct pms_softc *, int);
+
+int  pms_enable_intelli(struct pms_softc *);
+int  pms_enable_explorer(struct pms_softc *);
+int  pms_enable_netmouse(struct pms_softc *);
+int  pms_enable_netscroll(struct pms_softc *);
+
 struct cfattach pms_ca = {
-       sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
-       pmsactivate
+       sizeof(struct pms_softc), pmsmatch, pmsattach, NULL, pmsactivate
 };
 
-int    pms_change_state(struct pms_softc *, int);
-int    pms_ioctl(void *, u_long, caddr_t, int, struct proc *);
-int    pms_enable(void *);
-void   pms_disable(void *);
+struct cfdriver pms_cd = {
+       NULL, "pms", DV_DULL
+};
 
 const struct wsmouse_accessops pms_accessops = {
        pms_enable,
@@ -76,11 +147,165 @@ const struct wsmouse_accessops pms_acces
        pms_disable,
 };
 
+const struct pms_protocol pms_protocols[] = {
+       /* Generic PS/2 mouse */
+       {PMS_STANDARD, 3, 0xc0, 0, NULL},
+       /* Microsoft IntelliMouse */
+       {PMS_INTELLI, 4, 0x08, 0x08, pms_enable_intelli},
+       /* Microsoft IntelliMouse Explorer */
+       {PMS_EXPLORER, 4, 0xc8, 0x08, pms_enable_explorer},
+       /* Genius NetMouse/NetScroll Optical */
+       {PMS_NETMOUSE, 4, 0x08, 0x08, pms_enable_netmouse},
+       /* Genius NetScroll */
+       {PMS_NETSCROLL, 6, 0xc0, 0x00, pms_enable_netscroll}
+};
+
+int
+pms_enable_intelli(struct pms_softc *sc)
+{
+       static const int rates[] = {200, 100, 80};
+       u_char resp;
+       int res, i;
+
+       for (i = 0; i < nitems(rates); i++)
+               if (pms_set_rate(sc, rates[i]))
+                       return (0);
+
+       res = pms_get_devid(sc, &resp);
+       if (res || (resp != 0x03))
+               return (0);
+
+       return (1);
+}
+
+int
+pms_enable_explorer(struct pms_softc *sc)
+{
+       static const int rates[] = {200, 200, 80};
+       u_char resp;
+       int res, i;
+
+       for (i = 0; i < nitems(rates); i++)
+               if (pms_set_rate(sc, rates[i]))
+                       return (0);
+
+       res = pms_get_devid(sc, &resp);
+       if (res || (resp != 0x04))
+               return (0);
+
+       return (1);
+}
+
+int
+pms_enable_netmouse(struct pms_softc *sc)
+{
+       u_char resp[3];
+
+       if (pms_set_resolution(sc, 3) ||
+           pms_set_scaling(sc, 1) ||
+           pms_set_scaling(sc, 1) ||
+           pms_set_scaling(sc, 1) ||
+           pms_get_status(sc, resp) ||
+           resp[1] != '3' || resp[2] != 'U')
+               return (0);
+
+       return (1);
+}
+
+int
+pms_enable_netscroll(struct pms_softc *sc)
+{
+       u_char resp[3];
+
+       if (pms_set_resolution(sc, 3) ||
+           pms_set_scaling(sc, 1) ||
+           pms_set_scaling(sc, 1) ||
+           pms_set_scaling(sc, 1) ||
+           pms_get_status(sc, resp) ||
+           resp[1] != '3' || resp[2] != 'D')
+               return (0);
+
+       return (1);
+}
+
+int
+pms_get_devid(struct pms_softc *sc, u_char *resp)
+{
+       u_char cmd[1];
+       int res;
+
+       cmd[0] = PMS_SEND_DEV_ID;
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                               cmd, 1, 1, 1, resp);
+
+       return (res);
+}
+
+int
+pms_get_status(struct pms_softc *sc, u_char *resp)
+{
+       u_char cmd[1];
+       int res;
+
+       cmd[0] = PMS_SEND_DEV_STATUS;
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                               cmd, 1, 3, 1, resp);
+
+       return (res);
+}
+
+int
+pms_set_rate(struct pms_softc *sc, int value)
+{
+       u_char cmd[2];
+       int res;
+
+       cmd[0] = PMS_SET_SAMPLE;
+       cmd[1] = value;
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                               cmd, 2, 0, 1, NULL);
+
+       return (res);
+}
+
+int
+pms_set_resolution(struct pms_softc *sc, int value)
+{
+       u_char cmd[2];
+       int res;
+
+       cmd[0] = PMS_SET_RES;
+       cmd[1] = value;
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                               cmd, 2, 0, 1, NULL);
+
+       return (res);
+}
+
+int
+pms_set_scaling(struct pms_softc *sc, int scale)
+{
+       u_char cmd[1];
+       int res;
+
+       switch (scale) {
+       case 1:
+       default:
+               cmd[0] = PMS_SET_SCALE11;
+               break;
+       case 2:
+               cmd[0] = PMS_SET_SCALE21;
+               break;
+       }
+
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                               cmd, 1, 0, 1, NULL);
+
+       return (res);
+}
+
 int
-pmsprobe(parent, match, aux)
-       struct device *parent;
-       void *match;
-       void *aux;
+pmsmatch(struct device *parent, void *match, void *aux)
 {
        struct pckbc_attach_args *pa = aux;
        u_char cmd[1], resp[2];
@@ -89,43 +314,28 @@ pmsprobe(parent, match, aux)
        if (pa->pa_slot != PCKBC_AUX_SLOT)
                return (0);
 
-       /* Flush any garbage. */
+       /* 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("pmsprobe: reset error %d\n", res);
-#endif
-               return (0);
-       }
-       if (resp[0] != PMS_RSTDONE) {
-               printf("pmsprobe: reset response 0x%x\n", resp[0]);
-               return (0);
-       }
-
-       /* get type number (0 = mouse) */
-       if (resp[1] != 0) {
-#ifdef DEBUG
-               printf("pmsprobe: type 0x%x\n", resp[1]);
-#endif
+       if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
+               DPRINTF("pms: reset error %d (response 0x%x, type 0x%x)\n",
+                   res, resp[0], resp[1]);
                return (0);
        }
 
-       return (10);
+       return (1);
 }
 
 void
-pmsattach(parent, self, aux)
-       struct device *parent, *self;
-       void *aux;
+pmsattach(struct device *parent, struct device *self, void *aux)
 {
        struct pms_softc *sc = (void *)self;
        struct pckbc_attach_args *pa = aux;
        struct wsmousedev_attach_args a;
-       u_char cmd[1], resp[2];
+       u_char cmd[1];
        int res;
 
        sc->sc_kbctag = pa->pa_tag;
@@ -133,24 +343,8 @@ pmsattach(parent, self, aux)
 
        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("pmsattach: reset error\n");
-               return;
-       }
-#endif
-
-       sc->inputstate = 0;
-       sc->oldbuttons = 0;
-
        pckbc_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
-                              pmsinput, sc, sc->sc_dev.dv_xname);
+                              pmsinput, sc, DEVNAME(sc));
 
        a.accessops = &pms_accessops;
        a.accesscookie = sc;
@@ -167,7 +361,7 @@ pmsattach(parent, self, aux)
        cmd[0] = PMS_DEV_DISABLE;
        res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, NULL, 0);
        if (res)
-               printf("pmsattach: disable error\n");
+               printf("%s: disable error\n", DEVNAME(sc));
        pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
 }
 
@@ -192,69 +386,51 @@ pmsactivate(struct device *self, int act
 int
 pms_change_state(struct pms_softc *sc, int newstate)
 {
-       u_char cmd[1];
-       int res;
+       u_char cmd[1], resp[2];
+       int res, i;
 
        switch (newstate) {
        case PMS_STATE_ENABLED:
                if (sc->sc_state == PMS_STATE_ENABLED)
                        return EBUSY;
                sc->inputstate = 0;
-               sc->oldbuttons = 0;
+               sc->buttons = 0;
 
-               pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);
+               cmd[0] = PMS_RESET;
+               res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
+                                       cmd, 1, 2, 1, resp);
+
+               sc->protocol = pms_protocols[0];
+               for (i = 1; i < nitems(pms_protocols); i++)
+                       if (pms_protocols[i].enable(sc))
+                               sc->protocol = pms_protocols[i];
 
+               DPRINTF("%s: protocol type %d\n", DEVNAME(sc),
+                   sc->protocol.type);
+
+               pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);
                cmd[0] = PMS_DEV_ENABLE;
                res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
-                   cmd, 1, 0, 1, 0);
+                                       cmd, 1, 0, 1, NULL);
                if (res)
-                       printf("pms_enable: command error\n");
-#if 0
-               {
-                       u_char scmd[2];
-
-                       scmd[0] = PMS_SET_RES;
-                       scmd[1] = 3; /* 8 counts/mm */
-                       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, 
scmd,
-                                               2, 0, 1, 0);
-                       if (res)
-                               printf("pms_enable: setup error1 (%d)\n", res);
-
-                       scmd[0] = PMS_SET_SCALE21;
-                       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, 
scmd,
-                                               1, 0, 1, 0);
-                       if (res)
-                               printf("pms_enable: setup error2 (%d)\n", res);
-
-                       scmd[0] = PMS_SET_SAMPLE;
-                       scmd[1] = 100; /* 100 samples/sec */
-                       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, 
scmd,
-                                               2, 0, 1, 0);
-                       if (res)
-                               printf("pms_enable: setup error3 (%d)\n", res);
-               }
-#endif
-               sc->sc_state = newstate;
+                       printf("%s: enable command error\n", DEVNAME(sc));
                break;
        case PMS_STATE_DISABLED:
-
-               /* FALLTHROUGH */
        case PMS_STATE_SUSPENDED:
                cmd[0] = PMS_DEV_DISABLE;
                res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
-                   cmd, 1, 0, 1, 0);
+                                       cmd, 1, 0, 1, NULL);
                if (res)
-                       printf("pms_disable: command error\n");
+                       printf("%s: disable command error\n", DEVNAME(sc));
                pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
-               sc->sc_state = newstate;
                break;
        }
+       sc->sc_state = newstate;
        return 0;
 }
 
 int
-pms_enable(v)
-       void *v;
+pms_enable(void *v)
 {
        struct pms_softc *sc = v;
 
@@ -262,8 +438,7 @@ pms_enable(v)
 }
 
 void
-pms_disable(v)
-       void *v;
+pms_disable(void *v)
 {
        struct pms_softc *sc = v;
 
@@ -271,99 +446,130 @@ pms_disable(v)
 }
 
 int
-pms_ioctl(v, cmd, data, flag, p)
-       void *v;
-       u_long cmd;
-       caddr_t data;
-       int flag;
-       struct proc *p;
+pms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
 {
        struct pms_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;           
+               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("pms_ioctl: SET_RES command error\n");
+
+               if (pms_set_resolution(sc, i)) {
+                       DPRINTF("%s: ioctl: set resolution error\n",
+                           DEVNAME(sc));
+               }
                break;
-               
        default:
                return (-1);
        }
        return (0);
 }
 
-/* Masks for the first byte of a packet */
-#define PS2LBUTMASK 0x01
-#define PS2RBUTMASK 0x02
-#define PS2MBUTMASK 0x04
-
-void pmsinput(vsc, data)
-void *vsc;
-int data;
-{
-       struct pms_softc *sc = vsc;
-       signed char dy;
-       u_int changed;
+void
+pmsinput(void *v, int data)
+{
+       static const u_int butmap[8] = {
+           0,
+           PMS_BUTTON1DOWN,
+           PMS_BUTTON3DOWN,
+           PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
+           PMS_BUTTON2DOWN,
+           PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
+           PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
+           PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
+       };
+       struct pms_softc *sc = v;
+       u_int changed, newbuttons;
+       int  dx, dy, dz;
 
        if (sc->sc_state != PMS_STATE_ENABLED) {
                /* Interrupts are not expected.  Discard the byte. */
                return;
        }
 
-       switch (sc->inputstate) {
+       if ((sc->inputstate == 0) &&
+           ((data & sc->protocol.syncmask) != sc->protocol.sync)) {
+               DPRINTF("%s: not in sync yet, discard input\n", DEVNAME(sc));
+               return;
+       }
 
-       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;
+       if (sc->inputstate < sc->protocol.packetsize) {
+               sc->packet[sc->inputstate++] = data & 0xff;
+               if (sc->inputstate != sc->protocol.packetsize)
+                       return;
+       }
 
-       case 1:
-               sc->dx = data;
-               /* Bounding at -127 avoids a bug in XFree86. */
-               sc->dx = (sc->dx == -128) ? -127 : sc->dx;
-               ++sc->inputstate;
+       newbuttons = butmap[sc->packet[0] & PMS_PS2_BUTTONSMASK];
+       dx = (sc->packet[0] & PMS_PS2_XNEG) ?
+           sc->packet[1] - 256 : sc->packet[1];
+       dy = (sc->packet[0] & PMS_PS2_YNEG) ?
+           sc->packet[2] - 256 : sc->packet[2];
+
+       switch (sc->protocol.type) {
+       case PMS_STANDARD:
+               dz = 0;
                break;
+       case PMS_INTELLI:
+               dz = (char)sc->packet[3];
+               break;
+       case PMS_EXPLORER:
+               dz = (sc->packet[3] & PMS_EXPLORER_ZNEG) ?
+                    (sc->packet[3] & 0x0f) - 16 :
+                    (sc->packet[3] & 0x0f);
+               newbuttons |= (sc->packet[3] & PMS_EXPLORER_BUTTON4) ?
+                   PMS_BUTTON4DOWN : 0;
+               newbuttons |= (sc->packet[3] & PMS_EXPLORER_BUTTON5) ?
+                   PMS_BUTTON5DOWN : 0;
+               break;
+       case PMS_NETMOUSE:
+               dz = (char)sc->packet[3];
+               newbuttons |= (sc->packet[0] & PMS_NETMOUSE_BUTTON4) ?
+                   PMS_BUTTON4DOWN : 0;
+               newbuttons |= (sc->packet[0] & PMS_NETMOUSE_BUTTON5) ?
+                   PMS_BUTTON5DOWN : 0;
+               break;
+       case PMS_NETSCROLL:
+               dz = (sc->packet[3] & PMS_NETSCROLL_ZNEG) ?
+                   sc->packet[4] - 256 : sc->packet[4];
+               newbuttons |= (sc->packet[3] & PMS_NETSCROLL_BUTTON4) ?
+                   PMS_BUTTON4DOWN : 0;
+               newbuttons |= (sc->packet[3] & PMS_NETSCROLL_BUTTON5) ?
+                   PMS_BUTTON5DOWN : 0;
+               break;
+       }
 
-       case 2:
-               dy = data;
-               dy = (dy == -128) ? -127 : dy;
-               sc->inputstate = 0;
+       changed = (sc->buttons ^ newbuttons);
+       sc->buttons = newbuttons;
+       sc->inputstate = 0;
+
+#ifdef PMS_DEBUG
+       int i;
 
-               changed = (sc->buttons ^ sc->oldbuttons);
-               sc->oldbuttons = sc->buttons;
+       DPRINTFN(3, "%s: packet 0x", DEVNAME(sc));
+       for (i = 0; i < sc->protocol.packetsize; i++)
+               DPRINTFN(3, "%02x", sc->packet[i]);
+       DPRINTFN(3, "\n");
 
-               if (sc->dx || dy || changed)
-                       wsmouse_input(sc->sc_wsmousedev,
-                                     sc->buttons, sc->dx, dy, 0, 0,
-                                     WSMOUSE_INPUT_DELTA);
-               break;
+       DPRINTFN(2, "%s: dx %+03d dy %+03d dz %+03d buttons 0x%02x\n",
+           DEVNAME(sc), dx, dy, dz, newbuttons);
+#endif
+
+       if (dx || dy || dz || changed) {
+               wsmouse_input(sc->sc_wsmousedev,
+                             newbuttons, dx, dy, dz, 0,
+                             WSMOUSE_INPUT_DELTA);
        }
 
+       memset(sc->packet, 0, sc->protocol.packetsize);
+
        return;
 }
-
-struct cfdriver pms_cd = {
-       NULL, "pms", DV_DULL
-};
Index: sys/dev/pckbc/pms_intelli.c
===================================================================
RCS file: sys/dev/pckbc/pms_intelli.c
diff -N sys/dev/pckbc/pms_intelli.c
--- sys/dev/pckbc/pms_intelli.c 30 Jul 2010 17:15:14 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -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
-};
Index: sys/dev/pckbc/pmsreg.h
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pmsreg.h,v
retrieving revision 1.1
diff -u -p -r1.1 pmsreg.h
--- sys/dev/pckbc/pmsreg.h      1 Aug 2007 12:16:59 -0000       1.1
+++ sys/dev/pckbc/pmsreg.h      21 Sep 2010 18:03:49 -0000
@@ -2,19 +2,21 @@
 /* $NetBSD: psmreg.h,v 1.1 1998/03/22 15:41:28 drochner Exp $ */
 
 /* mouse commands */
-#define        PMS_SET_SCALE11 0xe6    /* set scaling 1:1 */
-#define        PMS_SET_SCALE21 0xe7    /* set scaling 2:1 */
-#define        PMS_SET_RES     0xe8    /* set resolution (0..3) */
-#define        PMS_GET_SCALE   0xe9    /* get scaling factor */
-#define PMS_SEND_DEV_STATUS    0xe9
-#define        PMS_SET_STREAM  0xea    /* set streaming mode */
-#define PMS_SEND_DEV_DATA      0xeb
+#define PMS_SET_SCALE11                0xe6    /* set scaling 1:1 */
+#define PMS_SET_SCALE21                0xe7    /* set scaling 2:1 */
+#define PMS_SET_RES            0xe8    /* set resolution (0..3) */
+#define PMS_SEND_DEV_STATUS    0xe9    /* status request */
+#define PMS_SET_STREAM_MODE    0xea
+#define PMS_SEND_DEV_DATA      0xeb    /* read data */
+#define PMS_RESET_WRAP_MODE    0xec
+#define PMS_SET_WRAP_MODE      0xed
 #define PMS_SET_REMOTE_MODE    0xf0
-#define PMS_SEND_DEV_ID        0xf2
-#define        PMS_SET_SAMPLE  0xf3    /* set sampling rate */
-#define        PMS_DEV_ENABLE  0xf4    /* mouse on */
-#define        PMS_DEV_DISABLE 0xf5    /* mouse off */
+#define PMS_SEND_DEV_ID                0xf2    /* read device type */
+#define PMS_SET_SAMPLE         0xf3    /* set sampling rate */
+#define PMS_DEV_ENABLE         0xf4    /* mouse on */
+#define PMS_DEV_DISABLE                0xf5    /* mouse off */
 #define PMS_SET_DEFAULTS       0xf6
-#define        PMS_RESET       0xff    /* reset */
+#define PMS_RESEND             0xfe
+#define PMS_RESET              0xff    /* reset */
 
-#define        PMS_RSTDONE     0xaa
+#define PMS_RSTDONE            0xaa

Reply via email to