Commit 39ccbd44 authored by Tristan Gingold's avatar Tristan Gingold

fw:fd: minor refactoring, add comments.

parent 54068117
......@@ -182,10 +182,11 @@ static void ts_adjust_delay(struct wr_timestamp *ts, uint32_t cycles, uint32_t f
{
ts->frac += frac;
if (ts->frac & 0x1000)
if (ts->frac & 0x1000) {
ts->ticks++;
ts->frac &= 0xfff;
}
ts->frac &= 0xfff;
ts->ticks += cycles;
if (ts->ticks >= 125000000) {
......@@ -347,11 +348,13 @@ static int check_output_timeout (struct wrtd_out_channel *out)
out->stats.last_programmed.ticks);
}
delta = tc.seconds - out->stats.last_programmed.seconds;
delta *= 125 * 1000 * 1000;
delta += tc.ticks - out->stats.last_programmed.ticks;
/* Current time exceeds FD setpoint? */
delta = tc.seconds - out->stats.last_programmed.seconds;
if (delta != 0)
return delta > 0;
delta = tc.ticks - out->stats.last_programmed.ticks;
return (delta > 0);
}
......@@ -398,14 +401,14 @@ static void drop_trigger(struct wrtd_out_channel *out,
/* Drop the pulse */
pulse_queue_pop(q);
pq_ent->rule->misses ++;
pq_ent->rule->misses++;
switch (reason) {
case WRTD_MISS_TIMEOUT:
out->stats.miss_timeout++;
break;
case WRTD_MISS_NO_WR:
out->stats.miss_no_timing ++;
out->stats.miss_no_timing++;
break;
}
......@@ -439,8 +442,10 @@ static void do_output (struct wrtd_out_channel *out)
}
else if (!(dcr & FD_DCR_PG_TRIG)) {
/* Nope, armed but still waiting for trigger */
if (check_output_timeout (out))
if (check_output_timeout (out)) {
/* Will never trigger. Missed. */
drop_trigger(out, pq_ent, q, WRTD_MISS_TIMEOUT);
}
} else {
out->stats.last_executed = pq_ent->trig;
if (pq_ent->rule)
......@@ -490,7 +495,7 @@ static void do_output (struct wrtd_out_channel *out)
fd_ch_writel(out, FD_DCR_MODE | FD_DCR_PG_ARM | FD_DCR_ENABLE,
FD_REG_DCR);
ts->ticks += 1000;
ts->ticks += 1000; /* 8ns */
if (ts->ticks >= 125000000) {
ts->ticks -= 125000000;
ts->seconds++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment