From 25f43374545965d80401603a041610eec12a6bb5 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 18 Apr 1999 15:12:11 +0000 Subject: [PATCH] Merge revs 1.57 and 1.60 of i386/isa/psm.c --- sys/dev/atkbdc/psm.c | 148 ++++++++++++++++++++++++++++--------------- sys/isa/psm.c | 148 ++++++++++++++++++++++++++++--------------- 2 files changed, 194 insertions(+), 102 deletions(-) diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index b3dc1d0583a..39aaa7848b6 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/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.3 1999/01/23 16:53:28 dfr Exp $ + * $Id: psm.c,v 1.4 1999/04/16 21:22:34 peter Exp $ */ /* @@ -62,6 +62,7 @@ */ #include "psm.h" +/* #include "apm.h" */ #include "opt_devfs.h" #include "opt_psm.h" @@ -185,20 +186,20 @@ devclass_t psm_devclass; #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_NOCHECKSYNC \ + | PSM_CONFIG_NOIDPROBE \ + | PSM_CONFIG_NORESET \ + | PSM_CONFIG_FORCETAP \ + | PSM_CONFIG_IGNPORTERROR) /* 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) @@ -243,12 +244,16 @@ 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 void psmintr(void*); @@ -286,6 +291,7 @@ static struct { { MOUSE_MODEL_GENERIC, 0xc0, MOUSE_PS2_PACKETSIZE, NULL, }, }; +#define GENERIC_MOUSE_ENTRY 6 /* device driver declarateion */ static device_method_t psm_methods[] = { @@ -447,6 +453,7 @@ 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()' @@ -462,6 +469,8 @@ set_mouse_mode(KBDC kbdc) return (res == PSM_ACK); } +#endif /* PSM_RESETAFTERSUSPEND */ + static int get_mouse_buttons(KBDC kbdc) @@ -579,6 +588,7 @@ 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. @@ -606,19 +616,28 @@ 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; } - /* - * 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; + 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; + } } /* @@ -631,15 +650,19 @@ reinitialize(int unit, mousemode_t *mode) } empty_both_buffers(kbdc, 10); /* remove stray data if any */ - /* FIXME: hardware ID, mouse buttons? */ + 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; + /* 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; + } } } @@ -672,6 +695,7 @@ reinitialize(int unit, mousemode_t *mode) return TRUE; } +#endif /* PSM_RESETAFTERSUSPEND */ static int doopen(int unit, int command_byte) @@ -807,6 +831,7 @@ psmprobe(device_t dev) printf("psm%d: unable to set the command byte.\n", unit); endprobe(ENXIO); } + write_controller_command(sc->kbdc, KBDC_ENABLE_AUX_PORT); /* * NOTE: `test_aux_port()' is designed to return with zero if the aux @@ -837,6 +862,8 @@ psmprobe(device_t dev) 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", @@ -844,17 +871,25 @@ psmprobe(device_t dev) endprobe(ENXIO); } - /* - * 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(ENXIO); + 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(ENXIO); + } } + /* * both the aux port and the aux device is functioning, see if the * device can be enabled. NOTE: when enabled, the device will start @@ -862,10 +897,11 @@ psmprobe(device_t dev) * the device can be enabled. */ if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) { - /* MOUSE ERROR */ - restore_controller(sc->kbdc, command_byte); - if (verbose) - printf("psm%d: failed to enable the aux device.\n", unit); + /* 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(ENXIO); } @@ -902,16 +938,21 @@ psmprobe(device_t dev) break; } - /* # of buttons */ - sc->hw.buttons = get_mouse_buttons(sc->kbdc); + 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; + /* 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; + } } } @@ -924,6 +965,8 @@ psmprobe(device_t dev) 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; @@ -1759,6 +1802,9 @@ psmintr(void *arg) 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) { @@ -1868,12 +1914,12 @@ psmpoll(dev_t dev, int events, struct proc *p) /* Return true if a mouse event available */ s = spltty(); - if (events & (POLLIN | POLLRDNORM)) + if (events & (POLLIN | POLLRDNORM)) { if (sc->queue.count > 0) revents |= events & (POLLIN | POLLRDNORM); else selrecord(p, &sc->rsel); - + } splx(s); return (revents); diff --git a/sys/isa/psm.c b/sys/isa/psm.c index b3dc1d0583a..39aaa7848b6 100644 --- a/sys/isa/psm.c +++ b/sys/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.3 1999/01/23 16:53:28 dfr Exp $ + * $Id: psm.c,v 1.4 1999/04/16 21:22:34 peter Exp $ */ /* @@ -62,6 +62,7 @@ */ #include "psm.h" +/* #include "apm.h" */ #include "opt_devfs.h" #include "opt_psm.h" @@ -185,20 +186,20 @@ devclass_t psm_devclass; #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_NOCHECKSYNC \ + | PSM_CONFIG_NOIDPROBE \ + | PSM_CONFIG_NORESET \ + | PSM_CONFIG_FORCETAP \ + | PSM_CONFIG_IGNPORTERROR) /* 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) @@ -243,12 +244,16 @@ 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 void psmintr(void*); @@ -286,6 +291,7 @@ static struct { { MOUSE_MODEL_GENERIC, 0xc0, MOUSE_PS2_PACKETSIZE, NULL, }, }; +#define GENERIC_MOUSE_ENTRY 6 /* device driver declarateion */ static device_method_t psm_methods[] = { @@ -447,6 +453,7 @@ 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()' @@ -462,6 +469,8 @@ set_mouse_mode(KBDC kbdc) return (res == PSM_ACK); } +#endif /* PSM_RESETAFTERSUSPEND */ + static int get_mouse_buttons(KBDC kbdc) @@ -579,6 +588,7 @@ 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. @@ -606,19 +616,28 @@ 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; } - /* - * 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; + 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; + } } /* @@ -631,15 +650,19 @@ reinitialize(int unit, mousemode_t *mode) } empty_both_buffers(kbdc, 10); /* remove stray data if any */ - /* FIXME: hardware ID, mouse buttons? */ + 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; + /* 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; + } } } @@ -672,6 +695,7 @@ reinitialize(int unit, mousemode_t *mode) return TRUE; } +#endif /* PSM_RESETAFTERSUSPEND */ static int doopen(int unit, int command_byte) @@ -807,6 +831,7 @@ psmprobe(device_t dev) printf("psm%d: unable to set the command byte.\n", unit); endprobe(ENXIO); } + write_controller_command(sc->kbdc, KBDC_ENABLE_AUX_PORT); /* * NOTE: `test_aux_port()' is designed to return with zero if the aux @@ -837,6 +862,8 @@ psmprobe(device_t dev) 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", @@ -844,17 +871,25 @@ psmprobe(device_t dev) endprobe(ENXIO); } - /* - * 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(ENXIO); + 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(ENXIO); + } } + /* * both the aux port and the aux device is functioning, see if the * device can be enabled. NOTE: when enabled, the device will start @@ -862,10 +897,11 @@ psmprobe(device_t dev) * the device can be enabled. */ if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) { - /* MOUSE ERROR */ - restore_controller(sc->kbdc, command_byte); - if (verbose) - printf("psm%d: failed to enable the aux device.\n", unit); + /* 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(ENXIO); } @@ -902,16 +938,21 @@ psmprobe(device_t dev) break; } - /* # of buttons */ - sc->hw.buttons = get_mouse_buttons(sc->kbdc); + 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; + /* 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; + } } } @@ -924,6 +965,8 @@ psmprobe(device_t dev) 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; @@ -1759,6 +1802,9 @@ psmintr(void *arg) 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) { @@ -1868,12 +1914,12 @@ psmpoll(dev_t dev, int events, struct proc *p) /* Return true if a mouse event available */ s = spltty(); - if (events & (POLLIN | POLLRDNORM)) + if (events & (POLLIN | POLLRDNORM)) { if (sc->queue.count > 0) revents |= events & (POLLIN | POLLRDNORM); else selrecord(p, &sc->rsel); - + } splx(s); return (revents);