Fix LEDs not working when atkbd is an active keyboard and the physical

keyboard is attached only after the system has already booted.

If USB keyboard is also present, and there's no kbdmux(4), the problem
has been hiding itself because as soon as we get to multi-user, the
USB keyboard becomes an active keyboard (see devd.conf), thus marking
atkbd inactive and letting the old code initialize the keyboard.

With kbdmux(4), or if there's no USB keyboard, the atkbd keyboard is
always active, whether it's physically attached or not, thus it never
initialized itself properly on a physical attach.

To fix this, move block that initialized the keyboard on attach upper
so it doesn't depend on the (KBD_IS_ACTIVE(kbd) && KBD_IS_BUSY(kbd))
condition.  Also move KBD_FOUND_DEVICE() a few lines upper so that
KDSETLED and KDSETREPEAT that follow it propagate to the controller.

MFC after:	3 days
This commit is contained in:
Ruslan Ermilov 2006-10-25 13:35:42 +00:00
parent f776aa327d
commit ac3912b020
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163687

View File

@ -480,6 +480,22 @@ atkbd_intr(keyboard_t *kbd, void *arg)
int delay[2];
int c;
if (!KBD_HAS_DEVICE(kbd)) {
/*
* The keyboard was not detected before;
* it must have been reconnected!
*/
state = (atkbd_state_t *)kbd->kb_data;
init_keyboard(state->kbdc, &kbd->kb_type,
kbd->kb_config);
KBD_FOUND_DEVICE(kbd);
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
get_typematic(kbd);
delay[0] = kbd->kb_delay1;
delay[1] = kbd->kb_delay2;
atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
}
if (KBD_IS_ACTIVE(kbd) && KBD_IS_BUSY(kbd)) {
/* let the callback function to process the input */
(*kbd->kb_callback.kc_func)(kbd, KBDIO_KEYINPUT,
@ -489,22 +505,6 @@ atkbd_intr(keyboard_t *kbd, void *arg)
do {
c = atkbd_read_char(kbd, FALSE);
} while (c != NOKEY);
if (!KBD_HAS_DEVICE(kbd)) {
/*
* The keyboard was not detected before;
* it must have been reconnected!
*/
state = (atkbd_state_t *)kbd->kb_data;
init_keyboard(state->kbdc, &kbd->kb_type,
kbd->kb_config);
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
get_typematic(kbd);
delay[0] = kbd->kb_delay1;
delay[1] = kbd->kb_delay2;
atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
KBD_FOUND_DEVICE(kbd);
}
}
return 0;
}