"ext Paul Anderson" <[EMAIL PROTECTED]> writes:
[...]
> > It hangs in this loop:
> > 
> >   while ((inb(0x64) & 2) == 2); /* wait */
> > 
> > I guess that line is trying to read something from an AT keyboard, but
> > I don't have one... 4.0.3 did not have this problem.
> > 
> > Just putting a 'return' before the infinite loop fixes the problem,
> > and I can also use my USB keyboard. But I don't believe this is a good
> > fix... :)

[...]

> What type of hardware are you using?
>
> This problem can arise if you are talking to a USB 
> keyboard on a system without a PS/2 controller.

I'm using a 'Nokia Mediaterminal', and you're right, it doesn't have a
PS/2 controller.

> The attached patch should address this.  Unfortunately,
> it's not based on the latest snapshot of that
> file, so someone could have already applied a similar
> fix, or the line numbers could be slightly off.
> It essentially adds a countdown to the 'while' loops in
> xf86SetKbdRepeat() so that it doesn't spin forever.
> 
> Let me know if this works.

Pretty close; I think you accidentally missed to reset the timeout
variable after the first countdown loop. For some reason it seems to
take much more than 250ms to time out. I decided to just return if the
first inb() times out. The complete patch is below, it's your patch +
check for timeout==0, and I verified it against today's CVS. I hope
something like this will be applied to the main tree.

Regards,

Pontus

Index: programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v
retrieving revision 3.20
diff -u -u -w -r3.20 lnx_io.c
--- programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c       2001/08/06 20:51:11   
3.20
+++ programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c       2001/09/25 08:04:26
@@ -34,6 +34,8 @@
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
 
+#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
+
 void
 xf86SoundKbdBell(int loudness, int pitch, int duration)
 {
@@ -140,6 +142,7 @@
 #endif
 {
   int i;
+  int timeout;
   int         value = 0x7f;    /* Maximum delay with slowest rate */
 
 #ifdef __sparc__
@@ -193,10 +196,18 @@
       value |= i << 5;
       break;
     }
+
+  timeout = KBC_TIMEOUT;
+  while (((inb(0x64) & 2) == 2) && --timeout)
+       usleep(1000); /* wait */
 
-  while ((inb(0x64) & 2) == 2); /* wait */
+  if (timeout == 0)
+      return;
+
   outb(0x60, 0xf3);             /* set typematic rate */
-  while ((inb(0x64) & 2) == 2); /* wait */
+  while (((inb(0x64) & 2) == 2) && --timeout)
+       usleep(1000); /* wait */
+
   usleep(10000);
   outb(0x60, value);
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to