[svn-commits] mattf: branch 1.4 r3754 - /branches/1.4/wctdm24xxp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jan 28 15:10:47 CST 2008


Author: mattf
Date: Mon Jan 28 15:10:46 2008
New Revision: 3754

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3754
Log:
Allow echo canceller parameters to be updated dynamically

Modified:
    branches/1.4/wctdm24xxp/base.c

Modified: branches/1.4/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/base.c?view=diff&rev=3754&r1=3753&r2=3754
==============================================================================
--- branches/1.4/wctdm24xxp/base.c (original)
+++ branches/1.4/wctdm24xxp/base.c Mon Jan 28 15:10:46 2008
@@ -286,8 +286,19 @@
 static int vpmdtmfsupport = 0;
 #define VPM_DEFAULT_DTMFTHRESHOLD 1250
 static int dtmfthreshold = VPM_DEFAULT_DTMFTHRESHOLD;
+/*
+ * This parameter is used to adjust the NLP type used.  The options are:
+ * 0 : None
+ * 1 : Mute
+ * 2 : Random Noise
+ * 3 : Hoth Noise
+ * 4 : Suppression NLP - In order to use this, you must set the vpmnlpmaxsupp parameter to
+ * 	some value in order to give the amount of dB to suppress to the suppressor
+ */
 static int vpmnlptype = 1;
+/* This is the threshold (in dB) for enabling and disabling of the NLP */
 static int vpmnlpthresh = 24;
+/* See vpmnlptype = 4 for more info */
 static int vpmnlpmaxsupp = 0;
 #endif
 
