diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-02-01 11:38:29 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-05 19:08:21 -0800 |
commit | 1af3e5362689497cbc5896cad8e907dd85c7e8ce (patch) | |
tree | 9daac181b8d5c8b00bdf2c494c24878a67492401 | |
parent | 59fe7c7a5861f95da3d3539a55e3ad019a615517 (diff) | |
download | chrome-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>
-rw-r--r-- | chip/stm32/usb_hid_keyboard.c | 3 | ||||
-rw-r--r-- | common/keyboard_scan.c | 16 | ||||
-rw-r--r-- | include/keyboard_scan.h | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index e882b88d7b..631ad15ef2 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -571,6 +571,9 @@ void keyboard_state_changed(int row, int col, int is_pressed) keyboard_process_queue(); } +void clear_typematic_key(void) +{ } + #ifdef CONFIG_USB_HID_KEYBOARD_BACKLIGHT void usb_hid_keyboard_init(void) { 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 */ diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index bce5046c9e..65492c59bd 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -87,6 +87,7 @@ enum kb_scan_disable_masks { KB_SCAN_DISABLE_LID_CLOSED = (1<<0), KB_SCAN_DISABLE_POWER_BUTTON = (1<<1), KB_SCAN_DISABLE_LID_ANGLE = (1<<2), + KB_SCAN_DISABLE_USB_SUSPENDED = (1<<3), }; #ifdef HAS_TASK_KEYSCAN |