New diff for the simple pms/pmsi merge.
--
Alexandr Shadchin
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 25 Sep 2010 08:12:38 -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.1064
diff -u -p -r1.1064 mi
--- distrib/sets/lists/man/mi 24 Sep 2010 12:48:26 -0000 1.1064
+++ distrib/sets/lists/man/mi 25 Sep 2010 08:12:39 -0000
@@ -1999,7 +1999,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.515
diff -u -p -r1.515 Makefile
--- share/man/man4/Makefile 23 Sep 2010 14:35:13 -0000 1.515
+++ share/man/man4/Makefile 25 Sep 2010 08:13:24 -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 25 Sep 2010 08:13:24 -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 25 Sep 2010 08:13:24 -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,11 @@ 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.
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 25 Sep 2010 08:13:24 -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 25 Sep 2010 08:13:24 -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.216
diff -u -p -r1.216 GENERIC
--- sys/arch/alpha/conf/GENERIC 23 Sep 2010 16:21:46 -0000 1.216
+++ sys/arch/alpha/conf/GENERIC 25 Sep 2010 08:13:26 -0000
@@ -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
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.303
diff -u -p -r1.303 GENERIC
--- sys/arch/amd64/conf/GENERIC 23 Sep 2010 16:21:46 -0000 1.303
+++ sys/arch/amd64/conf/GENERIC 25 Sep 2010 08:13:26 -0000
@@ -279,14 +279,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.697
diff -u -p -r1.697 GENERIC
--- sys/arch/i386/conf/GENERIC 23 Sep 2010 16:21:46 -0000 1.697
+++ sys/arch/i386/conf/GENERIC 25 Sep 2010 08:13:27 -0000
@@ -342,7 +342,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?
@@ -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?
Index: sys/arch/loongson/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/loongson/conf/GENERIC,v
retrieving revision 1.25
diff -u -p -r1.25 GENERIC
--- sys/arch/loongson/conf/GENERIC 23 Sep 2010 16:21:46 -0000 1.25
+++ sys/arch/loongson/conf/GENERIC 25 Sep 2010 08:13:28 -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 25 Sep 2010 08:13:28 -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 25 Sep 2010 08:13:30 -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 25 Sep 2010 08:13:30 -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.257
diff -u -p -r1.257 GENERIC
--- sys/arch/sparc64/conf/GENERIC 24 Sep 2010 07:23:00 -0000 1.257
+++ sys/arch/sparc64/conf/GENERIC 25 Sep 2010 08:13:31 -0000
@@ -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
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 25 Sep 2010 08:13:33 -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 25 Sep 2010 08:13:33 -0000
@@ -48,9 +48,11 @@ struct pms_softc { /* driver status inf
#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, i
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_acces
};
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, i
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;
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
-};