diff options
author | kan <kan@FreeBSD.org> | 2007-10-15 20:37:34 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2007-10-15 20:37:34 +0000 |
commit | 33db6d7cd5a5d910a4fc1f0818b62019b7ba8e2e (patch) | |
tree | 645e63d94746a57718e06f88c354d2856fe9e9f6 | |
parent | 21c6e78ea76156c007b7b36f2ef60b4fffd62f50 (diff) | |
download | FreeBSD-src-33db6d7cd5a5d910a4fc1f0818b62019b7ba8e2e.zip FreeBSD-src-33db6d7cd5a5d910a4fc1f0818b62019b7ba8e2e.tar.gz |
Make ukbd_getc respect non-blocking behavior if one is requested. Change
ukbd_poll to mark this keyboard instance as polling before calling
usbd_set_polling at USB level. usbd_set_polling runs softintr before
returning, stealing our input and making consequent polling getchar
kind of pointless.
This allows USB keyboards to coexist peacefully with serial console in DDB
and other contexts where polling is used.
MFC after: 1 week
-rw-r--r-- | sys/dev/usb/ukbd.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index d06bd37..4496e86 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -422,7 +422,7 @@ static int ukbd_enable_intr(keyboard_t *kbd, int on, usbd_intr_t *func); static void ukbd_timeout(void *arg); -static int ukbd_getc(ukbd_state_t *state); +static int ukbd_getc(ukbd_state_t *state, int wait); static int probe_keyboard(struct usb_attach_arg *uaa, int flags); static int init_keyboard(ukbd_state_t *state, int *type, int flags); @@ -845,7 +845,7 @@ ukbd_interrupt(keyboard_t *kbd, void *arg) } static int -ukbd_getc(ukbd_state_t *state) +ukbd_getc(ukbd_state_t *state, int wait) { int c; int s; @@ -853,8 +853,11 @@ ukbd_getc(ukbd_state_t *state) if (state->ks_polling) { DPRINTFN(1,("ukbd_getc: polling\n")); s = splusb(); - while (state->ks_inputs <= 0) + while (state->ks_inputs <= 0) { usbd_dopoll(state->ks_iface); + if (wait == FALSE) + break; + } splx(s); } s = splusb(); @@ -930,7 +933,7 @@ ukbd_read(keyboard_t *kbd, int wait) #endif /* UKBD_EMULATE_ATSCANCODE */ /* XXX */ - usbcode = ukbd_getc(state); + usbcode = ukbd_getc(state, wait); if (!KBD_IS_ACTIVE(kbd) || (usbcode == -1)) return -1; ++kbd->kb_count; @@ -1022,7 +1025,7 @@ next_code: /* see if there is something in the keyboard port */ /* XXX */ - usbcode = ukbd_getc(state); + usbcode = ukbd_getc(state, wait); if (usbcode == -1) return NOKEY; ++kbd->kb_count; @@ -1392,9 +1395,9 @@ ukbd_poll(keyboard_t *kbd, int on) s = splusb(); if (on) { - if (state->ks_polling == 0) - usbd_set_polling(dev, on); ++state->ks_polling; + if (state->ks_polling == 1) + usbd_set_polling(dev, on); } else { --state->ks_polling; if (state->ks_polling == 0) |