summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Chandra Sadineni <ravisadineni@chromium.org>2019-09-11 10:35:31 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-12 10:25:07 +0000
commit87502c08eb8b5855465257c314c5273fc7af7b26 (patch)
treef16be9ebfd2b566bb52a9b7ad23127593457aafc
parenta0e7e66ebd384455041b99d99cce30dea771ddfa (diff)
downloadchrome-ec-87502c08eb8b5855465257c314c5273fc7af7b26.tar.gz
tablet_mode: expose console command.
Expose console command to force tablet mode. This helps in testing whether a given device wakes on tablet mode switch. BUG=b:133262012 BRANCH=None TEST=Deploy on hatch and play with the command. Change-Id: Id6ffbf5226590e10a0758a07761f78024d57bb58 Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1797370 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/tablet_mode.c37
-rw-r--r--include/host_command.h2
2 files changed, 37 insertions, 2 deletions
diff --git a/common/tablet_mode.c b/common/tablet_mode.c
index 7773ba84d6..5da4db7821 100644
--- a/common/tablet_mode.c
+++ b/common/tablet_mode.c
@@ -17,6 +17,7 @@
/* 1: in tablet mode; 0: notebook mode; -1: uninitialized */
static int tablet_mode = -1;
+static int forced_tablet_mode = -1;
/* 1: hall sensor is reporting 360 degrees. */
static int hall_sensor_at_360;
@@ -29,6 +30,8 @@ static int disabled;
int tablet_get_mode(void)
{
+ if (forced_tablet_mode != -1)
+ return !!forced_tablet_mode;
return !!tablet_mode;
}
@@ -48,6 +51,10 @@ void tablet_set_mode(int mode)
}
tablet_mode = mode;
+
+ if (forced_tablet_mode != -1)
+ return;
+
CPRINTS("tablet mode %sabled", mode ? "en" : "dis");
hook_notify(HOOK_TABLET_MODE_CHANGE);
@@ -60,6 +67,18 @@ void tablet_set_mode(int mode)
#endif
}
+static void tabletmode_force_state(int mode)
+{
+ if (forced_tablet_mode == mode)
+ return;
+
+ forced_tablet_mode = mode;
+
+ hook_notify(HOOK_TABLET_MODE_CHANGE);
+ if (IS_ENABLED(CONFIG_HOSTCMD_EVENTS))
+ host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
+}
+
void tablet_disable(void)
{
tablet_mode = 0;
@@ -144,3 +163,21 @@ void hall_sensor_disable(void)
tablet_disable();
}
#endif
+
+static int command_settabletmode(int argc, char **argv)
+{
+ if (argc != 2)
+ return EC_ERROR_PARAM_COUNT;
+ if (argv[1][0] == 'o' && argv[1][1] == 'n')
+ tabletmode_force_state(1);
+ else if (argv[1][0] == 'o' && argv[1][1] == 'f')
+ tabletmode_force_state(0);
+ else if (argv[1][0] == 'r')
+ tabletmode_force_state(-1);
+ else
+ return EC_ERROR_PARAM1;
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(tabletmode, command_settabletmode,
+ "[on | off | reset]",
+ "Manually force tablet mode to on, off or reset.");
diff --git a/include/host_command.h b/include/host_command.h
index fbb2639175..3aa0d54d03 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -155,7 +155,6 @@ uint8_t *host_get_memmap(int offset);
*/
uint16_t host_command_process(struct host_cmd_handler_args *args);
-#ifdef CONFIG_HOSTCMD_EVENTS
/**
* Set a single host event.
*
@@ -205,7 +204,6 @@ int get_lazy_wake_mask(enum power_state state, host_event_t *mask);
*/
uint8_t lpc_is_active_wm_set_by_host(void);
#endif
-#endif
/**
* Send a response to the relevant driver for transmission