[svn-commits] mattf: branch mattf/zaptel-1.4-stackcleanup r4220 - in /team/mattf/zaptel-1.4...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 2 12:28:16 CDT 2008


Author: mattf
Date: Fri May  2 12:28:15 2008
New Revision: 4220

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4220
Log:
Merged revisions 4165-4170,4173,4175-4176,4183-4185,4187,4190-4196,4213,4217 via svnmerge from 
https://origsvn.digium.com/svn/zaptel/branches/1.4

........
r4165 | tzafrir | 2008-04-10 11:15:23 -0500 (Thu, 10 Apr 2008) | 5 lines

Officially bumping xpp version (xpp/.version) to 5566 .

Merged revisions 4164 via svnmerge from 
http://svn.digium.com/svn/zaptel/branches/1.2

........
r4166 | tzafrir | 2008-04-10 13:11:51 -0500 (Thu, 10 Apr 2008) | 2 lines

zaptel_svn_tarball - get a tarball fron an SVN snapshot.

........
r4167 | sruffell | 2008-04-10 16:01:59 -0500 (Thu, 10 Apr 2008) | 2 lines

Fixed typo in makefile which was preventing make from installing the udev rules.

........
r4168 | dbailey | 2008-04-10 17:25:30 -0500 (Thu, 10 Apr 2008) | 3 lines

Correct problem where drivers implementing echocan_with_params was not getting called
to disable the echo canceller

........
r4169 | mattf | 2008-04-11 16:16:47 -0500 (Fri, 11 Apr 2008) | 1 line

Make sure that we disable the echo canceller on the old style echocan() function even if parameters are passed in.
........
r4170 | mattf | 2008-04-11 16:17:55 -0500 (Fri, 11 Apr 2008) | 1 line

Take out part of a commit to the wct4xxp driver that wasn't supposed to go in
........
r4173 | kpfleming | 2008-04-17 07:20:26 -0500 (Thu, 17 Apr 2008) | 6 lines

when processing ZT_SET_DIALPARAMS, don't return an error for out-of-range tone durations, just ignore them (so that applications that don't initialize the entire zt_dialparams structure won't fail to set the ones they do initialize)

