diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2022-02-10 12:43:56 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-18 05:33:33 +0000 |
commit | 9f0d37406097da915f17562c5216629de17d4223 (patch) | |
tree | df3b86be26158ad79de16298f40cc199485de8ca | |
parent | a702a994884b4c315cf18186b85fcac5121f25ac (diff) | |
download | chrome-ec-9f0d37406097da915f17562c5216629de17d4223.tar.gz |
driver/tcs3400: Set timestamp when emulating interrupt
Use the same interrupt handler for wire or emulated interrupt,
so we are sure to timestamp the samples.
BUG=b:218890983,b:129419982
TEST=make -j buildall
Check on kukui/krane that tast test hardware.SensorIioserviceHard
passes.
It would fail previously with error like:
"error during validation: too much delta between samples for
lid cros-ec-gyro at index 174(1m52.310435376s):
got 14.894431ms; want <= 7.5ms"
BRANCH=kukui,asurada
Fixes: commit ae22b703601 ("driver: add an option to emulate irq event
in TCS3400")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: I9f4deaa214abe6e8ac7a2aa6b6071a02565f8825
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3454215
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
(cherry picked from commit c09e13ca676a25c64a66f5db2149d8e2197ffbb9)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3465946
-rw-r--r-- | driver/als_tcs3400.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 30b24c4412..b2c2041c70 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -97,11 +97,20 @@ static inline int tcs3400_i2c_write8(const struct motion_sensor_t *s, return i2c_write8(s->port, s->i2c_spi_addr_flags, reg, data); } +#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT static void tcs3400_read_deferred(void) +#else +void tcs3400_interrupt(enum gpio_signal signal) +#endif { + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + last_interrupt_timestamp = __hw_clock_source_read(); + task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT); } +#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT DECLARE_DEFERRED(tcs3400_read_deferred); +#endif /* convert ATIME register to integration time, in microseconds */ int tcs3400_get_integration_time(int atime) @@ -134,16 +143,10 @@ static int tcs3400_read(const struct motion_sensor_t *s, intv3_t v) if (ret) return ret; - if (IS_ENABLED(CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT)) { - int atime; - - ret = tcs3400_i2c_read8(s, TCS_I2C_ATIME, &atime); - if (ret) - return ret; - - hook_call_deferred(&tcs3400_read_deferred_data, - tcs3400_get_integration_time(atime)); - } +#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT + hook_call_deferred(&tcs3400_read_deferred_data, + tcs3400_get_integration_time(atime)); +#endif /* * If write succeeded, we've started the read process, but can't @@ -516,14 +519,6 @@ static int tcs3400_post_events(struct motion_sensor_t *s, return ret; } -void tcs3400_interrupt(enum gpio_signal signal) -{ - if (IS_ENABLED(CONFIG_ACCEL_FIFO)) - last_interrupt_timestamp = __hw_clock_source_read(); - - task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT); -} - /* * tcs3400_irq_handler - bottom half of the interrupt stack. * Ran from the motion_sense task, finds the events that raised the interrupt, |