[dahdi-commits] kpfleming: branch linux/kpfleming/modular_ec r4398 - in /linux/team/kpfleming...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Wed Jun 18 17:32:50 CDT 2008


Author: kpfleming
Date: Wed Jun 18 17:32:49 2008
New Revision: 4398

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4398
Log:
ok... now every channel can have a specific echo canceller defined, and it will be called when needed. nothing knows how to define them yet, though.

Modified:
    linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c
    linux/team/kpfleming/modular_ec/include/dahdi/kernel.h

Modified: linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c?view=diff&rev=4398&r1=4397&r2=4398
==============================================================================
--- linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c Wed Jun 18 17:32:49 2008
@@ -999,8 +999,8 @@
 	ppp = chan->ppp;
 	chan->ppp = NULL;
 #endif
-	ec = chan->ec;
-	chan->ec = NULL;
+	ec = chan->ec_state;
+	chan->ec_state = NULL;
 	readchunkpreec = chan->readchunkpreec;
 	chan->readchunkpreec = NULL;
 	chan->curtone = NULL;
@@ -1057,14 +1057,15 @@
 	if (chan->span && chan->span->dacs && oldconf)
 		chan->span->dacs(chan, NULL);
 
+	if (ec)
+		chan->ec->echo_can_free(ec);
+
 	spin_unlock_irqrestore(&chan->lock, flags);
 
 	hw_echocancel_off(chan);
 
 	if (rxgain)
 		kfree(rxgain);
-//	if (ec)
-//		echo_can_free(ec);
 	if (readchunkpreec)
 		kfree(readchunkpreec);
 
@@ -2162,8 +2163,8 @@
 	chan->txbufpolicy = DAHDI_POLICY_IMMEDIATE;
 
 	/* Free up the echo canceller if there is one */
-	ec = chan->ec;
-	chan->ec = NULL;
+	ec = chan->ec_state;
+	chan->ec_state = NULL;
 	chan->echocancel = 0;
 	chan->echostate = ECHO_STATE_IDLE;
 	chan->echolastupdate = 0;
@@ -2260,15 +2261,18 @@
 		chan->ringcadence[1] = DAHDI_RINGOFFTIME;
 	}
 
+	if (ec)
+		chan->ec->echo_can_free(ec);
+
 	spin_unlock_irqrestore(&chan->lock, flags);
+
 	set_tone_zone(chan, -1);
 
 	hw_echocancel_off(chan);
 
 	if (rxgain)
 		kfree(rxgain);
-//	if (ec)
-//		echo_can_free(ec);
+
 	return 0;
 }
 
@@ -3408,17 +3412,17 @@
 		printk(KERN_INFO "confna: %d, confn: %d, confmode: %d, confmute: %d\n",
 			mychan->confna, mychan->_confn, mychan->confmode, mychan->confmute);
 		printk(KERN_INFO "ec: %08lx, echocancel: %d, deflaw: %d, xlaw: %08lx\n",
-			(long) mychan->ec, mychan->echocancel, mychan->deflaw, (long) mychan->xlaw);
+			(long) mychan->ec_state, mychan->echocancel, mychan->deflaw, (long) mychan->xlaw);
 		printk(KERN_INFO "echostate: %02x, echotimer: %d, echolastupdate: %d\n",
 			(int) mychan->echostate, mychan->echotimer, mychan->echolastupdate);
 		printk(KERN_INFO "itimer: %d, otimer: %d, ringdebtimer: %d\n\n",
 			mychan->itimer, mychan->otimer, mychan->ringdebtimer);
 #if 0
