From 8f73372cefb375c60e0003e0c5839f014e2ca4fa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 16 Oct 2012 17:00:59 -0700 Subject: [PATCH] stm32: Swallow special keys instead of passing them to AP During the debounce refactor we unintentionally adjusted the behavior of special keys so that they are no longer swallowed (as per commit 9332d76). The LM4's keyboard behaves differently so this code cannot be brought over as is. Bring back the required behavior for STM32. BUG=chrome-os-partner:14496 TEST=hit alt-volume_up-r keys together. See that the AP does not see this keypress in U-Boot by checking the EC console has no 0x60 messages. BRANCH=snow Change-Id: I043fbba4d9be5941e550257b99bdb2137792c133 Signed-off-by: Simon Glass Reviewed-on: https://gerrit.chromium.org/gerrit/35767 Reviewed-by: Randall Spangler --- chip/stm32/keyboard_scan.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index 243292287a..a16bd09edb 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -243,8 +243,9 @@ void enter_polling_mode(void) * Check special runtime key combinations. * * @param state Keyboard state to use when checking keys. + * @return 1 if a special key was pressed, 0 if not */ -static void check_runtime_keys(const uint8_t *state) +static int check_runtime_keys(const uint8_t *state) { int num_press; int c; @@ -256,7 +257,7 @@ static void check_runtime_keys(const uint8_t *state) } if (num_press != 3) - return; + return 0; if (state[MASK_INDEX_KEYR] == MASK_VALUE_KEYR && state[MASK_INDEX_VOL_UP] == MASK_VALUE_VOL_UP && @@ -264,7 +265,10 @@ static void check_runtime_keys(const uint8_t *state) state[MASK_INDEX_LEFT_ALT] == MASK_VALUE_LEFT_ALT)) { keyboard_clear_state(); system_warm_reboot(); + return 1; } + + return 0; } /* Print the keyboard state. */ @@ -441,9 +445,10 @@ static int check_keys_changed(uint8_t *state) CPRINTF("\n"); #endif - check_runtime_keys(state); - - if (kb_fifo_add(state) == EC_SUCCESS) + /* Swallow special keys */ + if (check_runtime_keys(state)) + return 0; + else if (kb_fifo_add(state) == EC_SUCCESS) board_interrupt_host(1); else CPRINTF("dropped keystroke\n");