From 80dc858648497bb683ccee5157e9f62dbdf99ddb Mon Sep 17 00:00:00 2001 From: markster Date: Fri, 15 Nov 2002 21:27:46 +0000 Subject: Version 0.3.3 from FTP git-svn-id: http://svn.digium.com/svn/zaptel/trunk@131 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wct1xxp.c | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'wct1xxp.c') diff --git a/wct1xxp.c b/wct1xxp.c index 2d15692..1c6b4d4 100755 --- a/wct1xxp.c +++ b/wct1xxp.c @@ -142,6 +142,8 @@ struct t1xxp { int alarmtimer; int loopupcnt; int loopdowncnt; + int miss; + int misslast; int *chanmap; #ifdef FANCY_ALARM int alarmpos; @@ -867,18 +869,6 @@ static void t1xxp_receiveprep(struct t1xxp *wc, int ints) } else { rxbuf = wc->readchunk + ZT_CHUNKSIZE * 32; } - if (!wc->ise1) { - for (x=3;x<32;x+=4) { - if (rxbuf[(x + WC_OFFSET) & 0x1f] == 0x7f) { - if (wc->offset != (x-3)) { - wc->offset = x - 3; -#if 1 - if (debug) printk("New offset: %d\n", wc->offset); -#endif - } - } - } - } for (y=0;yspan.channels;x++) { /* XXX Optimize, remove * and + XXX */ @@ -886,6 +876,35 @@ static void t1xxp_receiveprep(struct t1xxp *wc, int ints) wc->chans[x].readchunk[y] = rxbuf[32 * y + ((wc->chanmap[x] + WC_OFFSET + wc->offset) & 0x1f)]; } + if (!wc->ise1) { + for (x=3;x<32;x+=4) { + if (rxbuf[32 * y + ((x + WC_OFFSET) & 0x1f)] == 0x7f) { + if (wc->offset != (x-3)) { + wc->offset = x - 3; +#if 1 + if (debug) printk("New offset: %d\n", wc->offset); +#endif + } + } + } + } else { + if (!wc->clocktimeout && !wc->span.alarms) { + if ((rxbuf[32 * y + ((3 + WC_OFFSET + wc->offset) & 0x1f)] & 0x7f) != 0x1b) { + if (wc->miss) { + if (debug) printk("Double miss (%d, %d)...\n", wc->misslast, rxbuf[32 * y + ((3 + WC_OFFSET + wc->offset) & 0x1f)]); + control_set_reg(wc, WC_CLOCK, 0x02 | wc->sync | wc->ise1); + wc->clocktimeout = 100; + } else { + wc->miss = 1; + wc->misslast = rxbuf[32 * y + ((3 + WC_OFFSET + wc->offset) & 0x1f)]; + } + } else { + wc->miss = 0; + } + } else { + wc->miss = 0; + } + } } for (x=0;xspan.channels;x++) { zt_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, @@ -1162,8 +1181,6 @@ static int t1xxp_hardware_init(struct t1xxp *wc) control_set_reg(wc, WC_LEDTEST, 0x00); - control_set_reg(wc, WC_CLOCK, 0x02); - wc->clocktimeout = 100; /* Sanity check also determines e1 or t1 */ if (t1xxp_framer_sanity_check(wc)) @@ -1172,6 +1189,10 @@ static int t1xxp_hardware_init(struct t1xxp *wc) wc->chanmap = chanmap_e1; else wc->chanmap = chanmap_t1; + /* Setup clock appropriately */ + control_set_reg(wc, WC_CLOCK, 0x02 | wc->sync | wc->ise1); + wc->clocktimeout = 100; + /* Reset the T1 and report */ t1xxp_framer_hard_reset(wc); start_alarm(wc); -- cgit v1.2.3