From 9ba4e07b16bf5efa450f9ab3b9f1eaa937d54a82 Mon Sep 17 00:00:00 2001 From: markster Date: Sat, 17 Aug 2002 00:28:51 +0000 Subject: Version 0.3.0 from FTP git-svn-id: http://svn.digium.com/svn/zaptel/trunk@98 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- tor2.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'tor2.c') diff --git a/tor2.c b/tor2.c index fbe7c37..8e1879a 100755 --- a/tor2.c +++ b/tor2.c @@ -103,6 +103,8 @@ struct tor2 { int spansstarted; /* number of spans started */ spinlock_t lock; /* lock context */ unsigned char leds; /* copy of LED register */ + unsigned char ec_chunk1[4][32][ZT_CHUNKSIZE]; /* first EC chunk buffer */ + unsigned char ec_chunk2[4][32][ZT_CHUNKSIZE]; /* second EC chunk buffer */ #ifdef ENABLE_TASKLETS int taskletrun; int taskletsched; @@ -707,11 +709,18 @@ static int tor2_startup(struct zt_span *span) return -1; } - spin_lock_irqsave(&p->tor->lock, flags); alreadyrunning = span->flags & ZT_FLAG_RUNNING; + /* initialize the start value for the entire chunk of last ec buffer */ + for(i = 0; i < span->channels; i++) + { + memset(p->tor->ec_chunk1[p->span][i], + ZT_LIN2X(0,&span->chans[i]),ZT_CHUNKSIZE); + memset(p->tor->ec_chunk2[p->span][i], + ZT_LIN2X(0,&span->chans[i]),ZT_CHUNKSIZE); + } if (p->tor->cardtype == TYPE_E1) { /* if this is an E1 card */ unsigned char tcr1,ccr1; if (!alreadyrunning) { @@ -937,11 +946,18 @@ static inline void tor2_run(struct tor2 *tor) int x,y; for (x=0;x<4;x++) { if (tor->spans[x].flags & ZT_FLAG_RUNNING) { + /* since the Tormenta 2 PCI is double-buffered, you + need to delay the transmit data 2 entire chunks so + that the transmit will be in sync with the receive */ for (y=0;yspans[x].channels;y++) { - /* XXX Technically, we're wasting 8 taps of echo canceller - because we're cancelling against something that won't be sent - until the next chunk XXX */ - zt_ec_chunk(&tor->spans[x].chans[y], tor->spans[x].chans[y].readchunk, tor->spans[x].chans[y].writechunk); + zt_ec_chunk(&tor->spans[x].chans[y], + tor->spans[x].chans[y].readchunk, + tor->ec_chunk2[x][y]); + memcpy(tor->ec_chunk2[x][y],tor->ec_chunk1[x][y], + ZT_CHUNKSIZE); + memcpy(tor->ec_chunk1[x][y], + tor->spans[x].chans[y].writechunk, + ZT_CHUNKSIZE); } zt_receive(&tor->spans[x]); } -- cgit v1.2.3