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 /common/lid_angle.c | |
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 'common/lid_angle.c')
-rw-r--r-- | common/lid_angle.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/common/lid_angle.c b/common/lid_angle.c index 02f72f1991..2bee31d8c9 100644 --- a/common/lid_angle.c +++ b/common/lid_angle.c @@ -8,6 +8,7 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "hooks.h" #include "keyboard_scan.h" #include "lid_angle.h" #include "lid_switch.h" @@ -125,16 +126,11 @@ void lidangle_keyscan_update(float lid_ang) lidangle_buffer[index] = lid_ang; index = (index == KEY_SCAN_LID_ANGLE_BUFFER_SIZE-1) ? 0 : index+1; -#ifdef CONFIG_LID_SWITCH /* - * If lid is closed, don't need to check if keyboard scanning should - * be enabled. + * Any time the chipset is off, manage whether or not keyboard scanning + * is enabled based on lid angle history. */ - if (!lid_is_open()) - return; -#endif - - if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { + if (!chipset_in_state(CHIPSET_STATE_ON)) { for (i = 0; i < KEY_SCAN_LID_ANGLE_BUFFER_SIZE; i++) { /* * If any lid angle samples are unreliable, then @@ -154,16 +150,20 @@ void lidangle_keyscan_update(float lid_ang) keys_ignore = 0; } - /* Enable or disable keyboard scanning if necessary. */ - if (keys_accept && !keyboard_scan_is_enabled()) { - CPRINTF("[%T Enabling keyboard scan, lid ang at %d]\n", - (int)lidangle_buffer[index]); - keyboard_scan_enable(1); - } else if (keys_ignore && !keys_accept && - keyboard_scan_is_enabled()) { - CPRINTF("[%T Disabling keyboard scan, lid ang at %d]\n", - (int)lidangle_buffer[index]); - keyboard_scan_enable(0); - } + /* Enable or disable keyboard scanning as necessary. */ + if (keys_accept) + keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE); + else if (keys_ignore && !keys_accept) + keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE); } } + +static void enable_keyboard(void) +{ + /* + * Make sure lid angle is not disabling keyboard scanning when AP is + * running. + */ + keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, enable_keyboard, HOOK_PRIO_DEFAULT); |