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
This commit is contained in:
Alexander Kabaev 2007-10-15 20:37:34 +00:00
parent 9f05d312b3
commit d5d78259ac

View File

@ -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)