summaryrefslogtreecommitdiff
path: root/tor2.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-08-17 00:28:51 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-08-17 00:28:51 +0000
commit9ba4e07b16bf5efa450f9ab3b9f1eaa937d54a82 (patch)
tree82eaee499b6fddeb273ac4614748ec2148d27fd5 /tor2.c
parentcae7000b30d70bede209225c841cf2702c84fb0f (diff)
Version 0.3.0 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@98 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'tor2.c')
-rwxr-xr-xtor2.c26
1 files changed, 21 insertions, 5 deletions
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;y<tor->spans[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]);
}