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 on drallion. Media key mapping is set in depthcharge and will be sent to libpayload keyboard driver. Whichever board requires this change will update its own media key mapping. BUG🅱️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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/36654 Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com> Reviewed-by: Mathew King <mathewk@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
e477626d82
commit
3557f12458
|
@ -35,6 +35,7 @@
|
||||||
#include "i8042.h"
|
#include "i8042.h"
|
||||||
|
|
||||||
#define POWER_BUTTON 0x90
|
#define POWER_BUTTON 0x90
|
||||||
|
#define MEDIA_KEY_PREFIX 0xE0
|
||||||
|
|
||||||
struct layout_maps {
|
struct layout_maps {
|
||||||
const char *country;
|
const char *country;
|
||||||
|
@ -43,6 +44,7 @@ struct layout_maps {
|
||||||
|
|
||||||
static struct layout_maps *map;
|
static struct layout_maps *map;
|
||||||
static int modifier = 0;
|
static int modifier = 0;
|
||||||
|
int (*media_key_mapping_callback)(char ch);
|
||||||
|
|
||||||
static struct layout_maps keyboard_layouts[] = {
|
static struct layout_maps keyboard_layouts[] = {
|
||||||
#if CONFIG(LP_PC_KEYBOARD_LAYOUT_US)
|
#if CONFIG(LP_PC_KEYBOARD_LAYOUT_US)
|
||||||
|
@ -230,6 +232,11 @@ int keyboard_getmodifier(void)
|
||||||
return modifier;
|
return modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initialize_keyboard_media_key_mapping_callback(int (*media_key_mapper)(char))
|
||||||
|
{
|
||||||
|
media_key_mapping_callback = media_key_mapper;
|
||||||
|
}
|
||||||
|
|
||||||
int keyboard_getchar(void)
|
int keyboard_getchar(void)
|
||||||
{
|
{
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
|
@ -239,6 +246,10 @@ int keyboard_getchar(void)
|
||||||
while (!keyboard_havechar()) ;
|
while (!keyboard_havechar()) ;
|
||||||
|
|
||||||
ch = keyboard_get_scancode();
|
ch = keyboard_get_scancode();
|
||||||
|
if ((media_key_mapping_callback != NULL) && (ch == MEDIA_KEY_PREFIX)) {
|
||||||
|
ch = keyboard_get_scancode();
|
||||||
|
return media_key_mapping_callback(ch);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(ch & 0x80) && ch < 0x59) {
|
if (!(ch & 0x80) && ch < 0x59) {
|
||||||
shift =
|
shift =
|
||||||
|
|
|
@ -187,6 +187,7 @@ unsigned char keyboard_get_scancode(void);
|
||||||
int keyboard_getchar(void);
|
int keyboard_getchar(void);
|
||||||
int keyboard_set_layout(char *country);
|
int keyboard_set_layout(char *country);
|
||||||
int keyboard_getmodifier(void);
|
int keyboard_getmodifier(void);
|
||||||
|
void initialize_keyboard_media_key_mapping_callback(int (*media_key_mapper)(char));
|
||||||
|
|
||||||
enum KEYBOARD_MODIFIERS {
|
enum KEYBOARD_MODIFIERS {
|
||||||
KB_MOD_SHIFT = (1 << 0),
|
KB_MOD_SHIFT = (1 << 0),
|
||||||
|
|
Loading…
Reference in New Issue