(closes issue #12456)
Reported by: fnordian
Tested by: fnordian

........
r4175 | tzafrir | 2008-04-17 09:27:50 -0500 (Thu, 17 Apr 2008) | 5 lines

Avoid a double-free in ztdynamic.c ztdynamic_chanfree.diff from bug #12406 .

Merged revisions 4174 via svnmerge from 
http://svn.digium.com/svn/zaptel/branches/1.2

........
r4176 | jdixon | 2008-04-18 10:19:00 -0500 (Fri, 18 Apr 2008) | 2 lines

Fixed monitoring of zap pseudo channels

........
r4183 | mattf | 2008-04-19 16:54:03 -0500 (Sat, 19 Apr 2008) | 1 line

Partial fix for #9379.  Fixes potential race condition in open and close routines for zaptel devices
........
r4184 | mattf | 2008-04-19 16:56:06 -0500 (Sat, 19 Apr 2008) | 1 line

Remove unintentional svn property addition
........
r4185 | mattf | 2008-04-19 17:05:42 -0500 (Sat, 19 Apr 2008) | 1 line

Fix compiler from complaining
........
r4187 | tzafrir | 2008-04-21 16:27:59 -0500 (Mon, 21 Apr 2008) | 4 lines

Zaptel::Config::Default - don't die if no config file.

(Accidentally left out of the merge from 1.2)

........
r4190 | jdixon | 2008-04-22 17:07:08 -0500 (Tue, 22 Apr 2008) | 2 lines

Fixed problem preventing multiple channels from using multiple CTCSS

........
r4191 | jdixon | 2008-04-22 23:36:22 -0500 (Tue, 22 Apr 2008) | 2 lines

Updated to latest code, fixed bug in serial i/o

........
r4192 | tzafrir | 2008-04-23 04:48:56 -0500 (Wed, 23 Apr 2008) | 2 lines

Bumped into yet another incompatibility.

........
r4193 | tzafrir | 2008-04-23 14:20:53 -0500 (Wed, 23 Apr 2008) | 10 lines

A test for a specific #define in zconfig.h was done by invoking cpp .
Sadly the change of CFLAGS handling in kernel 2.6.24 meant that it is no
longer as easy to invoke cpp on our own. 

Impact: On kernel >= 2.6.24, xpd_bri never got built, even if the
bri_dchan patch was applied.

Fix: use a simpler grep instead. Hopefully noone passes it through other
means. This should hopfully fix issue #12426 .

........
r4194 | sruffell | 2008-04-24 13:17:12 -0500 (Thu, 24 Apr 2008) | 5 lines

Fixes a regression in versions 1.2.25 and 1.4.19 identified by korihor where
the wctdm driver was no longer properly recognizing polarity reversals.

(closes issue #12419)

........
r4195 | qwell | 2008-04-25 13:10:06 -0500 (Fri, 25 Apr 2008) | 1 line

Based on a comment made by moy in #asterisk-dev, and the surrounding code in these functions, I believe that this is what was actually intended in r4130.
........
r4196 | qwell | 2008-04-25 15:47:07 -0500 (Fri, 25 Apr 2008) | 7 lines

Since MF R2 tones are generated continuously, we need to not set the dialing status.

(closes issue #12526)
Reported by: moy
Patches:
      zaptel-mf-dialing-rev4195.patch uploaded by moy (license 222)

........
r4213 | twilson | 2008-05-01 11:46:44 -0500 (Thu, 01 May 2008) | 2 lines

Allow $(ARCH) to be overridden and pass on through $(KMAKE)

........
r4217 | qwell | 2008-05-01 14:37:07 -0500 (Thu, 01 May 2008) | 7 lines

Clarify a message.  Some hardware doesn't provide timing, so this could be confusing.

(closes issue #12459)
Reported by: panderson
Patches:
      zaptel.init.patch uploaded by panderson (license 469)

........

Added:
    team/mattf/zaptel-1.4-stackcleanup/build_tools/zaptel_svn_tarball
      - copied unchanged from r4217, branches/1.4/build_tools/zaptel_svn_tarball
Modified:
    team/mattf/zaptel-1.4-stackcleanup/   (props changed)
    team/mattf/zaptel-1.4-stackcleanup/Makefile
    team/mattf/zaptel-1.4-stackcleanup/README
    team/mattf/zaptel-1.4-stackcleanup/kernel/pciradio.c
    team/mattf/zaptel-1.4-stackcleanup/kernel/wctdm.c
    team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/.version
    team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/Kbuild
    team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm
    team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c
    team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel.h
    team/mattf/zaptel-1.4-stackcleanup/kernel/ztdynamic.c
    team/mattf/zaptel-1.4-stackcleanup/zaptel.init
    team/mattf/zaptel-1.4-stackcleanup/ztcfg.c

Propchange: team/mattf/zaptel-1.4-stackcleanup/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/mattf/zaptel-1.4-stackcleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May  2 12:28:15 2008
@@ -1,1 +1,1 @@
-/branches/1.4:1-4150
+/branches/1.4:1-4219

Modified: team/mattf/zaptel-1.4-stackcleanup/Makefile
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/Makefile?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/Makefile (original)
+++ team/mattf/zaptel-1.4-stackcleanup/Makefile Fri May  2 12:28:15 2008
@@ -18,7 +18,9 @@
 PWD:=$(shell pwd)
 endif
 
+ifeq ($(ARCH),)
 ARCH:=$(shell uname -m | sed -e s/i.86/i386/)
+endif
 
 ifeq ($(DEB_HOST_GNU_TYPE),)
 UNAME_M:=$(shell uname -m)
@@ -190,7 +192,7 @@
   UNAME_M=$(UNAME_M) \
   BUILD_TOPDIR_MODULES="$(BUILD_TOPDIR_MODULES)" BUILD_SUBDIR_MODULES="$(BUILD_SUBDIR_MODULES)"
 else
-KMAKE  = $(MAKE) -C $(KSRC) SUBDIRS=$(PWD)/kernel \
+KMAKE  = $(MAKE) -C $(KSRC) ARCH=$(ARCH) SUBDIRS=$(PWD)/kernel \
   HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) KBUILD_OBJ_M="$(KBUILD_OBJ_M)"
 endif
 KMAKE_INST = $(KMAKE) \
@@ -504,11 +506,11 @@
 		N=$$[$$N+1]; \
 	done
 else # DYNFS
-  ifneq (yes,$(UDEVRULES))
+  ifneq (yes,$(UDEVRULES)) #!UDEVRULES
+	@echo "**** Dynamic filesystem detected -- not creating device nodes"
+  else # UDEVRULES
 	install -d $(DESTDIR)/etc/udev/rules.d
 	build_tools/genudevrules > $(DESTDIR)/etc/udev/rules.d/zaptel.rules
-  else # !UDEVRULES
-	@echo "**** Dynamic filesystem detected -- not creating device nodes"
   endif
 endif
 

Modified: team/mattf/zaptel-1.4-stackcleanup/README
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/README?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/README (original)
+++ team/mattf/zaptel-1.4-stackcleanup/README Fri May  2 12:28:15 2008
@@ -644,8 +644,14 @@
 appear slightly confusing in the code, but it is useful for writing code
 that works with both versions of Zaptel. 
 
+
 Past Incompatibilities
 ^^^^^^^^^^^^^^^^^^^^^^
+
+.Zaptel 1.4.10:
+* Semantics of ZT_LOADZONE. Using newer ztcfg with older modules will
+  yield -EINVAL with the kernel message 'Invalid tone (96) defined'
+
 .Zaptel 1.4.8:
 * ZT_GET_PARAMS_V1
 * ZT_SET_PARAMS_V1

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/pciradio.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/pciradio.c?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/pciradio.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/pciradio.c Fri May  2 12:28:15 2008
@@ -1355,8 +1355,9 @@
 				stack.p.index = rad->rxindex;
 				break;
 			}
-			/* wait for done only if in SERIAL_ASCII mode */
-			if (rad->remmode[chan->chanpos - 1] == ZT_RADPAR_REM_SERIAL_ASCII)
+			/* wait for done if in SERIAL_ASCII mode, or if no Rx aftwards */
+			if ((rad->remmode[chan->chanpos - 1] == ZT_RADPAR_REM_SERIAL_ASCII) ||
+				(!stack.p.data))
 			{			
 				/* wait for TX to be done if not already */
 				while(rad->txlen && (rad->txindex < rad->txlen))

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/wctdm.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/wctdm.c?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/wctdm.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/wctdm.c Fri May  2 12:28:15 2008
@@ -909,18 +909,18 @@
 				fxo->battdebounce = battdebounce / MS_PER_CHECK_HOOK;
 			}
 		}
-
-		if (fxo->lastpol >= 0) {
-			if (b < 0) {
-				fxo->lastpol = -1;
-				fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
-			}
-		} 
-		if (fxo->lastpol <= 0) {
-			if (b > 0) {
-				fxo->lastpol = 1;
-				fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
-			}
+	}
+
+	if (fxo->lastpol >= 0) {
+		if (b < 0) {
+			fxo->lastpol = -1;
+			fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
+		}
+	} 
+	if (fxo->lastpol <= 0) {
+		if (b > 0) {
+			fxo->lastpol = 1;
+			fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
 		}
 	}
 

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/.version
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/.version?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/.version (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/.version Fri May  2 12:28:15 2008
@@ -1,1 +1,1 @@
-trunk-r5512
+trunk-r5566

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/Kbuild
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/Kbuild?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/Kbuild (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/Kbuild Fri May  2 12:28:15 2008
@@ -20,7 +20,7 @@
 
 obj-m		+= xpp.o xpd_fxs.o xpd_fxo.o xpd_pri.o
 
-HAS_BRISTUFF		:= $(shell cpp $(CPPFLAGS) -dM $(ZAP_KERNEL)/zconfig.h | sed -n 's/^.*CONFIG_ZAPATA_BRI_DCHANS/y/p')
+HAS_BRISTUFF	:= $(shell grep '^[[:space:]]*\#[[:space:]]*define[[:space:]]\+CONFIG_ZAPATA_BRI_DCHANS\>' $(ZAP_KERNEL)/zconfig.h)
 
 # Build only supported modules
 ifneq	(,$(filter y m,$(CONFIG_USB)))

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm Fri May  2 12:28:15 2008
@@ -46,7 +46,9 @@
 			}
 		}
 	}
