Skip to content

Instantly share code, notes, and snippets.

@sknsean
Created June 2, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sknsean/415d1b9c34f20db4419a0c61a58eb188 to your computer and use it in GitHub Desktop.
Save sknsean/415d1b9c34f20db4419a0c61a58eb188 to your computer and use it in GitHub Desktop.
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 7de10bd636ea..7333443f58bc 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -288,6 +288,8 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw)
if (err < 0)
return err;
+ printk("st_lsm6dsx_reset_hw_ts\n");
+
for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
if (!hw->iio_devs[i])
continue;
@@ -298,18 +300,37 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw)
* hw timestamp
*/
sensor->ts_ref = iio_get_time_ns(hw->iio_devs[i]);
+ printk("ktime_get_real_ns: %lld, ktime_get_ns: %lld, ktime_get_raw_ns: %lld\n", ktime_get_real_ns(), ktime_get_ns(), ktime_get_raw_ns());
}
return 0;
}
int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw)
{
- int err;
+ int err, i;
+ struct st_lsm6dsx_sensor *sensor;
+
+ printk("st_lsm6dsx_resume_fifo\n");
+ for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
+ if (!hw->iio_devs[i])
+ continue;
+ sensor = iio_priv(hw->iio_devs[i]);
+ printk("Before[%d]: %lld\n", i, sensor->ts_ref);
+ }
/* reset hw ts counter */
err = st_lsm6dsx_reset_hw_ts(hw);
if (err < 0)
return err;
+ for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
+ if (!hw->iio_devs[i])
+ continue;
+
+ sensor = iio_priv(hw->iio_devs[i]);
+ printk("After[%d]: %lld\n", i, sensor->ts_ref);
+ }
+
+ printk("ktime_get_real_ns: %lld, ktime_get_ns: %lld, ktime_get_raw_ns: %lld\n", ktime_get_real_ns(), ktime_get_ns(), ktime_get_raw_ns());
return st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
}
@@ -465,6 +486,8 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
iio_push_to_buffers_with_timestamp(
hw->iio_devs[ST_LSM6DSX_ID_ACC],
acc_buff, acc_sensor->ts_ref + ts);
+ printk("ts_ref %lld, ts %lld, sample_time %lld\n", acc_sensor->ts_ref, ts, acc_sensor->ts_ref + ts);
+ printk("ktime_get_real_ns: %lld\n", ktime_get_real_ns());
acc_sip--;
}
if (ext_sip > 0 && !(sip % ext_sensor->decimator)) {
--
2.26.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment