diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-04-10 12:32:05 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-04-11 20:02:30 +0000 |
commit | 3344c8e2e64fd4985f6fbb55810452f195b7b7eb (patch) | |
tree | 648fae08de74b86d43a8430b523ec52ac701ab5c /include/keyboard_scan.h | |
parent | 2dc7016541daf1bf7e9e96131eced09fe6a94776 (diff) | |
download | chrome-ec-3344c8e2e64fd4985f6fbb55810452f195b7b7eb.tar.gz |
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 <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/194287
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/keyboard_scan.h')
-rw-r--r-- | include/keyboard_scan.h | 23 |
1 files changed, 15 insertions, 8 deletions
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. |