linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Use BIOS Keyboard variable to set Numlock
@ 2012-04-13 19:08 Joshua C.
  2012-04-19  8:59 ` Joshua C.
  2012-05-08 22:10 ` [tip:x86/platform] keyboard: " tip-bot for Joshua Cov
  0 siblings, 2 replies; 4+ messages in thread
From: Joshua C. @ 2012-04-13 19:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: H. Peter Anvin, Alan Cox

I re-worked the prosed patch and moved the code around to better fit
some architectural requirements. I hope it can be merged now.

--Joshua

-----------------------------------

>From 6f49bbce0aa65384ce8dc9cb2e7ca26a94497406 Mon Sep 17 00:00:00 2001
From: Joshua Cov <joshuacov@googlemail.com>
Date: Fri, 13 Apr 2012 22:53:37 +0200
Subject: [PATCH v2] Use BIOS Keyboard variable to set Numlock

The PC BIOS does provide a NUMLOCK flag containing the desired state
of this LED. This patch sets the current state according to the data
in the bios.

Signed-Off-By: Joshua Cov <joshuacov@googlemail.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>

---
 arch/parisc/include/asm/kbdleds.h |   19 +++++++++++++++++++
 arch/x86/boot/main.c              |   18 ++++++++++++------
 arch/x86/include/asm/bootparam.h  |    3 ++-
 arch/x86/include/asm/kbdleds.h    |   17 +++++++++++++++++
 drivers/tty/vt/keyboard.c         |   21 +++++++--------------
 5 files changed, 57 insertions(+), 21 deletions(-)
 create mode 100644 arch/parisc/include/asm/kbdleds.h
 create mode 100644 arch/x86/include/asm/kbdleds.h

diff --git a/arch/parisc/include/asm/kbdleds.h
b/arch/parisc/include/asm/kbdleds.h
new file mode 100644
index 0000000..2a23ca9
--- /dev/null
+++ b/arch/parisc/include/asm/kbdleds.h
@@ -0,0 +1,19 @@
+#ifndef _ASM_PARISC_KBDLEDS_H
+#define _ASM_PARISC_KBDLEDS_H
+
+/*
+ * On HIL keyboards of PARISC machines there is no NumLock key and
+ * everyone expects the keypad to be used for numbers. That's why
+ * we can safely turn on the NUMLOCK bit.
+ */
+
+inline int kbd_defleds(void)
+{
+#if defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD)
+	return 1 << VC_NUMLOCK;
+#else
+	return 0;
+#endif
+}
+
+#endif /* _ASM_PARISC_KBDLEDS_H */
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 40358c8..cf6083d 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -57,14 +57,20 @@ static void copy_boot_params(void)
 }

 /*
- * Set the keyboard repeat rate to maximum.  Unclear why this
+ * Query the keyboard lock status as given by the BIOS, and
+ * set the keyboard repeat rate to maximum.  Unclear why the latter
  * is done here; this might be possible to kill off as stale code.
  */
-static void keyboard_set_repeat(void)
+static void keyboard_init(void)
 {
-	struct biosregs ireg;
+	struct biosregs ireg, oreg;
 	initregs(&ireg);
-	ireg.ax = 0x0305;
+
+	ireg.ah = 0x02;		/* Get keyboard status */
+	intcall(0x16, &ireg, &oreg);
+	boot_params.kbd_status = oreg.al;
+
+	ireg.ax = 0x0305;	/* Set keyboard repeat rate */
 	intcall(0x16, &ireg, NULL);
 }

@@ -151,8 +157,8 @@ void main(void)
 	/* Detect memory layout */
 	detect_memory();

-	/* Set keyboard repeat rate (why?) */
-	keyboard_set_repeat();
+	/* Set keyboard repeat rate (why?) and query the lock flags */
+	keyboard_init();

 	/* Query MCA information */
 	query_mca();
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 2f90c51..eb45aa6 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -112,7 +112,8 @@ struct boot_params {
 	__u8  e820_entries;				/* 0x1e8 */
 	__u8  eddbuf_entries;				/* 0x1e9 */
 	__u8  edd_mbr_sig_buf_entries;			/* 0x1ea */
-	__u8  _pad6[6];					/* 0x1eb */
+	__u8  kbd_status;				/* 0x1eb */
+	__u8  _pad6[5];					/* 0x1ec */
 	struct setup_header hdr;    /* setup header */	/* 0x1f1 */
 	__u8  _pad7[0x290-0x1f1-sizeof(struct setup_header)];
 	__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX];	/* 0x290 */
