[Asterisk-cvs] zaptel wct4xxp.c,1.80,1.81

kpfleming kpfleming
Mon Aug 8 17:59:34 CDT 2005


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv9516

Modified Files:
	wct4xxp.c 
Log Message:
minor optimizations


Index: wct4xxp.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wct4xxp.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- wct4xxp.c	27 Jul 2005 22:05:47 -0000	1.80
+++ wct4xxp.c	8 Aug 2005 22:03:11 -0000	1.81
@@ -523,9 +523,12 @@
 	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
+static const char vpm_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', '*', '#'};
+
 static void __t4_check_vpm(struct t4 *wc, unsigned int newio)
 {
 	unsigned int digit, regval = 0;
+	unsigned int regbyte;
 	int x, i;
 	short energy;
 	static unsigned int lastio = 0;
@@ -541,27 +544,22 @@
 			continue;
 		ts = wc->tspans[x%4];
 		/* Start of DTMF detection process */	
-		regval = __t4_vpm_in(wc, x, 0xb8);
-		__t4_vpm_out(wc, x, 0xb8, regval); /* Write 1 to clear */
-		regval = regval << 8;
-		regval |= __t4_vpm_in(wc, x, 0xb9);
-		__t4_vpm_out(wc, x, 0xb9, regval & 0xff);
+		regbyte = __t4_vpm_in(wc, x, 0xb8);
+		__t4_vpm_out(wc, x, 0xb8, regbyte); /* Write 1 to clear */
+		regval = regbyte << 8;
+		regbyte = __t4_vpm_in(wc, x, 0xb9);
+		__t4_vpm_out(wc, x, 0xb9, regbyte);
+		regval |= regbyte;
 
 		for(i = 0; (i < MAX_DTMF_DET) && regval; i++) {
 			if(regval & 0x0001) {
 				int channel = (i << 1) + (x >> 2);
 				int base = channel - 1;
+
 				if (!wc->t1e1)
 					base -= 4;
-				digit = __t4_vpm_in(wc, x, 0xa8 + i);
-				if (digit < 10) 
-					digit += '0'; 
-				else if (digit < 0xe) 
-					digit += 'A' - 0xe; 
-				else if (digit == 0xe) 
-					digit = '*';
-				else if (digit == 0xf) 
-					digit = '#';
+				regbyte = __t4_vpm_in(wc, x, 0xa8 + i);
+				digit = vpm_digits[regbyte];
 				energy = __t4_vpm_in(wc, x, 0x58 + channel);
 				energy = ZT_XLAW(energy, ts->chans);
 				ts->dtmfactive |= (1 << base);




More information about the svn-commits mailing list