From owner-freebsd-current@FreeBSD.ORG Fri Aug 13 23:00:00 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BCDF16A4CE for ; Fri, 13 Aug 2004 23:00:00 +0000 (GMT) Received: from aslan.scsiguy.com (mail.scsiguy.com [63.229.232.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 79DC943D2F for ; Fri, 13 Aug 2004 22:59:59 +0000 (GMT) (envelope-from gibbs@scsiguy.com) Received: from aslan.scsiguy.com (aslan.scsiguy.com [63.229.232.106]) by aslan.scsiguy.com (8.12.11/8.12.11) with ESMTP id i7DMxtIX045762 for ; Fri, 13 Aug 2004 16:59:55 -0600 (MDT) (envelope-from gibbs@scsiguy.com) Date: Fri, 13 Aug 2004 16:59:55 -0600 From: "Justin T. Gibbs" To: current@FreeBSD.org Message-ID: X-Mailer: Mulberry/3.1.6 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Change in PSM sync behavior X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Justin T. Gibbs" List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2004 23:00:00 -0000 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)) {