summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-04-08 10:28:29 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-11 04:00:44 +0000
commiteaa645e0cc092fbaaa1a81ed5308831e71ebf86c (patch)
treeebf92cd466682ee38fc2d0f5caa801d6e8a3d431 /util
parent335ad0c397f61d81d7fb5db8e3fb24e9bc089a2d (diff)
downloadchrome-ec-eaa645e0cc092fbaaa1a81ed5308831e71ebf86c.tar.gz
accel: Add host cmd for setting lid angle threshold for disabling keyboard wake
Added a sub-command to the motionsense host command (0x2b) for getting/setting the lid angle at which the keyboard is disabled as a wake source in S3. The value can be anywhere from 0 to 360 degrees, default set to 180. Note, this only takes affect for boards that have CONFIG_LID_ANGLE_KEY_SCAN defined. Modified ectool motionsense command to use new host sub-command. Also modified the lid angle measurement in the EC to be in the range [0, 360], instead of [-180, 180], and changed casting of lid angle as an int to round to nearest. BUG=none BRANCH=rambi TEST=Tested on a glimmer: Using default keyboard disable lid angle of 180, made sure that when lid angle is past 180, key presses do not wake system, and when lid angle is less than 180, key presses do wake up system. Used ectool motionsense kb_wake to set the keyboard disable lid angle to 0. Made sure that keyboard never wakes up the system. Set keyboard disable lid angle to 360 and made sure that the keyboard always wakes up the system. Change-Id: I437164c6e38c29169ef6e20e86c9cf2a1c78f86e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193663 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/194172
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index f8c1b13339..4d827f52af 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1702,6 +1702,7 @@ static const struct {
MS_SIZES(ec_rate),
MS_SIZES(sensor_odr),
MS_SIZES(sensor_range),
+ MS_SIZES(kb_wake_angle),
};
BUILD_ASSERT(ARRAY_SIZE(ms_command_sizes) == MOTIONSENSE_NUM_CMDS);
#undef MS_SIZES
@@ -1715,6 +1716,7 @@ static int ms_help(const char *cmd)
printf(" %s ec_rate [RATE_MS] - set/get sample rate\n", cmd);
printf(" %s odr NUM [ODR [ROUNDUP]] - set/get sensor ODR\n", cmd);
printf(" %s range NUM [RANGE [ROUNDUP]]- set/get sensor range\n", cmd);
+ printf(" %s kb_wake NUM - set/get KB wake ang\n", cmd);
return 0;
}
@@ -1935,6 +1937,29 @@ static int cmd_motionsense(int argc, char **argv)
return 0;
}
+ if (argc < 4 && !strcasecmp(argv[1], "kb_wake")) {
+ param.cmd = MOTIONSENSE_CMD_KB_WAKE_ANGLE;
+ param.kb_wake_angle.data = EC_MOTION_SENSE_NO_VALUE;
+
+ if (argc == 3) {
+ param.kb_wake_angle.data = strtol(argv[2], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad %s arg.\n", argv[1]);
+ return -1;
+ }
+ }
+
+ rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 0,
+ &param, ms_command_sizes[param.cmd].insize,
+ &resp, ms_command_sizes[param.cmd].outsize);
+
+ if (rv < 0)
+ return rv;
+
+ printf("%d\n", resp.kb_wake_angle.ret);
+ return 0;
+ }
+
return ms_help(argv[0]);
}