Messages in this thread Patch in this message | | | Date | Tue, 16 Mar 1999 02:14:56 +0100 | From | Ralf Corsepius <> | Subject | Re: /dev/psaux troubles with 2.2.2 |
| |
Johan Myreen wrote:
> For all of you having problems with the PS/2 mouse detection code: here > is a patch based on ideas suggested by Vojtech Pavlik.
> [..]
> > > The patch patches the pc_keyb.c file in the linux/drivers/char/ > directory. > > Please try this out and report problems and success stories.
I have a partial success story for you:
The first loop of your patch fails to detect psaux (sets d3ok=0). The second loop successfully detects psaux (sets d2ok=1), however it doesn't set retval=1.
=> detect_auxiliary_port() fails to detect psaux.
AFAIU, this problem might be just a last-minute screw-up and the patch below might be what you had intented. At least, in this version it seems to work for me (detects psaux inside the second loop).
Ralf
-- Ralf Corsepius Forschungsinstitut fuer Anwendungsorientierte Wissensverarbeitung (FAW) Helmholtzstr. 16, 89081 Ulm, Germany Tel: +49/731/501-8690 mailto:corsepiu@faw.uni-ulm.de FAX: +49/731/501-999 http://www.faw.uni-ulm.de
--- pc_keyb.c.orig Tue Mar 9 17:08:09 1999 +++ pc_keyb.c Tue Mar 16 01:44:53 1999 @@ -739,6 +739,10 @@ spin_lock_irqsave(&kbd_controller_lock, flags); + /* + * Test the aux port in the controller. + */ + /* Put the value 0x5A in the output buffer using the "Write * Auxiliary Device Output Buffer" command (0xD3). Poll the * Status Register for a while to see if the value really @@ -752,20 +756,74 @@ kb_wait(); outb(0x5a, KBD_DATA_REG); /* 0x5a is a random dummy value. */ + loops = 10; do { unsigned char status = inb(KBD_STATUS_REG); if (status & KBD_STAT_OBF) { (void) inb(KBD_DATA_REG); if (status & KBD_STAT_MOUSE_OBF) { - printk(KERN_INFO "Detected PS/2 Mouse Port.\n"); retval = 1; } break; } mdelay(1); } while (--loops); + + if (!retval) { + /* + * Ok, if the test above failed, we have two possibilities: + * - there really is no aux port on the machine + * - the 0xD3 command is not implemented + * Test if the 0xD2 command works. If it does, assume + * we don't have a aux port, if it doesn't, assume + * 0xD2 and 0xD3 are not implemented; proceed with testing. + */ + kb_wait(); + outb(0xD2, KBD_CNTL_REG); + + kb_wait(); + outb(0xa5, KBD_DATA_REG); /* 0xa5 is a random dummy value. */ + + loops = 10; + do { + unsigned char status = inb(KBD_STATUS_REG); + + if (status & KBD_STAT_OBF) { + (void) inb(KBD_DATA_REG); + retval = 1; + break; + } + mdelay(1); + } while (--loops); + + if (!retval) { + /* + * Check using the "Test Mouse Port" command. This command + * is not implemented on all kbd/aux controllers. Another + * problem is that this command can return "true" on machines + * without an AUX port. So we try this as a last resort, + * if the above tests indicate the 0xD2/0xD3 commands are + * broken. + */ + kb_wait(); + outb(KBD_CCMD_TEST_MOUSE, KBD_CNTL_REG); + do { + unsigned char status = inb(KBD_STATUS_REG); + if (status & KBD_STAT_OBF) { + if (inb(KBD_DATA_REG) == 0x00) + retval = 1; + } + mdelay(1); + } while (loops--); + } + } + + spin_unlock_irqrestore(&kbd_controller_lock, flags); + + if (retval == 1) + printk(KERN_INFO "Detected PS/2 Mouse Port.\n"); return retval; } | |