From f4f7e3f42c265bb2d9dfbd2fe442f149d84bd6b0 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Thu, 10 Apr 2014 12:32:05 -0700 Subject: Refactored keyboard scan enable flag to allow for multiple disable reasons Refactored keyboard scan enable/disable flag such that it is a mask of potential disable sources. When all disable sources are off, scanning is enabled, otherwise scanning is disabled. This fixes a recently introduced bug in which enabling/disabling keyboard scanning due to lid angle in S3 was interfering with enabling/disabling keyboard scanning due to power button. This also allows for easy expansion for future causes for disabling keyboard scanning. BUG=chrome-os-partner:27851 BRANCH=rambi TEST=Manual tests with a glimmer. Used the ksstate console command to check state of keyboard scanning under all permutations of power button pressed/unpressed, lid switch open/closed, and lid angle in tablet position vs. laptop positon. Change-Id: Ied4c5ebb94510b1078cd81d71373c0f1bd0d6678 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/194097 Reviewed-by: Randall Spangler --- include/keyboard_scan.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index 8359cbd174..41cdbdf611 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -75,20 +75,27 @@ static inline enum boot_key keyboard_scan_get_boot_key(void) */ const uint8_t *keyboard_scan_get_state(void); +enum kb_scan_disable_masks { + /* Reasons why keyboard scanning should be disabled */ + KB_SCAN_DISABLE_LID_CLOSED = (1<<0), + KB_SCAN_DISABLE_POWER_BUTTON = (1<<1), + KB_SCAN_DISABLE_LID_ANGLE = (1<<2), +}; + #ifdef HAS_TASK_KEYSCAN /** - * Enables/disables keyboard matrix scan. + * Enable/disable keyboard scanning. Scanning will be disabled if any disable + * reason bit is set. Scanning is enabled only if no disable reasons are set. + * + * @param enable Clear(=1) or set(=0) disable-bits from the mask. + * @param mask Disable reasons from kb_scan_disable_masks */ -void keyboard_scan_enable(int enable); +void keyboard_scan_enable(int enable, enum kb_scan_disable_masks mask); #else -static inline void keyboard_scan_enable(int enable) { } +static inline void keyboard_scan_enable(int enable, + enum kb_scan_disable_masks mask) { } #endif -/** - * Returns if keyboard matrix scanning is enabled/disabled. - */ -int keyboard_scan_is_enabled(void); - #ifdef CONFIG_KEYBOARD_SUPPRESS_NOISE /** * Indicate to audio codec that a key has been pressed. -- cgit v1.2.1