diff options
author | Kevin K Wong <kevin.k.wong@intel.com> | 2015-11-18 23:59:42 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-25 18:15:38 -0800 |
commit | e24ac972e21d60a65d15e957605e8b78bd25e039 (patch) | |
tree | 51044b14b8c8b7b5966d7bd774f1499f55b931ef | |
parent | 767e132d133b6f1216d630bd3b59e893a59bcffa (diff) | |
download | chrome-ec-e24ac972e21d60a65d15e957605e8b78bd25e039.tar.gz |
ectool: provide lid angle info
Added new host command to support returning lid angle.
New output from ectool:
System with lid angle support:
------------------------------------------
localhost ~ # ectool motionsense lid_angle
Lid angle: 72
System without lid angle support:
------------------------------------------
localhost ~ # ectool motionsense lid_angle
EC result 3 (INVALID_PARAM)
BUG=none
BRANCH=none
TEST=run "ectool motionsense lid_angle"
verify the value matches the physical lid angle position
Change-Id: I4179172c778f643640561e819216f7adfee679d2
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/313345
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/motion_lid.c | 9 | ||||
-rw-r--r-- | include/ec_commands.h | 21 | ||||
-rw-r--r-- | include/motion_lid.h | 3 | ||||
-rw-r--r-- | util/ectool.c | 21 |
4 files changed, 50 insertions, 4 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c index a563b1019b..df876563fe 100644 --- a/common/motion_lid.c +++ b/common/motion_lid.c @@ -233,6 +233,15 @@ int host_cmd_motion_lid(struct host_cmd_handler_args *args) break; + case MOTIONSENSE_CMD_LID_ANGLE: +#ifdef CONFIG_LID_ANGLE + out->lid_angle.value = motion_lid_get_angle(); + args->response_size = sizeof(out->lid_angle); +#else + return EC_RES_INVALID_PARAM; +#endif + break; + default: return EC_RES_INVALID_PARAM; } diff --git a/include/ec_commands.h b/include/ec_commands.h index 54f91e3054..7901745e9e 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1713,6 +1713,11 @@ enum motionsense_command { */ MOTIONSENSE_CMD_SET_ACTIVITY = 13, + /* + * Lid Angle + */ + MOTIONSENSE_CMD_LID_ANGLE = 14, + /* Number of motionsense sub-commands. */ MOTIONSENSE_NUM_CMDS }; @@ -1827,6 +1832,8 @@ struct ec_motion_sense_activity { /* Set Calibration information */ #define MOTION_SENSE_SET_OFFSET 1 +#define LID_ANGLE_UNRELIABLE 500 + struct ec_params_motion_sense { uint8_t cmd; union { @@ -1915,6 +1922,10 @@ struct ec_params_motion_sense { } fifo_read; struct ec_motion_sense_activity set_activity; + + /* Used for MOTIONSENSE_CMD_LID_ANGLE */ + struct { + } lid_angle; }; } __packed; @@ -1978,6 +1989,16 @@ struct ec_response_motion_sense { struct { } set_activity; + + + /* Used for MOTIONSENSE_CMD_LID_ANGLE */ + struct { + /* + * Angle between 0 and 360 degree if available, + * LID_ANGLE_UNRELIABLE otherwise. + */ + uint16_t value; + } lid_angle; }; } __packed; diff --git a/include/motion_lid.h b/include/motion_lid.h index b005688bb7..21803e6260 100644 --- a/include/motion_lid.h +++ b/include/motion_lid.h @@ -10,9 +10,6 @@ #include "host_command.h" -/* Anything outside of lid angle range [-180, 180] should work. */ -#define LID_ANGLE_UNRELIABLE 500 - /** * This structure defines all of the data needed to specify the orientation * of the base and lid accelerometers in order to calculate the lid angle. diff --git a/util/ectool.c b/util/ectool.c index 0b2f561211..d551610906 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -3250,7 +3250,6 @@ static int cmd_lightbar(int argc, char **argv) sizeof(((struct ec_response_motion_sense *)0)->fifo_info) \ + sizeof(uint16_t) * ECTOOL_MAX_SENSOR} - static const struct { uint8_t outsize; uint8_t insize; @@ -3269,6 +3268,7 @@ static const struct { MS_SIZES(sensor_offset), MS_SIZES(list_activities), MS_SIZES(set_activity), + MS_SIZES(lid_angle), }; BUILD_ASSERT(ARRAY_SIZE(ms_command_sizes) == MOTIONSENSE_NUM_CMDS); #undef MS_SIZES @@ -3294,6 +3294,7 @@ static int ms_help(const char *cmd) cmd); printf(" %s set_activity NUM ACT EN - enable/disable activity\n", cmd); + printf(" %s lid_angle - print lid angle\n", cmd); return 0; } @@ -3724,6 +3725,24 @@ static int cmd_motionsense(int argc, char **argv) return rv; return 0; } + + if (argc == 2 && !strcasecmp(argv[1], "lid_angle")) { + param.cmd = MOTIONSENSE_CMD_LID_ANGLE; + rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 2, + ¶m, ms_command_sizes[param.cmd].outsize, + resp, ms_command_sizes[param.cmd].insize); + if (rv < 0) + return rv; + + printf("Lid angle: "); + if (resp->lid_angle.value == LID_ANGLE_UNRELIABLE) + printf("unreliable\n"); + else + printf("%d\n", resp->lid_angle.value); + + return 0; + } + return ms_help(argv[0]); } |