@@ -1581,17 +1592,17 @@
 		return 0;
 #ifdef VPM150M_SUPPORT
 	} else if (wc->vpm150m) {
-		struct adt_lec_params params;
 		struct vpm150m *vpm150m = wc->vpm150m;
 		unsigned int ret;
-
-		adt_lec_init_defaults(&params, 32);
-
-		if ((ret = adt_lec_parse_params(&params, ecp, p)))
+		int channo = chan->chanpos - 1;
+
+		if ((ret = adt_lec_parse_params(&vpm150m->desiredecstate[channo], ecp, p)))
 			return ret;
 
-		vpm150m->desiredecstate[chan->chanpos - 1] = params;
-		if (test_bit(VPM150M_ACTIVE, &vpm150m->control))
+		vpm150m->desiredecstate[channo].tap_length = ecp->tap_length;
+
+		if (memcmp(&vpm150m->curecstate[channo], &vpm150m->desiredecstate[channo], sizeof(vpm150m->curecstate[channo]))
+				&& test_bit(VPM150M_ACTIVE, &vpm150m->control))
 			queue_work(vpm150m->wq, &vpm150m->work);
 
 		return 0;
@@ -3299,6 +3310,68 @@
 
 #ifdef VPM150M_SUPPORT
 
+void vpm150m_set_chanconfig_from_state(struct adt_lec_params * parms, int channum, GpakChannelConfig_t *chanconfig)
+{
+	chanconfig->PcmInPortA = 3;
+	chanconfig->PcmInSlotA = channum;
+	chanconfig->PcmOutPortA = SerialPortNull;
+	chanconfig->PcmOutSlotA = channum;
+	chanconfig->PcmInPortB = 2;
+	chanconfig->PcmInSlotB = channum;
+	chanconfig->PcmOutPortB = 3;
+	chanconfig->PcmOutSlotB = channum;
+	if (vpmdtmfsupport) {
+		chanconfig->ToneTypesA = DTMF_tone;
+		chanconfig->MuteToneA = Enabled;
+		chanconfig->FaxCngDetA = Enabled;
+	} else {
+		chanconfig->ToneTypesA = Null_tone;
+		chanconfig->MuteToneA = Disabled;
+		chanconfig->FaxCngDetA = Disabled;
+	}
+	chanconfig->ToneTypesB = Null_tone;
+	chanconfig->EcanEnableA = Enabled;
+	chanconfig->EcanEnableB = Disabled;
+	chanconfig->MuteToneB = Disabled;
+	chanconfig->FaxCngDetB = Disabled;
+
+	if (alawoverride)
+		chanconfig->SoftwareCompand = cmpPCMA;
+	else
+		chanconfig->SoftwareCompand = cmpPCMU;
+
+	chanconfig->FrameRate = rate2ms;
+	chanconfig->EcanParametersA.EcanTapLength = 1024;
+	chanconfig->EcanParametersA.EcanNlpType = parms->nlp_type;
+	chanconfig->EcanParametersA.EcanAdaptEnable = 1;
+	chanconfig->EcanParametersA.EcanG165DetEnable = 1;
+	chanconfig->EcanParametersA.EcanDblTalkThresh = 6;
+	chanconfig->EcanParametersA.EcanNlpThreshold = parms->nlp_threshold;
+	chanconfig->EcanParametersA.EcanNlpConv = 0;
+	chanconfig->EcanParametersA.EcanNlpUnConv = 0;
+	chanconfig->EcanParametersA.EcanNlpMaxSuppress = parms->nlp_max_suppress;
+	chanconfig->EcanParametersA.EcanCngThreshold = 43;
+	chanconfig->EcanParametersA.EcanAdaptLimit = 50;
+	chanconfig->EcanParametersA.EcanCrossCorrLimit = 15;
+	chanconfig->EcanParametersA.EcanNumFirSegments = 3;
+	chanconfig->EcanParametersA.EcanFirSegmentLen = 64;
+
+	chanconfig->EcanParametersB.EcanTapLength = 1024;
+	chanconfig->EcanParametersB.EcanNlpType = parms->nlp_type;
+	chanconfig->EcanParametersB.EcanAdaptEnable = 1;
+	chanconfig->EcanParametersB.EcanG165DetEnable = 1;
+	chanconfig->EcanParametersB.EcanDblTalkThresh = 6;
+	chanconfig->EcanParametersB.EcanNlpThreshold = parms->nlp_threshold;
+	chanconfig->EcanParametersB.EcanNlpConv = 0;
+	chanconfig->EcanParametersB.EcanNlpUnConv = 0;
+	chanconfig->EcanParametersB.EcanNlpMaxSuppress = parms->nlp_max_suppress;
+	chanconfig->EcanParametersB.EcanCngThreshold = 43;
+	chanconfig->EcanParametersB.EcanAdaptLimit = 50;
+	chanconfig->EcanParametersB.EcanCrossCorrLimit = 15;
+	chanconfig->EcanParametersB.EcanNumFirSegments = 3;
+	chanconfig->EcanParametersB.EcanFirSegmentLen = 64;
+}
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
 static void vpm150m_bh(void *data)
 {
@@ -3346,17 +3419,13 @@
 		GpakAsyncEventCode_t eventcode;
 		GpakAsyncEventData_t eventdata;
 		gpakReadEventFIFOMessageStat_t  res;
-#if 1
 		unsigned int start = wc->intcount;
-#endif
 
 		do {
 			res = gpakReadEventFIFOMessage(vpm150m->dspid, &channel, &eventcode, &eventdata);
 
-#if 1
 			if (debug & DEBUG_ECHOCAN)
 				printk("ReadEventFIFOMessage took %d ms\n", wc->intcount - start);
-#endif
 
 			if (res == RefInvalidEvent || res == RefDspCommFailure) {
 				printk("Uh oh (%d)\n", res);
@@ -3409,27 +3478,52 @@
 	for (i = 0; i < wc->type; i++) {
 		unsigned int start = wc->intcount;
 		GPAK_AlgControlStat_t pstatus;
-		int res;
-
-		if (!memcmp(&vpm150m->curecstate[i], &vpm150m->desiredecstate[i], sizeof(vpm150m->curecstate)))
-			continue;
-
-		if (vpm150m->desiredecstate[i].tap_length) {
-			res = gpakAlgControl(vpm150m->dspid, i, EnableEcanA, &pstatus);
+		int res = 1;
+
+		if ((vpm150m->desiredecstate[i].nlp_type != vpm150m->curecstate[i].nlp_type)
+			|| (vpm150m->desiredecstate[i].nlp_threshold != vpm150m->curecstate[i].nlp_threshold)
+			|| (vpm150m->desiredecstate[i].nlp_max_suppress != vpm150m->curecstate[i].nlp_max_suppress)) {
+
+			GPAK_ChannelConfigStat_t cstatus;
+			GPAK_TearDownChanStat_t tstatus;
+			GpakChannelConfig_t chanconfig;
+
 			if (debug & DEBUG_ECHOCAN)
-				printk("Echocan enable took %d ms\n", wc->intcount - start);
-		} else {
-			res = gpakAlgControl(vpm150m->dspid, i, BypassEcanA, &pstatus);
-			if (debug & DEBUG_ECHOCAN)
-				printk("Echocan disable took %d ms\n", wc->intcount - start);
-		}
+				printk("Reconfiguring chan %d for nlp %d, nlp_thresh %d, and max_supp %d\n", i + 1, vpm150m->desiredecstate[i].nlp_type,
+					vpm150m->desiredecstate[i].nlp_threshold, vpm150m->desiredecstate[i].nlp_max_suppress);
+
+			vpm150m_set_chanconfig_from_state(&vpm150m->desiredecstate[i], i, &chanconfig);
+
+			if ((res = gpakTearDownChannel(vpm150m->dspid, i, &tstatus))) {
+				goto vpm_bh_out;
+			}
+
+			if ((res = gpakConfigureChannel(vpm150m->dspid, i, tdmToTdm, &chanconfig, &cstatus))) {
+				goto vpm_bh_out;
+			}
+
+			if (!vpm150m->desiredecstate[i].tap_length)
+				res = gpakAlgControl(vpm150m->dspid, i, BypassEcanA, &pstatus);
+
+		} else if (vpm150m->desiredecstate[i].tap_length != vpm150m->curecstate[i].tap_length) {
+			if (vpm150m->desiredecstate[i].tap_length) {
+				res = gpakAlgControl(vpm150m->dspid, i, EnableEcanA, &pstatus);
+				if (debug & DEBUG_ECHOCAN)
+					printk("Echocan enable took %d ms\n", wc->intcount - start);
+			} else {
+				if (debug & DEBUG_ECHOCAN)
+					printk("Echocan disable took %d ms\n", wc->intcount - start);
+			}
+		}
+
+vpm_bh_out:
 		if (!res)
 			vpm150m->curecstate[i] = vpm150m->desiredecstate[i];
 	}
 			
 	return;
 }
-
+	
 static int vpm150m_config_hw(struct wctdm *wc)
 {
 	struct vpm150m *vpm150m = wc->vpm150m;
@@ -3524,66 +3618,17 @@
 	}
 
 	for (i = 0; i < wc->type; i++) {
-		/* Let's configure a channel */
-		chanconfig.PcmInPortA = 3;
-		chanconfig.PcmInSlotA = i;
-		chanconfig.PcmOutPortA = SerialPortNull;
-		chanconfig.PcmOutSlotA = i;
-		chanconfig.PcmInPortB = 2;
-		chanconfig.PcmInSlotB = i;
-		chanconfig.PcmOutPortB = 3;
-		chanconfig.PcmOutSlotB = i;
-		if (vpmdtmfsupport) {
-			chanconfig.ToneTypesA = DTMF_tone;
-			chanconfig.MuteToneA = Enabled;
-			chanconfig.FaxCngDetA = Enabled;
-		} else {
-			chanconfig.ToneTypesA = Null_tone;
-			chanconfig.MuteToneA = Disabled;
-			chanconfig.FaxCngDetA = Disabled;
-		}
-		chanconfig.ToneTypesB = Null_tone;
-		chanconfig.EcanEnableA = Enabled;
-		chanconfig.EcanEnableB = Disabled;
-		chanconfig.MuteToneB = Disabled;
-		chanconfig.FaxCngDetB = Disabled;
-
-		if (alawoverride)
-			chanconfig.SoftwareCompand = cmpPCMA;
-		else
-			chanconfig.SoftwareCompand = cmpPCMU;
-
-		chanconfig.FrameRate = rate2ms;
-	
-		chanconfig.EcanParametersA.EcanTapLength = 1024;
-		chanconfig.EcanParametersA.EcanNlpType = vpmnlptype;
-		chanconfig.EcanParametersA.EcanAdaptEnable = 1;
-		chanconfig.EcanParametersA.EcanG165DetEnable = 1;
-		chanconfig.EcanParametersA.EcanDblTalkThresh = 6;
-		chanconfig.EcanParametersA.EcanNlpThreshold = vpmnlpthresh;
-		chanconfig.EcanParametersA.EcanNlpConv = 0;
-		chanconfig.EcanParametersA.EcanNlpUnConv = 0;
-		chanconfig.EcanParametersA.EcanNlpMaxSuppress = vpmnlpmaxsupp;
-		chanconfig.EcanParametersA.EcanCngThreshold = 43;
-		chanconfig.EcanParametersA.EcanAdaptLimit = 50;
-		chanconfig.EcanParametersA.EcanCrossCorrLimit = 15;
-		chanconfig.EcanParametersA.EcanNumFirSegments = 3;
-		chanconfig.EcanParametersA.EcanFirSegmentLen = 64;
-	
-		chanconfig.EcanParametersB.EcanTapLength = 1024;
-		chanconfig.EcanParametersB.EcanNlpType = vpmnlptype;
-		chanconfig.EcanParametersB.EcanAdaptEnable = 1;
-		chanconfig.EcanParametersB.EcanG165DetEnable = 1;
-		chanconfig.EcanParametersB.EcanDblTalkThresh = 6;
-		chanconfig.EcanParametersB.EcanNlpThreshold = vpmnlpthresh;
-		chanconfig.EcanParametersB.EcanNlpConv = 0;
-		chanconfig.EcanParametersB.EcanNlpUnConv = 0;
-		chanconfig.EcanParametersB.EcanNlpMaxSuppress = vpmnlpmaxsupp;
-		chanconfig.EcanParametersB.EcanCngThreshold = 43;
-		chanconfig.EcanParametersB.EcanAdaptLimit = 50;
-		chanconfig.EcanParametersB.EcanCrossCorrLimit = 15;
-		chanconfig.EcanParametersB.EcanNumFirSegments = 3;
-		chanconfig.EcanParametersB.EcanFirSegmentLen = 64;
+		vpm150m->curecstate[i].tap_length = 0;
+		vpm150m->curecstate[i].nlp_type = vpmnlptype;
+		vpm150m->curecstate[i].nlp_threshold = vpmnlpthresh;
+		vpm150m->curecstate[i].nlp_max_suppress = vpmnlpmaxsupp;
+	
+		vpm150m->desiredecstate[i].tap_length = 0;
+		vpm150m->desiredecstate[i].nlp_type = vpmnlptype;
+		vpm150m->desiredecstate[i].nlp_threshold = vpmnlpthresh;
+		vpm150m->desiredecstate[i].nlp_max_suppress = vpmnlpmaxsupp;
+	
+		vpm150m_set_chanconfig_from_state(&vpm150m->curecstate[i], i, &chanconfig);
 	
 		if ((res = gpakConfigureChannel(vpm150m->dspid, i, tdmToTdm, &chanconfig, &cstatus))) {
 			printk("Unable to configure channel (%d)\n", res);




More information about the svn-commits mailing list