-		if (mychan->ec) {
+		if (mychan->ec_state) {
 			int x;
 			/* Dump the echo canceller parameters */
-			for (x=0;x<mychan->ec->taps;x++) {
-				printk(KERN_INFO "tap %d: %d\n", x, mychan->ec->fir_taps[x]);
+			for (x=0;x<mychan->ec_state->taps;x++) {
+				printk(KERN_INFO "tap %d: %d\n", x, mychan->ec_state->fir_taps[x]);
 			}
 		}
 #endif
@@ -4491,16 +4495,16 @@
 	if (ecp->tap_length == 0) {
 		/* disable mode, don't need to inspect params */
 		spin_lock_irqsave(&chan->lock, flags);
-		tec = chan->ec;
-		chan->ec = NULL;
+		tec = chan->ec_state;
+		chan->ec_state = NULL;
 		chan->echocancel = 0;
 		chan->echostate = ECHO_STATE_IDLE;
 		chan->echolastupdate = 0;
 		chan->echotimer = 0;
+		if (tec)
+			chan->ec->echo_can_free(tec);
 		spin_unlock_irqrestore(&chan->lock, flags);
 		hw_echocancel_off(chan);
-//		if (tec)
-//			echo_can_free(tec);
 
 		return 0;
 	}
@@ -4524,13 +4528,12 @@
 	}
 	
 	spin_lock_irqsave(&chan->lock, flags);
-	tec = chan->ec;
-	chan->ec = NULL;
+	tec = chan->ec_state;
+	chan->ec_state = NULL;
+	if (tec)
+		chan->ec->echo_can_free(tec);
 	spin_unlock_irqrestore(&chan->lock, flags);
 	
-//	if (tec)
-//		echo_can_free(tec);
-
 	ret = -ENODEV;
 	
 	/* attempt to use the span's echo canceler; fall back to built-in
@@ -4555,12 +4558,12 @@
 			ecp->tap_length = deftaps;
 		}
 		
-//		if ((ret = echo_can_create(ecp, params, &ec)))
-//			goto exit_with_free;
+		if ((ret = chan->ec->echo_can_create(ecp, params, &ec)))
+			goto exit_with_free;
 		
 		spin_lock_irqsave(&chan->lock, flags);
 		chan->echocancel = ecp->tap_length;
-		chan->ec = ec;
+		chan->ec_state = ec;
 		chan->echostate = ECHO_STATE_IDLE;
 		chan->echolastupdate = 0;
 		chan->echotimer = 0;
@@ -4634,8 +4637,8 @@
 			memset(chan->conflast, 0, sizeof(chan->conflast));
 			memset(chan->conflast1, 0, sizeof(chan->conflast1));
 			memset(chan->conflast2, 0, sizeof(chan->conflast2));
-			ec = chan->ec;
-			chan->ec = NULL;
+			ec = chan->ec_state;
+			chan->ec_state = NULL;
 			/* release conference resource, if any to release */
 			reset_conf(chan);
 			if (chan->gainalloc && chan->rxgain)
@@ -4646,15 +4649,15 @@
 			chan->rxgain = defgain;
 			chan->txgain = defgain;
 			chan->gainalloc = 0;
+			if (ec)
+				chan->ec->echo_can_free(ec);
+			spin_unlock_irqrestore(&chan->lock, flags);
+
 			/* Disable any native echo cancellation as well */
-			spin_unlock_irqrestore(&chan->lock, flags);
-
 			hw_echocancel_off(chan);
 
 			if (rxgain)
 				kfree(rxgain);
-//			if (ec)
-//				echo_can_free(ec);
 			if (oldconf) dahdi_check_conf(oldconf);
 		}
 		break;
@@ -4687,8 +4690,8 @@
 						chan->ppp = NULL;
 						return ret;
 					}
-					tec = chan->ec;
-					chan->ec = NULL;
+					tec = chan->ec_state;
+					chan->ec_state = NULL;
 					chan->echocancel = 0;
 					chan->echostate = ECHO_STATE_IDLE;
 					chan->echolastupdate = 0;
@@ -4703,8 +4706,8 @@
 					chan->flags |= (DAHDI_FLAG_PPP | DAHDI_FLAG_HDLC | DAHDI_FLAG_FCS);
 					hw_echocancel_off(chan);
 					
-//					if (tec)
-//						echo_can_free(tec);
+					if (tec)
+						chan->ec->echo_can_free(tec);
 				} else
 					return -ENOMEM;
 			}
@@ -4775,7 +4778,7 @@
 		if ((j < 0) || (j >= DAHDI_MAX_PRETRAINING))
 			return -EINVAL;
 		j <<= 3;
