From 6d522eef9d672c56335ece32cf3473a2e274bea9 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 27 Sep 2013 16:29:10 -0700 Subject: [PATCH] Wake keyboard task when lid opens If keyboard scanning is active when the lid closes, it will disable scanning put the scan task to sleep. We need a corresponding task wake when the lid opens, or scanning will be stuck off (until something else happens, like poking the power button). BUG=chrome-os-partner:22190 BRANCH=peppy TEST=Hold down a key. Use a magnet to trigger the lid switch. Scanning should stop while the lid is "closed", and restart when the magnet is moved to "open" the lid again. Change-Id: I0a900f17f65b75cbdb45950cea7f50190d2bf9b1 Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/170993 Reviewed-by: Bill Richardson --- common/keyboard_scan.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 0873dee71c..8214d7c415 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -8,6 +8,7 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "hooks.h" #include "host_command.h" #include "keyboard_config.h" #include "keyboard_protocol.h" @@ -555,6 +556,18 @@ void keyboard_scan_enable(int enable) } } +#ifdef CONFIG_LID_SWITCH + +static void keyboard_lid_change(void) +{ + /* If lid is open, wake the keyboard task */ + if (lid_is_open()) + task_wake(TASK_ID_KEYSCAN); +} +DECLARE_HOOK(HOOK_LID_CHANGE, keyboard_lid_change, HOOK_PRIO_DEFAULT); + +#endif + /*****************************************************************************/ /* Host commands */