diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2019-07-11 11:45:05 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-30 17:04:16 +0000 |
commit | bff87743ed058db1971aeb16c6fb2387feb531f5 (patch) | |
tree | 83cc2455671d75be389c8d90dca30a571ac9403f | |
parent | 18e2dc171100e4ebe145184a816119431ce1a7a0 (diff) | |
download | chrome-ec-bff87743ed058db1971aeb16c6fb2387feb531f5.tar.gz |
tablet-mode: Disable tablet mode in recovery boot
In recovery boot, keyboard could be unintentionally disabled due to
unstable accels, which are not calibrated.
This patch disables tablet mode in recovery boot.
We get the same effect if motion sensors or a motion sense task are
disabled in RO.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=chromium:984086,b/137251616
BRANCH=none
TEST=buildall
Change-Id: Idcf53ad119edbd8ff9362523ec7a72f438ae4401
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1696914
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1726333
Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | common/keyboard_scan.c | 11 | ||||
-rw-r--r-- | common/tablet_mode.c | 35 | ||||
-rw-r--r-- | include/tablet_mode.h | 5 |
3 files changed, 44 insertions, 7 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index fa8ce3d98f..33b811e626 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -18,6 +18,7 @@ #include "lid_switch.h" #include "switch.h" #include "system.h" +#include "tablet_mode.h" #include "task.h" #include "timer.h" #include "util.h" @@ -645,6 +646,16 @@ void keyboard_scan_init(void) #ifdef CONFIG_HOSTCMD_EVENTS if (boot_key_value & BOOT_KEY_ESC) { host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY); + /* + * In recovery mode, we should force clamshell mode in order to + * prevent the keyboard from being disabled unintentionally due + * to unstable accel readings. + * + * You get the same effect if motion sensors or a motion sense + * task are disabled in RO. + */ + if (IS_ENABLED(CONFIG_TABLET_MODE)) + tablet_disable(); if (boot_key_value & BOOT_KEY_LEFT_SHIFT) host_set_single_event( EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT); diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 4a9a0b2364..3e1f261337 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -3,21 +3,44 @@ * found in the LICENSE file. */ +#include "console.h" #include "hooks.h" +#include "tablet_mode.h" -/* Return 1 if in tablet mode, 0 otherwise */ -static int tablet_mode = 1; +#define CPRINTS(format, args...) cprints(CC_MOTION_LID, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_MOTION_LID, format, ## args) + +/* 1: in tablet mode; 0: notebook mode; -1: uninitialized */ +static int tablet_mode = -1; + +/* + * 1: all calls to tablet_set_mode are ignored and tablet_mode if forced to 0 + * 0: all calls to tablet_set_mode are honored + */ +static int disabled; int tablet_get_mode(void) { - return tablet_mode; + return !!tablet_mode; } void tablet_set_mode(int mode) { - if (tablet_mode != mode) { - tablet_mode = mode; - hook_notify(HOOK_TABLET_MODE_CHANGE); + if (tablet_mode == mode) + return; + + if (disabled) { + CPRINTS("Tablet mode set while disabled (ignoring)!"); + return; } + + tablet_mode = mode; + CPRINTS("tablet mode %sabled", mode ? "en" : "dis"); + hook_notify(HOOK_TABLET_MODE_CHANGE); } +void tablet_disable(void) +{ + tablet_mode = 0; + disabled = 1; +} diff --git a/include/tablet_mode.h b/include/tablet_mode.h index 6f4ee95e1e..48e8fdd590 100644 --- a/include/tablet_mode.h +++ b/include/tablet_mode.h @@ -9,4 +9,7 @@ int tablet_get_mode(void); void tablet_set_mode(int mode); - +/** + * Disable tablet mode + */ +void tablet_disable(void); |