diff options
-rw-r--r-- | common/motion_sense.c | 19 | ||||
-rw-r--r-- | include/ec_commands.h | 26 | ||||
-rw-r--r-- | util/ectool.c | 1 |
3 files changed, 37 insertions, 9 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 030d5264d3..27a87e9430 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -386,6 +386,23 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) sizeof(struct ec_response_motion_sensor_data); break; + case MOTIONSENSE_CMD_DATA: + sensor = host_sensor_id_to_motion_sensor( + in->sensor_odr.sensor_num); + + if (sensor == NULL) + return EC_RES_INVALID_PARAM; + + out->data.flags = 0; + + mutex_lock(&g_sensor_mutex); + out->data.data[X] = sensor->xyz[X]; + out->data.data[Y] = sensor->xyz[Y]; + out->data.data[Z] = sensor->xyz[Z]; + mutex_unlock(&g_sensor_mutex); + args->response_size = sizeof(out->data); + break; + case MOTIONSENSE_CMD_INFO: sensor = host_sensor_id_to_motion_sensor( in->sensor_odr.sensor_num); @@ -493,7 +510,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_MOTION_SENSE_CMD, host_cmd_motion_sense, - EC_VER_MASK(1)); + EC_VER_MASK(1) | EC_VER_MASK(2)); /*****************************************************************************/ /* Console commands */ diff --git a/include/ec_commands.h b/include/ec_commands.h index fbae48cb49..09c65f6b34 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1555,7 +1555,7 @@ struct ec_response_led_control { */ /* Verified boot hash command */ -#define EC_CMD_VBOOT_HASH 0x2A +#define EC_CMD_VBOOT_HASH 0x2a struct ec_params_vboot_hash { uint8_t cmd; /* enum ec_vboot_hash_cmd */ @@ -1607,7 +1607,7 @@ enum ec_vboot_hash_status { * Motion sense commands. We'll make separate structs for sub-commands with * different input args, so that we know how much to expect. */ -#define EC_CMD_MOTION_SENSE_CMD 0x2B +#define EC_CMD_MOTION_SENSE_CMD 0x2b /* Motion sense commands */ enum motionsense_command { @@ -1651,6 +1651,11 @@ enum motionsense_command { */ MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5, + /* + * Returns a single sensor data. + */ + MOTIONSENSE_CMD_DATA = 6, + /* Number of motionsense sub-commands. */ MOTIONSENSE_NUM_CMDS }; @@ -1660,12 +1665,14 @@ enum motionsensor_type { MOTIONSENSE_TYPE_ACCEL = 0, MOTIONSENSE_TYPE_GYRO = 1, MOTIONSENSE_TYPE_MAG = 2, + MOTIONSENSE_TYPE_MAX = 3, }; /* List of motion sensor locations. */ enum motionsensor_location { MOTIONSENSE_LOC_BASE = 0, MOTIONSENSE_LOC_LID = 1, + MOTIONSENSE_LOC_MAX = 2, }; /* List of motion sensor chips. */ @@ -1710,10 +1717,10 @@ struct ec_params_motion_sense { int16_t data; } ec_rate, kb_wake_angle; - /* Used for MOTIONSENSE_CMD_INFO. */ + /* Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA. */ struct { uint8_t sensor_num; - } info; + } info, data; /* * Used for MOTIONSENSE_CMD_SENSOR_ODR and @@ -1771,6 +1778,9 @@ struct ec_response_motion_sense { uint8_t chip; } info; + /* Used for MOTIONSENSE_CMD_DATA */ + struct ec_response_motion_sensor_data data; + /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, * MOTIONSENSE_CMD_SENSOR_RANGE, and @@ -3112,8 +3122,8 @@ struct ec_response_pd_log { /* The timestamp is the microsecond counter shifted to get about a ms. */ #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */ -#define PD_LOG_SIZE_MASK 0x1F -#define PD_LOG_PORT_MASK 0xE0 +#define PD_LOG_SIZE_MASK 0x1f +#define PD_LOG_PORT_MASK 0xe0 #define PD_LOG_PORT_SHIFT 5 #define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \ ((size) & PD_LOG_SIZE_MASK)) @@ -3139,7 +3149,7 @@ struct ec_response_pd_log { #define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0) #define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1) /* Returned in the "type" field, when there is no entry available */ -#define PD_EVENT_NO_ENTRY 0xFF +#define PD_EVENT_NO_ENTRY 0xff /* * PD_EVENT_MCU_CHARGE event definition : @@ -3154,7 +3164,7 @@ struct ec_response_pd_log { #define CHARGE_FLAGS_OVERRIDE (1 << 13) /* Charger type */ #define CHARGE_FLAGS_TYPE_SHIFT 3 -#define CHARGE_FLAGS_TYPE_MASK (0xF << CHARGE_FLAGS_TYPE_SHIFT) +#define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT) /* Power delivery role */ #define CHARGE_FLAGS_ROLE_MASK (7 << 0) diff --git a/util/ectool.c b/util/ectool.c index 9470600029..c2836df3c9 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -3219,6 +3219,7 @@ static const struct { MS_SIZES(sensor_odr), MS_SIZES(sensor_range), MS_SIZES(kb_wake_angle), + MS_SIZES(data), }; BUILD_ASSERT(ARRAY_SIZE(ms_command_sizes) == MOTIONSENSE_NUM_CMDS); #undef MS_SIZES |