Hello Thejaswani Putta,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/36654
to review the following change.
Change subject: libpayload: keyboard: Ignore special keys ......................................................................
libpayload: keyboard: Ignore special keys
some special keys emit a prefix scan code 0xE0, we will ignore all these except for the power button, F12 and cursor keys.
These changes are enabled with a config flag in libpayload and by default it is disabled, whichever board needs it will enable it in its Kconfig.
BUG:b:139511038 TEST=boot in recovery mode, press F12 to go to diagnostic mode and power button to confirm. Also in recovery mode left arrow, right arrow, up arrow, down arrow changes the language on the firmware screen.
Change-Id: I1c11939d18391bebe53ca21cf33a096ba369cd56 Signed-off-by: Thejaswani Putta thejaswani.putta@intel.corp-partner.google.com --- M payloads/libpayload/Kconfig M payloads/libpayload/drivers/i8042/keyboard.c 2 files changed, 44 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/36654/1
diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig index 97b970b..16e4c3a 100644 --- a/payloads/libpayload/Kconfig +++ b/payloads/libpayload/Kconfig @@ -353,6 +353,10 @@ bool "Ignore keyboard failures during init and always add input device" default n
+config PC_KEYBOARD_TREAT_MEDIA_KEYS_AS_FN + bool "Donot ignore prefix scan code OXE0 for some special keys" + default n + config PC_KEYBOARD_LAYOUT_US bool "English (US) keyboard layout" depends on PC_KEYBOARD diff --git a/payloads/libpayload/drivers/i8042/keyboard.c b/payloads/libpayload/drivers/i8042/keyboard.c index 48d35a0..e079a96 100644 --- a/payloads/libpayload/drivers/i8042/keyboard.c +++ b/payloads/libpayload/drivers/i8042/keyboard.c @@ -230,6 +230,40 @@ return modifier; }
+/* Ignore almost all special function keys & get the next key */ +/* F12 key generates 0xe0 0xb on press when fn is engaged. */ +static int keyboard_media_keys(void) +{ + unsigned char ch; + int ret = 0; + + ch = keyboard_get_scancode(); + switch (ch) { + case 0xb: + ret = KEY_F(12); + break; + case 0x5e: + ret = POWER_BUTTON; + break; + case 0x4b: + ret = KEY_LEFT; + break; + case 0x4d: + ret = KEY_RIGHT; + break; + case 0x48: + ret = KEY_UP; + break; + case 0x50: + ret = KEY_DOWN; + break; + default: + ret = 0; + } + printf("Teja: Returning %x \n", ret); + return ret; +} + int keyboard_getchar(void) { unsigned char ch; @@ -240,6 +274,12 @@
ch = keyboard_get_scancode();
+ /* process media keys, only return the keys that are needed */ + if (IS_ENABLED(CONFIG_LP_PC_KEYBOARD_TREAT_MEDIA_KEYS_AS_FN)) { + if (ch == 0xe0) { + return keyboard_media_keys(); + } + } if (!(ch & 0x80) && ch < 0x59) { shift = (modifier & KB_MOD_SHIFT) ^ (modifier & KB_MOD_CAPSLOCK) ? 1 : 0;