mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
core: Add subcommands to MOTION_SENSE_CMD
These subcommands allow accessing sensor (accel+gyro) over i2c. BRANCH=ToT BUG=chrome-os-partner:31071 TEST=Compile. Change-Id: Ic6c3e9bf9c23f369de9f540c50daab7f2e4582ee Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225653
This commit is contained in:
committed by
chrome-internal-fetch
parent
f3b29e3fec
commit
d5b32aa6e1
@@ -1301,6 +1301,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
|
||||
};
|
||||
@@ -1351,10 +1363,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
|
||||
@@ -1367,7 +1379,6 @@ struct ec_params_motion_sense {
|
||||
|
||||
/* Used for MOTIONSENSE_CMD_INFO. */
|
||||
struct {
|
||||
/* Should be element of enum motionsensor_id. */
|
||||
uint8_t sensor_num;
|
||||
} info;
|
||||
|
||||
@@ -1376,7 +1387,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. */
|
||||
@@ -1392,18 +1402,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. */
|
||||
@@ -1416,6 +1448,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
|
||||
|
||||
@@ -2323,6 +2323,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;
|
||||
@@ -2333,6 +2344,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
|
||||
|
||||
Reference in New Issue
Block a user