summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-09-04 10:17:21 -0600
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-09-18 15:38:04 +0000
commit85efa7f4d912beb6671069bd3c156601421b6354 (patch)
tree0a7d061f96dbedc15e18d220007f3c6fe61f9d14
parent9ff66b6e3c9adae9eed838053a81a67f4dc62f9b (diff)
downloadchrome-ec-85efa7f4d912beb6671069bd3c156601421b6354.tar.gz
tablet-mode: add disable function
For clamshell SKUs, we do not want to ever enable tablet mode. Since the firmware is shared between convertibles and clamshells, we need to compile in the tablet mode switch support but have a way to disable it at run-time BRANCH=none BUG=b:113837268 TEST=verify that a clamshell SKU does not go into tablet mode when a free magnet gets close to the sensor (with CL stack) Change-Id: Icc0f72253014f05598d658601eb8437bfe0ff488 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1204451 Reviewed-on: https://chromium-review.googlesource.com/1230975 Reviewed-by: Martin Roth <martinroth@chromium.org> Commit-Queue: Martin Roth <martinroth@chromium.org> Tested-by: Martin Roth <martinroth@chromium.org>
-rw-r--r--common/tablet_mode.c20
-rw-r--r--include/tablet_mode.h6
2 files changed, 26 insertions, 0 deletions
diff --git a/common/tablet_mode.c b/common/tablet_mode.c
index edda95085f..5185895ce4 100644
--- a/common/tablet_mode.c
+++ b/common/tablet_mode.c
@@ -16,6 +16,8 @@
/* 1: in tablet mode. 0: otherwise */
static int tablet_mode = 1;
+static int disabled;
+
int tablet_get_mode(void)
{
return tablet_mode;
@@ -26,6 +28,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);
@@ -62,10 +69,23 @@ void tablet_mode_isr(enum gpio_signal signal)
static void tablet_mode_init(void)
{
+ /* If this sub-system was disabled before initializing, honor that. */
+ if (disabled)
+ return;
+
gpio_enable_interrupt(TABLET_MODE_GPIO_L);
/* Ensure tablet mode is initialized according to the hardware state
* so that the cached state reflects reality. */
tablet_mode_debounce();
}
DECLARE_HOOK(HOOK_INIT, tablet_mode_init, HOOK_PRIO_DEFAULT);
+
+void tablet_disable_switch(void)
+{
+ gpio_disable_interrupt(TABLET_MODE_GPIO_L);
+ /* Cancel any pending debounce calls */
+ hook_call_deferred(&tablet_mode_debounce_data, -1);
+ tablet_set_mode(0);
+ disabled = 1;
+}
#endif
diff --git a/include/tablet_mode.h b/include/tablet_mode.h
index 9c783ef1ff..2568ba2e86 100644
--- a/include/tablet_mode.h
+++ b/include/tablet_mode.h
@@ -17,3 +17,9 @@ void tablet_set_mode(int mode);
* @param signal: GPIO signal
*/
void tablet_mode_isr(enum gpio_signal signal);
+
+/**
+ * Disables the tablet mode switch sub-system and turns off tablet mode. This is
+ * useful for clamshell devices.
+ */
+void tablet_disable_switch(void);