-		if (chan->ec) {
+		if (chan->ec_state) {
 			/* Start pretraining stage */
 			chan->echostate = ECHO_STATE_PRETRAINING;
 			chan->echotimer = j;
@@ -5297,7 +5300,7 @@
 	for (x=0;x<DAHDI_CHUNKSIZE;x++)
 		getlin[x] = DAHDI_XLAW(txb[x], ms);
 #ifndef NO_ECHOCAN_DISABLE
-	if (ms->ec) {
+	if (ms->ec_state) {
 		for (x=0;x<DAHDI_CHUNKSIZE;x++) {
 			/* Check for echo cancel disabling tone */
 			if (echo_can_disable_detector_update(&ms->txecdis, getlin[x])) {
@@ -5306,8 +5309,8 @@
 				ms->echostate = ECHO_STATE_IDLE;
 				ms->echolastupdate = 0;
 				ms->echotimer = 0;
-//				echo_can_free(ms->ec);
-				ms->ec = NULL;
+				ms->ec->echo_can_free(ms->ec_state);
+				ms->ec_state = NULL;
 				__qevent(ss, DAHDI_EVENT_EC_DISABLED);
 				break;
 			}
@@ -5479,14 +5482,14 @@
 			if (!chans[ms->confna])
 				break;
 			if (chans[ms->confna]->flags & DAHDI_FLAG_PSEUDO) {
-				if (ms->ec) {
+				if (ms->ec_state) {
 					for (x=0;x<DAHDI_CHUNKSIZE;x++)
 						txb[x] = DAHDI_LIN2X(chans[ms->confna]->getlin[x], ms);
 				} else {
 					memcpy(txb, chans[ms->confna]->getraw, DAHDI_CHUNKSIZE);
 				}
 			} else {
-				if (ms->ec) {
+				if (ms->ec_state) {
 					for (x=0;x<DAHDI_CHUNKSIZE;x++)
 						txb[x] = DAHDI_LIN2X(chans[ms->confna]->putlin[x], ms);
 				} else {
@@ -6112,7 +6115,7 @@
 	}
 
 	/* Perform echo cancellation on a chunk if necessary */
-	if (ss->ec) {
+	if (ss->ec_state) {
 #if defined(CONFIG_DAHDI_MMX) || defined(ECHO_CAN_FP)
 		dahdi_kernel_fpu_begin();
 #endif		
@@ -6132,12 +6135,12 @@
 					ss->echostate = ECHO_STATE_TRAINING;
 				}
 				if (ss->echostate == ECHO_STATE_TRAINING) {
-//					if (echo_can_traintap(ss->ec, ss->echolastupdate++, rxlin)) {
+					if (ss->ec->echo_can_traintap(ss->ec_state, ss->echolastupdate++, rxlin)) {
 #if 0
-//						printk("Finished training (%d taps trained)!\n", ss->echolastupdate);
+						printk("Finished training (%d taps trained)!\n", ss->echolastupdate);
 #endif						
-//						ss->echostate = ECHO_STATE_ACTIVE;
-//					}
+						ss->echostate = ECHO_STATE_ACTIVE;
+					}
 				}
 				rxlin = 0;
 				rxchunk[x] = DAHDI_LIN2X((int)rxlin, ss);
@@ -6148,7 +6151,7 @@
 				rxlins[x] = DAHDI_XLAW(rxchunk[x], ss);
 				txlins[x] = DAHDI_XLAW(txchunk[x], ss);
 			}
-//			echo_can_array_update(ss->ec, rxlins, txlins);
+			ss->ec->echo_can_array_update(ss->ec_state, rxlins, txlins);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxchunk[x] = DAHDI_LIN2X((int) rxlins[x], ss);
 		}
@@ -6244,7 +6247,7 @@
 	}
 
 #ifndef NO_ECHOCAN_DISABLE
-	if (ms->ec) {
+	if (ms->ec_state) {
 		for (x=0;x<DAHDI_CHUNKSIZE;x++) {
 			if (echo_can_disable_detector_update(&ms->rxecdis, putlin[x])) {
 				printk("DAHDI Disabled echo canceller because of tone (rx) on channel %d\n", ss->channo);
@@ -6252,8 +6255,8 @@
 				ms->echostate = ECHO_STATE_IDLE;
 				ms->echolastupdate = 0;
 				ms->echotimer = 0;
-//				echo_can_free(ms->ec);
-				ms->ec = NULL;
+				ms->ec->echo_can_free(ms->ec_state);
+				ms->ec_state = NULL;
 				break;
 			}
 		}

Modified: linux/team/kpfleming/modular_ec/include/dahdi/kernel.h
URL: http://svn.digium.com/view/dahdi/linux/team/kpfleming/modular_ec/include/dahdi/kernel.h?view=diff&rev=4398&r1=4397&r2=4398
==============================================================================
--- linux/team/kpfleming/modular_ec/include/dahdi/kernel.h (original)
+++ linux/team/kpfleming/modular_ec/include/dahdi/kernel.h Wed Jun 18 17:32:49 2008
@@ -1347,7 +1347,8 @@
 
 	/* Is echo cancellation enabled or disabled */
 	int		echocancel;
-	struct echo_can_state	*ec;
+	struct dahdi_echocan *ec;
+	struct echo_can_state *ec_state;
 	echo_can_disable_detector_state_t txecdis;
 	echo_can_disable_detector_state_t rxecdis;
 	




More information about the dahdi-commits mailing list