diff options
Diffstat (limited to 'util/ectool.c')
-rw-r--r-- | util/ectool.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/util/ectool.c b/util/ectool.c index 651fcfcbaa..6a8441f172 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -3473,7 +3473,7 @@ static const struct { uint8_t insize; } ms_command_sizes[] = { MS_DUMP_SIZE(), - MS_SIZES(info), + MS_SIZES(info_3), MS_SIZES(ec_rate), MS_SIZES(sensor_odr), MS_SIZES(sensor_range), @@ -3601,18 +3601,34 @@ static int cmd_motionsense(int argc, char **argv) } if (argc == 3 && !strcasecmp(argv[1], "info")) { - param.cmd = MOTIONSENSE_CMD_INFO; + struct ec_params_get_cmd_versions p; + struct ec_response_get_cmd_versions r; + int version = 0; + param.cmd = MOTIONSENSE_CMD_INFO; param.sensor_odr.sensor_num = strtol(argv[2], &e, 0); if (e && *e) { fprintf(stderr, "Bad %s arg.\n", argv[2]); return -1; } - rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 1, + /* tool defaults to using latest version of info command */ + p.cmd = EC_CMD_MOTION_SENSE_CMD; + rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &p, sizeof(p), + &r, sizeof(r)); + if (rv < 0) { + if (rv == -EC_RES_INVALID_PARAM) + printf("Command 0x%02x not supported by EC.\n", + EC_CMD_GET_CMD_VERSIONS); + return rv; + } + + if (r.version_mask) + version = __fls(r.version_mask); + + rv = ec_command(EC_CMD_MOTION_SENSE_CMD, version, ¶m, ms_command_sizes[param.cmd].outsize, resp, ms_command_sizes[param.cmd].insize); - if (rv < 0) return rv; @@ -3688,6 +3704,14 @@ static int cmd_motionsense(int argc, char **argv) printf("unknown\n"); } + if (version >= 3) { + printf("Min Frequency: %d mHz\n", + resp->info_3.min_frequency); + printf("Max Frequency: %d mHz\n", + resp->info_3.max_frequency); + printf("FIFO Max Event Count: %d\n", + resp->info_3.fifo_max_event_count); + } return 0; } |