[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKL7Q7qU0OKzqC-XnM1mY7YWs1SstayqH-8P-5MY3Yg7_wrQZw@mail.gmail.com>
Date: Mon, 27 Feb 2012 20:23:11 +0100
From: "Joshua C." <joshuacov@...glemail.com>
To: linux-kernel@...r.kernel.org
Cc: Bodo Eggert <7eggert@....de>, "H. Peter Anvin" <hpa@...or.com>
Subject: [RESUBMIT] [PATCH] Use BIOS Keyboard variable to set Numlock
I rebased this on the latest kernel-3.3-rc5 so that it can be properly applied.
------------------
>From 36e15b8d9d491817a3bada5ef9375aabe9439d9b Mon Sep 17 00:00:00 2012
From: Joshua Cov <joshuacov@...glemail.com>
Date: Mon, 27 Feb 2012 20:49:18 +0100
Subject: [PATCH] Use BIOS Keyboard variable to set Numlock
The PC BIOS does provide a NUMLOCK flag containing the desired state
of this LED. Bit 0x417 has the current keyboard modifier state. This
patch sets the current state according to the data in the bios and
introduces a module parameter "numlock" which can be used to
explicitely disable the NumLock (1 = enable, 0 = disable).
See first discussion back in 2007 at:
http://lkml.indiana.edu/hypermail/linux/kernel/0707.1/1834.html
Signed-Off-By: Joshua Cov <joshuacov@...glemail.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Bodo Eggert <7eggert@....de>
---
drivers/input/keyboard/Kconfig | 14 ++++++++++++++
drivers/tty/vt/keyboard.c | 21 +++++++++++++++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index cdc385b..1dd1965 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -84,6 +84,20 @@ config KEYBOARD_ATKBD
To compile this driver as a module, choose M here: the
module will be called atkbd.
+config KBD_DEFLEDS_PCBIOS
+ bool "Enable Num-Lock based on BIOS settings"
+ depends on KEYBOARD_ATKBD && X86
+ default y
+ help
+ Turns on Numlock depending on the BIOS settings.
+ This works by reading the BIOS data area as defined for IBM PCs (1981).
+ You can also controll the NumLock state with the kernel parameter
+ numlock.
+
+ If you have an alternative firmware like OpenFirmware or LinuxBios,
+ this flag might not be set correctly, which results in a random state
+ of the Numlock key.
+
config KEYBOARD_ATKBD_HP_KEYCODES
bool "Use HP keyboard scancodes"
depends on PARISC && KEYBOARD_ATKBD
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index a605549..d254396 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -24,6 +24,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <asm/io.h>
#include <linux/consolemap.h>
#include <linux/module.h>
#include <linux/sched.h>
@@ -59,7 +60,13 @@ extern void ctrl_alt_del(void);
* to be used for numbers.
*/
-#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) ||
defined(CONFIG_KEYBOARD_HIL_OLD))
+#ifdef CONFIG_KBD_DEFLEDS_PCBIOS
+/* KBD_DEFLEDS is a variable */
+#undef KBD_DEFLEDS
+ static int numlock = 1;
+ MODULE_PARM_DESC(numlock, "Toggle Numlock (1 = enable, 0 = disable)");
+ module_param_named(numlock, numlock, int, 0400);
+#elif defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) ||
defined(CONFIG_KEYBOARD_HIL_OLD))
#define KBD_DEFLEDS (1 << VC_NUMLOCK)
#else
#define KBD_DEFLEDS 0
@@ -1432,7 +1439,17 @@ int __init kbd_init(void)
{
int i;
int error;
-
+
+#ifdef CONFIG_KBD_DEFLEDS_PCBIOS
+ int KBD_DEFLEDS = 0;
+ /* address 0x40:0x17 */
+ char * bios_kbd_status=xlate_dev_mem_ptr(0x417);
+
+ /* Numlock status bit set? */
+ if ((*bios_kbd_status & 0x20) && numlock)
+ KBD_DEFLEDS = 1 << VC_NUMLOCK;
+#endif
+
for (i = 0; i < MAX_NR_CONSOLES; i++) {
kbd_table[i].ledflagstate = KBD_DEFLEDS;
kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists