From ecd016f737088d6ae010ba9cf7ea05ed373c8a7f Mon Sep 17 00:00:00 2001 From: kpfleming Date: Mon, 8 Aug 2005 22:03:11 +0000 Subject: minor optimizations git-svn-id: http://svn.digium.com/svn/zaptel/trunk@725 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wct4xxp.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/wct4xxp.c b/wct4xxp.c index 3d877d6..2b2830d 100755 --- a/wct4xxp.c +++ b/wct4xxp.c @@ -523,9 +523,12 @@ static inline void t4_vpm_out(struct t4 *wc, int unit, const unsigned int addr, 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 @@ static void __t4_check_vpm(struct t4 *wc, unsigned int newio) 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); -- cgit v1.2.3