summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-07-11 11:45:05 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-04 17:10:57 +0000
commitdb917eb36a6ea2a7d1eae5e966efdd1e0dde570f (patch)
tree3ebab6ffa3ecb7697cca895b25d11c65e495651a
parenta9ea6907339ff2a99970f8de4d1655bc17107435 (diff)
downloadchrome-ec-db917eb36a6ea2a7d1eae5e966efdd1e0dde570f.tar.gz
tablet-mode: Disable tablet mode in recovery boot
*** Require RO update *** 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> (cherry picked from commit bff87743ed058db1971aeb16c6fb2387feb531f5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747048 (cherry picked from commit b51d17781e2f9316f5bb154a45a2515a3eaaf8b6) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1842032
-rw-r--r--common/keyboard_scan.c11
-rw-r--r--common/tablet_mode.c18
-rw-r--r--include/tablet_mode.h5
3 files changed, 34 insertions, 0 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index f5fb7542de..9de1dea614 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -19,6 +19,7 @@
#include "lid_switch.h"
#include "switch.h"
#include "system.h"
+#include "tablet_mode.h"
#include "task.h"
#include "timer.h"
#include "usb_api.h"
@@ -702,6 +703,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 edda95085f..5f137d3d94 100644
--- a/common/tablet_mode.c
+++ b/common/tablet_mode.c
@@ -9,6 +9,7 @@
#include "lid_angle.h"
#include "tablet_mode.h"
#include "timer.h"
+#include "tablet_mode.h"
#define CPRINTS(format, args...) cprints(CC_MOTION_LID, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_MOTION_LID, format, ## args)
@@ -16,6 +17,12 @@
/* 1: in tablet mode. 0: otherwise */
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;
@@ -26,6 +33,11 @@ void tablet_set_mode(int mode)
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);
@@ -69,3 +81,9 @@ static void tablet_mode_init(void)
}
DECLARE_HOOK(HOOK_INIT, tablet_mode_init, HOOK_PRIO_DEFAULT);
#endif
+
+void tablet_disable(void)
+{
+ tablet_mode = 0;
+ disabled = 1;
+}
diff --git a/include/tablet_mode.h b/include/tablet_mode.h
index 9c783ef1ff..b9aebcf6c1 100644
--- a/include/tablet_mode.h
+++ b/include/tablet_mode.h
@@ -17,3 +17,8 @@ void tablet_set_mode(int mode);
* @param signal: GPIO signal
*/
void tablet_mode_isr(enum gpio_signal signal);
+
+/**
+ * Disable tablet mode
+ */
+void tablet_disable(void);