[zaptel-commits] russell: branch group/vldtmf r1321 - /team/group/vldtmf/zaptel.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Thu Aug 17 14:13:09 MST 2006


Author: russell
Date: Thu Aug 17 16:13:08 2006
New Revision: 1321

URL: http://svn.digium.com/view/zaptel?rev=1321&view=rev
Log:
support continuous mfv1 tones with the ZT_SENDTONE ioctl

Modified:
    team/group/vldtmf/zaptel.c

Modified: team/group/vldtmf/zaptel.c
URL: http://svn.digium.com/view/zaptel/team/group/vldtmf/zaptel.c?rev=1321&r1=1320&r2=1321&view=diff
==============================================================================
--- team/group/vldtmf/zaptel.c (original)
+++ team/group/vldtmf/zaptel.c Thu Aug 17 16:13:08 2006
@@ -339,6 +339,7 @@
 #include "digits.h"
 
 static struct zt_tone *dtmf_tones_continuous = NULL;
+static struct zt_tone *mfv1_tones_continuous = NULL;
 
 static int zt_chan_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data, int unit);
 
@@ -1112,7 +1113,7 @@
 	chan->curtone = NULL;
 	chan->pdialcount = 0;
 	chan->txdialbuf[0] = '\0';
-	chan->dialing =  0;
+	chan->dialing = 0;
 
 	if (tone == -1) {
 		/* Just stop the current tone */
@@ -1128,8 +1129,17 @@
 		} else	/* Note that no tone zone exists at the moment */
 			res = -ENODATA;
 	} else if (tone >= ZT_TONE_DTMF_BASE && tone <= ZT_TONE_DTMF_MAX) {
-		chan->curtone = dtmf_tones_continuous + (tone - ZT_TONE_DTMF_BASE);
+		/* ZT_SENDTONE should never be used on a channel configured for pulse dialing */
+		chan->dialing = 1;
 		res = 0;
+		if (chan->digitmode == DIGIT_MODE_DTMF)
+			chan->curtone = dtmf_tones_continuous + (tone - ZT_TONE_DTMF_BASE);
+		else if (chan->digitmode == DIGIT_MODE_MFV1 && tone != ZT_TONE_DTMF_MAX) /* No 'D' */
+			chan->curtone = mfv1_tones_continuous + (tone - ZT_TONE_DTMF_BASE);
+		else {
+			chan->dialing = 0;
+			res = -EINVAL;
+		}
 	}
 
 	if (chan->curtone)
@@ -6926,9 +6936,19 @@
 		return -ENOMEM;
 	}
 
+	if (!(mfv1_tones_continuous = kmalloc(sizeof(mfv1_tones), GFP_KERNEL))) {
+		printk(KERN_ERR "Zaptel: THERE IS A CRISIS IN THE BATCAVE!"
+			" Unable to allocate memory for continuous MFV1 tones list!\n");
+		return -ENOMEM;
+	}
+
 	memcpy(dtmf_tones_continuous, dtmf_tones, sizeof(dtmf_tones));
 	for (i = 0; i < (sizeof(dtmf_tones) / sizeof(dtmf_tones[0])); i++)
 		dtmf_tones_continuous[i].next = dtmf_tones_continuous + i;
+
+	memcpy(mfv1_tones_continuous, mfv1_tones, sizeof(mfv1_tones));
+	for (i = 0; i < (sizeof(mfv1_tones) / sizeof(mfv1_tones[0])); i++)
+		mfv1_tones_continuous[i].next = mfv1_tones_continuous + i;
 
 	printk(KERN_INFO "Zapata Telephony Interface Registered on major %d\n", ZT_MAJOR);
 	printk(KERN_INFO "Zaptel Version: %s Echo Canceller: %s\n", ZAPTEL_VERSION,
@@ -6960,6 +6980,11 @@
 	if (dtmf_tones_continuous) {
 		kfree(dtmf_tones_continuous);
 		dtmf_tones_continuous = NULL;
+	}
+
+	if (mfv1_tones_continuous) {
+		kfree(mfv1_tones_continuous);
+		mfv1_tones_continuous = NULL;
 	}
 
 #ifdef CONFIG_DEVFS_FS



More information about the zaptel-commits mailing list