summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2022-07-11 03:38:58 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-16 18:41:51 +0000
commit5237c030bcd17c11a8976125fc9cd24d6b38787d (patch)
treed648e803630503c80435443c1187cdf6f8d6c74b
parent4cf7761eccbeff52aad58661989775dd38d558c4 (diff)
downloadchrome-ec-5237c030bcd17c11a8976125fc9cd24d6b38787d.tar.gz
motion_sense_fifo: Move lost to motion_sensor_fifo
Move lost field from the sensor object to inside motion_sense_fifo: It is not used anywhere else. BUG=b:237305991, b:243492849 BRANCH=brya,trogdor TEST=make -j BOARD=crota Conflicts: zephyr/test/drivers/default/src/host_cmd/motion_sense.c: absent. (cherry picked from commit a2efacf4a0a5857176bc6f39c9bd1e4cd2e1d6ec) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3754211 Reviewed-by: Yuval Peress <peress@google.com> Change-Id: Idfb159ed9025e859e86bb494cf5da98df9cf4a36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3881924 Tested-by: Chao Gui <chaogui@google.com> Commit-Queue: Bob Moragues <moragues@chromium.org> Reviewed-by: Chao Gui <chaogui@google.com> Reviewed-by: Bob Moragues <moragues@chromium.org>
-rw-r--r--common/motion_sense.c4
-rw-r--r--common/motion_sense_fifo.c21
-rw-r--r--include/motion_sense.h6
3 files changed, 19 insertions, 12 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 4e3547b2c2..48928535e0 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1309,10 +1309,6 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args)
break;
}
motion_sense_fifo_get_info(&out->fifo_info, 1);
- for (i = 0; i < motion_sensor_count; i++) {
- out->fifo_info.lost[i] = motion_sensors[i].lost;
- motion_sensors[i].lost = 0;
- }
args->response_size = sizeof(out->fifo_info) +
sizeof(uint16_t) * motion_sensor_count;
break;
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index eb222fcef6..94f7b24f7f 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -50,6 +50,12 @@ static struct queue fifo = QUEUE_NULL(CONFIG_ACCEL_FIFO_SIZE,
struct ec_response_motion_sensor_data);
/** Count of the number of entries lost due to a small queue. */
static int fifo_lost;
+/*
+ * How many vector events are lost in the FIFO since last time
+ * FIFO info has been transmitted.
+ */
+static uint16_t fifo_sensor_lost[MAX_MOTION_SENSORS];
+
/** Metadata for the fifo, used for staging and spreading data. */
static struct fifo_staged fifo_staged;
@@ -149,7 +155,7 @@ static void fifo_pop(void)
/* Increment lost counter if we have valid data. */
if (!is_timestamp(head))
- motion_sensors[head->sensor_num].lost++;
+ fifo_sensor_lost[head->sensor_num]++;
/*
* We're done if the initial count was non-zero and we only advanced the
@@ -228,6 +234,7 @@ static inline bool is_new_timestamp(uint8_t sensor_num)
* @param data The data to stage.
* @param sensor The sensor that generated the data
* @param valid_data The number of readable data entries in the data.
+ * sensor can be NULL (for activity sensors). valid_data must be 0 then.
*/
static void fifo_stage_unit(
struct ec_response_motion_sensor_data *data,
@@ -562,17 +569,24 @@ void motion_sense_fifo_get_info(
struct ec_response_motion_sense_fifo_info *fifo_info,
int reset)
{
+ int i;
+
mutex_lock(&g_sensor_mutex);
fifo_info->size = fifo.buffer_units;
fifo_info->count = queue_count(&fifo);
fifo_info->total_lost = fifo_lost;
+ for (i = 0; i < MAX_MOTION_SENSORS; i++) {
+ fifo_info->lost[i] = fifo_sensor_lost[i];
+ }
mutex_unlock(&g_sensor_mutex);
#ifdef CONFIG_MKBP_EVENT
fifo_info->timestamp = mkbp_last_event_time;
#endif
- if (reset)
+ if (reset) {
fifo_lost = 0;
+ memset(fifo_sensor_lost, 0, sizeof(fifo_sensor_lost));
+ }
}
static int motion_sense_get_next_event(uint8_t *out)
@@ -614,10 +628,13 @@ int motion_sense_fifo_read(int capacity_bytes, int max_count, void *out,
void motion_sense_fifo_reset(void)
{
+ static struct ec_response_motion_sense_fifo_info fifo_info;
+
next_timestamp_initialized = 0;
memset(&fifo_staged, 0, sizeof(fifo_staged));
motion_sense_fifo_init();
queue_init(&fifo);
+ motion_sense_fifo_get_info(&fifo_info, /*reset=*/true);
}
#ifdef CONFIG_CMD_ACCEL_FIFO
diff --git a/include/motion_sense.h b/include/motion_sense.h
index ce999cbd81..0c8b17780e 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -225,12 +225,6 @@ struct motion_sensor_t {
uint16_t oversampling_ratio;
/*
- * How many vector events are lost in the FIFO since last time
- * FIFO info has been transmitted.
- */
- uint16_t lost;
-
- /*
* For sensors in forced mode the ideal time to collect the next
* measurement.
*