From 9ed9aac023ab4fb9f8fa12d3ef3b8d2bb6da9712 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Thu, 23 Sep 2010 21:05:18 +0200 Subject: [WIP] Ugly hack to compensate lost time on TS change (high TS -> low TS) Signed-off-by: Sylvain Munaut --- src/target/firmware/layer1/sync.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c index 36f42975..0cf4f10b 100644 --- a/src/target/firmware/layer1/sync.c +++ b/src/target/firmware/layer1/sync.c @@ -187,6 +187,7 @@ void l1s_reset_hw(void) static int last_timestamp; +static int last_ts = 0; static inline void check_lost_frame(void) { int diff, timestamp = hwtimer_read(1); @@ -196,6 +197,26 @@ static inline void check_lost_frame(void) diff = last_timestamp - timestamp; + /* TS change compensation */ + if (l1s.dedicated.type) { + if (l1s.dedicated.tn < last_ts) { + int ediff = ((8 - last_ts + l1s.dedicated.tn) * TIMER_TICKS_PER_TDMA) >> 3; + printf("TS Chg back: %d -> %d | %d %d\n", + last_ts, l1s.dedicated.tn, diff, ediff); + + // if (((ediff - 2) < diff) && ((ediff + 2) > diff)) { + puts("ADV !\n"); + l1s.current_time = l1s.next_time; + l1s_time_inc(&l1s.next_time, 1); + // } + } else if (l1s.dedicated.tn > last_ts) + printf("TS Chg forth: %d -> %d | %d\n", + last_ts, l1s.dedicated.tn, diff); + last_ts = l1s.dedicated.tn; + } +// } else +// last_ts = 0; + /* allow for a bit of jitter */ if (diff < TIMER_TICKS_PER_TDMA - TIMER_TICK_JITTER || diff > TIMER_TICKS_PER_TDMA + TIMER_TICK_JITTER) @@ -367,6 +388,7 @@ void l1s_reset(void) /* Leave dedicated mode */ l1s.dedicated.type = GSM_DCHAN_NONE; + last_ts = 0; /* reset scheduler and hardware */ sched_gsmtime_reset(); -- cgit v1.2.3