diff --git a/arch/x86/include/asm/kbdleds.h b/arch/x86/include/asm/kbdleds.h
new file mode 100644
index 0000000..2f6fa42
--- /dev/null
+++ b/arch/x86/include/asm/kbdleds.h
@@ -0,0 +1,17 @@
+#ifndef _ASM_X86_KBDLEDS_H
+#define _ASM_X86_KBDLEDS_H
+
+/*
+ * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
+ * This seems a good reason to start with NumLock off. That's why on X86 we
+ * ask the bios for the correct state.
+ */
+
+#include <asm/setup.h>
+
+inline int kbd_defleds(void)
+{
+	return boot_params.kbd_status & 0x20 ? (1 << VC_NUMLOCK) : 0;
+}
+
+#endif /* _ASM_X86_KBDLEDS_H */
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index a605549..5ea4359 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -52,19 +52,12 @@ extern void ctrl_alt_del(void);

 #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))

-/*
- * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
- * This seems a good reason to start with NumLock off. On HIL keyboards
- * of PARISC machines however there is no NumLock key and everyone
expects the keypad
- * to be used for numbers.
- */
-
-#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) ||
defined(CONFIG_KEYBOARD_HIL_OLD))
-#define KBD_DEFLEDS (1 << VC_NUMLOCK)
-#else
-#define KBD_DEFLEDS 0
+#if defined(CONFIG_X86) || defined(CONFIG_PARISC)
+#include <asm/kbdleds.h>
 #endif

+extern __weak int kbd_defleds(void);
+
 #define KBD_DEFLOCK 0

 void compute_shiftstate(void);
@@ -1433,9 +1426,9 @@ int __init kbd_init(void)
 	int i;
 	int error;

-        for (i = 0; i < MAX_NR_CONSOLES; i++) {
-		kbd_table[i].ledflagstate = KBD_DEFLEDS;
-		kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
+	for (i = 0; i < MAX_NR_CONSOLES; i++) {
+		kbd_table[i].ledflagstate = kbd_defleds();
+		kbd_table[i].default_ledflagstate = kbd_defleds();
 		kbd_table[i].ledmode = LED_SHOW_FLAGS;
 		kbd_table[i].lockstate = KBD_DEFLOCK;
 		kbd_table[i].slockstate = 0;
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Use BIOS Keyboard variable to set Numlock
  2012-04-13 19:08 [PATCH v2] Use BIOS Keyboard variable to set Numlock Joshua C.
@ 2012-04-19  8:59 ` Joshua C.
  2012-05-07 11:49   ` Joshua C.
  2012-05-08 22:10 ` [tip:x86/platform] keyboard: " tip-bot for Joshua Cov
  1 sibling, 1 reply; 4+ messages in thread
From: Joshua C. @ 2012-04-19  8:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox

2012/4/13 Joshua C. <joshuacov@googlemail.com>:
> I re-worked the prosed patch and moved the code around to better fit
> some architectural requirements. I hope it can be merged now.
>
> --Joshua
>
> -----------------------------------
>
> From 6f49bbce0aa65384ce8dc9cb2e7ca26a94497406 Mon Sep 17 00:00:00 2001
> From: Joshua Cov <joshuacov@googlemail.com>
> Date: Fri, 13 Apr 2012 22:53:37 +0200
> Subject: [PATCH v2] Use BIOS Keyboard variable to set Numlock
>
> The PC BIOS does provide a NUMLOCK flag containing the desired state
> of this LED. This patch sets the current state according to the data
> in the bios.
>
> Signed-Off-By: Joshua Cov <joshuacov@googlemail.com>
> Acked-by: H. Peter Anvin <hpa@zytor.com>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
>
> ---
>  arch/parisc/include/asm/kbdleds.h |   19 +++++++++++++++++++
>  arch/x86/boot/main.c              |   18 ++++++++++++------
>  arch/x86/include/asm/bootparam.h  |    3 ++-
>  arch/x86/include/asm/kbdleds.h    |   17 +++++++++++++++++
>  drivers/tty/vt/keyboard.c         |   21 +++++++--------------
>  5 files changed, 57 insertions(+), 21 deletions(-)
>  create mode 100644 arch/parisc/include/asm/kbdleds.h
>  create mode 100644 arch/x86/include/asm/kbdleds.h
>
> diff --git a/arch/parisc/include/asm/kbdleds.h
> b/arch/parisc/include/asm/kbdleds.h
> new file mode 100644
> index 0000000..2a23ca9
> --- /dev/null
> +++ b/arch/parisc/include/asm/kbdleds.h
> @@ -0,0 +1,19 @@
> +#ifndef _ASM_PARISC_KBDLEDS_H
> +#define _ASM_PARISC_KBDLEDS_H
> +
> +/*
> + * On HIL keyboards of PARISC machines there is no NumLock key and
> + * everyone expects the keypad to be used for numbers. That's why
> + * we can safely turn on the NUMLOCK bit.
> + */
> +
> +inline int kbd_defleds(void)
> +{
> +#if defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD)
> +       return 1 << VC_NUMLOCK;
> +#else
> +       return 0;
> +#endif
> +}
> +
> +#endif /* _ASM_PARISC_KBDLEDS_H */
> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
> index 40358c8..cf6083d 100644
> --- a/arch/x86/boot/main.c
> +++ b/arch/x86/boot/main.c
> @@ -57,14 +57,20 @@ static void copy_boot_params(void)
>  }
>
>  /*
> - * Set the keyboard repeat rate to maximum.  Unclear why this
> + * Query the keyboard lock status as given by the BIOS, and
> + * set the keyboard repeat rate to maximum.  Unclear why the latter
>  * is done here; this might be possible to kill off as stale code.
>  */
> -static void keyboard_set_repeat(void)
> +static void keyboard_init(void)
>  {
> -       struct biosregs ireg;
> +       struct biosregs ireg, oreg;
>        initregs(&ireg);
> -       ireg.ax = 0x0305;
> +
> +       ireg.ah = 0x02;         /* Get keyboard status */
> +       intcall(0x16, &ireg, &oreg);
> +       boot_params.kbd_status = oreg.al;
> +
> +       ireg.ax = 0x0305;       /* Set keyboard repeat rate */
>        intcall(0x16, &ireg, NULL);
>  }
>
> @@ -151,8 +157,8 @@ void main(void)
>        /* Detect memory layout */
>        detect_memory();
>
> -       /* Set keyboard repeat rate (why?) */
> -       keyboard_set_repeat();
> +       /* Set keyboard repeat rate (why?) and query the lock flags */
> +       keyboard_init();
>
>        /* Query MCA information */
>        query_mca();
> diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
> index 2f90c51..eb45aa6 100644
> --- a/arch/x86/include/asm/bootparam.h
> +++ b/arch/x86/include/asm/bootparam.h
> @@ -112,7 +112,8 @@ struct boot_params {
>        __u8  e820_entries;                             /* 0x1e8 */
>        __u8  eddbuf_entries;                           /* 0x1e9 */
>        __u8  edd_mbr_sig_buf_entries;                  /* 0x1ea */
> -       __u8  _pad6[6];                                 /* 0x1eb */
> +       __u8  kbd_status;                               /* 0x1eb */
> +       __u8  _pad6[5];                                 /* 0x1ec */
>        struct setup_header hdr;    /* setup header */  /* 0x1f1 */
>        __u8  _pad7[0x290-0x1f1-sizeof(struct setup_header)];
>        __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX];      /* 0x290 */
> diff --git a/arch/x86/include/asm/kbdleds.h b/arch/x86/include/asm/kbdleds.h
> new file mode 100644
> index 0000000..2f6fa42
> --- /dev/null
> +++ b/arch/x86/include/asm/kbdleds.h
> @@ -0,0 +1,17 @@
> +#ifndef _ASM_X86_KBDLEDS_H
> +#define _ASM_X86_KBDLEDS_H
> +
> +/*
> + * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
> + * This seems a good reason to start with NumLock off. That's why on X86 we
> + * ask the bios for the correct state.
> + */
> +
> +#include <asm/setup.h>
> +
> +inline int kbd_defleds(void)
> +{
> +       return boot_params.kbd_status & 0x20 ? (1 << VC_NUMLOCK) : 0;
> +}
> +
> +#endif /* _ASM_X86_KBDLEDS_H */
> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> index a605549..5ea4359 100644
> --- a/drivers/tty/vt/keyboard.c
> +++ b/drivers/tty/vt/keyboard.c
> @@ -52,19 +52,12 @@ extern void ctrl_alt_del(void);
>
>  #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
>
> -/*
> - * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
> - * This seems a good reason to start with NumLock off. On HIL keyboards
> - * of PARISC machines however there is no NumLock key and everyone
> expects the keypad
> - * to be used for numbers.
> - */
> -
> -#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) ||
> defined(CONFIG_KEYBOARD_HIL_OLD))
> -#define KBD_DEFLEDS (1 << VC_NUMLOCK)
> -#else
> -#define KBD_DEFLEDS 0
> +#if defined(CONFIG_X86) || defined(CONFIG_PARISC)
> +#include <asm/kbdleds.h>
>  #endif
>
> +extern __weak int kbd_defleds(void);
> +
>  #define KBD_DEFLOCK 0
>
>  void compute_shiftstate(void);
> @@ -1433,9 +1426,9 @@ int __init kbd_init(void)
>        int i;
>        int error;
>
> -        for (i = 0; i < MAX_NR_CONSOLES; i++) {
> -               kbd_table[i].ledflagstate = KBD_DEFLEDS;
> -               kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
> +       for (i = 0; i < MAX_NR_CONSOLES; i++) {
> +               kbd_table[i].ledflagstate = kbd_defleds();
> +               kbd_table[i].default_ledflagstate = kbd_defleds();
>                kbd_table[i].ledmode = LED_SHOW_FLAGS;
>                kbd_table[i].lockstate = KBD_DEFLOCK;
>                kbd_table[i].slockstate = 0;
> --
> 1.7.10

Is there any chance to get this into mainline? The patch was reworked
to include any suggestion I got from here and I think it should be
pushed into the kernel.

--Joshua

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Use BIOS Keyboard variable to set Numlock
  2012-04-19  8:59 ` Joshua C.
@ 2012-05-07 11:49   ` Joshua C.
  0 siblings, 0 replies; 4+ messages in thread
From: Joshua C. @ 2012-05-07 11:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox, hpa

2012/4/19 Joshua C. <joshuacov@googlemail.com>:
> 2012/4/13 Joshua C. <joshuacov@googlemail.com>:
>> I re-worked the prosed patch and moved the code around to better fit
>> some architectural requirements. I hope it can be merged now.
>>
>> --Joshua
>>
>> -----------------------------------
>>
>> From 6f49bbce0aa65384ce8dc9cb2e7ca26a94497406 Mon Sep 17 00:00:00 2001
>> From: Joshua Cov <joshuacov@googlemail.com>
>> Date: Fri, 13 Apr 2012 22:53:37 +0200
>> Subject: [PATCH v2] Use BIOS Keyboard variable to set Numlock
>>
>> The PC BIOS does provide a NUMLOCK flag containing the desired state
>> of this LED. This patch sets the current state according to the data
>> in the bios.
>>
>> Signed-Off-By: Joshua Cov <joshuacov@googlemail.com>
>> Acked-by: H. Peter Anvin <hpa@zytor.com>
>> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
>>
>> ---
>>  arch/parisc/include/asm/kbdleds.h |   19 +++++++++++++++++++
>>  arch/x86/boot/main.c              |   18 ++++++++++++------
>>  arch/x86/include/asm/bootparam.h  |    3 ++-
>>  arch/x86/include/asm/kbdleds.h    |   17 +++++++++++++++++
>>  drivers/tty/vt/keyboard.c         |   21 +++++++--------------
>>  5 files changed, 57 insertions(+), 21 deletions(-)
>>  create mode 100644 arch/parisc/include/asm/kbdleds.h
>>  create mode 100644 arch/x86/include/asm/kbdleds.h
>>
>> diff --git a/arch/parisc/include/asm/kbdleds.h
>> b/arch/parisc/include/asm/kbdleds.h
>> new file mode 100644
>> index 0000000..2a23ca9
>> --- /dev/null
>> +++ b/arch/parisc/include/asm/kbdleds.h
>> @@ -0,0 +1,19 @@
>> +#ifndef _ASM_PARISC_KBDLEDS_H
>> +#define _ASM_PARISC_KBDLEDS_H
>> +
>> +/*
>> + * On HIL keyboards of PARISC machines there is no NumLock key and
>> + * everyone expects the keypad to be used for numbers. That's why
>> + * we can safely turn on the NUMLOCK bit.
>> + */
>> +
>> +inline int kbd_defleds(void)
>> +{
>> +#if defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD)
>> +       return 1 << VC_NUMLOCK;
>> +#else
>> +       return 0;
>> +#endif
>> +}
>> +
>> +#endif /* _ASM_PARISC_KBDLEDS_H */
>> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
>> index 40358c8..cf6083d 100644
>> --- a/arch/x86/boot/main.c
>> +++ b/arch/x86/boot/main.c
>> @@ -57,14 +57,20 @@ static void copy_boot_params(void)
>>  }
>>
>>  /*
>> - * Set the keyboard repeat rate to maximum.  Unclear why this
>> + * Query the keyboard lock status as given by the BIOS, and
>> + * set the keyboard repeat rate to maximum.  Unclear why the latter
>>  * is done here; this might be possible to kill off as stale code.
>>  */
>> -static void keyboard_set_repeat(void)
>> +static void keyboard_init(void)
>>  {
>> -       struct biosregs ireg;
>> +       struct biosregs ireg, oreg;
>>        initregs(&ireg);
>> -       ireg.ax = 0x0305;
>> +
>> +       ireg.ah = 0x02;         /* Get keyboard status */
>> +       intcall(0x16, &ireg, &oreg);
>> +       boot_params.kbd_status = oreg.al;
>> +
>> +       ireg.ax = 0x0305;       /* Set keyboard repeat rate */
>>        intcall(0x16, &ireg, NULL);
>>  }
>>
>> @@ -151,8 +157,8 @@ void main(void)
>>        /* Detect memory layout */
>>        detect_memory();
>>
>> -       /* Set keyboard repeat rate (why?) */
>> -       keyboard_set_repeat();
>> +       /* Set keyboard repeat rate (why?) and query the lock flags */
>> +       keyboard_init();
>>
>>        /* Query MCA information */
>>        query_mca();
>> diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
>> index 2f90c51..eb45aa6 100644
>> --- a/arch/x86/include/asm/bootparam.h
>> +++ b/arch/x86/include/asm/bootparam.h
>> @@ -112,7 +112,8 @@ struct boot_params {
>>        __u8  e820_entries;                             /* 0x1e8 */
>>        __u8  eddbuf_entries;                           /* 0x1e9 */
>>        __u8  edd_mbr_sig_buf_entries;                  /* 0x1ea */
>> -       __u8  _pad6[6];                                 /* 0x1eb */
>> +       __u8  kbd_status;                               /* 0x1eb */
>> +       __u8  _pad6[5];                                 /* 0x1ec */
>>        struct setup_header hdr;    /* setup header */  /* 0x1f1 */
>>        __u8  _pad7[0x290-0x1f1-sizeof(struct setup_header)];
>>        __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX];      /* 0x290 */
>> diff --git a/arch/x86/include/asm/kbdleds.h b/arch/x86/include/asm/kbdleds.h
>> new file mode 100644
>> index 0000000..2f6fa42
>> --- /dev/null
>> +++ b/arch/x86/include/asm/kbdleds.h
>> @@ -0,0 +1,17 @@
>> +#ifndef _ASM_X86_KBDLEDS_H
>> +#define _ASM_X86_KBDLEDS_H
>> +
>> +/*
>> + * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
>> + * This seems a good reason to start with NumLock off. That's why on X86 we
>> + * ask the bios for the correct state.
>> + */
>> +
>> +#include <asm/setup.h>
>> +
>> +inline int kbd_defleds(void)
>> +{
>> +       return boot_params.kbd_status & 0x20 ? (1 << VC_NUMLOCK) : 0;
>> +}
>> +
>> +#endif /* _ASM_X86_KBDLEDS_H */
>> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
>> index a605549..5ea4359 100644
>> --- a/drivers/tty/vt/keyboard.c
>> +++ b/drivers/tty/vt/keyboard.c
>> @@ -52,19 +52,12 @@ extern void ctrl_alt_del(void);
>>
>>  #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
>>
>> -/*
>> - * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
>> - * This seems a good reason to start with NumLock off. On HIL keyboards
>> - * of PARISC machines however there is no NumLock key and everyone
>> expects the keypad
>> - * to be used for numbers.
>> - */
>> -
>> -#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) ||
>> defined(CONFIG_KEYBOARD_HIL_OLD))
>> -#define KBD_DEFLEDS (1 << VC_NUMLOCK)
>> -#else
>> -#define KBD_DEFLEDS 0
>> +#if defined(CONFIG_X86) || defined(CONFIG_PARISC)
>> +#include <asm/kbdleds.h>
>>  #endif
>>
>> +extern __weak int kbd_defleds(void);
>> +
>>  #define KBD_DEFLOCK 0
>>
>>  void compute_shiftstate(void);
>> @@ -1433,9 +1426,9 @@ int __init kbd_init(void)
>>        int i;
>>        int error;
>>
>> -        for (i = 0; i < MAX_NR_CONSOLES; i++) {
>> -               kbd_table[i].ledflagstate = KBD_DEFLEDS;
>> -               kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
>> +       for (i = 0; i < MAX_NR_CONSOLES; i++) {
>> +               kbd_table[i].ledflagstate = kbd_defleds();
>> +               kbd_table[i].default_ledflagstate = kbd_defleds();
>>                kbd_table[i].ledmode = LED_SHOW_FLAGS;
>>                kbd_table[i].lockstate = KBD_DEFLOCK;
>>                kbd_table[i].slockstate = 0;
>> --
>> 1.7.10
>
> Is there any chance to get this into mainline? The patch was reworked
> to include any suggestion I got from here and I think it should be
> pushed into the kernel.
>
> --Joshua

Alan, what else should be done to this to include it in the mainline?
It was already discussed with hpa and he gave his ok. It's a trivia to
set the corresponding bit.

-- 

-- joshua

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:x86/platform] keyboard: Use BIOS Keyboard variable to set Numlock
  2012-04-13 19:08 [PATCH v2] Use BIOS Keyboard variable to set Numlock Joshua C.
  2012-04-19  8:59 ` Joshua C.
@ 2012-05-08 22:10 ` tip-bot for Joshua Cov
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Joshua Cov @ 2012-05-08 22:10 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, joshuacov, tglx, alan

Commit-ID:  b2d0b7a061bfddd27155c7dcd53f365d9dc0c7c3
Gitweb:     http://git.kernel.org/tip/b2d0b7a061bfddd27155c7dcd53f365d9dc0c7c3
Author:     Joshua Cov <joshuacov@googlemail.com>
AuthorDate: Fri, 13 Apr 2012 21:08:26 +0200
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Tue, 8 May 2012 14:19:41 -0700

keyboard: Use BIOS Keyboard variable to set Numlock

The PC BIOS does provide a NUMLOCK flag containing the desired state
of this LED. This patch sets the current state according to the data
in the bios.

[ hpa: fixed __weak declaration without definition, changed "inline"
  to "static inline" ]

Signed-Off-By: Joshua Cov <joshuacov@googlemail.com>
Link: http://lkml.kernel.org/r/CAKL7Q7rvq87TNS1T_Km8fW_5OzS%2BSbYazLXKxW-6ztOxo3zorg@mail.gmail.com
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/parisc/include/asm/kbdleds.h |   19 +++++++++++++++++++
 arch/x86/boot/main.c              |   18 ++++++++++++------
 arch/x86/include/asm/bootparam.h  |    3 ++-
 arch/x86/include/asm/kbdleds.h    |   17 +++++++++++++++++
 drivers/tty/vt/keyboard.c         |   20 ++++++++------------
 5 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/arch/parisc/include/asm/kbdleds.h b/arch/parisc/include/asm/kbdleds.h
new file mode 100644
index 0000000..2e2e75a
--- /dev/null
+++ b/arch/parisc/include/asm/kbdleds.h
@@ -0,0 +1,19 @@
+#ifndef _ASM_PARISC_KBDLEDS_H
+#define _ASM_PARISC_KBDLEDS_H
+
+/*
+ * On HIL keyboards of PARISC machines there is no NumLock key and
+ * everyone expects the keypad to be used for numbers. That's why
+ * we can safely turn on the NUMLOCK bit.
+ */
+
+static inline int kbd_defleds(void)
+{
+#if defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD)
+	return 1 << VC_NUMLOCK;
+#else
+	return 0;
+#endif
+}
+
+#endif /* _ASM_PARISC_KBDLEDS_H */
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 40358c8..cf6083d 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -57,14 +57,20 @@ static void copy_boot_params(void)
 }
 
 /*
- * Set the keyboard repeat rate to maximum.  Unclear why this
+ * Query the keyboard lock status as given by the BIOS, and
+ * set the keyboard repeat rate to maximum.  Unclear why the latter
  * is done here; this might be possible to kill off as stale code.
  */
-static void keyboard_set_repeat(void)
+static void keyboard_init(void)
 {
-	struct biosregs ireg;
+	struct biosregs ireg, oreg;
 	initregs(&ireg);
-	ireg.ax = 0x0305;
+
+	ireg.ah = 0x02;		/* Get keyboard status */
+	intcall(0x16, &ireg, &oreg);
+	boot_params.kbd_status = oreg.al;
+
+	ireg.ax = 0x0305;	/* Set keyboard repeat rate */
 	intcall(0x16, &ireg, NULL);
 }
 
@@ -151,8 +157,8 @@ void main(void)
 	/* Detect memory layout */
 	detect_memory();
 
-	/* Set keyboard repeat rate (why?) */
-	keyboard_set_repeat();
+	/* Set keyboard repeat rate (why?) and query the lock flags */
+	keyboard_init();
 
 	/* Query MCA information */
 	query_mca();
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 2f90c51..eb45aa6 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -112,7 +112,8 @@ struct boot_params {
 	__u8  e820_entries;				/* 0x1e8 */
 	__u8  eddbuf_entries;				/* 0x1e9 */
 	__u8  edd_mbr_sig_buf_entries;			/* 0x1ea */
-	__u8  _pad6[6];					/* 0x1eb */
+	__u8  kbd_status;				/* 0x1eb */
+	__u8  _pad6[5];					/* 0x1ec */
 	struct setup_header hdr;    /* setup header */	/* 0x1f1 */
 	__u8  _pad7[0x290-0x1f1-sizeof(struct setup_header)];
 	__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX];	/* 0x290 */
diff --git a/arch/x86/include/asm/kbdleds.h b/arch/x86/include/asm/kbdleds.h
new file mode 100644
index 0000000..f27ac5f
--- /dev/null
+++ b/arch/x86/include/asm/kbdleds.h
@@ -0,0 +1,17 @@
+#ifndef _ASM_X86_KBDLEDS_H
+#define _ASM_X86_KBDLEDS_H
+
+/*
+ * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
+ * This seems a good reason to start with NumLock off. That's why on X86 we
+ * ask the bios for the correct state.
+ */
+
+#include <asm/setup.h>
+
+static inline int kbd_defleds(void)
+{
+	return boot_params.kbd_status & 0x20 ? (1 << VC_NUMLOCK) : 0;
+}
+
+#endif /* _ASM_X86_KBDLEDS_H */
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 86dd1e3..b021a18 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -53,17 +53,13 @@ extern void ctrl_alt_del(void);
 
 #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
 
-/*
- * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
- * This seems a good reason to start with NumLock off. On HIL keyboards
- * of PARISC machines however there is no NumLock key and everyone expects the
- * keypad to be used for numbers.
- */
-
-#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD))
-#define KBD_DEFLEDS (1 << VC_NUMLOCK)
+#if defined(CONFIG_X86) || defined(CONFIG_PARISC)
+#include <asm/kbdleds.h>
 #else
-#define KBD_DEFLEDS 0
+static inline int kbd_defleds(void)
+{
+	return 0;
+}
 #endif
 
 #define KBD_DEFLOCK 0
@@ -1512,8 +1508,8 @@ int __init kbd_init(void)
 	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 = kbd_defleds();
+		kbd_table[i].default_ledflagstate = kbd_defleds();
 		kbd_table[i].ledmode = LED_SHOW_FLAGS;
 		kbd_table[i].lockstate = KBD_DEFLOCK;
 		kbd_table[i].slockstate = 0;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-08 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 19:08 [PATCH v2] Use BIOS Keyboard variable to set Numlock Joshua C.
2012-04-19  8:59 ` Joshua C.
2012-05-07 11:49   ` Joshua C.
2012-05-08 22:10 ` [tip:x86/platform] keyboard: " tip-bot for Joshua Cov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).