diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-11-15 21:27:46 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-11-15 21:27:46 +0000 |
commit | 80dc858648497bb683ccee5157e9f62dbdf99ddb (patch) | |
tree | 749c0184abc22eaa37ac9219ae5fbb2b58b0a6af /wct1xxp.c | |
parent | 99b0ac36f5f327f8dedd4ca8686f913cc52cc75e (diff) |
Version 0.3.3 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@131 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wct1xxp.c')
-rwxr-xr-x | wct1xxp.c | 49 |
1 files changed, 35 insertions, 14 deletions
@@ -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;y<ZT_CHUNKSIZE;y++) { for (x=0;x<wc->span.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;x<wc->span.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); |