summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-05-05 15:49:10 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-06 23:00:53 +0000
commita7cfc11ca71e1e4f77fe108408db9a5b4042b4d9 (patch)
tree1ef37967247d6c048a585c6fc1881e0aabc1988d
parent2279c445358f90ee7df9f0688c35837260684546 (diff)
downloadchrome-ec-a7cfc11ca71e1e4f77fe108408db9a5b4042b4d9.tar.gz
clapper: glimmer: fix for keyboard occasionally disabled on wake
Fixes bug in which the keyboard remains disabled after resuming. The problem occurs when the lidangle_keyscan_update() occurs after the CHIPSET_RESUME hook triggers and before chipset state is CHIPSET_STATE_ON, and the lid angle is in range to disable the keyboard. The fix is to not use a hook at all on chipset resume, and instead just keep track of the last chipset state locally in lidangle_keyscan_update(). That way we guarantee that when the AP is turned on, the next time we check for lidangle keyscanning state, it will enable the keyboard. BUG=chrome-os-partner:28480 BRANCH=rambi TEST=tested on a glimmer: Added a hook to detect chipset resume in lid_angle.c: static void enable_keyboard(void) { hook_fired = 1; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, enable_keyboard, HOOK_PRIO_DEFAULT); Then in lidangle_keyscan_update() added: if (hook_fired && !chipset_in_state(CHIPSET_STATE_ON)) ccprintf("Hook fired, but chipset state still reads off\n"); hook_fired = 0; Using this code, I used the lid switch on the servo board to open and close the lid repeatedly until I saw the printf above. Without this CL, when the printf is shown, the keyboard remains disabled in S0. With this CL, the keyboard is enabled in S0. Change-Id: Iac017a6468d46e0f011ec9d84a8c73b89622d8cc Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/198285 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/lid_angle.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/common/lid_angle.c b/common/lid_angle.c
index 2bee31d8c9..fa9e71dee6 100644
--- a/common/lid_angle.c
+++ b/common/lid_angle.c
@@ -118,6 +118,7 @@ void lidangle_keyscan_update(float lid_ang)
{
static float lidangle_buffer[KEY_SCAN_LID_ANGLE_BUFFER_SIZE];
static int index;
+ static int last_chipset_state_on;
int i;
int keys_accept = 1, keys_ignore = 1;
@@ -131,6 +132,7 @@ void lidangle_keyscan_update(float lid_ang)
* is enabled based on lid angle history.
*/
if (!chipset_in_state(CHIPSET_STATE_ON)) {
+ last_chipset_state_on = 0;
for (i = 0; i < KEY_SCAN_LID_ANGLE_BUFFER_SIZE; i++) {
/*
* If any lid angle samples are unreliable, then
@@ -153,17 +155,18 @@ void lidangle_keyscan_update(float lid_ang)
/* 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)
+ else if (keys_ignore)
keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
+ } else {
+ /*
+ * Make sure lid angle is not disabling keyboard scanning when
+ * AP is running. Note, we can't use a hook here for chipset
+ * resume because the hook triggers before the chipset state
+ * variable changes, (crosbug.com/p/28529)
+ */
+ if (!last_chipset_state_on) {
+ keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
+ last_chipset_state_on = 1;
+ }
}
}
-
-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);