Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pckbc Apply patch from Peter Seebach (in private Mai...



details:   https://anonhg.NetBSD.org/src/rev/fd677b8b92f4
branches:  trunk
changeset: 533715:fd677b8b92f4
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Jul 08 07:43:31 2002 +0000

description:
Apply patch from Peter Seebach (in private Mail, similar to the one proposed
in PR kern/17506):

If we reset the mouse and discover a different protocol after the reset
than before, reset it again after one second. This makes protocol detection
after a KVA switched to another machine more reliable and should not affect
the standard situation with one mouse connected to one machine.

diffstat:

 sys/dev/pckbc/pms.c |  40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diffs (88 lines):

diff -r 4e2f4bdc8439 -r fd677b8b92f4 sys/dev/pckbc/pms.c
--- a/sys/dev/pckbc/pms.c       Mon Jul 08 02:54:58 2002 +0000
+++ b/sys/dev/pckbc/pms.c       Mon Jul 08 07:43:31 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pms.c,v 1.6 2002/05/29 09:30:35 martin Exp $ */
+/* $NetBSD: pms.c,v 1.7 2002/07/08 07:43:31 martin Exp $ */
 
 /*-
  * Copyright (c) 1994 Charles M. Hannum.
@@ -24,12 +24,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.6 2002/05/29 09:30:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.7 2002/07/08 07:43:31 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
+#include <sys/kernel.h>
 #include <sys/kthread.h>
 
 #include <machine/bus.h>
@@ -253,9 +254,6 @@
 {
        u_char cmd[1];
        int res;
-#ifdef PMS_PREFER_PROTOCOL
-       int i;
-#endif
 
        sc->inputstate = 0;
        sc->buttons = 0;
@@ -431,6 +429,7 @@
        struct pms_softc *sc = arg;
        u_char cmd[1], resp[2];
        int res;
+       int save_protocol;
 
        for (;;) {
                tsleep(&sc->sc_enabled, PWAIT, "pmsreset", 0);
@@ -441,6 +440,7 @@
                        printf("%s: resetting mouse interface\n", 
                            sc->sc_dev.dv_xname);
 #endif
+               save_protocol = sc->protocol;
                pms_disable(sc);
                cmd[0] = PMS_RESET;
                res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1,
@@ -448,8 +448,36 @@
                if (res)
                        DPRINTF(("%s: reset error %d\n", sc->sc_dev.dv_xname, 
                            res));
-               sc->protocol = PMS_UNKNOWN;     /* reprobe protocol */
+               sc->protocol = PMS_UNKNOWN;
                pms_enable(sc);
+               if (sc->protocol != save_protocol) {
+#if defined(PMSDEBUG) || defined(DIAGNOSTIC)
+                       printf("%s: protocol change, sleeping and retrying\n",
+                           sc->sc_dev.dv_xname);
+#endif
+                       pms_disable(sc);
+                       cmd[0] = PMS_RESET;
+                       res = pckbc_enqueue_cmd(sc->sc_kbctag,
+                           sc->sc_kbcslot, cmd, 1, 2, 1, resp);
+                       if (res)
+                               DPRINTF(("%s: reset error %d\n",
+                                   sc->sc_dev.dv_xname, res));
+                       tsleep(pms_reset_thread, PWAIT, "pmsreset", hz);
+                       cmd[0] = PMS_RESET;
+                       res = pckbc_enqueue_cmd(sc->sc_kbctag,
+                           sc->sc_kbcslot, cmd, 1, 2, 1, resp);
+                       if (res)
+                               DPRINTF(("%s: reset error %d\n",
+                                   sc->sc_dev.dv_xname, res));
+                       sc->protocol = PMS_UNKNOWN;     /* reprobe protocol */
+                       pms_enable(sc);
+#if defined(PMSDEBUG) || defined(DIAGNOSTIC)
+                       if (sc->protocol != save_protocol) {
+                               printf("%s: protocol changed.\n",
+                                   sc->sc_dev.dv_xname);
+                       }
+#endif
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index