[PATCH] Default keyboard LEDs - Kernel

This is a discussion on [PATCH] Default keyboard LEDs - Kernel ; In many cases, one prefers to have e.g. the NumLock on by default. In many cases, one doesn't want to have it by default, e.g. on laptops. Distributions actually have a very hard time trying to set this correctly after ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: [PATCH] Default keyboard LEDs

  1. [PATCH] Default keyboard LEDs

    In many cases, one prefers to have e.g. the NumLock on by default. In
    many cases, one doesn't want to have it by default, e.g. on laptops.

    Distributions actually have a very hard time trying to set this
    correctly after the kernel boot, and that doesn't work for new consoles
    that are created via the openvt(1) command anyway. This hence adds a
    keyboard.default_leds boot parameter that permits to configure the
    default keyboard LEDs.

    Signed-off-by: Samuel Thibault

    ---

    Actually, what would be perfect would be to use the configuration that
    the BIOS sets at boot by default. That is device-dependent, however.

    --- linux/drivers/char/keyboard.c.orig 2008-01-14 00:26:12.000000000 +0000
    +++ linux/drivers/char/keyboard.c 2008-01-14 00:33:03.000000000 +0000
    @@ -67,6 +67,9 @@

    #define KBD_DEFLOCK 0

    +unsigned char default_leds = KBD_DEFLEDS;
    +module_param(default_leds, byte, S_IRUGO | S_IWUSR);
    +
    void compute_shiftstate(void);

    /*
    @@ -1405,8 +1408,8 @@
    int error;

    for (i = 0; i < MAX_NR_CONSOLES; i++) {
    - kbd_table[i].ledflagstate = KBD_DEFLEDS;
    - kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
    + kbd_table[i].ledflagstate = default_leds;
    + kbd_table[i].default_ledflagstate = default_leds;
    kbd_table[i].ledmode = LED_SHOW_FLAGS;
    kbd_table[i].lockstate = KBD_DEFLOCK;
    kbd_table[i].slockstate = 0;
    --- linux/include/linux/kbd_kern.h.orig 2008-01-14 00:32:36.000000000 +0000
    +++ linux/include/linux/kbd_kern.h 2008-01-14 00:32:48.000000000 +0000
    @@ -13,6 +13,7 @@
    extern char func_buf[];
    extern char *funcbufptr;
    extern int funcbufsize, funcbufleft;
    +extern unsigned char default_leds;

    /*
    * kbd->xxx contains the VC-local things (flag settings etc..)
    --- linux/Documentation/kernel-parameters.txt.orig 2008-01-14 00:38:40.000000000 +0000
    +++ linux/Documentation/kernel-parameters.txt 2008-01-14 00:41:21.000000000 +0000
    @@ -550,6 +550,15 @@
    Set system-wide default UTF-8 mode for all tty's.
    Default is 0 and by setting to 1, it enables UTF-8
    mode for all newly opened or allocated terminals.
    +
    + keyboard.default_leds=
    + [KEYBOARD]
    + Format=
    + Mask of the leds to activate on consoles by default.
    + ScrollLock: 1
    + NumLock: 2
    + CapsLock: 4
    + KanaLock: 8

    dhash_entries= [KNL]
    Set number of hash buckets for dentry cache.
    --
    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/

  2. Re: [PATCH] Default keyboard LEDs


    On Jan 14 2008 00:52, Samuel Thibault wrote:
    >
    >In many cases, one prefers to have e.g. the NumLock on by default. In
    >many cases, one doesn't want to have it by default, e.g. on laptops.
    >
    >Distributions actually have a very hard time trying to set this
    >correctly after the kernel boot, and that doesn't work for new consoles
    >that are created via the openvt(1) command anyway. This hence adds a
    >keyboard.default_leds boot parameter that permits to configure the
    >default keyboard LEDs.


    Apart from openvt being able to find the first unused tty,
    what is openvt good for? (Read: I could just as well run
    `bash /dev/tty8 2>/dev/tty8`)
    --
    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/

  3. Re: [PATCH] Default keyboard LEDs

    Samuel Thibault wrote:
    > In many cases, one prefers to have e.g. the NumLock on by default. In
    > many cases, one doesn't want to have it by default, e.g. on laptops.
    >
    > Distributions actually have a very hard time trying to set this
    > correctly after the kernel boot, and that doesn't work for new consoles
    > that are created via the openvt(1) command anyway. This hence adds a
    > keyboard.default_leds boot parameter that permits to configure the
    > default keyboard LEDs.
    >
    > Signed-off-by: Samuel Thibault
    >
    > Actually, what would be perfect would be to use the configuration that
    > the BIOS sets at boot by default. That is device-dependent, however.
    >


    It is, but it can be read out either by INT calls at initialization
    time, or by reading out the byte at physical address 0x417:

    --------K-M00400017--------------------------
    MEM 0040h:0017h - KEYBOARD - STATUS FLAGS 1
    Size: BYTE
    SeeAlso: MEM 0040h:0018h,INT 16/AH=02h,MEM 0040h:0096h

    Bitfields for keyboard status flags 1:
    Bit(s) Description (Table M0010)
    7 INSert active
    6 Caps Lock active
    5 Num Lock active
    4 Scroll Lock active
    3 either Alt pressed
    2 either Ctrl pressed
    1 Left Shift pressed
    0 Right Shift pressed
    SeeAlso: #M0011,#00587

    The same information is available through INT 16h, AH=02h.

    -hpa
    --
    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/

  4. Re: [PATCH] Default keyboard LEDs

    Jan Engelhardt, le Mon 14 Jan 2008 02:40:08 +0100, a écrit :
    > On Jan 14 2008 00:52, Samuel Thibault wrote:
    > >In many cases, one prefers to have e.g. the NumLock on by default. In
    > >many cases, one doesn't want to have it by default, e.g. on laptops.
    > >
    > >Distributions actually have a very hard time trying to set this
    > >correctly after the kernel boot, and that doesn't work for new consoles
    > >that are created via the openvt(1) command anyway. This hence adds a
    > >keyboard.default_leds boot parameter that permits to configure the
    > >default keyboard LEDs.

    >
    > Apart from openvt being able to find the first unused tty,
    > what is openvt good for? (Read: I could just as well run
    > `bash /dev/tty8 2>/dev/tty8`)


    But it is a burden (you forgot '&' btw ). Also, openvt properly sets
    the controlling tty, can run a login shell, etc...

    Anyway, be it openvt or bash, the LED issue exists

    Samuel
    --
    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/

  5. Re: [PATCH] Default keyboard LEDs

    H. Peter Anvin, le Sun 13 Jan 2008 19:50:34 -0800, a écrit :
    > >Actually, what would be perfect would be to use the configuration that
    > >the BIOS sets at boot by default. That is device-dependent, however.
    > >

    >
    > It is, but it can be read out either by INT calls at initialization
    > time, or by reading out the byte at physical address 0x417:


    I should have said "arch-dependent".
    I didn't mean it wasn't possible, but just it'd probably be better that
    driver experts do it, not me

    > --------K-M00400017--------------------------
    > MEM 0040h:0017h - KEYBOARD - STATUS FLAGS 1
    > Size: BYTE
    > SeeAlso: MEM 0040h:0018h,INT 16/AH=02h,MEM 0040h:0096h
    >
    > Bitfields for keyboard status flags 1:
    > Bit(s) Description (Table M0010)
    > 7 INSert active
    > 6 Caps Lock active
    > 5 Num Lock active
    > 4 Scroll Lock active
    > 3 either Alt pressed
    > 2 either Ctrl pressed
    > 1 Left Shift pressed
    > 0 Right Shift pressed
    > SeeAlso: #M0011,#00587
    >
    > The same information is available through INT 16h, AH=02h.


    Samuel
    --
    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/

+ Reply to Thread