Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Aug 2004 16:59:55 -0600
From:      "Justin T. Gibbs" <gibbs@scsiguy.com>
To:        current@FreeBSD.org
Subject:   Change in PSM sync behavior
Message-ID:  <F56563B4A6F108225A448206@aslan.scsiguy.com>

next in thread | raw e-mail | index | archive | help
I've had this change locally for some time and think it may be
a worth while change to commit to the tree.  My patch defers the
setup of the sync bits until the first "normal" data packet is
received from the mouse.  In the case of Avocent Outlook KVM's,
this avoids a bug in their intellimouse emulator that sends back
incorrect sync when you explicitly request a data packet from the
mouse.  Without this change, you must force the driver into stock
PS/2 mode or be flooded with a never ending stream of "out of sync"
messages.

--
Justin

Index: psm.c
===================================================================
RCS file: /usr/cvs/src/sys/isa/psm.c,v
retrieving revision 1.76
diff -d -u -r1.76 psm.c
--- psm.c	8 Aug 2004 01:26:00 -0000	1.76
+++ psm.c	13 Aug 2004 16:54:27 -0000
@@ -200,6 +200,7 @@
 #define PSM_OPEN		1	/* Device is open */
 #define PSM_ASLP		2	/* Waiting for mouse data */
 #define PSM_SOFTARMED		4	/* Software interrupt armed */
+#define PSM_NEED_SYNCBITS	8	/* Set syncbits using next data pkt */
 
 /* driver configuration flags (config) */
 #define PSM_CONFIG_RESOLUTION	0x000f	/* resolution */
@@ -739,16 +740,8 @@
         set_mouse_mode(kbdc);	
     }
 
-    /* request a data packet and extract sync. bits */
-    if (get_mouse_status(kbdc, stat, 1, 3) < 3) {
-        log(LOG_DEBUG, "psm%d: failed to get data (doinitialize).\n",
-	    sc->unit);
-        sc->mode.syncmask[0] = 0;
-    } else {
-        sc->mode.syncmask[1] = stat[0] & sc->mode.syncmask[0];	/* syncbits */
-	/* the NetScroll Mouse will send three more bytes... Ignore them */
-	empty_aux_buffer(kbdc, 5);
-    }
+    /* Record sync on the next data packet we see. */
+    sc->flags |= PSM_NEED_SYNCBITS;
 
     /* just check the status of the mouse */
     if (get_mouse_status(kbdc, stat, 0, 3) < 3)
@@ -890,7 +883,8 @@
                 (c & KBD_KBD_CONTROL_BITS)
                     | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
             /* CONTROLLER ERROR */
-            log(LOG_ERR, "psm%d: failed to disable the aux port (reinitialize).\n",
+            log(LOG_ERR,
+                "psm%d: failed to disable the aux port (reinitialize).\n",
                 sc->unit);
             err = EIO;
 	}
@@ -1209,15 +1203,8 @@
     }
     set_mouse_scaling(sc->kbdc, 1);
 
-    /* request a data packet and extract sync. bits */
-    if (get_mouse_status(sc->kbdc, stat, 1, 3) < 3) {
-        printf("psm%d: failed to get data.\n", unit);
-        sc->mode.syncmask[0] = 0;
-    } else {
-        sc->mode.syncmask[1] = stat[0] & sc->mode.syncmask[0];	/* syncbits */
-	/* the NetScroll Mouse will send three more bytes... Ignore them */
-	empty_aux_buffer(sc->kbdc, 5);
-    }
+    /* Record sync on the next data packet we see. */
+    sc->flags |= PSM_NEED_SYNCBITS;
 
     /* just check the status of the mouse */
     /* 
@@ -2081,6 +2068,11 @@
 	c = pb->ipacket[0];
 
 	if ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1]) {
+	    if ((sc->flags & PSM_NEED_SYNCBITS) != 0) {
+		sc->mode.syncmask[1] = (c & sc->mode.syncmask[0]);
+		sc->flags &= ~PSM_NEED_SYNCBITS;
+		goto valid_sync;
+	    }
 #if DEBUG
             log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x) %d"
 		" cmds since last error.\n", 
@@ -2119,6 +2111,7 @@
 	    }
 	    continue;
 	}
+valid_sync:
 	/* if this packet is at all bogus then drop the packet. */
 	if (haderror ||
 	    !timeelapsed(&sc->lastinputerr, psmerrsecs, psmerrusecs, &now)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F56563B4A6F108225A448206>