*BSD News Article 87117


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!vixen.cso.uiuc.edu!uwm.edu!news.he.net!nr1.scn.co.jp!news02.so-net.or.jp!news01.so-net.or.jp!sinfony-news01!wnoc-tyo-news!news.nc.u-tokyo.ac.jp!train.ad.jp!iroha.utsunomiya-u.ac.jp!nikko.utsunomiya-u.ac.jp!yokota
From: yokota@zodiac.mech.utsunomiya-u.ac.jp. (Kazutaka YOKOTA)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: X11R6 on compaq laptop
Date: 30 Jan 1997 03:35:06 GMT
Organization: Utsunomiya University, Utsunomiya, Japan
Lines: 364
Message-ID: <5cp4ta$a5q@nikko.utsunomiya-u.ac.jp>
References: <5cea5b$8nq@news.montanavision.net>
NNTP-Posting-Host: zodiac.mech.utsunomiya-u.ac.jp
X-Newsreader: mnews [version 1.19PL2] 1996-01/26(Fri)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:34240

ron@3rivers.net wrote:

ron>>I just got X11R6 running at 800x600 on my 4120 compaq armada, with
ron>>2.2-BETA, by copying over a previous version XF86_SVGA, and 
ron>>kludging the device section. However, I haven't yet succeeded in
ron>>getting the touchpad mouse to be recognized. I compiled psm0 in
ron>>the kernel, but it is not found on boot. Any suggestions???
ron>>
ron>>Ron

There have been reports that built-in PS/2 mouse/pad devices in some
laptop computers are not recognized under 2.2-BETA. Here is a patch
which successfully fixed the problems with Dell and DEC laptops.

Apply the patch in /usr/src/sys/i386/isa (psm.c, kbdio.c, and kbdio.h
will be modified), rebuild the kernel, and see if it works for you.

If you have further questions, don't hesitate to ask me.

Kazu

===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/psm.c,v
retrieving revision 1.25.2.3
retrieving revision 1.25.2.5
diff -u -r1.25.2.3 -r1.25.2.5
--- src/sys/i386/isa/psm.c	1996/12/03 10:47:24	1.25.2.3
+++ src/sys/i386/isa/psm.c	1997/01/15 12:03:33	1.25.2.5
@@ -19,7 +19,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.25.2.3 1996/12/03 10:47:24 phk Exp $
+ * $Id: psm.c,v 1.25.2.5 1997/01/15 12:03:33 sos Exp $
  */
 
 /*
@@ -435,6 +435,11 @@
     int i;
 
     switch((i = test_aux_port(port))) {
+    case 1:	/* ignore this error */
+	if (verbose)
+	    log(LOG_DEBUG, "psm%d: strange result for test aux port (%d).\n",
+	        PSM_UNIT(dev), i);
+	/* fall though */
     case 0:	/* no error */
     	break;
     case -1: 	/* time out */
@@ -478,10 +483,14 @@
     }
 
     /* just check the status of the mouse */
+    i = get_mouse_status(port, stat);
     if (verbose) {
-        get_mouse_status(port, stat);
-        log(LOG_DEBUG, "psm%d: status %02x %02x %02x (reinitialized)\n",
-            PSM_UNIT(dev), stat[0], stat[1], stat[2]);
+	if (i)
+            log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
+                PSM_UNIT(dev), stat[0], stat[1], stat[2]);
+	else
+	    log(LOG_DEBUG, "psm%d: failed to get mouse status\n", 
+		PSM_UNIT(dev));
     }
 
     return TRUE;
@@ -508,6 +517,8 @@
     if (unit >= NPSM)
         return (0);
 
+    psm_softc[unit] = NULL; 
+
     sc =  malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
 
     bzero(sc, sizeof *sc);
@@ -556,6 +567,7 @@
      */
 
     /* save the current command byte; it will be used later */
