Kevin O'Connor wrote:
]> I also have USB keyboard problems, but my problem is different. For ]> each key I press, it repeats a couple dozen times. I solve the problem ]> by adding a 'break' to usb-hid.c: ]> ]> for (;;) { ]> struct keyevent data; ]> int ret = usb_poll_intr(pipe, &data); ]> if (ret) ]> break; ]> handle_key(&data); ]> break; <================== ] ]Can you generate and send a log with debug level set to 8 and the ]dprintf in usb-hid.c:handle_key() changed to 8? Getting timestamps on ]the log (as with tools/readserial.py) would also help. ] ]> With this change, I am able to type well enough to get windbg started, ]> which is all I needed at the time. But typing is very sluggish. I ]> believe the sluggishness is due to use of 8254 periodic interrupt ]> polling to service the keyboard. ] ]Yeah - since the loop was disabled there's no longer a queue on USB ]key events. This means any keys pressed faster than 55ms are dropped.
Hello Kevin,
I decided to try and debug this myself. The attached patch is what I came up with. Within the limitations of typing abilities, it is now perfect. No sluggishness and no dropped keys. The head == next check was failing when it should have passed. The reason is that the toggleCarry bit is often set in endpoint descriptor dword #2, at least on AMD hardware. Hopefully this change is compatible with qemu, Intel, and other OHCI controllers.
Thanks, Scott
Mask toggleCarry and Halted flags in endpoint descriptor dword #2 so that the remaining head pointer field is valid for comparing with the next pointer.
Signed-off-by: Scott Duplichan scott@notabs.org
--- seabios-0.6.2-original\src\usb-ohci.c Mon Feb 28 21:10:57 2011 +++ seabios-0.6.2\src\usb-ohci.c Sun May 29 02:47:30 2011 @@ -501,7 +501,7 @@
struct ohci_pipe *pipe = container_of(p, struct ohci_pipe, pipe); struct ohci_td *tds = GET_FLATPTR(pipe->tds); - struct ohci_td *head = (void*)GET_FLATPTR(pipe->ed.hwHeadP); + struct ohci_td *head = (void*)(GET_FLATPTR(pipe->ed.hwHeadP) & 0xffffffff0); struct ohci_td *tail = (void*)GET_FLATPTR(pipe->ed.hwTailP); int count = GET_FLATPTR(pipe->count); int pos = (tail - tds + 1) % count;