Lines Matching +full:clk +full:- +full:out +full:- +full:frequency
1 /*-
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * clockcalib(clk, clkname):
35 * Return the frequency of the provided timer, as calibrated against the
36 * current best-available timecounter.
39 clockcalib(uint64_t (*clk)(void), const char *clkname) in clockcalib()
54 /*- in clockcalib()
55 * The idea here is to compute a best-fit linear regression between in clockcalib()
57 * that line multiplied by the frequency of the reference clock gives in clockcalib()
58 * us the frequency we're looking for. in clockcalib()
68 * measured the target clock frequency. in clockcalib()
74 * (variance(x) * variance(y) - covariance(x, y)^2) in clockcalib()
75 * ------------------------------------------------ in clockcalib()
76 * covariance(x, y)^2 * (N - 2) in clockcalib()
84 * would introduce a multiple-comparisons problem (cf. sequential in clockcalib()
93 * we measure later in order to reduce floating-point rounding errors. in clockcalib()
97 clk0 = clk(); in clockcalib()
98 t0 = tc->tc_get_timecount(tc) & tc->tc_counter_mask; in clockcalib()
105 clk1 = clk() - clk0; in clockcalib()
106 t1 = tc->tc_get_timecount(tc) & tc->tc_counter_mask; in clockcalib()
108 tadj += (uint64_t)tc->tc_counter_mask + 1; in clockcalib()
110 t1 += tadj - t0; in clockcalib()
113 if (t1 > tc->tc_frequency) { in clockcalib()
119 freq = (double)(tc->tc_frequency) * clk1 / t1; in clockcalib()
127 d1 = clk1 - mu_clk; in clockcalib()
129 d2 = d1 * (clk1 - mu_clk); in clockcalib()
130 va_clk += (d2 - va_clk) * inv_n; in clockcalib()
133 d1 = t1 - mu_t; in clockcalib()
135 d2 = d1 * (t1 - mu_t); in clockcalib()
136 va_t += (d2 - va_t) * inv_n; in clockcalib()
139 d2 = d1 * (clk1 - mu_clk); in clockcalib()
140 cva += (d2 - cva) * inv_n; in clockcalib()
143 * Count low-uncertainty iterations. This is a rearrangement in clockcalib()
149 if (TSC_UNCERTAINTY_SQR * (n - 2) * cva * cva > in clockcalib()
150 (va_t + 4) * (va_clk + 4) - cva * cva) in clockcalib()
157 freq = (double)(tc->tc_frequency) * cva / va_t; in clockcalib()
162 1000000.0 / tc->tc_frequency), in clockcalib()
169 * resulting from this loop synchronizing with the frequency in clockcalib()
171 * O(1 / n) time here -- long enough to avoid aliasing, but in clockcalib()
174 clk_delay = clk() + (clk() - clk0) / (n * n); in clockcalib()
175 while (clk() < clk_delay) in clockcalib()