aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorJoshua Cov <joshuacov@googlemail.com>2012-04-13 15:08:26 -0400
committerH. Peter Anvin <hpa@zytor.com>2012-05-08 17:19:41 -0400
commitb2d0b7a061bfddd27155c7dcd53f365d9dc0c7c3 (patch)
tree8063c6df479723b7adc509ee2aad728889faa9a4 /arch/x86
parentc2c21e9bb17549e8add4ff76931bcec2e2d3ad48 (diff)
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>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/boot/main.c18
-rw-r--r--arch/x86/include/asm/bootparam.h3
-rw-r--r--arch/x86/include/asm/kbdleds.h17
3 files changed, 31 insertions, 7 deletions
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 40358c8905b..cf6083d444f 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -57,14 +57,20 @@ static void copy_boot_params(void)
57} 57}
58 58
59/* 59/*
60 * Set the keyboard repeat rate to maximum. Unclear why this 60 * Query the keyboard lock status as given by the BIOS, and
61 * set the keyboard repeat rate to maximum. Unclear why the latter
61 * is done here; this might be possible to kill off as stale code. 62 * is done here; this might be possible to kill off as stale code.
62 */ 63 */
63static void keyboard_set_repeat(void) 64static void keyboard_init(void)
64{ 65{
65 struct biosregs ireg; 66 struct biosregs ireg, oreg;
66 initregs(&ireg); 67 initregs(&ireg);
67 ireg.ax = 0x0305; 68
69 ireg.ah = 0x02; /* Get keyboard status */
70 intcall(0x16, &ireg, &oreg);
71 boot_params.kbd_status = oreg.al;
72
73 ireg.ax = 0x0305; /* Set keyboard repeat rate */
68 intcall(0x16, &ireg, NULL); 74 intcall(0x16, &ireg, NULL);
69} 75}
70 76
@@ -151,8 +157,8 @@ void main(void)
151 /* Detect memory layout */ 157 /* Detect memory layout */
152 detect_memory(); 158 detect_memory();
153 159
154 /* Set keyboard repeat rate (why?) */ 160 /* Set keyboard repeat rate (why?) and query the lock flags */
155 keyboard_set_repeat(); 161 keyboard_init();
156 162
157 /* Query MCA information */ 163 /* Query MCA information */
158 query_mca(); 164 query_mca();
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 2f90c51cc49..eb45aa6b1f2 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -112,7 +112,8 @@ struct boot_params {
112 __u8 e820_entries; /* 0x1e8 */ 112 __u8 e820_entries; /* 0x1e8 */
113 __u8 eddbuf_entries; /* 0x1e9 */ 113 __u8 eddbuf_entries; /* 0x1e9 */
114 __u8 edd_mbr_sig_buf_entries; /* 0x1ea */ 114 __u8 edd_mbr_sig_buf_entries; /* 0x1ea */
115 __u8 _pad6[6]; /* 0x1eb */ 115 __u8 kbd_status; /* 0x1eb */
116 __u8 _pad6[5]; /* 0x1ec */
116 struct setup_header hdr; /* setup header */ /* 0x1f1 */ 117 struct setup_header hdr; /* setup header */ /* 0x1f1 */
117 __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; 118 __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
118 __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ 119 __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 00000000000..f27ac5ff597
--- /dev/null
+++ b/arch/x86/include/asm/kbdleds.h
@@ -0,0 +1,17 @@
1#ifndef _ASM_X86_KBDLEDS_H
2#define _ASM_X86_KBDLEDS_H
3
4/*
5 * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
6 * This seems a good reason to start with NumLock off. That's why on X86 we
7 * ask the bios for the correct state.
8 */
9
10#include <asm/setup.h>
11
12static inline int kbd_defleds(void)
13{
14 return boot_params.kbd_status & 0x20 ? (1 << VC_NUMLOCK) : 0;
15}
16
17#endif /* _ASM_X86_KBDLEDS_H */