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-12-15 03:23:28 +0000
commitd2847a353e6a4045fe084b9f95cded431a9be932 (patch)
treec6c165689ed719c981f841325b6e6ee8b2b9dcb7
parent76106e8b9be18f12ef13a5d10f608c66cccddd20 (diff)
downloadchrome-ec-d2847a353e6a4045fe084b9f95cded431a9be932.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 BRANCH=brya TEST=make -j BOARD=crota Conflicts: zephyr//motion_sense.c: no zephyr (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/+/3788022 Tested-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Commit-Queue: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
-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 428963c569..b1ac47a9b1 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1329,10 +1329,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 d0bbfcd342..d3f0558c30 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;
@@ -161,7 +167,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
@@ -240,6 +246,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,
@@ -566,17 +573,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));
+ }
}
/* LCOV_EXCL_START - function cannot be tested due to limitations with mkbp */
@@ -619,10 +633,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);
}
void motion_sense_set_data_period(int sensor_num, uint32_t data_period)
diff --git a/include/motion_sense.h b/include/motion_sense.h
index e642851845..9afd279a5c 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -223,12 +223,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.
*