diff options
Diffstat (limited to 'xpp/xbus-pcm.h')
-rw-r--r-- | xpp/xbus-pcm.h | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/xpp/xbus-pcm.h b/xpp/xbus-pcm.h index 79d0078..3265f68 100644 --- a/xpp/xbus-pcm.h +++ b/xpp/xbus-pcm.h @@ -40,27 +40,50 @@ enum sync_mode { }; /* - * A generic timing source. Encapsulates all sampling - * logic, average and standard deviation computation, - * tick_rate computation. - * - * Each xbus has embedded instance. - * Also there is a global instance for external reference - * syncing (e.g: from zaptel) + * Abstract representation of timestamp. + * It would (eventually) replace the hard-coded + * timeval structs so we can migrate to better + * time representations. + */ +struct xpp_timestamp { + struct timeval tv; +}; + +/* + * A ticker encapsulates the timing information of some + * abstract tick source. The following tickers are used: + * - Each xbus has an embedded ticker. + * - There is one global zaptel_ticker to represent ticks + * of external zaptel card (in case we want to sync + * from other zaptel devices). + */ +struct xpp_ticker { /* for rate calculation */ + int count; + int cycle; + struct xpp_timestamp first_sample; + struct xpp_timestamp last_sample; + int tick_period; /* usec/tick */ + spinlock_t lock; +}; + +/* + * xpp_drift represent the measurements of the offset between an + * xbus ticker to a reference ticker. */ -struct xpp_timing { - const char *name; - struct timeval timing_val; - unsigned long timing_count; - long accumulated_usec; - long accumulated_usec_sqr; - int tick_avg; - int tick_stddev; +struct xpp_drift { + int wanted_offset; /* fixed */ + int delta_tick; /* from ref_ticker */ + int lost_ticks; /* occurances */ + int lost_tick_count; + int delta_max; + int delta_min; + int median; /* (max + min) / 2 */ + int jitter; /* max - min */ + int calc_drift; spinlock_t lock; - unsigned int tick_rate; }; -void xpp_timing_init(struct xpp_timing *timing, const char *name); +void xpp_drift_init(xbus_t *xbus); static inline long usec_diff(const struct timeval *tv1, const struct timeval *tv2) { @@ -100,6 +123,11 @@ extern int xpp_ec; #define xpp_ec 0 #endif +#ifdef DEBUG_PCMTX +extern int pcmtx; +extern int pcmtx_chan; +#endif + #endif /* __KERNEL__ */ #endif /* XBUS_PCM_H */ |