summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Van Patten <timvp@google.com>2022-10-31 15:21:05 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-12 01:43:32 +0000
commit69652675a2763d2396b0a080857211a5e1f2318f (patch)
tree3322f2718f09855eedeed020ee973048e82e3b2e
parent03eb03f2b2ac8d298ba2ea9f8c263a7018375314 (diff)
downloadchrome-ec-69652675a2763d2396b0a080857211a5e1f2318f.tar.gz
Add ectool command tabletmode
Add the ectool command tabletmode. This matches the EC console command tabletmode, which turns tablet mode on/off. BRANCH=none BUG=b:256015402 TEST=ectool tabletmode on 22-11-03 16:01:49.043 [151.513200 HC 0x0002] 22-11-03 16:01:51.496 [151.515300 HC 0x000b] 22-11-03 16:01:51.501 [15[151.520400 event clear 0x0000000010000000] 22-11-03 16:01:51.504 [151.523200 ACPI query = 29] 22-11-03 16:01:51.507 1.516400 HC 0x0031] 22-11-03 16:01:51.510 [151.517200 tablet mode enabled] 22-11-03 16:01:51.512 [151.518000 mkbp switches: 3] 22-11-03 16:01:51.518 [151.519200 event set 0x0000000010000000] 22-11-03 16:01:51.521 [151.527200 HC 0x0067 err 9] 22-11-03 16:01:51.527 [151.533000 lid-accel ODR: 12500 - roundup 1 from config 0 [AP 12500]] TEST=ectool tabletmode off 22-11-03 16:02:17.579 [180.879700 HC 0x0002] 22-11-03 16:02:21.199 [180.882200 HC 0x000b] 22-11-03 16:02:21.205 [180.883300 HC 0x003[180.887300 event clear 0x0000000010000000] 22-11-03 16:02:21.210 [180.891000 ACPI query = 29] 22-11-03 16:02:21.213 1] 22-11-03 16:02:21.213 [180.884100 tablet mode disabled] 22-11-03 16:02:21.216 [180.884800 mkbp switches: 1] 22-11-03 16:02:21.221 [180.885600 event set 0x0000000010000000] 22-11-03 16:02:21.224 [180.897300 HC 0x0067 err 9] 22-11-03 16:02:21.230 [180.900500 lid-accel ODR: 12500 - roundup 1 from config 1 [AP 0]] TEST=ectool tabletmode reset 22-11-03 16:02:54.397 [216.057600 HC 0x0002] 22-11-03 16:02:56.776 [216.060100 HC 0x000b] 22-11-03 16:02:56.782 [216.061200 HC 0x0031[216.065300 event clear 0x0000000010000000] 22-11-03 16:02:56.787 [216.069000 ACPI query = 29] 22-11-03 16:02:56.790 ] 22-11-03 16:02:56.790 [216.062000 tablet mode disabled] 22-11-03 16:02:56.793 [216.062800 mkbp switches: 1] 22-11-03 16:02:56.798 [216.063500 event set 0x0000000010000000] 22-11-03 16:02:56.801 [216.073700 HC 0x0067 err 9] Change-Id: I1fd435dc2ac32e94384402407c7efaf6997387e2 Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994296 Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> (cherry picked from commit d81eb64c92a80bcc7211bf522f91a6839d6fc8a5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4410550 Commit-Queue: Knox Chiou <knoxchiou@chromium.org> Tested-by: Mike Lee <mike5@huaqin.corp-partner.google.com>
-rw-r--r--util/ectool.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/util/ectool.cc b/util/ectool.cc
index c116b35fcc..cbb62e1e30 100644
--- a/util/ectool.cc
+++ b/util/ectool.cc
@@ -33,6 +33,7 @@
#include "lock/gec_lock.h"
#include "misc_util.h"
#include "panic.h"
+#include "tablet_mode.h"
#include "usb_pd.h"
/* Maximum flash size (16 MB, conservative) */
@@ -315,6 +316,8 @@ const char help_str[] =
" Display system info.\n"
" switches\n"
" Prints current EC switch positions\n"
+ " tabletmode [on | off | reset]\n"
+ " Manually force tablet mode to on, off or reset.\n"
" temps <sensorid>\n"
" Print temperature and temperature ratio between fan_off and\n"
" fan_max values, which could be a fan speed if it's controlled\n"
@@ -7336,6 +7339,37 @@ int cmd_switches(int argc, char *argv[])
return 0;
}
+int cmd_tabletmode(int argc, char *argv[])
+{
+ struct ec_params_set_tablet_mode p;
+
+ if (argc != 2)
+ return EC_ERROR_PARAM_COUNT;
+
+ memset(&p, 0, sizeof(p));
+ if (argv[1][0] == 'o' && argv[1][1] == 'n') {
+ p.tablet_mode = TABLET_MODE_FORCE_TABLET;
+ } else if (argv[1][0] == 'o' && argv[1][1] == 'f') {
+ p.tablet_mode = TABLET_MODE_FORCE_CLAMSHELL;
+ } else if (argv[1][0] == 'r') {
+ // Match tablet mode to the current HW orientation.
+ p.tablet_mode = TABLET_MODE_DEFAULT;
+ } else {
+ return EC_ERROR_PARAM1;
+ }
+
+ int rv = ec_command(EC_CMD_SET_TABLET_MODE, 0, &p, sizeof(p), NULL, 0);
+ rv = (rv < 0 ? rv : 0);
+
+ if (rv < 0) {
+ fprintf(stderr, "Failed to set tablet mode, rv=%d\n", rv);
+ } else {
+ printf("\n");
+ printf("SUCCESS. The tablet mode has been set.\n");
+ }
+ return rv;
+}
+
int cmd_wireless(int argc, char *argv[])
{
char *e;
@@ -11020,6 +11054,7 @@ const struct command commands[] = {
{ "sysinfo", cmd_sysinfo },
{ "port80flood", cmd_port_80_flood },
{ "switches", cmd_switches },
+ { "tabletmode", cmd_tabletmode },
{ "temps", cmd_temperature },
{ "tempsinfo", cmd_temp_sensor_info },
{ "test", cmd_test },