-	die "No default_file" unless $default_file;
+	if (! $default_file) {
+		return ("", ());
+	}
 	my %vars = Zaptel::Config::Defaults::do_source($default_file, @vars);
 	return ($default_file, %vars);
 }

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c Fri May  2 12:28:15 2008
@@ -995,6 +995,22 @@
 }
 
 
+static inline int hw_echocancel_off(struct zt_chan *chan)
+{
+	struct zt_echocanparams ecp;
+	
+	int ret = -ENODEV;
+	if (chan->span) {
+		if (chan->span->echocan) {
+			ret = chan->span->echocan(chan, 0);
+		} else if (chan->span->echocan_with_params) {
+			memset(&ecp, 0, sizeof(ecp));  /* Sets tap length to 0 */
+			ret = chan->span->echocan_with_params(chan, &ecp, NULL);
+		}
+	}
+	return ret;
+}
+
 static void close_channel(struct zt_chan *chan)
 {
 	unsigned long flags;
@@ -1074,8 +1090,7 @@
 
 	spin_unlock_irqrestore(&chan->lock, flags);
 
-	if (chan->span && chan->span->echocan)
-		chan->span->echocan(chan, 0);
+	hw_echocancel_off(chan);
 
 	if (rxgain)
 		kfree(rxgain);
@@ -1199,7 +1214,6 @@
 		}
 	} else if (chan->digitmode == DIGIT_MODE_MFR2_FWD) {
 		if ((tone >= ZT_TONE_MFR2_FWD_BASE) && (tone <= ZT_TONE_MFR2_FWD_MAX)) {
-			chan->dialing = 1;
 			res = 0;
 			tone -= ZT_TONE_MFR2_FWD_BASE;
 			if (chan->curzone) {
@@ -1220,7 +1234,6 @@
 		}
 	} else if (chan->digitmode == DIGIT_MODE_MFR2_REV) {
 		if ((tone >= ZT_TONE_MFR2_REV_BASE) && (tone <= ZT_TONE_MFR2_REV_MAX)) {
-			chan->dialing = 1;
 			res = 0;
 			tone -= ZT_TONE_MFR2_REV_BASE;
 			if (chan->curzone) {
@@ -2376,8 +2389,7 @@
 	spin_unlock_irqrestore(&chan->lock, flags);
 	set_tone_zone(chan, -1);
 
-	if (chan->span && chan->span->echocan)
-		chan->span->echocan(chan, 0);
+	hw_echocancel_off(chan);
 
 	if (rxgain)
 		kfree(rxgain);
@@ -2447,18 +2459,20 @@
 
 	if (chans[unit] && chans[unit]->sig) {
 		/* Make sure we're not already open, a net device, or a slave device */
-		if (chans[unit]->flags & ZT_FLAG_OPEN) 
-			res = -EBUSY;
-		else if (chans[unit]->flags & ZT_FLAG_NETDEV)
+		if (chans[unit]->flags & ZT_FLAG_NETDEV)
 			res = -EBUSY;
 		else if (chans[unit]->master != chans[unit])
 			res = -EBUSY;
 		else if ((chans[unit]->sig & __ZT_SIG_DACS) == __ZT_SIG_DACS)
 			res = -EBUSY;
-		else {
+		else if (!test_and_set_bit(ZT_FLAGBIT_OPEN, &chans[unit]->flags)) {
 			unsigned long flags;
-			/* Assume everything is going to be okay */
 			res = initialize_channel(chans[unit]);
+			if (res) {
+				/* Reallocbufs must have failed */
+				clear_bit(ZT_FLAGBIT_OPEN, &chans[unit]->flags);
+				return res;
+			}
 			spin_lock_irqsave(&chans[unit]->lock, flags);
 			if (chans[unit]->flags & ZT_FLAG_PSEUDO) 
 				chans[unit]->flags |= ZT_FLAG_AUDIO;
@@ -2471,13 +2485,14 @@
 				if (inc)
 					MOD_INC_USE_COUNT;
 #endif					
-				chans[unit]->flags |= ZT_FLAG_OPEN;
 				spin_unlock_irqrestore(&chans[unit]->lock, flags);
 			} else {
 				spin_unlock_irqrestore(&chans[unit]->lock, flags);
 				close_channel(chans[unit]);
-			}
-		}
+				clear_bit(ZT_FLAGBIT_OPEN, &chans[unit]->flags);
+			}
+		} else
+			res = -EBUSY;
 	} else
 		res = -ENXIO;
 	return res;
@@ -2486,15 +2501,18 @@
 static int zt_specchan_release(struct inode *node, struct file *file, int unit)
 {
 	int res=0;
+	unsigned long flags;
+
 	if (chans[unit]) {
-		unsigned long flags;
+		/* Chan lock protects contents against potentially non atomic accesses.
+		 * So if the pointer setting is not atomic, we should protect */
 		spin_lock_irqsave(&chans[unit]->lock, flags);
-		chans[unit]->flags &= ~ZT_FLAG_OPEN;
+		chans[unit]->file = NULL;
 		spin_unlock_irqrestore(&chans[unit]->lock, flags);
-		chans[unit]->file = NULL;
 		close_channel(chans[unit]);
 		if (chans[unit]->span && chans[unit]->span->close)
 			res = chans[unit]->span->close(chans[unit]);
+		clear_bit(ZT_FLAGBIT_OPEN, &chans[unit]->flags);
 	} else
 		res = -ENXIO;
 #ifndef LINUX26
@@ -2981,7 +2999,7 @@
 		case 'C':
 		case 'D':
 		case 'E':
-		case 'O':
+		case 'F':
 			tone_index = ZT_TONE_MFR2_FWD_10 + (digit - 'A');
 			break;
 		case 'W':
@@ -3038,7 +3056,7 @@
 			chan->digitmode = DIGIT_MODE_MFR1;
 			chan->tonep = 0;
 			break;
-		case 'F':
+		case 'O':
 			chan->digitmode = DIGIT_MODE_MFR2_FWD;
 			chan->tonep = 0;
 			break;
@@ -3523,7 +3541,7 @@
 		printk(KERN_INFO "Dump of Zaptel Channel %d (%s,%d,%d):\n\n",j,
 			mychan->name,mychan->channo,mychan->chanpos);
 		printk(KERN_INFO "flags: %x hex, writechunk: %08lx, readchunk: %08lx\n",
-			mychan->flags, (long) mychan->writechunk, (long) mychan->readchunk);
+			(unsigned int) mychan->flags, (long) mychan->writechunk, (long) mychan->readchunk);
 		printk(KERN_INFO "rxgain: %08lx, txgain: %08lx, gainalloc: %d\n",
 			(long) mychan->rxgain, (long)mychan->txgain, mychan->gainalloc);
 		printk(KERN_INFO "span: %08lx, sig: %x hex, sigcap: %x hex\n",
@@ -3914,14 +3932,16 @@
 
 		if (copy_from_user(&tdp, (struct zt_dialparams *) data, sizeof(tdp)))
 			return -EFAULT;
-		if ((tdp.dtmf_tonelen > 4000) || (tdp.dtmf_tonelen < 10))
-			return -EINVAL;
-		if ((tdp.mfv1_tonelen > 4000) || (tdp.mfv1_tonelen < 10))
-			return -EINVAL;
-		if ((tdp.mfr2_tonelen > 4000) || (tdp.mfr2_tonelen < 10))
-			return -EINVAL;
-
-		global_dialparams = tdp;
+
+		if ((tdp.dtmf_tonelen <= 4000) || (tdp.dtmf_tonelen >= 10)) {
+			global_dialparams.dtmf_tonelen = tdp.dtmf_tonelen;
+		}
+		if ((tdp.mfv1_tonelen <= 4000) || (tdp.mfv1_tonelen >= 10)) {
+			global_dialparams.mfv1_tonelen = tdp.mfv1_tonelen;
+		}
+		if ((tdp.mfr2_tonelen <= 4000) || (tdp.mfr2_tonelen >= 10)) {
+			global_dialparams.mfr2_tonelen = tdp.mfr2_tonelen;
+		}
 
 		/* update the lengths in all currently loaded zones */
 		write_lock(&zone_lock);
@@ -3932,27 +3952,27 @@
 				continue;
 
 			for (i = 0; i < sizeof(z->dtmf) / sizeof(z->dtmf[0]); i++) {
-				z->dtmf[i].tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
+				z->dtmf[i].tonesamples = global_dialparams.dtmf_tonelen * ZT_CHUNKSIZE;
 			}
 
 			/* for MFR1, we only adjust the length of the digits */
 			for (i = ZT_TONE_MFR1_0; i <= ZT_TONE_MFR1_9; i++) {
-				z->mfr1[i - ZT_TONE_MFR1_BASE].tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
+				z->mfr1[i - ZT_TONE_MFR1_BASE].tonesamples = global_dialparams.mfv1_tonelen * ZT_CHUNKSIZE;
 			}
 
 			for (i = 0; i < sizeof(z->mfr2_fwd) / sizeof(z->mfr2_fwd[0]); i++) {
-				z->mfr2_fwd[i].tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+				z->mfr2_fwd[i].tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 			}
 
 			for (i = 0; i < sizeof(z->mfr2_rev) / sizeof(z->mfr2_rev[0]); i++) {
-				z->mfr2_rev[i].tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+				z->mfr2_rev[i].tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 			}
 		}
 		write_unlock(&zone_lock);
 
-		dtmf_silence.tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
-		mfr1_silence.tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
-		mfr2_silence.tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+		dtmf_silence.tonesamples = global_dialparams.dtmf_tonelen * ZT_CHUNKSIZE;
+		mfr1_silence.tonesamples = global_dialparams.mfv1_tonelen * ZT_CHUNKSIZE;
+		mfr2_silence.tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 
 		break;
 	}
@@ -4634,8 +4654,7 @@
 		chan->echolastupdate = 0;
 		chan->echotimer = 0;
 		spin_unlock_irqrestore(&chan->lock, flags);
-		if (chan->span && chan->span->echocan)
-			chan->span->echocan(chan, 0);
+		hw_echocancel_off(chan);
 		if (tec)
 			echo_can_free(tec);
 
@@ -4673,14 +4692,10 @@
 	/* attempt to use the span's echo canceler; fall back to built-in
 	   if it fails (but not if an error occurs) */
 	if (chan->span) {
-		if (ecp->param_count) {
-			if (chan->span->echocan_with_params)
-				ret = chan->span->echocan_with_params(chan, ecp, params);
-		} else if (chan->span->echocan) {
+		if (chan->span->echocan_with_params)
+			ret = chan->span->echocan_with_params(chan, ecp, params);
+		else if (chan->span->echocan)
 			ret = chan->span->echocan(chan, ecp->tap_length);
-		} else if (chan->span->echocan_with_params) {
-			ret = chan->span->echocan_with_params(chan, ecp, NULL);
-		}
 	}
 	
 	if (ret == -ENODEV) {
@@ -4790,8 +4805,7 @@
 			/* Disable any native echo cancellation as well */
 			spin_unlock_irqrestore(&chan->lock, flags);
 
-			if (chan->span && chan->span->echocan)
-				chan->span->echocan(chan, 0);
+			hw_echocancel_off(chan);
 
 			if (rxgain)
 				kfree(rxgain);
@@ -4843,8 +4857,8 @@
 					chan->gainalloc = 0;
 					chan->flags &= ~ZT_FLAG_AUDIO;
 					chan->flags |= (ZT_FLAG_PPP | ZT_FLAG_HDLC | ZT_FLAG_FCS);
-					if (chan->span && chan->span->echocan)
-						chan->span->echocan(chan, 0);
+					hw_echocancel_off(chan);
+					
 					if (tec)
 						echo_can_free(tec);
 				} else
@@ -5173,6 +5187,11 @@
 		span->deflaw = ZT_LAW_MULAW;
 	}
 
