mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bodo Eggert <7eggert@gmx.de>
To: linux-input@atrey.karlin.mff.cuni.cz,
	linux-kernel@vger.kernel.org, torvalds@linux-foundation.org
Subject: [PATCH] Get NUMLOCK from PC BIOS
Date: Sun, 30 Dec 2007 12:38:11 +0100 (CET)	[thread overview]
Message-ID: <alpine.LSU.0.999.0712301230270.3273@be1.lrz> (raw)

This patch enables reading the default NUMLOCK status from the BIOS data
area as defined for IBM PCs (1981). Using this area has been a reliable way
to detect (or set) the NUMLOCK status for about 27 years, and it will
continue to work on any IBM-compatible system that might run DOS. 
Especially, the NUMLOCK status on Linus' famous laptop should be usable.

---

I'd like some information about how this patch works non non-IBM-compatible
x86 PCs. For now, I've documented the wordt possible outcome I can imagine.

Signed-Off-By: Bodo Eggert <7eggert@gmx.de>

diff -pruN -X dontdiff linux-2.6.23.pure/drivers/char/keyboard.c linux-2.6.23.base/drivers/char/keyboard.c
--- linux-2.6.23.pure/drivers/char/keyboard.c	2007-10-11 14:15:18.000000000 +0200
+++ linux-2.6.23.base/drivers/char/keyboard.c	2007-12-30 12:12:11.000000000 +0100
@@ -24,6 +24,7 @@
  * 21-08-02: Converted to input API, major cleanup. (Vojtech Pavlik)
  */
 
+#include <asm/io.h>
 #include <linux/consolemap.h>
 #include <linux/module.h>
 #include <linux/sched.h>
@@ -57,7 +58,10 @@ 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
+#elif defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD))
 #define KBD_DEFLEDS (1 << VC_NUMLOCK)
 #else
 #define KBD_DEFLEDS 0
@@ -1358,8 +1362,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)
+		KBD_DEFLEDS = 1 << VC_NUMLOCK;
+#endif
 
-        for (i = 0; i < MAX_NR_CONSOLES; i++) {
+	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;
diff -pruN -X dontdiff linux-2.6.23.pure/drivers/input/keyboard/Kconfig linux-2.6.23.base/drivers/input/keyboard/Kconfig
--- linux-2.6.23.pure/drivers/input/keyboard/Kconfig	2007-10-11 14:14:41.000000000 +0200
+++ linux-2.6.23.base/drivers/input/keyboard/Kconfig	2007-12-30 12:11:45.000000000 +0100
@@ -12,6 +12,17 @@ menuconfig INPUT_KEYBOARD
 
 if INPUT_KEYBOARD
 
+config KBD_DEFLEDS_PCBIOS
+	bool "Enable Num-Lock based on BIOS settings"
+	depends on X86_PC && EXPERIMENTAL
+	help
+	  Turns on Numlock depending on the BIOS settings.
+	  This works by reading the BIOS data area as defined for IBM PCs (1981).
+
+	  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
 	tristate "AT keyboard" if EMBEDDED || !X86_PC
 	default y

-- 
Top 100 things you don't want the sysadmin to say:
39. It is only a minor upgrade, the system should be back up in
    a few hours.  ( This is said on a monday afternoon.)

             reply	other threads:[~2007-12-30 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-30 11:38 Bodo Eggert [this message]
2008-01-02 15:11 ` Niels de Vos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.0.999.0712301230270.3273@be1.lrz \
    --to=7eggert@gmx.de \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®