[zaptel-commits] kpfleming: branch 1.4 r3649 - in /branches/1.4: ./ wcte12xp/

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Jan 10 17:15:29 CST 2008


Author: kpfleming
Date: Thu Jan 10 17:15:28 2008
New Revision: 3649

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3649
Log:
add some code to parse parameters for ADT-based echo cancelers, and update the wcte12xp driver to be able to push the parameters all the way down to the DSP initialization function (actually pushing them out to the DSP will come later)

Added:
    branches/1.4/adt_lec.c   (with props)
    branches/1.4/adt_lec.h   (with props)
Modified:
    branches/1.4/wcte12xp/base.c
    branches/1.4/wcte12xp/vpmadt032.c
    branches/1.4/wcte12xp/vpmadt032.h

Added: branches/1.4/adt_lec.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/adt_lec.c?view=auto&rev=3649
==============================================================================
--- branches/1.4/adt_lec.c (added)
+++ branches/1.4/adt_lec.c Thu Jan 10 17:15:28 2008
@@ -1,0 +1,63 @@
+/*
+ * ADT Line Echo Canceller Parameter Parsing
+ *
+ * Copyright (C) 2008 Digium, Inc.
+ *
+ * Kevin P. Fleming <kpfleming at digium.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
+ */
+
+#ifndef _ADT_LEC_C
+#define _ADT_LEC_C
+
+static inline void adt_lec_init_defaults(struct adt_lec_params *params, __u32 tap_length)
+{
+	memset(params, 0, sizeof(*params));
+	params->tap_length = tap_length;
+}
+
+static int adt_lec_parse_params(struct adt_lec_params *params, struct zt_echocanparams *ecp, struct zt_echocanparam *p)
+{
+	unsigned int x;
+
+	for (x = 0; x < ecp->param_count; x++) {
+		if (!strcasecmp(p[x].name, "nlp_type")) {
+			switch (p[x].value) {
+			case ADT_LEC_NLP_OFF:
+			case ADT_LEC_NLP_MUTE:
+			case ADT_LEC_RANDOM_NOISE:
+			case ADT_LEC_HOTH_NOISE:
+			case ADT_LEC_SUPPRESS:
+				params->nlp_type = p[x].value;
+				break;
+			default:
+				return -EINVAL;
+			}
+		} else if (!strcasecmp(p[x].name, "nlp_thresh")) {
+			params->nlp_threshold = p[x].value;
+		} else if (!strcasecmp(p[x].name, "nlp_suppress")) {
+			params->nlp_max_suppress = p[x].value;
+		} else {
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+#endif /* _ADT_LEC_C */

Propchange: branches/1.4/adt_lec.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/1.4/adt_lec.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: branches/1.4/adt_lec.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: branches/1.4/adt_lec.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/adt_lec.h?view=auto&rev=3649
==============================================================================
--- branches/1.4/adt_lec.h (added)
+++ branches/1.4/adt_lec.h Thu Jan 10 17:15:28 2008
@@ -1,0 +1,43 @@
+/*
+ * ADT Line Echo Canceller Parameter Parsing
+ *
+ * Copyright (C) 2008 Digium, Inc.
+ *
+ * Kevin P. Fleming <kpfleming at digium.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
+ */
+
+#ifndef _ADT_LEC_H
+#define _ADT_LEC_H
+
+enum adt_lec_nlp_type {
+	ADT_LEC_NLP_OFF = 0,
+	ADT_LEC_NLP_MUTE,
+	ADT_LEC_RANDOM_NOISE,
+	ADT_LEC_HOTH_NOISE,
+	ADT_LEC_SUPPRESS,
+};
+
+struct adt_lec_params {
+	__u32 tap_length;
+	enum adt_lec_nlp_type nlp_type;
+	__u32 nlp_threshold;
+	__u32 nlp_max_suppress;
+};
+
+#endif /* _ADT_LEC_H */

Propchange: branches/1.4/adt_lec.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/1.4/adt_lec.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: branches/1.4/adt_lec.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: branches/1.4/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/base.c?view=diff&rev=3649&r1=3648&r2=3649
==============================================================================
--- branches/1.4/wcte12xp/base.c (original)
+++ branches/1.4/wcte12xp/base.c Thu Jan 10 17:15:28 2008
@@ -1286,32 +1286,43 @@
 }
 
 #ifdef VPM_SUPPORT
-static int t1xxp_echocan(struct zt_chan *chan, int eclen)
-{
+
+#include "adt_lec.c"
+
+static int t1xxp_echocan_with_params(struct zt_chan *chan, struct zt_echocanparams *ecp, struct zt_echocanparam *p)
+{
+	struct adt_lec_params params;
 	struct t1 *wc = chan->pvt;
-	if (wc->vpm150m) {
-		struct vpm150m *vpm150m = wc->vpm150m;
-		unsigned int flags;
-
-		/* add this to our list of work to do */
-		struct vpm150m_workentry *work;
-		work = kmalloc(sizeof(*work), GFP_ATOMIC); 
-		if(!work)
-			return -ENODEV;
-		work->eclen = eclen;
-		work->wc = wc;
-		work->chan = chan; 
-		spin_lock_irqsave(&vpm150m->lock, flags);
-		list_add_tail(&work->list, &vpm150m->worklist);
-		spin_unlock_irqrestore(&vpm150m->lock, flags);
-
-		/* we must do this later since we cannot sleep in the echocan function */
-		if (test_bit(VPM150M_ACTIVE, &vpm150m->control))
-			queue_work(vpm150m->wq, &vpm150m->work_echocan);
-		return 0; /* how do I return the status since it is done later by the workqueue? */
-	} else
-		return -ENODEV; 
-
+	struct vpm150m *vpm150m = wc->vpm150m;
+	unsigned int flags;
+	struct vpm150m_workentry *work;
+	unsigned int ret;
+
+	if (!wc->vpm150m)
+		return -ENODEV;
+
+	adt_lec_init_defaults(&params, 32);
+
+	if ((ret = adt_lec_parse_params(&params, ecp, p)))
+		return ret;
+
+	work = kmalloc(sizeof(*work), GFP_ATOMIC); 
+	if(!work)
+		return -ENODEV;
+	work->params = params;
+	/* we can't really control the tap length, but the value is used
+	   to control whether the ec is on or off, so translate it */
+	work->params.tap_length = ecp->tap_length ? 1 : 0;
+	work->wc = wc;
+	work->chan = chan; 
+	spin_lock_irqsave(&vpm150m->lock, flags);
+	list_add_tail(&work->list, &vpm150m->worklist);
+	spin_unlock_irqrestore(&vpm150m->lock, flags);
+	
+	/* we must do this later since we cannot sleep in the echocan function */
+	if (test_bit(VPM150M_ACTIVE, &vpm150m->control))
+		queue_work(vpm150m->wq, &vpm150m->work_echocan);
+	return 0; /* how do I return the status since it is done later by the workqueue? */
 }
 #endif
 
@@ -1353,7 +1364,7 @@
 	wc->span.close = t1xxp_close;
 	wc->span.ioctl = t1xxp_ioctl;
 #ifdef VPM_SUPPORT
-	wc->span.echocan = t1xxp_echocan;
+	wc->span.echocan_with_params = t1xxp_echocan_with_params;
 #endif
 
 	if (wc->spantype == TYPE_E1) {

Modified: branches/1.4/wcte12xp/vpmadt032.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/vpmadt032.c?view=diff&rev=3649&r1=3648&r2=3649
==============================================================================
--- branches/1.4/wcte12xp/vpmadt032.c (original)
+++ branches/1.4/wcte12xp/vpmadt032.c Thu Jan 10 17:15:28 2008
@@ -506,12 +506,17 @@
 		int res;
 		GPAK_AlgControlStat_t pstatus;
 
-		if (we->eclen) {
+		if (we->params.tap_length) {
 			/* configure channel for the ulaw/alaw */
 			unsigned int start = wc->intcount;
 
+			if (memcmp(&we->params, &vpm150m->chan_params[chan->chanpos - 1], sizeof(we->params))) {
+				/* set parameters */
+				vpm150m->chan_params[chan->chanpos - 1] = we->params;
+			}
+
 			deflaw = chan->span->deflaw;
-			debug_printk(1, "Enabling EC on channel %d (law %d and eclen %d)\n", chan->chanpos, deflaw, we->eclen);
+			debug_printk(1, "Enabling EC on channel %d (law %d)\n", chan->chanpos, deflaw);
 			if (deflaw == 2) /* alaw */
 				res = gpakAlgControl(vpm150m->dspid, chan->chanpos - 1, EnableALawSwCompanding, &pstatus);
 			else if (deflaw == 1) /* alaw */

Modified: branches/1.4/wcte12xp/vpmadt032.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/vpmadt032.h?view=diff&rev=3649&r1=3648&r2=3649
==============================================================================
--- branches/1.4/wcte12xp/vpmadt032.h (original)
+++ branches/1.4/wcte12xp/vpmadt032.h Thu Jan 10 17:15:28 2008
@@ -32,6 +32,7 @@
 #define _VPM150M_H
 
 #include "wcte12xp.h"
+#include "adt_lec.h"
 
 struct t1_firmware {
 	const struct firmware *fw;
@@ -96,6 +97,7 @@
 	unsigned char curtone[32];
 	unsigned long curdtmfmutestate;
 	unsigned long desireddtmfmutestate;
+	struct adt_lec_params chan_params[32];
 	struct t1 *wc;
 };
 
@@ -104,7 +106,7 @@
 	struct list_head list;
 	struct t1 *wc; /* what card are we dealing with? */
 	struct zt_chan *chan; /* what channels are we going to deal with? */
-	int eclen; /* how should we behave? */
+	struct adt_lec_params params; /* how should we behave? */
 };
 
 extern int debug;




More information about the zaptel-commits mailing list