summaryrefslogtreecommitdiff
path: root/sys/i386/isa/psm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/isa/psm.c')
-rw-r--r--sys/i386/isa/psm.c160
1 files changed, 55 insertions, 105 deletions
diff --git a/sys/i386/isa/psm.c b/sys/i386/isa/psm.c
index ca85f57386d88..389b1b8828e27 100644
--- a/sys/i386/isa/psm.c
+++ b/sys/i386/isa/psm.c
@@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: psm.c,v 1.59 1999/01/11 03:18:23 yokota Exp $
+ * $Id: psm.c,v 1.54 1998/07/06 16:10:06 eivind Exp $
*/
/*
@@ -86,10 +86,8 @@
#include <machine/limits.h>
#include <machine/mouse.h>
-#include <dev/kbd/atkbdcreg.h>
-
-#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
+#include <i386/isa/kbdio.h>
/*
* Driver specific options: the following options may be set by
@@ -181,20 +179,20 @@ static struct psm_softc { /* Driver status information */
#define PSM_CONFIG_RESOLUTION 0x000f /* resolution */
#define PSM_CONFIG_ACCEL 0x00f0 /* acceleration factor */
#define PSM_CONFIG_NOCHECKSYNC 0x0100 /* disable sync. test */
-#define PSM_CONFIG_NOIDPROBE 0x0200 /* disable mouse model probe */
-#define PSM_CONFIG_NORESET 0x0400 /* don't reset the mouse */
-#define PSM_CONFIG_FORCETAP 0x0800 /* assume `tap' action exists */
-#define PSM_CONFIG_IGNPORTERROR 0x1000 /* ignore error in aux port test */
#define PSM_CONFIG_FLAGS (PSM_CONFIG_RESOLUTION \
| PSM_CONFIG_ACCEL \
- | PSM_CONFIG_NOCHECKSYNC \
- | PSM_CONFIG_NOIDPROBE \
- | PSM_CONFIG_NORESET \
- | PSM_CONFIG_FORCETAP \
- | PSM_CONFIG_IGNPORTERROR)
+ | PSM_CONFIG_NOCHECKSYNC)
/* other flags (flags) */
+/*
+ * Pass mouse data packet to the user land program `as is', even if
+ * the mouse has vendor-specific enhanced features and uses non-standard
+ * packet format. Otherwise manipulate the mouse data packet so that
+ * it can be recognized by the programs which can only understand
+ * the standard packet format.
+*/
+#define PSM_FLAGS_NATIVEMODE 0x0200
/* for backward compatibility */
#define OLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t)
@@ -240,19 +238,14 @@ static int get_aux_id __P((KBDC));
static int set_mouse_sampling_rate __P((KBDC, int));
static int set_mouse_scaling __P((KBDC, int));
static int set_mouse_resolution __P((KBDC, int));
-#ifdef PSM_RESETAFTERSUSPEND
static int set_mouse_mode __P((KBDC));
-#endif /* PSM_RESETAFTERSUSPEND */
static int get_mouse_buttons __P((KBDC));
static int is_a_mouse __P((int));
static void recover_from_error __P((KBDC));
static int restore_controller __P((KBDC, int));
-#ifdef PSM_RESETAFTERSUSPEND
static int reinitialize __P((int, mousemode_t *));
-#endif
static int doopen __P((int, int));
static char *model_name(int);
-static ointhand2_t psmintr;
/* vendor specific features */
typedef int probefunc_t __P((struct psm_softc *));
@@ -287,7 +280,6 @@ static struct {
{ MOUSE_MODEL_GENERIC,
0xc0, MOUSE_PS2_PACKETSIZE, NULL, },
};
-#define GENERIC_MOUSE_ENTRY 6
/* device driver declarateion */
struct isa_driver psmdriver = { psmprobe, psmattach, "psm", FALSE };
@@ -435,7 +427,6 @@ set_mouse_resolution(KBDC kbdc, int val)
return ((res == PSM_ACK) ? val : -1);
}
-#ifdef PSM_RESETAFTERSUSPEND
/*
* NOTE: once `set_mouse_mode()' is called, the mouse device must be
* re-enabled by calling `enable_aux_dev()'
@@ -451,8 +442,6 @@ set_mouse_mode(KBDC kbdc)
return (res == PSM_ACK);
}
-#endif /* PSM_RESETAFTERSUSPEND */
-
static int
get_mouse_buttons(KBDC kbdc)
@@ -570,7 +559,6 @@ restore_controller(KBDC kbdc, int command_byte)
}
}
-#ifdef PSM_RESETAFTERSUSPEND
/*
* Re-initialize the aux port and device. The aux port must be enabled
* and its interrupt must be disabled before calling this routine.
@@ -598,28 +586,19 @@ reinitialize(int unit, mousemode_t *mode)
case -1: /* time out */
default: /* error */
recover_from_error(kbdc);
- if (sc->config & PSM_CONFIG_IGNPORTERROR)
- break;
log(LOG_ERR, "psm%d: the aux port is not functioning (%d).\n",
unit, i);
return FALSE;
}
- if (sc->config & PSM_CONFIG_NORESET) {
- /*
- * Don't try to reset the pointing device. It may possibly be
- * left in the unknown state, though...
- */
- } else {
- /*
- * NOTE: some controllers appears to hang the `keyboard' when
- * the aux port doesn't exist and `PSMC_RESET_DEV' is issued.
- */
- if (!reset_aux_dev(kbdc)) {
- recover_from_error(kbdc);
- log(LOG_ERR, "psm%d: failed to reset the aux device.\n", unit);
- return FALSE;
- }
+ /*
+ * NOTE: some controllers appears to hang the `keyboard' when
+ * the aux port doesn't exist and `PSMC_RESET_DEV' is issued.
+ */
+ if (!reset_aux_dev(kbdc)) {
+ recover_from_error(kbdc);
+ log(LOG_ERR, "psm%d: failed to reset the aux device.\n", unit);
+ return FALSE;
}
/*
@@ -632,19 +611,15 @@ reinitialize(int unit, mousemode_t *mode)
}
empty_both_buffers(kbdc, 10); /* remove stray data if any */
- if (sc->config & PSM_CONFIG_NOIDPROBE) {
- i = GENERIC_MOUSE_ENTRY;
- } else {
- /* FIXME: hardware ID, mouse buttons? */
-
- /* other parameters */
- for (i = 0; vendortype[i].probefunc != NULL; ++i) {
- if ((*vendortype[i].probefunc)(sc)) {
- if (verbose >= 2)
- log(LOG_ERR, "psm%d: found %s\n",
- unit, model_name(vendortype[i].model));
- break;
- }
+ /* FIXME: hardware ID, mouse buttons? */
+
+ /* other parameters */
+ for (i = 0; vendortype[i].probefunc != NULL; ++i) {
+ if ((*vendortype[i].probefunc)(sc)) {
+ if (verbose >= 2)
+ log(LOG_ERR, "psm%d: found %s\n",
+ unit, model_name(vendortype[i].model));
+ break;
}
}
@@ -677,7 +652,6 @@ reinitialize(int unit, mousemode_t *mode)
return TRUE;
}
-#endif /* PSM_RESETAFTERSUSPEND */
static int
doopen(int unit, int command_byte)
@@ -818,7 +792,6 @@ psmprobe(struct isa_device *dvp)
printf("psm%d: unable to set the command byte.\n", unit);
endprobe(0);
}
- write_controller_command(sc->kbdc, KBDC_ENABLE_AUX_PORT);
/*
* NOTE: `test_aux_port()' is designed to return with zero if the aux
@@ -849,8 +822,6 @@ psmprobe(struct isa_device *dvp)
case -1: /* time out */
default: /* error */
recover_from_error(sc->kbdc);
- if (sc->config & PSM_CONFIG_IGNPORTERROR)
- break;
restore_controller(sc->kbdc, command_byte);
if (verbose)
printf("psm%d: the aux port is not functioning (%d).\n",
@@ -858,25 +829,17 @@ psmprobe(struct isa_device *dvp)
endprobe(0);
}
- if (sc->config & PSM_CONFIG_NORESET) {
- /*
- * Don't try to reset the pointing device. It may possibly be
- * left in the unknown state, though...
- */
- } else {
- /*
- * NOTE: some controllers appears to hang the `keyboard' when the aux
- * port doesn't exist and `PSMC_RESET_DEV' is issued.
- */
- if (!reset_aux_dev(sc->kbdc)) {
- recover_from_error(sc->kbdc);
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: failed to reset the aux device.\n", unit);
- endprobe(0);
- }
+ /*
+ * NOTE: some controllers appears to hang the `keyboard' when the aux
+ * port doesn't exist and `PSMC_RESET_DEV' is issued.
+ */
+ if (!reset_aux_dev(sc->kbdc)) {
+ recover_from_error(sc->kbdc);
+ restore_controller(sc->kbdc, command_byte);
+ if (verbose)
+ printf("psm%d: failed to reset the aux device.\n", unit);
+ endprobe(0);
}
-
/*
* both the aux port and the aux device is functioning, see if the
* device can be enabled. NOTE: when enabled, the device will start
@@ -884,12 +847,11 @@ psmprobe(struct isa_device *dvp)
* the device can be enabled.
*/
if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) {
- /* MOUSE ERROR */
- recover_from_error(sc->kbdc);
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: failed to enable the aux device.\n", unit);
- endprobe(0);
+ /* MOUSE ERROR */
+ restore_controller(sc->kbdc, command_byte);
+ if (verbose)
+ printf("psm%d: failed to enable the aux device.\n", unit);
+ endprobe(0);
}
/* save the default values after reset */
@@ -925,21 +887,16 @@ psmprobe(struct isa_device *dvp)
break;
}
- if (sc->config & PSM_CONFIG_NOIDPROBE) {
- sc->hw.buttons = 2;
- i = GENERIC_MOUSE_ENTRY;
- } else {
- /* # of buttons */
- sc->hw.buttons = get_mouse_buttons(sc->kbdc);
-
- /* other parameters */
- for (i = 0; vendortype[i].probefunc != NULL; ++i) {
- if ((*vendortype[i].probefunc)(sc)) {
- if (verbose >= 2)
- printf("psm%d: found %s\n",
- unit, model_name(vendortype[i].model));
- break;
- }
+ /* # of buttons */
+ sc->hw.buttons = get_mouse_buttons(sc->kbdc);
+
+ /* other parameters */
+ for (i = 0; vendortype[i].probefunc != NULL; ++i) {
+ if ((*vendortype[i].probefunc)(sc)) {
+ if (verbose >= 2)
+ printf("psm%d: found %s\n",
+ unit, model_name(vendortype[i].model));
+ break;
}
}
@@ -952,8 +909,6 @@ psmprobe(struct isa_device *dvp)
sc->dflt_mode.syncmask[0] = 0;
else
sc->dflt_mode.syncmask[0] = vendortype[i].syncmask;
- if (sc->config & PSM_CONFIG_FORCETAP)
- sc->mode.syncmask[0] &= ~MOUSE_PS2_TAP;
sc->dflt_mode.syncmask[1] = 0; /* syncbits */
sc->mode = sc->dflt_mode;
sc->mode.packetsize = vendortype[i].packetsize;
@@ -1013,7 +968,7 @@ psmprobe(struct isa_device *dvp)
psm_softc[unit] = sc;
kbdc_set_device_mask(sc->kbdc, mask | KBD_AUX_CONTROL_BITS);
kbdc_lock(sc->kbdc, FALSE);
- return ((dvp->id_iobase < 0) ? -1 : IO_PSMSIZE);
+ return (IO_PSMSIZE);
}
static int
@@ -1022,8 +977,6 @@ psmattach(struct isa_device *dvp)
int unit = dvp->id_unit;
struct psm_softc *sc = psm_softc[unit];
- dvp->id_ointr = psmintr;
-
if (sc == NULL) /* shouldn't happen */
return (0);
@@ -1709,7 +1662,7 @@ psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
return error;
}
-static void
+void
psmintr(int unit)
{
/*
@@ -1778,9 +1731,6 @@ psmintr(int unit)
z = 0;
ms.obutton = sc->button; /* previous button state */
ms.button = butmap[c & MOUSE_PS2_BUTTONS];
- /* `tapping' action */
- if (sc->config & PSM_CONFIG_FORCETAP)
- ms.button |= ((c & MOUSE_PS2_TAP)) ? 0 : MOUSE_BUTTON4DOWN;
switch (sc->hw.model) {