summaryrefslogtreecommitdiff
path: root/driver/als_si114x.c
diff options
context:
space:
mode:
authorAlexandru M Stan <amstan@chromium.org>2017-12-04 19:44:42 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-14 04:06:52 -0700
commitb63595258df33b0c31effe979feb4bfe884cc9fb (patch)
tree3de3e0bf2293c177bf4103cebffde756b1f78b02 /driver/als_si114x.c
parente74d21f5bdf7f05f13a3b6d496fe37235cb4fdef (diff)
downloadchrome-ec-b63595258df33b0c31effe979feb4bfe884cc9fb.tar.gz
motion: Lower jitter of Sensor->EC timestamp
Instead getting the time for each sample in the task code, we should be getting it as soon as the sensor reported it added it to its fifo (so sensor just finished integration). Because of that each sensor should provide the time when it provides a sample, ideally from an accurate spot like an interrupt. Deprecate motion_sense_fifo_add_unit (without a timestamp) in favour of motion_sense_fifo_add_data (which adds the timestamps). Update all relevant sensors to use the new api. Note: for now I focused on the BMI160, where I actually made it get the time in the interrupt. The other sensors were made to use the new api, but still don't record the time in the right place (though it's not any worse than before). BUG=b:67743747 TEST=In the kernel, fifo_info->info.timestamp still has sane values. TEST=CTS should still pass BRANCH=master Change-Id: I9829343f8702e00cc19f9c88134fa1f258c9e1e9 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807331 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'driver/als_si114x.c')
-rw-r--r--driver/als_si114x.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index 5d9e595f07..567caa917c 100644
--- a/driver/als_si114x.c
+++ b/driver/als_si114x.c
@@ -11,6 +11,7 @@
#include "console.h"
#include "driver/als_si114x.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "i2c.h"
#include "math_util.h"
#include "task.h"
@@ -150,7 +151,12 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb)
for (i = nb; i < 3; i++)
vector.data[i] = 0;
vector.sensor_num = s - motion_sensors;
- motion_sense_fifo_add_unit(&vector, s, nb);
+ motion_sense_fifo_add_data(&vector, s, nb,
+ __hw_clock_source_read());
+ /*
+ * TODO: get time at a more accurate spot.
+ * Like in si114x_interrupt
+ */
#else
/* We need to copy raw_xyz into xyz with mutex */
#endif