On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
Kevin O'Connor kevin@koconnor.net writes:
Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in. The detection for NAK was added so that it doesn't take a full second to recognize that no keyboard is present. The patch you sent would loop infinitely in this situation.
Yes, the patch was only for testing purposes. :)
I feared that are controllers out there that behave like this, so i have to find another solution.
How about something like (untested):
--- a/src/ps2port.c +++ b/src/ps2port.c @@ -438,9 +438,14 @@ keyboard_init(void *data)
/* ------------------- keyboard side ------------------------*/ /* reset keyboard and self test (keyboard side) */ - ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); - if (ret) - return; + u64 end = calc_future_tsc(4000); + for (;;) { + ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); + if (!ret) + break; + if (check_tsc(end)) + return; + } if (param[0] != 0xaa) { dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]); return;
If it works, the 4000 could be turned into a config option.
-Kevin