Re: KDSKBLED

Andries.Brouwer@cwi.nl
Sat, 23 Jun 2001 22:34:43 +0200 (MET DST)


Why does the console ioctl, KDSKBLED, work with
caps and num lock, but not scroll lock.
...
But "setleds +scroll" changes the scroll lock led without
changing the behavior of the keyboard. I then have to press
the scoll lock key twice to get the scroll lock light to turn off,
because kbd->ledflagstate is out of sync with ledstate in the kernel.

The KDSKBLED in vt.c sets ledflagstate, which is tested directly
in the keyboard driver when the status of CapsLock or NumLock is needed.
(See kbd_kern.h, vc_kbd_led().)
However, the function of the ScrollLock key is to stop output,
and the "stopped" bit lives in the tty driver, not in the kbd driver.

You can trace what happens as follows:
1. What code is generated by the ScrollLock key? Ask showkey.
2. What keysym is bound to that code? Ask dumpkeys.
3. What is the hex value of that keysym? Ask dumpkeys -l.
In step 2 you found ScrollLock, in step 3 0x0209.
Now look at keyboard.c. The 02 part of 0209 is the index in the
array key_handler[], so we are going to call do_spec().
The 09 part of 0209 is the index in spec_fn_table[], so we
are going to call hold(). Now all is clear:

static void hold(void) {
if (tty->stopped)
start_tty(tty);
else
stop_tty(tty);
}

You see what happens. The setleds command sets the led, but does
not do stop_tty(). The next press on ScrollLock does stop_tty()
(and sets the led that was on already). The next press on ScrollLock
does start_tty() and clears the led again.

Is this a bug? I don't know. Slightly confusing perhaps,
but now that it has been like this for over seven years
I don't think there is reason to change, except possibly
as part of a global change of these drivers.

> I noticed that the setleds program does not work with
> scroll lock either. In fact, it looks like it passes a
> value of zero to the KDSKBLED ioctl when I do ./setleds +num,
> which clears the num lock instead of setting it.

Works for me. Maybe you are using console-tools instead of kbd?

Andries

[cc to linux-kernel]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/