keyboard_scan: Add option to not handle boot key combinations

On some boards, the boot key combinations do not make a lot of
sense, so we can just not process them and save a little bit
of code space.

BRANCH=none
BUG=b:37422577
TEST=Flash hammer
TEST=make newsizes shows we save 156 bytes in hammer RW.

Change-Id: Ic96d7ed1dbee10f44f8b08568ab70b2f20961842
Reviewed-on: https://chromium-review.googlesource.com/495968
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Nicolas Boichat
2017-05-04 16:55:00 +08:00
committed by chrome-bot
parent 541ddb0f88
commit a16b2e7c2d
3 changed files with 15 additions and 1 deletions

View File

@@ -71,12 +71,14 @@ struct boot_key_entry {
uint8_t mask_value;
};
#ifdef CONFIG_KEYBOARD_BOOT_KEYS
static const struct boot_key_entry boot_key_list[] = {
{KEYBOARD_COL_ESC, KEYBOARD_MASK_ESC}, /* Esc */
{KEYBOARD_COL_DOWN, KEYBOARD_MASK_DOWN}, /* Down-arrow */
{KEYBOARD_COL_LEFT_SHIFT, KEYBOARD_MASK_LEFT_SHIFT}, /* Left-Shift */
};
static uint32_t boot_key_value = BOOT_KEY_NONE;
#endif
/* Debounced key matrix */
static uint8_t __bss_slow debounced_state[KEYBOARD_COLS];
@@ -524,6 +526,7 @@ static int check_keys_changed(uint8_t *state)
return any_pressed;
}
#ifdef CONFIG_KEYBOARD_BOOT_KEYS
/*
* Returns mask of the boot keys that are pressed, with at most the keys used
* for keyboard-controlled reset also pressed.
@@ -598,6 +601,7 @@ static uint32_t check_boot_key(const uint8_t *state)
return check_key_list(state);
}
#endif
static void keyboard_freq_change(void)
{
@@ -614,10 +618,12 @@ struct keyboard_scan_config *keyboard_scan_get_config(void)
return &keyscan_config;
}
#ifdef CONFIG_KEYBOARD_BOOT_KEYS
uint32_t keyboard_scan_get_boot_keys(void)
{
return boot_key_value;
}
#endif
const uint8_t *keyboard_scan_get_state(void)
{
@@ -636,6 +642,7 @@ void keyboard_scan_init(void)
read_matrix(debounced_state);
memcpy(prev_state, debounced_state, sizeof(prev_state));
#ifdef CONFIG_KEYBOARD_BOOT_KEYS
/* Check for keys held down at boot */
boot_key_value = check_boot_key(debounced_state);
@@ -654,6 +661,7 @@ void keyboard_scan_init(void)
EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT);
}
#endif
#endif /* CONFIG_KEYBOARD_BOOT_KEYS */
}
void keyboard_scan_task(void)

View File

@@ -1505,6 +1505,12 @@
*/
#undef CONFIG_KEYBOARD_BOARD_CONFIG
/*
* Support for boot key combinations (e.g. refresh key being held on boot to
* trigger recovery).
*/
#define CONFIG_KEYBOARD_BOOT_KEYS
/*
* Minimum CPU clocks between scans. This ensures that keyboard scanning
* doesn't starve the other EC tasks of CPU when running at a decreased system

View File

@@ -56,7 +56,7 @@ enum boot_key {
BOOT_KEY_LEFT_SHIFT = (1 << 2),
};
#ifdef HAS_TASK_KEYSCAN
#if defined(HAS_TASK_KEYSCAN) && defined(CONFIG_KEYBOARD_BOOT_KEYS)
/**
* Returns mask of all the keys held down at boot time in addition to the
* keyboard-controlled reset keys. If more than one boot key is held, mask bits