diff options
author | Yuval Peress <peress@chromium.org> | 2020-02-05 14:25:02 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-11 08:45:42 +0000 |
commit | 6a0ad26931135a3811eedade595a7b1a80bb1931 (patch) | |
tree | 14f63e4bea2e0561aaeb5699658399df64db9e6f /common | |
parent | 2e94c27c3866debba24369adc1c31908f4d7d74a (diff) | |
download | chrome-ec-6a0ad26931135a3811eedade595a7b1a80bb1931.tar.gz |
common: motion_sense: implement AP command to read dirty calibration
BRANCH=None
BUG=b:138303429,chromium:1023858
TEST=buildall
Change-Id: I857dbc0975a239a6d8419015d8b9e34415b477cf
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2044702
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/motion_sense.c | 17 | ||||
-rw-r--r-- | common/online_calibration.c | 8 |
2 files changed, 21 insertions, 4 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 74537df5a1..572696ce80 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -21,6 +21,7 @@ #include "motion_sense.h" #include "motion_sense_fifo.h" #include "motion_lid.h" +#include "online_calibration.h" #include "power.h" #include "queue.h" #include "tablet_mode.h" @@ -1312,6 +1313,22 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; } break; + case MOTIONSENSE_CMD_ONLINE_CALIB_READ: + if (!IS_ENABLED(CONFIG_ONLINE_CALIB)) + return EC_RES_INVALID_PARAM; + sensor = host_sensor_id_to_real_sensor( + in->online_calib_read.sensor_num); + if (sensor == NULL) + return EC_RES_INVALID_PARAM; + + + args->response_size = + online_calibration_read( + (int)(sensor - motion_sensors), + out->online_calib_read.data) + ? sizeof(struct ec_response_online_calibration_data) + : 0; + break; #ifdef CONFIG_GESTURE_HOST_DETECTION case MOTIONSENSE_CMD_LIST_ACTIVITIES: { uint32_t enabled, disabled, mask, i; diff --git a/common/online_calibration.c b/common/online_calibration.c index 6a7318c5a6..519b1be8e3 100644 --- a/common/online_calibration.c +++ b/common/online_calibration.c @@ -110,11 +110,11 @@ bool online_calibration_has_new_values(void) bool online_calibration_read(int sensor_num, int16_t out[3]) { - bool has_dirty; + bool has_valid; mutex_lock(&g_calib_cache_mutex); - has_dirty = (sensor_calib_cache_dirty_map & BIT(sensor_num)) != 0; - if (has_dirty) { + has_valid = (sensor_calib_cache_valid_map & BIT(sensor_num)) != 0; + if (has_valid) { /* Update data in out */ memcpy(out, motion_sensors[sensor_num].online_calib_data->cache, @@ -124,7 +124,7 @@ bool online_calibration_read(int sensor_num, int16_t out[3]) } mutex_unlock(&g_calib_cache_mutex); - return has_dirty; + return has_valid; } int online_calibration_process_data( |