Rework the frequency ratio estimator to use the tmv functions.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-08-30 18:24:10 +02:00
parent 95598b4fde
commit 829c785414
1 changed files with 8 additions and 5 deletions

13
clock.c
View File

@ -169,6 +169,7 @@ static int clock_master_lost(struct clock *c)
static enum servo_state clock_no_adjust(struct clock *c) static enum servo_state clock_no_adjust(struct clock *c)
{ {
double ratio; double ratio;
tmv_t origin2;
struct freq_estimator *f = &c->fest; struct freq_estimator *f = &c->fest;
enum servo_state state = SERVO_UNLOCKED; enum servo_state state = SERVO_UNLOCKED;
/* /*
@ -192,16 +193,18 @@ static enum servo_state clock_no_adjust(struct clock *c)
if (f->count < f->max_count) { if (f->count < f->max_count) {
return state; return state;
} }
/*
* origin2 = c->t1 (+c->path_delay) + c->c1 + c->c2;
*/
origin2 = tmv_add(c->t1, tmv_add(c->c1, c->c2));
if (f->ingress1) { if (f->ingress1) {
ratio = tmv_dbl(tmv_sub(c->t2, f->ingress1)) /
ratio = (c->t2 - f->ingress1 + 0.0) / tmv_dbl(tmv_sub(origin2, f->origin1));
(c->t1 /*+c->path_delay*/ + c->c1 + c->c2 - f->origin1);
pr_info("master offset %10lld s%d ratio %.9f path delay %10lld", pr_info("master offset %10lld s%d ratio %.9f path delay %10lld",
c->master_offset, state, ratio, c->path_delay); c->master_offset, state, ratio, c->path_delay);
} }
f->ingress1 = c->t2; f->ingress1 = c->t2;
f->origin1 = c->t1 /*+c->path_delay*/ + c->c1 + c->c2; f->origin1 = origin2;
f->count = 0; f->count = 0;
return state; return state;