+    empty_both_buffers(ioport, 20);	
     if (!write_controller_command(ioport,KBDC_GET_COMMAND_BYTE)) {
         /* CONTROLLER ERROR */
         printf("psm%d: failed to get the current command byte value.\n",
@@ -604,8 +616,18 @@
      * supporsed to return with an error code or simply time out. In any
      * case, we have to continue probing the port even when the controller
      * passes this test.
+     *
+     * XXX: some controllers erroneously return the error code 1 when
+     * it has the perfectly functional aux port. We have to ignore this
+     * error code. Even if the controller HAS error with the aux port,
+     * it will be detected later...
      */
     switch ((i = test_aux_port(ioport))) {
+    case 1:	   /* ignore this error */
+        if (verbose)
+	    printf("psm%d: strange result for test aux port (%d).\n",
+	        unit, i);
+	/* fall though */
     case 0:        /* no error */
         break;
     case -1:        /* time out */
@@ -693,6 +715,7 @@
 
     /* set mouse parameters */
     /* FIXME:XXX should we set them in `psmattach()' rather than here? */
+#if 0
     if (setparams) {
         if (sc->mode.rate > 0)
             sc->mode.rate = set_mouse_sampling_rate(ioport, sc->mode.rate);
@@ -703,12 +726,25 @@
     /* FIXME:XXX I don't know if these parameters are reasonable */
     set_mouse_scaling(ioport);    /* 1:1 scaling */
     set_mouse_mode(ioport);    /* stream mode */
+#else
+    i = send_aux_command(ioport, PSMC_SET_DEFAULTS);
+    if (verbose >= 2)
+	log(LOG_DEBUG, "psm%d: SET_DEFAULTS return code:%04x\n", unit, i);
+#endif
 
     /* just check the status of the mouse */
+    /* 
+     * XXX there are some arcane controller/mouse combinations out there,
+     * which hung the controller unless there is data transmission 
+     * after ACK from the mouse.
+     */
+    i = get_mouse_status(ioport, stat);
     if (verbose) {
-        get_mouse_status(ioport, stat);
-        log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
-            unit, stat[0], stat[1], stat[2]);
+	if (i)
+            log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
+                unit, stat[0], stat[1], stat[2]);
+	else
+	    log(LOG_DEBUG, "psm%d: failed to get mouse status\n", unit);
     }
 
     /* disable the aux port for now... */
@@ -745,6 +781,9 @@
     int unit = dvp->id_unit;
     struct psm_softc *sc = psm_softc[unit];
 
+    if (sc == NULL)    /* shouldn't happen */ 
+	return (0); 
+
     /* initial operation mode */
     sc->mode.accelfactor = PSM_ACCEL;
     sc->mode.protocol = MOUSE_PROTO_PS2;
@@ -763,8 +802,11 @@
         DV_CHR, 0, 0, 0666, "npsm%d", unit);
 #endif
 
-    printf("psm%d: device ID %d, %d buttons?\n",
-        unit, sc->hw.hwid, sc->hw.buttons);
+    if (verbose)
+        printf("psm%d: device ID %d, %d buttons?\n",
+            unit, sc->hw.hwid, sc->hw.buttons);
+    else
+        printf("psm%d: device ID %d\n", unit, sc->hw.hwid);
 
     if (bootverbose)
         --verbose;
@@ -779,6 +821,7 @@
     int ioport;
     struct psm_softc *sc;
     int stat[3];
+    int ret;
 
     /* Validate unit number */
     if (unit >= NPSM)
@@ -786,7 +829,7 @@
 
     /* Get device data */
     sc = psm_softc[unit];
-    if ((sc->state & PSM_VALID) == 0)
+    if ((sc == NULL) || (sc->state & PSM_VALID) == 0)
 	/* the device is no longer valid/functioning */
         return (ENXIO);
     ioport = sc->addr;
@@ -849,10 +892,14 @@
         return (EIO);
     }
 
+    ret = get_mouse_status(ioport, stat);
     if (verbose >= 2) {
-        get_mouse_status(ioport, stat);
-        log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
-            unit, stat[0], stat[1], stat[2]);
+	if (ret)
+            log(LOG_DEBUG, "psm%d: status %02x %02x %02x (psmopen)\n",
+                unit, stat[0], stat[1], stat[2]);
+	else
+	    log(LOG_DEBUG, "psm%d: failed to get mouse status (psmopen).\n",
+		unit);
     }
 
     /* enable the aux port and interrupt */
