summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-02-01 11:38:29 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-05 19:08:21 -0800
commit1af3e5362689497cbc5896cad8e907dd85c7e8ce (patch)
tree9daac181b8d5c8b00bdf2c494c24878a67492401 /common
parent59fe7c7a5861f95da3d3539a55e3ad019a615517 (diff)
downloadchrome-ec-1af3e5362689497cbc5896cad8e907dd85c7e8ce.tar.gz
keyboard_scan: Disable when USB is suspended without wake
Keyboard matrix scanning can be disabled when the USB interface is disabled without setting the remote wake feature (USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be ignored anyway. BRANCH=none BUG=b:72683995 TEST=keyboard matrix scanning is disabled when lid is closed. Change-Id: I0b2346cc3426b9ef51127424f9953fd5c20ecd49 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/897068 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/keyboard_scan.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index 23925fc218..34474917b3 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -20,6 +20,7 @@
#include "system.h"
#include "task.h"
#include "timer.h"
+#include "usb_api.h"
#include "util.h"
/* Console output macros */
@@ -777,6 +778,21 @@ DECLARE_HOOK(HOOK_INIT, keyboard_lid_change, HOOK_PRIO_INIT_LID + 1);
#endif
+#ifdef CONFIG_USB_SUSPEND
+static void keyboard_usb_pm_change(void)
+{
+ /*
+ * If USB interface is suspended, and host is not asking us to do remote
+ * wakeup, we can turn off the key scanning.
+ */
+ if (usb_is_suspended() && !usb_is_remote_wakeup_enabled())
+ keyboard_scan_enable(0, KB_SCAN_DISABLE_USB_SUSPENDED);
+ else
+ keyboard_scan_enable(1, KB_SCAN_DISABLE_USB_SUSPENDED);
+}
+DECLARE_HOOK(HOOK_USB_PM_CHANGE, keyboard_usb_pm_change, HOOK_PRIO_DEFAULT);
+#endif
+
/*****************************************************************************/
/* Host commands */