summaryrefslogtreecommitdiff
path: root/common/tablet_mode.c
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-09-04 10:17:21 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-09-04 16:53:42 -0700
commitb002393a5156fee4d223915b2a59004d15f39aeb (patch)
tree462fffb207b624d83f6ef8065c63f6a2f00b48ff /common/tablet_mode.c
parent17502f46b05bb0e8702b8019dfdf79cc4019a3c9 (diff)
downloadchrome-ec-b002393a5156fee4d223915b2a59004d15f39aeb.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
Diffstat (limited to 'common/tablet_mode.c')
-rw-r--r--common/tablet_mode.c20
1 files changed, 20 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