diff options
author | Ravi Chandra Sadineni <ravisadineni@chromium.org> | 2019-09-11 10:35:31 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-12 10:25:07 +0000 |
commit | 87502c08eb8b5855465257c314c5273fc7af7b26 (patch) | |
tree | f16be9ebfd2b566bb52a9b7ad23127593457aafc /common | |
parent | a0e7e66ebd384455041b99d99cce30dea771ddfa (diff) | |
download | chrome-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>
Diffstat (limited to 'common')
-rw-r--r-- | common/tablet_mode.c | 37 |
1 files changed, 37 insertions, 0 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."); |