@@ -877,6 +924,8 @@
 {
     struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
     int ioport = sc->addr;
+    int stat[3];
+    int ret;
 
     /* disable the aux interrupt */
     if (!set_controller_command_byte(ioport, sc->command_byte,
@@ -905,6 +954,17 @@
 	log(LOG_ERR, "psm%d: failed to disable the device (psmclose).\n",
 	    PSM_UNIT(dev));
     }
+
+    ret = get_mouse_status(ioport, stat);
+    if (verbose >= 2) {
+	if (ret)
+            log(LOG_DEBUG, "psm%d: status %02x %02x %02x (psmclose)\n",
+                PSM_UNIT(dev), stat[0], stat[1], stat[2]);
+	else
+	    log(LOG_DEBUG, "psm%d: failed to get mouse status (psmclose).\n",
+		PSM_UNIT(dev));
+    }
+
     if (!set_controller_command_byte(ioport, sc->command_byte,
 	KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
 	/* CONTROLLER ERROR; 

===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/kbdio.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- src/sys/i386/isa/kbdio.c	1996/12/04 16:11:39	1.1.2.2
+++ src/sys/i386/isa/kbdio.c	1997/01/15 12:03:38	1.1.2.3
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: kbdio.c,v 1.1.2.2 1996/12/04 16:11:39 phk Exp $
+ * $Id: kbdio.c,v 1.1.2.3 1997/01/15 12:03:38 sos Exp $
  */
 
 #include <sys/param.h>
@@ -295,64 +295,76 @@
 
 /* discard data from the keyboard */
 void
-empty_kbd_buffer(int port, int t)
+empty_kbd_buffer(int port, int wait)
 {
+    int t;
     int b;
     int c = 0;
     int delta = 2;
 
-    for (; t > 0; t -= delta) { 
+    for (t = wait; t > 0; ) { 
         if ((inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
     	   == KBDS_KBD_BUFFER_FULL) {
 	    DELAY(KBDD_DELAYTIME);
-        b = inb(port + KBD_DATA_PORT);
-        ++c;
-    }
+            b = inb(port + KBD_DATA_PORT);
+            ++c;
+	    t = wait;
+	} else {
+	    t -= delta;
+        }
         DELAY(delta*1000);
     }
     if ((verbose >= 2) && (c > 0))
-    log(LOG_DEBUG,"kbdio: %d char read (empty_kbd_buffer)\n",c);
+        log(LOG_DEBUG,"kbdio: %d char read (empty_kbd_buffer)\n",c);
 }
 
 /* discard data from the aux device */
 void
-empty_aux_buffer(int port, int t)
+empty_aux_buffer(int port, int wait)
 {
+    int t;
     int b;
     int c = 0;
     int delta = 2;
 
-    for (; t > 0; t -= delta) { 
+    for (t = wait; t > 0; ) { 
         if ((inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
     	    == KBDS_AUX_BUFFER_FULL) {
 	    DELAY(KBDD_DELAYTIME);
-        b = inb(port + KBD_DATA_PORT);
-        ++c;
-    }
+            b = inb(port + KBD_DATA_PORT);
+            ++c;
+	    t = wait;
+	} else {
+	    t -= delta;
+        }
 	DELAY(delta*1000);
     }
     if ((verbose >= 2) && (c > 0))
-    log(LOG_DEBUG,"kbdio: %d char read (empty_aux_buffer)\n",c);
+        log(LOG_DEBUG,"kbdio: %d char read (empty_aux_buffer)\n",c);
 }
 
 /* discard any data from the keyboard or the aux device */
 void
-empty_both_buffers(int port, int t)
+empty_both_buffers(int port, int wait)
 {
+    int t;
     int b;
     int c = 0;
     int delta = 2;
 
-    for (; t > 0; t -= delta) { 
+    for (t = wait; t > 0; ) { 
         if (inb(port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) {
 	    DELAY(KBDD_DELAYTIME);
-        b = inb(port + KBD_DATA_PORT);
-        ++c;
-    }
+            b = inb(port + KBD_DATA_PORT);
+            ++c;
+	    t = wait;
+	} else {
+	    t -= delta;
+        }
 	DELAY(delta*1000);
     }
     if ((verbose >= 2) && (c > 0))
-    log(LOG_DEBUG,"kbdio: %d char read (empty_both_buffers)\n",c);
+        log(LOG_DEBUG,"kbdio: %d char read (empty_both_buffers)\n",c);
 }
 
 /* keyboard and mouse device control */

===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/kbdio.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- src/sys/i386/isa/kbdio.h	1996/12/04 16:11:45	1.1.2.2
+++ src/sys/i386/isa/kbdio.h	1997/01/15 12:03:41	1.1.2.3
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: kbdio.h,v 1.1.2.2 1996/12/04 16:11:45 phk Exp $
+ * $Id: kbdio.h,v 1.1.2.3 1997/01/15 12:03:41 sos Exp $
  */
 
 #ifndef _I386_ISA_KBDIO_H_
@@ -93,6 +93,7 @@
 #define PSMC_RESET_DEV	     	0x00ff
 #define PSMC_ENABLE_DEV      	0x00f4
 #define PSMC_DISABLE_DEV     	0x00f5
+#define PSMC_SET_DEFAULTS	0x00f6
 #define PSMC_SEND_DEV_ID     	0x00f2
 #define PSMC_SEND_DEV_STATUS 	0x00e9
 #define PSMC_SEND_DEV_DATA	0x00eb