~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/iio/common/inv_sensors_timestamp.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  * Copyright (C) 2020 Invensense, Inc.
  4  */
  5 
  6 #ifndef INV_SENSORS_TIMESTAMP_H_
  7 #define INV_SENSORS_TIMESTAMP_H_
  8 
  9 /**
 10  * struct inv_sensors_timestamp_chip - chip internal properties
 11  * @clock_period:       internal clock period in ns
 12  * @jitter:             acceptable jitter in per-mille
 13  * @init_period:        chip initial period at reset in ns
 14  */
 15 struct inv_sensors_timestamp_chip {
 16         uint32_t clock_period;
 17         uint32_t jitter;
 18         uint32_t init_period;
 19 };
 20 
 21 /**
 22  * struct inv_sensors_timestamp_interval - timestamps interval
 23  * @lo: interval lower bound
 24  * @up: interval upper bound
 25  */
 26 struct inv_sensors_timestamp_interval {
 27         int64_t lo;
 28         int64_t up;
 29 };
 30 
 31 /**
 32  * struct inv_sensors_timestamp_acc - accumulator for computing an estimation
 33  * @val:        current estimation of the value, the mean of all values
 34  * @idx:        current index of the next free place in values table
 35  * @values:     table of all measured values, use for computing the mean
 36  */
 37 struct inv_sensors_timestamp_acc {
 38         uint32_t val;
 39         size_t idx;
 40         uint32_t values[32];
 41 };
 42 
 43 /**
 44  * struct inv_sensors_timestamp - timestamp management states
 45  * @chip:               chip internal characteristics
 46  * @min_period:         minimal acceptable clock period
 47  * @max_period:         maximal acceptable clock period
 48  * @it:                 interrupts interval timestamps
 49  * @timestamp:          store last timestamp for computing next data timestamp
 50  * @mult:               current internal period multiplier
 51  * @new_mult:           new set internal period multiplier (not yet effective)
 52  * @period:             measured current period of the sensor
 53  * @chip_period:        accumulator for computing internal chip period
 54  */
 55 struct inv_sensors_timestamp {
 56         struct inv_sensors_timestamp_chip chip;
 57         uint32_t min_period;
 58         uint32_t max_period;
 59         struct inv_sensors_timestamp_interval it;
 60         int64_t timestamp;
 61         uint32_t mult;
 62         uint32_t new_mult;
 63         uint32_t period;
 64         struct inv_sensors_timestamp_acc chip_period;
 65 };
 66 
 67 void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
 68                                 const struct inv_sensors_timestamp_chip *chip);
 69 
 70 int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
 71                                      uint32_t period, bool fifo);
 72 
 73 void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 74                                      size_t sample_nb, int64_t timestamp);
 75 
 76 static inline int64_t inv_sensors_timestamp_pop(struct inv_sensors_timestamp *ts)
 77 {
 78         ts->timestamp += ts->period;
 79         return ts->timestamp;
 80 }
 81 
 82 void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
 83                                      uint32_t fifo_period, size_t fifo_nb,
 84                                      unsigned int fifo_no);
 85 
 86 static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
 87 {
 88         const struct inv_sensors_timestamp_interval interval_init = {0LL, 0LL};
 89 
 90         ts->it = interval_init;
 91         ts->timestamp = 0;
 92 }
 93 
 94 #endif
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php