21 #include <linux/module.h>
22 #include <linux/slab.h>
24 #include <linux/kernel.h>
32 #define TIMECOMPARE_SKEW_RESOLUTION (((s64)1)<<30)
39 nsec = source_tstamp + sync->
offset;
43 return ns_to_ktime(nsec);
51 u64 start_source = 0, end_source = 0;
86 sample.duration_target = ktime_to_ns(ktime_sub(end, start));
87 if (sample.duration_target >= 0) {
94 (ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
100 if (samples[index].duration_target <
101 sample.duration_target)
103 samples[index + 1] = samples[
index];
106 samples[index + 1] = sample;
111 if (counter >= num_samples ||
i >= 100000) {
117 *source_tstamp = (end_source + start_source) / 2;
120 used = counter * 3 / 4;
126 for (index = 0; index <
used; index++)
127 off += samples[index].offset;
128 *offset = div_s64(off, used);
131 if (samples && samples !=
buffer)
155 if (delta_nsec >= 10000) {
156 s64 delta_offset_nsec = offset - sync->
offset;
164 divisor = delta_nsec;
170 skew = div_s64(skew, 2);
173 skew = div_s64(skew, divisor);
182 #define TIMECOMPARE_NEW_SKEW_PER_16 12