diff options
| author | Joshua Cov <joshuacov@googlemail.com> | 2012-04-13 15:08:26 -0400 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2012-05-08 17:19:41 -0400 |
| commit | b2d0b7a061bfddd27155c7dcd53f365d9dc0c7c3 (patch) | |
| tree | 8063c6df479723b7adc509ee2aad728889faa9a4 | |
| parent | c2c21e9bb17549e8add4ff76931bcec2e2d3ad48 (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>
| -rw-r--r-- | arch/parisc/include/asm/kbdleds.h | 19 | ||||
| -rw-r--r-- | arch/x86/boot/main.c | 18 | ||||
| -rw-r--r-- | arch/x86/include/asm/bootparam.h | 3 | ||||
| -rw-r--r-- | arch/x86/include/asm/kbdleds.h | 17 | ||||
| -rw-r--r-- | 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 00000000000..2e2e75a83c2 --- /dev/null +++ b/arch/parisc/include/asm/kbdleds.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #ifndef _ASM_PARISC_KBDLEDS_H | ||
| 2 | #define _ASM_PARISC_KBDLEDS_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * On HIL keyboards of PARISC machines there is no NumLock key and | ||
| 6 | * everyone expects the keypad to be used for numbers. That's why | ||
| 7 | * we can safely turn on the NUMLOCK bit. | ||
| 8 | */ | ||
| 9 | |||
| 10 | static inline int kbd_defleds(void) | ||
| 11 | { | ||
| 12 | #if defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD) | ||
| 13 | return 1 << VC_NUMLOCK; | ||
| 14 | #else | ||
| 15 | return 0; | ||
| 16 | #endif | ||
| 17 | } | ||
| 18 | |||
| 19 | #endif /* _ASM_PARISC_KBDLEDS_H */ | ||
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 | */ |
| 63 | static void keyboard_set_repeat(void) | 64 | static 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 | |||
| 12 | static 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 */ | ||
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 86dd1e302bb..b021a181766 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c | |||
| @@ -53,17 +53,13 @@ extern void ctrl_alt_del(void); | |||
| 53 | 53 | ||
| 54 | #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META)) | 54 | #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META)) |
| 55 | 55 | ||
| 56 | /* | 56 | #if defined(CONFIG_X86) || defined(CONFIG_PARISC) |
| 57 | * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on. | 57 | #include <asm/kbdleds.h> |
| 58 | * This seems a good reason to start with NumLock off. On HIL keyboards | ||
| 59 | * of PARISC machines however there is no NumLock key and everyone expects the | ||
| 60 | * keypad to be used for numbers. | ||
| 61 | */ | ||
| 62 | |||
| 63 | #if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD)) | ||
| 64 | #define KBD_DEFLEDS (1 << VC_NUMLOCK) | ||
| 65 | #else | 58 | #else |
| 66 | #define KBD_DEFLEDS 0 | 59 | static inline int kbd_defleds(void) |
| 60 | { | ||
| 61 | return 0; | ||
| 62 | } | ||
| 67 | #endif | 63 | #endif |
| 68 | 64 | ||
| 69 | #define KBD_DEFLOCK 0 | 65 | #define KBD_DEFLOCK 0 |
| @@ -1512,8 +1508,8 @@ int __init kbd_init(void) | |||
| 1512 | int error; | 1508 | int error; |
| 1513 | 1509 | ||
| 1514 | for (i = 0; i < MAX_NR_CONSOLES; i++) { | 1510 | for (i = 0; i < MAX_NR_CONSOLES; i++) { |
| 1515 | kbd_table[i].ledflagstate = KBD_DEFLEDS; | 1511 | kbd_table[i].ledflagstate = kbd_defleds(); |
| 1516 | kbd_table[i].default_ledflagstate = KBD_DEFLEDS; | 1512 | kbd_table[i].default_ledflagstate = kbd_defleds(); |
| 1517 | kbd_table[i].ledmode = LED_SHOW_FLAGS; | 1513 | kbd_table[i].ledmode = LED_SHOW_FLAGS; |
| 1518 | kbd_table[i].lockstate = KBD_DEFLOCK; | 1514 | kbd_table[i].lockstate = KBD_DEFLOCK; |
| 1519 | kbd_table[i].slockstate = 0; | 1515 | kbd_table[i].slockstate = 0; |
