[svn-commits] sruffell: branch linux/sruffell/improved_ecreference r6955 - in /linux/team/s...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 11 14:08:32 CDT 2009


Author: sruffell
Date: Tue Aug 11 14:08:29 2009
New Revision: 6955

URL: http://svn.asterisk.org/svn-view/dahdi?view=rev&rev=6955
Log:
wcte12xp-wip: Initial cut at improving the refernece signals for swechocan.

Instead of using two buffers which means that at best we're two milliseconds
behind, we instead use a circular buffer where audio data is written on the
tranmit side, and on the receive patch data is read from.  This way,
regardless of the amount of latency the system is currently experiencing, the
reference for the echocanceler will match up.

Modified:
    linux/team/sruffell/improved_ecreference/drivers/dahdi/voicebus/voicebus.h
    linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/base.c
    linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/wcte12xp.h

Modified: linux/team/sruffell/improved_ecreference/drivers/dahdi/voicebus/voicebus.h
URL: http://svn.asterisk.org/svn-view/dahdi/linux/team/sruffell/improved_ecreference/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=6955&r1=6954&r2=6955
==============================================================================
--- linux/team/sruffell/improved_ecreference/drivers/dahdi/voicebus/voicebus.h (original)
+++ linux/team/sruffell/improved_ecreference/drivers/dahdi/voicebus/voicebus.h Tue Aug 11 14:08:29 2009
@@ -32,6 +32,7 @@
 struct voicebus;
 
 #define VOICEBUS_DEFAULT_LATENCY 3
+#define VOICEBUS_MAX_LATENCY 16
 
 void voicebus_setdebuglevel(struct voicebus *vb, u32 level);
 int voicebus_getdebuglevel(struct voicebus *vb);

Modified: linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/base.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/base.c?view=diff&rev=6955&r1=6954&r2=6955
==============================================================================
--- linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/base.c Tue Aug 11 14:08:29 2009
@@ -38,6 +38,7 @@
 #include <linux/interrupt.h>
 #include <linux/workqueue.h>
 #include <linux/delay.h>
+#include <linux/kfifo.h>
 
 #include <dahdi/kernel.h>
 
@@ -880,11 +881,20 @@
 {
 	struct t1 *wc = span->pvt;
 	int i;
+	int x;
+	unsigned char buffer[DAHDI_CHUNKSIZE];
 
 	/* initialize the start value for the entire chunk of last ec buffer */
 	for (i = 0; i < span->channels; i++) {
-		memset(wc->ec_chunk1[i], DAHDI_LIN2X(0, span->chans[i]), DAHDI_CHUNKSIZE);
-		memset(wc->ec_chunk2[i], DAHDI_LIN2X(0, span->chans[i]), DAHDI_CHUNKSIZE);
+		__kfifo_reset(wc->ec_reference[i]);
+		for (x = 0; x < DAHDI_CHUNKSIZE; ++x)
+			buffer[x] = DAHDI_LIN2X(0, span->chans[i]);
+
+		for (x = 0; x < __kfifo_len(wc->ec_reference[i]);
+		     x += DAHDI_CHUNKSIZE) {
+			__kfifo_put(wc->ec_reference[i], buffer,
+				    ARRAY_SIZE(buffer));
+		}
 	}
 
 	/* Reset framer with proper parameters and start */
@@ -1252,6 +1262,12 @@
 		return -1;
 	}
 
+	for (x = 0; x < ARRAY_SIZE(wc->ec_reference); ++x) {
+		wc->ec_reference[x] = kfifo_alloc(DAHDI_CHUNKSIZE *
+						  VOICEBUS_MAX_LATENCY,
+						  GFP_KERNEL, NULL);
+	}
+
 	set_bit(INITIALIZED, &wc->bit_flags);
 
 	return 0;
@@ -1564,6 +1580,11 @@
 		dahdi_transmit(&wc->span);
 	}
 
+	for (chan = 0; chan < wc->span.channels; chan++) {
+		__kfifo_put(wc->ec_reference[chan],
+			    wc->chans[chan]->writechunk, DAHDI_CHUNKSIZE);
+	}
+
 	for (x = 0; x < DAHDI_CHUNKSIZE; x++) {
 		if (likely(test_bit(INITIALIZED, &wc->bit_flags))) {
 			for (chan = 0; chan < wc->span.channels; chan++)
@@ -1588,6 +1609,8 @@
 		}
 		writechunk += (EFRAME_SIZE + EFRAME_GAP);
 	}
+
+
 }
 
 static inline void t1_receiveprep(struct t1 *wc, unsigned char* readchunk)
@@ -1625,10 +1648,12 @@
 	
 	/* echo cancel */
 	if (likely(test_bit(INITIALIZED, &wc->bit_flags))) {
+		unsigned char buffer[DAHDI_CHUNKSIZE];
 		for (x = 0; x < wc->span.channels; x++) {
-			dahdi_ec_chunk(wc->chans[x], wc->chans[x]->readchunk, wc->ec_chunk2[x]);
-			memcpy(wc->ec_chunk2[x],wc->ec_chunk1[x],DAHDI_CHUNKSIZE);
-			memcpy(wc->ec_chunk1[x],wc->chans[x]->writechunk,DAHDI_CHUNKSIZE);
+			__kfifo_get(wc->ec_reference[x], buffer,
+				    ARRAY_SIZE(buffer));
+			dahdi_ec_chunk(wc->chans[x], wc->chans[x]->readchunk,
+				       buffer);
 		}
 		dahdi_receive(&wc->span);
 	}

Modified: linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/wcte12xp.h
URL: http://svn.asterisk.org/svn-view/dahdi/linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/wcte12xp.h?view=diff&rev=6955&r1=6954&r2=6955
==============================================================================
--- linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/wcte12xp.h (original)
+++ linux/team/sruffell/improved_ecreference/drivers/dahdi/wcte12xp/wcte12xp.h Tue Aug 11 14:08:29 2009
@@ -115,11 +115,10 @@
 	unsigned long bit_flags;
 	unsigned long alarmtimer;
 	unsigned char ledstate;
-	unsigned char ec_chunk1[32][DAHDI_CHUNKSIZE];
-	unsigned char ec_chunk2[32][DAHDI_CHUNKSIZE];
 	struct dahdi_span span;						/* Span */
 	struct dahdi_chan *chans[32];					/* Channels */
 	struct dahdi_echocan_state *ec[32];				/* Echocan state for channels */
+	struct kfifo *ec_reference[32];
 	unsigned long ctlreg;
 	struct voicebus* vb;
 	atomic_t txints;




More information about the svn-commits mailing list