Subject: kern/17506: Possible improvement in mouse resets
To: None <gnats-bugs@gnats.netbsd.org>
From: seebs <seebs@ged.plethora.net>
List: netbsd-bugs
Date: 07/07/2002 12:49:58
>Number:         17506
>Category:       kern
>Synopsis:       my old mouse reset code failed too often
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 07 10:52:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     seebs
>Release:        NetBSD 1.6B
>Organization:
	
>Environment:
System: NetBSD ged.plethora.net 1.6B NetBSD 1.6B (GED) #1: Fri Jul 5 09:37:47 CDT 2002 seebs@ged.plethora.net:/usr/src/sys/arch/i386/compile/GED i386
Architecture: i386
Machine: i386
>Description:
	I contributed code a while back to probe PS/2 mice for their protocol,
	and re-probe them in the event of confusion.  About one time in five
	to ten, this code failed to redetect my scroll wheel correctly; after
	some observation of the Windows mouse driver, I have what appears to
	be a fix, or at the very least an improvement.
>How-To-Repeat:
	Play around with a KVM switch.
>Fix:
(Not sure what the #ifdef was still doing there, but it's gone now.)

Instead of just resetting the mouse once, we send a reset, wait a second, and
then send another reset; this appears to give the mouse time to "properly"
reset itself.

Index: pms.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pckbc/pms.c,v
retrieving revision 1.6
diff -c -r1.6 pms.c
*** pms.c	2002/05/29 09:30:35	1.6
--- pms.c	2002/07/07 17:51:13
***************
*** 30,35 ****
--- 30,36 ----
  #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,261 ****
  {
  	u_char cmd[1];
  	int res;
- #ifdef PMS_PREFER_PROTOCOL
- 	int i;
- #endif
  
  	sc->inputstate = 0;
  	sc->buttons = 0;
--- 254,259 ----
***************
*** 442,447 ****
--- 440,452 ----
  			    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);
>Release-Note:
>Audit-Trail:
>Unformatted: