[svn-commits] kpfleming: branch kpfleming/echocanparams r3521 - /team/kpfleming/echocanparams/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 18 13:14:59 CST 2007


Author: kpfleming
Date: Tue Dec 18 13:14:59 2007
New Revision: 3521

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3521
Log:
getting closer to something usable, yay

Modified:
    team/kpfleming/echocanparams/mg2ec.h
    team/kpfleming/echocanparams/zaptel-base.c
    team/kpfleming/echocanparams/zaptel.h

Modified: team/kpfleming/echocanparams/mg2ec.h
URL: http://svn.digium.com/view/zaptel/team/kpfleming/echocanparams/mg2ec.h?view=diff&rev=3521&r1=3520&r2=3521
==============================================================================
--- team/kpfleming/echocanparams/mg2ec.h (original)
+++ team/kpfleming/echocanparams/mg2ec.h Tue Dec 18 13:14:59 2007
@@ -508,7 +508,7 @@
 					memset(max_coeffs, 0, USED_COEFFS*sizeof(int));
 #endif
 #ifdef MEC2_STATS_DETAILED
-				printk( KERN_INFO "updating coefficients with: ec->Lu_i %9d\n", ec->Lu_i);
+				printk(KERN_INFO "updating coefficients with: ec->Lu_i %9d\n", ec->Lu_i);
 #endif
 #ifdef MEC2_STATS
 				ec->avg_Lu_i_ok = ec->avg_Lu_i_ok + ec->Lu_i;  
@@ -550,7 +550,7 @@
 #endif
 		 	 } else { 
 #ifdef MEC2_STATS_DETAILED
-				printk( KERN_INFO "insufficient signal to update coefficients ec->Lu_i %5d < %5d\n", ec->Lu_i, MIN_UPDATE_THRESH_I);
+				printk(KERN_INFO "insufficient signal to update coefficients ec->Lu_i %5d < %5d\n", ec->Lu_i, MIN_UPDATE_THRESH_I);
 #endif
 #ifdef MEC2_STATS
 				ec->avg_Lu_i_toolow = ec->avg_Lu_i_toolow + ec->Lu_i;  
@@ -565,7 +565,7 @@
 	 */
 #ifdef MEC2_STATS_DETAILED
 	if (ec->HCNTR_d == 0)
-		printk( KERN_INFO "possibily correcting frame with ec->Ly_i %9d ec->Lu_i %9d and expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
+		printk(KERN_INFO "possibily correcting frame with ec->Ly_i %9d ec->Lu_i %9d and expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
 #endif
 
 #ifndef NO_ECHO_SUPPRESSOR
@@ -575,7 +575,7 @@
 			u = u * (ec->Lu_i >> DEFAULT_SIGMA_LU_I) / ((ec->Ly_i >> (DEFAULT_SIGMA_LY_I)) + 1);
 		}
 #ifdef MEC2_STATS_DETAILED
-		printk( KERN_INFO "aggresively correcting frame with ec->Ly_i %9d ec->Lu_i %9d expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
+		printk(KERN_INFO "aggresively correcting frame with ec->Ly_i %9d ec->Lu_i %9d expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
 #endif
 #ifdef MEC2_STATS
 		++ec->cntr_residualcorrected_frames;
@@ -588,7 +588,7 @@
 	  			u = u * (ec->Lu_i >> DEFAULT_SIGMA_LU_I) / ((ec->Ly_i >> (DEFAULT_SIGMA_LY_I + 2)) + 1);
 			}
 #ifdef MEC2_STATS_DETAILED
-			printk( KERN_INFO "correcting frame with ec->Ly_i %9d ec->Lu_i %9d expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
+			printk(KERN_INFO "correcting frame with ec->Ly_i %9d ec->Lu_i %9d expression %d\n", ec->Ly_i, ec->Lu_i, (ec->Ly_i/(ec->Lu_i + 1)));
 #endif
 #ifdef MEC2_STATS
 		  	++ec->cntr_residualcorrected_frames;
@@ -628,7 +628,7 @@
 		else
 			ec->avg_Lu_i_ok = -1;
 
-		printk( KERN_INFO "%d: Near end speech: %5d Residuals corrected/skipped: %5d/%5d Coefficients updated ok/low sig: %3d/%3d Lu_i avg ok/low sig %6d/%5d\n", 
+		printk(KERN_INFO "%d: Near end speech: %5d Residuals corrected/skipped: %5d/%5d Coefficients updated ok/low sig: %3d/%3d Lu_i avg ok/low sig %6d/%5d\n", 
 			ec->id,
 			ec->cntr_nearend_speech_frames, 
 			ec->cntr_residualcorrected_frames, ec->cntr_residualcorrected_framesskipped, 
@@ -650,12 +650,19 @@
 	return u;
 }
 
-static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
-{
-	struct echo_can_state *ec;
+static int echo_can_create(struct zt_echocanparams *ecp, struct zt_echocanparam *p,
+			   struct echo_can_state **ec)
+{
 	int maxy;
 	int maxu;
-	maxy = len + DEFAULT_M;
+	size_t size;
+
+	if (ecp->param_count > 0) {
+		printk(KERN_WARNING "MG2 echo canceler does not support parameters; failing request\n");
+		return -EINVAL;
+	}
+
+	maxy = ecp->tap_length + DEFAULT_M;
 	maxu = DEFAULT_M;
 	if (maxy < (1 << DEFAULT_ALPHA_YT_I))
 		maxy = (1 << DEFAULT_ALPHA_YT_I);
@@ -663,30 +670,23 @@
 		maxy = (1 << DEFAULT_SIGMA_LY_I);
 	if (maxu < (1 << DEFAULT_SIGMA_LU_I))
 		maxu = (1 << DEFAULT_SIGMA_LU_I);
-	ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) +
-									4 + 						/* align */
-									sizeof(int) * len +			/* a_i */
-									sizeof(short) * len + 		/* a_s */
-									sizeof(int) * len +		/* b_i */
-									sizeof(int) * len +		/* c_i */
-									2 * sizeof(short) * (maxy) +	/* y_s */
-									2 * sizeof(short) * (1 << DEFAULT_ALPHA_ST_I) + /* s_s */
-									2 * sizeof(short) * (maxu) +		/* u_s */
-									2 * sizeof(short) * len);			/* y_tilde_s */
-	if (ec) {
-		memset(ec, 0, sizeof(struct echo_can_state) +
-									4 + 						/* align */
-									sizeof(int) * len +			/* a_i */
-									sizeof(short) * len + 		/* a_s */
-									sizeof(int) * len +		/* b_i */
-									sizeof(int) * len +		/* c_i */
-									2 * sizeof(short) * (maxy) +	/* y_s */
-									2 * sizeof(short) * (1 << DEFAULT_ALPHA_ST_I) + /* s_s */
-									2 * sizeof(short) * (maxu) +		/* u_s */
-									2 * sizeof(short) * len);			/* y_tilde_s */
-		init_cc(ec, len, maxy, maxu);
-	}
-	return ec;
+	size = sizeof(**ec) +
+		4 + 						/* align */
+		sizeof(int) * ecp->tap_length +			/* a_i */
+		sizeof(short) * ecp->tap_length + 		/* a_s */
+		sizeof(int) * ecp->tap_length +			/* b_i */
+		sizeof(int) * ecp->tap_length +			/* c_i */
+		2 * sizeof(short) * (maxy) +			/* y_s */
+		2 * sizeof(short) * (1 << DEFAULT_ALPHA_ST_I) + /* s_s */
+		2 * sizeof(short) * (maxu) +			/* u_s */
+		2 * sizeof(short) * ecp->tap_length;		/* y_tilde_s */
+
+	if (!(*ec = MALLOC(size)))
+		return -ENOMEM;
+
+	memset(*ec, 0, size);
+
+	return 0;
 }
 
 static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)

Modified: team/kpfleming/echocanparams/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/echocanparams/zaptel-base.c?view=diff&rev=3521&r1=3520&r2=3521
==============================================================================
--- team/kpfleming/echocanparams/zaptel-base.c (original)
+++ team/kpfleming/echocanparams/zaptel-base.c Tue Dec 18 13:14:59 2007
@@ -4308,14 +4308,17 @@
 }
 #endif
 
+#define MAX_ECHOCANPARAMS 8
+
 static int ioctl_echocancel(struct zt_chan *chan, struct zt_echocanparams *ecp, void *data)
 {
 	struct echo_can_state *ec, *tec;
+	struct zt_echocanparam params[MAX_ECHOCANPARAMS];
 	int ret;
 	unsigned long flags;
 
-	if (ecp->param_count > 8)
-		return -EINVAL;
+	if (ecp->param_count > MAX_ECHOCANPARAMS)
+		return -E2BIG;
 
 	if (ecp->tap_length == 0) {
 		/* disable mode, don't need to inspect params */
@@ -4342,9 +4345,8 @@
 		return -EINVAL;
 	
 	/* enable mode, need the params */
-	struct zt_echocanparam params[ecp->param_count];
 	
-	if (copy_from_user(params, (struct zt_echocanparam *) data, sizeof(params)))
+	if (copy_from_user(params, (struct zt_echocanparam *) data, sizeof(params[0]) * ecp->param_count))
 		return -EFAULT;
 	
 	spin_lock_irqsave(&chan->lock, flags);
@@ -4372,10 +4374,10 @@
 			ecp->tap_length = deftaps;
 		}
 		
-		if (!(ec = echo_can_create(ecp, params))) {
+		if ((ret = echo_can_create(ecp, params, &ec))) {
 			if (tec)
 				echo_can_free(tec);
-			return -ENOMEM;
+			return ret;
 		}
 		
 		spin_lock_irqsave(&chan->lock, flags);
@@ -4388,6 +4390,7 @@
 		echo_can_disable_detector_init(&chan->rxecdis);
 		spin_unlock_irqrestore(&chan->lock, flags);
 	}
+
 	if (tec)
 		echo_can_free(tec);
 

Modified: team/kpfleming/echocanparams/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/kpfleming/echocanparams/zaptel.h?view=diff&rev=3521&r1=3520&r2=3521
==============================================================================
--- team/kpfleming/echocanparams/zaptel.h (original)
+++ team/kpfleming/echocanparams/zaptel.h Tue Dec 18 13:14:59 2007
@@ -1183,7 +1183,7 @@
 void echo_can_init(void);
 void echo_chan_shutdown(void);
 void echo_can_identify(char *buf, size_t len);
-struct echo_can_state *echo_can_create(struct zt_echocanparams *ecp, struct zt_echocanparam *p);
+int echo_can_create(struct zt_echocanparams *ecp, struct zt_echocanparam *p, struct echo_can_state **ec);
 void echo_can_free(struct echo_can_state *ec);
 short echo_can_update(struct echo_can_state *ec, short iref, short isig);
 void echo_can_array_update(struct echo_can_state *ec, short *iref, short *isig);




More information about the svn-commits mailing list