summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2022-07-11 03:39:57 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-03 22:02:17 +0000
commit1404036c889324442a9559812f5c4ed6143506f3 (patch)
tree3fb75cd665c2f862e975995aeffa0d2c0b3db022 /test
parenta2efacf4a0a5857176bc6f39c9bd1e4cd2e1d6ec (diff)
downloadchrome-ec-1404036c889324442a9559812f5c4ed6143506f3.tar.gz
motion_sense_fifo: Reset timestamp only when ODR changes
Timestamp spreading is reset after each fifo commit. It prevents the fifo logic to operate when the EC takes more than a period to collect the samples. Reset timestamp spreading only when ODR changes. Move needed fields inside motion_sense_fifo to handle virtual sensors. Fixes commit bc9660a4b3e8 ("common: motionsense fifo: Reset the initialized bits after commit") BUG=b:168335284,b:237305991,b:217580259 BRANCH=all TEST=make run-motion_sense_fifo Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: If7265079f7fc7f4e7e22dd80865305f4553df020 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3754212 Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/motion_sense_fifo.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c
index e9c2b749f2..23a4767d2e 100644
--- a/test/motion_sense_fifo.c
+++ b/test/motion_sense_fifo.c
@@ -273,7 +273,7 @@ static int test_spread_data_in_window(void)
int read_count;
motion_sensors[0].oversampling_ratio = 1;
- motion_sensors[0].collection_rate = 20; /* us */
+ motion_sense_set_data_period(0, 20 /* us */);
now = __hw_clock_source_read();
motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 18);
@@ -300,9 +300,9 @@ static int test_spread_data_on_overflow(void)
int i, read_count;
/* Set up the sensors */
- motion_sensors[0].collection_rate = 20; /* us */
motion_sensors[0].oversampling_ratio = 1;
motion_sensors[1].oversampling_ratio = 1;
+ motion_sense_set_data_period(0, 20 /* us */);
/* Add 1 sample for sensor [1]. This will be evicted. */
data->sensor_num = 1;
@@ -351,7 +351,7 @@ static int test_spread_data_by_collection_rate(void)
int read_count;
motion_sensors[0].oversampling_ratio = 1;
- motion_sensors[0].collection_rate = 20; /* us */
+ motion_sense_set_data_period(0, 20 /* us */);
motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25);
motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25);
motion_sense_fifo_commit_data();
@@ -366,42 +366,13 @@ static int test_spread_data_by_collection_rate(void)
return EC_SUCCESS;
}
-static int test_spread_double_commit_same_timestamp(void)
-{
- const uint32_t now = __hw_clock_source_read();
- int read_count;
-
- /*
- * Stage and commit the same sample. This is not expected to happen
- * since batches of sensor samples should be staged together and only
- * commit once. We assume that the driver did this on purpose and will
- * allow the same timestamp to be sent.
- */
- motion_sensors[0].oversampling_ratio = 1;
- motion_sensors[0].collection_rate = 20; /* us */
- motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25);
- motion_sense_fifo_commit_data();
- motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25);
- motion_sense_fifo_commit_data();
-
- read_count = motion_sense_fifo_read(
- sizeof(data), CONFIG_ACCEL_FIFO_SIZE, data, &data_bytes_read);
- TEST_EQ(read_count, 4, "%d");
- TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP);
- TEST_EQ(data[0].timestamp, now - 25, "%u");
- TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP);
- TEST_EQ(data[2].timestamp, now - 25, "%u");
-
- return EC_SUCCESS;
-}
-
static int test_commit_non_data_or_timestamp_entries(void)
{
const uint32_t now = __hw_clock_source_read();
int read_count;
motion_sensors[0].oversampling_ratio = 1;
- motion_sensors[0].collection_rate = 20; /* us */
+ motion_sense_set_data_period(0, 20 /* us */);
/* Insert non-data entry */
data[0].flags = MOTIONSENSE_SENSOR_FLAG_ODR;
@@ -462,7 +433,6 @@ void run_test(int argc, char **argv)
RUN_TEST(test_spread_data_in_window);
RUN_TEST(test_spread_data_on_overflow);
RUN_TEST(test_spread_data_by_collection_rate);
- RUN_TEST(test_spread_double_commit_same_timestamp);
RUN_TEST(test_commit_non_data_or_timestamp_entries);
RUN_TEST(test_get_info_size);