+	if (span->echocan && span->echocan_with_params) {
+		printk("zaptel: Span %s implements both echocan and echocan_with_params functions, preserving only echocan_with_params, please fix driver!\n", span->name);
+		span->echocan = NULL;
+	}
+
 	for (x=0;x<span->channels;x++) {
 		span->chans[x].span = span;
 		zt_chan_reg(&span->chans[x]); 
@@ -5594,8 +5613,11 @@
 					SCSS(ms->conflast, conf_sums[ms->_confn]);
 					/* Really add in new value */
 					ACSS(conf_sums[ms->_confn], ms->conflast);
-				} else memset(ms->conflast, 0, ZT_CHUNKSIZE * sizeof(short));
-				memcpy(getlin, ms->getlin, ZT_CHUNKSIZE * sizeof(short));
+					memcpy(ms->getlin, getlin, ZT_CHUNKSIZE * sizeof(short));
+				} else {
+					memset(ms->conflast, 0, ZT_CHUNKSIZE * sizeof(short));
+					memcpy(getlin, ms->getlin, ZT_CHUNKSIZE * sizeof(short));
+				}
 				txb[0] = ZT_LIN2X(0, ms);
 				memset(txb + 1, txb[0], ZT_CHUNKSIZE - 1);
 				break;
@@ -6571,7 +6593,7 @@
 				/* Convert back */
 				for(x=0;x<ZT_CHUNKSIZE;x++)
 					rxb[x] = ZT_LIN2X(putlin[x], ms);
