diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-05-04 16:55:00 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-08 07:04:06 -0700 |
commit | a16b2e7c2d03bb64787770c114920fa8f5635a82 (patch) | |
tree | ac2207283e51c6908b2e59e44126a17fb3e7fd95 | |
parent | 541ddb0f889c2630e457fbab475cf6e2f781b54c (diff) | |
download | chrome-ec-a16b2e7c2d03bb64787770c114920fa8f5635a82.tar.gz |
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>
-rw-r--r-- | common/keyboard_scan.c | 8 | ||||
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | include/keyboard_scan.h | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 3ad4805b90..c4053d583e 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -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) diff --git a/include/config.h b/include/config.h index 07c02acd5a..74f5726569 100644 --- a/include/config.h +++ b/include/config.h @@ -1506,6 +1506,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 * clock. diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index 94457dd16d..bce5046c9e 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -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 |