|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
|
80913e |
Date: Thu, 3 Dec 2020 09:13:24 +0100
|
|
|
80913e |
Subject: [PATCH] at_keyboard: use set 1 when keyboard is in Translate mode
|
|
|
80913e |
MIME-Version: 1.0
|
|
|
80913e |
Content-Type: text/plain; charset=UTF-8
|
|
|
80913e |
Content-Transfer-Encoding: 8bit
|
|
|
80913e |
|
|
|
80913e |
When keyboard controller acts in Translate mode (0x40 mask), then use
|
|
|
80913e |
set 1 since translation is done.
|
|
|
80913e |
Otherwise use the mode queried from the controller (usually set 2).
|
|
|
80913e |
|
|
|
80913e |
Added "atkeyb" debugging messages in at_keyboard module as well.
|
|
|
80913e |
|
|
|
80913e |
Resolves: rhbz#1897587
|
|
|
80913e |
|
|
|
80913e |
Tested on:
|
|
|
80913e |
- Asus N53SN (set 1 used)
|
|
|
80913e |
- Dell Precision (set 1 used)
|
|
|
80913e |
- HP Elitebook (set 2 used)
|
|
|
80913e |
- HP G5430 (set 1 used, keyboard in XT mode!)
|
|
|
80913e |
- Lenovo P71 & Lenovo T460s (set 2 used)
|
|
|
80913e |
- QEMU/KVM (set 1 used)
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/term/at_keyboard.c | 29 ++++++++++++++++++++++++-----
|
|
|
80913e |
include/grub/at_keyboard.h | 4 ++++
|
|
|
80913e |
2 files changed, 28 insertions(+), 5 deletions(-)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c
|
|
|
b32e65 |
index f0a986eb1..69d99b61d 100644
|
|
|
80913e |
--- a/grub-core/term/at_keyboard.c
|
|
|
80913e |
+++ b/grub-core/term/at_keyboard.c
|
|
|
80913e |
@@ -135,20 +135,28 @@ query_mode (void)
|
|
|
80913e |
int e;
|
|
|
80913e |
|
|
|
80913e |
e = write_mode (0);
|
|
|
80913e |
- if (!e)
|
|
|
80913e |
+ if (!e) {
|
|
|
80913e |
+ grub_dprintf("atkeyb", "query_mode: write_mode(0) failed\n");
|
|
|
80913e |
return 0;
|
|
|
80913e |
+ }
|
|
|
80913e |
|
|
|
80913e |
do {
|
|
|
80913e |
keyboard_controller_wait_until_ready ();
|
|
|
80913e |
ret = grub_inb (KEYBOARD_REG_DATA);
|
|
|
80913e |
} while (ret == GRUB_AT_ACK);
|
|
|
80913e |
/* QEMU translates the set even in no-translate mode. */
|
|
|
80913e |
- if (ret == 0x43 || ret == 1)
|
|
|
80913e |
+ if (ret == 0x43 || ret == 1) {
|
|
|
80913e |
+ grub_dprintf("atkeyb", "query_mode: returning 1 (ret=0x%x)\n", ret);
|
|
|
80913e |
return 1;
|
|
|
80913e |
- if (ret == 0x41 || ret == 2)
|
|
|
80913e |
+ }
|
|
|
80913e |
+ if (ret == 0x41 || ret == 2) {
|
|
|
80913e |
+ grub_dprintf("atkeyb", "query_mode: returning 2 (ret=0x%x)\n", ret);
|
|
|
80913e |
return 2;
|
|
|
80913e |
- if (ret == 0x3f || ret == 3)
|
|
|
80913e |
+ }
|
|
|
80913e |
+ if (ret == 0x3f || ret == 3) {
|
|
|
80913e |
+ grub_dprintf("atkeyb", "query_mode: returning 3 (ret=0x%x)\n", ret);
|
|
|
80913e |
return 3;
|
|
|
80913e |
+ }
|
|
|
80913e |
return 0;
|
|
|
80913e |
}
|
|
|
80913e |
|
|
|
80913e |
@@ -165,7 +173,13 @@ set_scancodes (void)
|
|
|
80913e |
}
|
|
|
80913e |
|
|
|
80913e |
#if !USE_SCANCODE_SET
|
|
|
80913e |
- ps2_state.current_set = 1;
|
|
|
80913e |
+ if ((grub_keyboard_controller_orig & KEYBOARD_AT_TRANSLATE) == KEYBOARD_AT_TRANSLATE) {
|
|
|
80913e |
+ grub_dprintf ("atkeyb", "queried set is %d but keyboard in Translate mode, so actually in set 1\n", grub_keyboard_orig_set);
|
|
|
80913e |
+ ps2_state.current_set = 1;
|
|
|
80913e |
+ } else {
|
|
|
80913e |
+ grub_dprintf ("atkeyb", "using queried set %d\n", grub_keyboard_orig_set);
|
|
|
80913e |
+ ps2_state.current_set = grub_keyboard_orig_set;
|
|
|
80913e |
+ }
|
|
|
80913e |
return;
|
|
|
80913e |
#else
|
|
|
80913e |
|
|
|
80913e |
@@ -266,6 +280,7 @@ grub_keyboard_controller_init (void)
|
|
|
80913e |
grub_keyboard_orig_set = 2;
|
|
|
80913e |
#else
|
|
|
80913e |
grub_keyboard_controller_orig = grub_keyboard_controller_read ();
|
|
|
80913e |
+ grub_dprintf ("atkeyb", "grub_keyboard_controller_orig = 0x%x\n", grub_keyboard_controller_orig);
|
|
|
80913e |
grub_keyboard_orig_set = query_mode ();
|
|
|
80913e |
#endif
|
|
|
80913e |
set_scancodes ();
|
|
|
80913e |
@@ -275,11 +290,15 @@ grub_keyboard_controller_init (void)
|
|
|
80913e |
static grub_err_t
|
|
|
80913e |
grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused)))
|
|
|
80913e |
{
|
|
|
80913e |
+/* In !USE_SCANCODE_SET mode, we didn't change anything, so nothing to restore */
|
|
|
80913e |
+#if USE_SCANCODE_SET
|
|
|
80913e |
if (ps2_state.current_set == 0)
|
|
|
80913e |
return GRUB_ERR_NONE;
|
|
|
80913e |
+ grub_dprintf ("atkeyb", "restoring set %d, controller 0x%x\n", grub_keyboard_orig_set, grub_keyboard_controller_orig);
|
|
|
80913e |
if (grub_keyboard_orig_set)
|
|
|
80913e |
write_mode (grub_keyboard_orig_set);
|
|
|
80913e |
grub_keyboard_controller_write (grub_keyboard_controller_orig);
|
|
|
80913e |
+#endif
|
|
|
80913e |
return GRUB_ERR_NONE;
|
|
|
80913e |
}
|
|
|
80913e |
|
|
|
80913e |
diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h
|
|
|
b32e65 |
index bcb4d9ba7..9414dc1b9 100644
|
|
|
80913e |
--- a/include/grub/at_keyboard.h
|
|
|
80913e |
+++ b/include/grub/at_keyboard.h
|
|
|
80913e |
@@ -19,6 +19,10 @@
|
|
|
80913e |
#ifndef GRUB_AT_KEYBOARD_HEADER
|
|
|
80913e |
#define GRUB_AT_KEYBOARD_HEADER 1
|
|
|
80913e |
|
|
|
80913e |
+/*
|
|
|
80913e |
+ * Refer to https://wiki.osdev.org/%228042%22_PS/2_Controller for details.
|
|
|
80913e |
+ */
|
|
|
80913e |
+
|
|
|
80913e |
/* Used for sending commands to the controller. */
|
|
|
80913e |
#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
|
|
|
80913e |
#define KEYBOARD_COMMAND_READ 0x20
|