-				memcpy(ss->getlin, putlin, ZT_CHUNKSIZE * sizeof(short));
+				memcpy(ss->putlin, putlin, ZT_CHUNKSIZE * sizeof(short));
 				break;
 			   }
 			/* fall through */

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel.h?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel.h (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel.h Fri May  2 12:28:15 2008
@@ -1318,7 +1318,7 @@
 	/* Specified by zaptel */
 	int channo;			/* Zaptel Channel number */
 	int chanpos;
-	int flags;
+	unsigned long flags;
 	long rxp1;
 	long rxp2;
 	long rxp3;
@@ -1529,7 +1529,6 @@
 	ZT_RXSIG_INITIAL
 } zt_rxsig_t;
 	
-
 /* Span flags */
 #define ZT_FLAG_REGISTERED		(1 << 0)
 #define ZT_FLAG_RUNNING			(1 << 1)
@@ -1555,6 +1554,30 @@
 #define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */
 #define ZT_FLAG_NOSTDTXRX		(1 << 17)	/* Do NOT do standard transmit and receive on every interrupt */
 #define ZT_FLAG_LOOPED			(1 << 18)	/* Loopback the receive data from the channel to the transmit */
+
+/* This is a redefinition of the flags from above to allow use of the kernel atomic bit testing and changing routines.
+ * See the above descriptions for ZT_FLAG_....  for documentation about function. */
+enum {
+	ZT_FLAGBIT_REGISTERED = 0,
+	ZT_FLAGBIT_RUNNING    = 1,
+	ZT_FLAGBIT_RBS	      = 12,
+	ZT_FLAGBIT_DTMFDECODE = 2,
+	ZT_FLAGBIT_MFDECODE   = 3,
+	ZT_FLAGBIT_ECHOCANCEL = 4,
+	ZT_FLAGBIT_HDLC	      = 5,
+	ZT_FLAGBIT_NETDEV     = 6,
+	ZT_FLAGBIT_PSEUDO     = 7,
+	ZT_FLAGBIT_CLEAR      = 8,
+	ZT_FLAGBIT_AUDIO      = 9,
+	ZT_FLAGBIT_OPEN	      = 10,
+	ZT_FLAGBIT_FCS	      = 11,
+	ZT_FLAGBIT_LINEAR     = 13,
+	ZT_FLAGBIT_PPP	      = 14,
+	ZT_FLAGBIT_T1PPP      = 15,
+	ZT_FLAGBIT_SIGFREEZE  = 16,
+	ZT_FLAGBIT_NOSTDTXRX  = 17,
+	ZT_FLAGBIT_LOOPED     = 18,
+};
 
 struct zt_span {
 	spinlock_t lock;

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/ztdynamic.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/ztdynamic.c?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/ztdynamic.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/ztdynamic.c Fri May  2 12:28:15 2008
@@ -433,7 +433,7 @@
 		kfree(z->msgbuf);
 
 	/* Free channels */
-	if (z->chans);
+	if (z->chans)
 		vfree(z->chans);
 	/* Free z */
 	kfree(z);

Modified: team/mattf/zaptel-1.4-stackcleanup/zaptel.init
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/zaptel.init?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/zaptel.init (original)
+++ team/mattf/zaptel-1.4-stackcleanup/zaptel.init Fri May  2 12:28:15 2008
@@ -200,7 +200,7 @@
 	xpp_startup
 	
 	if [ ! -e /proc/zaptel/1 ]; then
-		echo "No functioning zap hardware found in /proc/zaptel, loading ztdummy"
+		echo "No hardware timing source found in /proc/zaptel, loading ztdummy"
 		modprobe ztdummy 2> /dev/null
 	fi
 

Modified: team/mattf/zaptel-1.4-stackcleanup/ztcfg.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/ztcfg.c?view=diff&rev=4220&r1=4219&r2=4220
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/ztcfg.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/ztcfg.c Fri May  2 12:28:15 2008
@@ -1018,6 +1018,7 @@
 	int x,i,n;
 	struct zt_radio_param p;
 
+	toneindex = 1;
 	bzero(chans, sizeof(chans));
 	res = rad_apply_channels(chans, args);
 	if (res <= 0)




More information about the svn-commits mailing list