Lines Matching +full:up +full:- +full:samples

1 // SPDX-License-Identifier: GPL-2.0-or-later
15 /* allow a jitter of +/- 2% */
19 (((_p) * (100 - INV_ICM42600_TIMESTAMP_JITTER)) / 100)
29 acc->values[acc->idx++] = val; in inv_update_acc()
30 if (acc->idx >= ARRAY_SIZE(acc->values)) in inv_update_acc()
31 acc->idx = 0; in inv_update_acc()
34 for (i = 0; i < ARRAY_SIZE(acc->values); ++i) { in inv_update_acc()
35 if (acc->values[i] == 0) in inv_update_acc()
37 sum += acc->values[i]; in inv_update_acc()
40 acc->val = div_u64(sum, i); in inv_update_acc()
50 ts->mult = default_period / INV_ICM42600_TIMESTAMP_PERIOD; in inv_icm42600_timestamp_init()
51 ts->period = default_period; in inv_icm42600_timestamp_init()
53 ts->new_mult = period / INV_ICM42600_TIMESTAMP_PERIOD; in inv_icm42600_timestamp_init()
56 inv_update_acc(&ts->chip_period, INV_ICM42600_TIMESTAMP_PERIOD); in inv_icm42600_timestamp_init()
66 return regmap_update_bits(st->map, INV_ICM42600_REG_TMST_CONFIG, in inv_icm42600_timestamp_setup()
74 if (fifo && ts->new_mult != 0) in inv_icm42600_timestamp_update_odr()
75 return -EAGAIN; in inv_icm42600_timestamp_update_odr()
77 ts->new_mult = period / INV_ICM42600_TIMESTAMP_PERIOD; in inv_icm42600_timestamp_update_odr()
106 inv_update_acc(&ts->chip_period, new_chip_period); in inv_compute_chip_period()
118 uint32_t period = ts->period; in inv_icm42600_timestamp_interrupt()
126 it = &ts->it; in inv_icm42600_timestamp_interrupt()
127 it->lo = it->up; in inv_icm42600_timestamp_interrupt()
128 it->up = timestamp; in inv_icm42600_timestamp_interrupt()
129 delta = it->up - it->lo; in inv_icm42600_timestamp_interrupt()
130 if (it->lo != 0) { in inv_icm42600_timestamp_interrupt()
131 /* compute period: delta time divided by number of samples */ in inv_icm42600_timestamp_interrupt()
136 ts->period = ts->mult * ts->chip_period.val; in inv_icm42600_timestamp_interrupt()
140 if (ts->timestamp == 0) { in inv_icm42600_timestamp_interrupt()
141 /* elapsed time: sensor period * sensor samples number */ in inv_icm42600_timestamp_interrupt()
142 interval = (int64_t)ts->period * (int64_t)sensor_nb; in inv_icm42600_timestamp_interrupt()
143 ts->timestamp = it->up - interval; in inv_icm42600_timestamp_interrupt()
150 fifo_period = fifo_mult * ts->chip_period.val; in inv_icm42600_timestamp_interrupt()
152 delta = it->lo - ts->timestamp; in inv_icm42600_timestamp_interrupt()
153 /* if there are multiple samples, go back to first one */ in inv_icm42600_timestamp_interrupt()
155 delta -= fifo_period; in inv_icm42600_timestamp_interrupt()
157 m = INV_ICM42600_TIMESTAMP_MAX_PERIOD(ts->period) - ts->period; in inv_icm42600_timestamp_interrupt()
160 else if (delta < -m) in inv_icm42600_timestamp_interrupt()
161 delta = -m; in inv_icm42600_timestamp_interrupt()
162 ts->timestamp += delta; in inv_icm42600_timestamp_interrupt()
173 if (ts->new_mult == 0) in inv_icm42600_timestamp_apply_odr()
177 ts->mult = ts->new_mult; in inv_icm42600_timestamp_apply_odr()
178 ts->new_mult = 0; in inv_icm42600_timestamp_apply_odr()
179 ts->period = ts->mult * ts->chip_period.val; in inv_icm42600_timestamp_apply_odr()
185 * total number of samples and the current sample numero. in inv_icm42600_timestamp_apply_odr()
187 if (ts->timestamp != 0) { in inv_icm42600_timestamp_apply_odr()
190 fifo_period = fifo_mult * ts->chip_period.val; in inv_icm42600_timestamp_apply_odr()
192 interval = (int64_t)(fifo_nb - fifo_no) * (int64_t)fifo_period; in inv_icm42600_timestamp_apply_odr()
193 ts->timestamp = ts->it.up - interval; in inv_icm42600_timestamp_apply_odr()