diff options
-rw-r--r-- | include/ec_commands.h | 49 | ||||
-rw-r--r-- | util/ectool.c | 13 |
2 files changed, 56 insertions, 6 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h index d51c9b7efe..980dfa2b1e 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1300,6 +1300,18 @@ enum motionsense_command { */ MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5, + /* + * Sensor subsytem status. + * Same format as EC_MEMMAP_ACC_STATUS + * - for system without LPC - + */ + MOTIONSENSE_CMD_GET_STATUS = 6, + + /* + * Retrieve data and flags from all accel/gyro sensors. + */ + MOTIONSENSE_CMD_GET_DATA = 7, + /* Number of motionsense sub-commands. */ MOTIONSENSE_NUM_CMDS }; @@ -1350,10 +1362,10 @@ enum motionsensor_chip { struct ec_params_motion_sense { uint8_t cmd; union { - /* Used for MOTIONSENSE_CMD_DUMP. */ + /* Used for MOTIONSENSE_CMD_DUMP, GET_STATUS, GET_DATA. */ struct { /* no args */ - } dump; + } data, dump, status; /* * Used for MOTIONSENSE_CMD_EC_RATE and @@ -1366,7 +1378,6 @@ struct ec_params_motion_sense { /* Used for MOTIONSENSE_CMD_INFO. */ struct { - /* Should be element of enum motionsensor_id. */ uint8_t sensor_num; } info; @@ -1375,7 +1386,6 @@ struct ec_params_motion_sense { * MOTIONSENSE_CMD_SENSOR_RANGE. */ struct { - /* Should be element of enum motionsensor_id. */ uint8_t sensor_num; /* Rounding flag, true for round-up, false for down. */ @@ -1391,18 +1401,40 @@ struct ec_params_motion_sense { struct ec_response_motion_sense { union { - /* Used for MOTIONSENSE_CMD_DUMP. */ + /* Used for MOTIONSENSE_CMD_DUMP */ struct { /* Flags representing the motion sensor module. */ uint8_t module_flags; - /* Flags for each sensor in enum motionsensor_id. */ + /* Flags for each sensor. */ uint8_t sensor_flags[EC_MOTION_SENSOR_COUNT]; /* Array of all sensor data. Each sensor is 3-axis. */ int16_t data[3*EC_MOTION_SENSOR_COUNT]; } dump; + /* Used for MOTIONSENSE_CMD_GET_DATA */ + struct { + /* Flags representing the motion sensor module. */ + uint8_t module_flags; + + /* Number of sensors managed directly by the EC */ + uint8_t sensor_number; + + /* + * sensor data is truncated if response_max is too small + * for holding all the data. + */ + struct sensor_data { + /* Flags for each sensor. */ + uint8_t flags; + uint8_t padding; + + /* Each sensor is up to 3-axis. */ + int16_t data[3]; + } sensor[0]; + } data; + /* Used for MOTIONSENSE_CMD_INFO. */ struct { /* Should be element of enum motionsensor_type. */ @@ -1415,6 +1447,11 @@ struct ec_response_motion_sense { uint8_t chip; } info; + /* Used for MOTIONSENSE_CMD_GET_STATUS */ + struct { + uint8_t value; + } status; + /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, * MOTIONSENSE_CMD_SENSOR_RANGE, and diff --git a/util/ectool.c b/util/ectool.c index 964af5e191..c5fa0dfa71 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -2347,6 +2347,17 @@ static int cmd_lightbar(int argc, char **argv) sizeof(((struct ec_params_motion_sense *)0)->SUBCMD) \ + sizeof(((struct ec_params_motion_sense *)0)->cmd), \ sizeof(((struct ec_response_motion_sense *)0)->SUBCMD) } +/* + * For ectool only, assume no more than 16 sensors. + * More advanced implementation would allocate the right amount of + * memory depending on the number of sensors. + */ +#define ECTOOL_MAX_SENSOR 16 +#define MS_DATA_SIZE() { \ + sizeof(((struct ec_params_motion_sense *)0)->data) \ + + sizeof(((struct ec_params_motion_sense *)0)->cmd), \ + sizeof(((struct ec_response_motion_sense *)0)->data) \ + + ECTOOL_MAX_SENSOR * sizeof(struct sensor_data) } static const struct { uint8_t insize; uint8_t outsize; @@ -2357,6 +2368,8 @@ static const struct { MS_SIZES(sensor_odr), MS_SIZES(sensor_range), MS_SIZES(kb_wake_angle), + MS_SIZES(status), + MS_DATA_SIZE(), }; BUILD_ASSERT(ARRAY_SIZE(ms_command_sizes) == MOTIONSENSE_NUM_CMDS); #undef MS_SIZES |