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 16:00:37 +0000 |
commit | f4f7e3f42c265bb2d9dfbd2fe442f149d84bd6b0 (patch) | |
tree | e3e8e8dacfea31156b653c4809f441c738b42e31 /include | |
parent | 0abb7a45d973a5d612d901726588db78e4679720 (diff) | |
download | chrome-ec-f4f7e3f42c265bb2d9dfbd2fe442f149d84bd6b0.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/194097
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-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. |