From 13e607262480c596ffaddbe713219a9a2f6f351e Mon Sep 17 00:00:00 2001 From: markster Date: Tue, 25 May 2004 15:07:52 +0000 Subject: Add Audio based RING detection git-svn-id: http://svn.digium.com/svn/zaptel/trunk@400 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wcfxs.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'wcfxs.c') diff --git a/wcfxs.c b/wcfxs.c index 37f01ea..f297469 100755 --- a/wcfxs.c +++ b/wcfxs.c @@ -34,7 +34,11 @@ #include "proslic.h" #include "wcfxs.h" - +/* + * Define for audio vs. register based ring detection + * + */ +#define AUDIO_RINGCHECK static alpha indirect_regs[] = { {0,"DTMF_ROW_0_PEAK",0x55C2}, @@ -270,18 +274,19 @@ static inline void ring_check(struct wcfxs *wc, int card) short sample; if (wc->modtype[card] != MOD_TYPE_FXO) return; + wc->mod.fxo.pegtimer[card] += ZT_CHUNKSIZE; for (x=0;xchans[card].readchunk[x], (&(wc->chans[card]))); - if ((sample > 32000) && (wc->mod.fxo.peg[card] != 1)) { - printk("High peg!\n"); + if ((sample > 10000) && (wc->mod.fxo.peg[card] != 1)) { + if (debug > 1) printk("High peg!\n"); if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME)) wc->mod.fxo.pegcount[card]++; wc->mod.fxo.pegtimer[card] = 0; wc->mod.fxo.peg[card] = 1; - } else if ((sample < -32000) && (wc->mod.fxo.peg[card] != -1)) { - printk("Low peg!\n"); - if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME)) + } else if ((sample < -10000) && (wc->mod.fxo.peg[card] != -1)) { + if (debug > 1) printk("Low peg!\n"); + if ((wc->mod.fxo.pegtimer[card] < (PEGTIME >> 2)) && (wc->mod.fxo.pegtimer[card] > (MINPEGTIME >> 2))) wc->mod.fxo.pegcount[card]++; wc->mod.fxo.pegtimer[card] = 0; wc->mod.fxo.peg[card] = -1; @@ -299,7 +304,8 @@ static inline void ring_check(struct wcfxs *wc, int card) /* It's ringing */ if (debug) printk("RING on %d/%d!\n", wc->span.spanno, card + 1); - zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); + if (!wc->mod.fxo.offhook[card]) + zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); wc->mod.fxo.ring[card] = 1; } if (wc->mod.fxo.ring[card] && !wc->mod.fxo.pegcount[card]) { @@ -1206,12 +1212,16 @@ static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card) static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) { +#ifndef AUDIO_RINGCHECK unsigned char res; +#endif signed char b; /* Try to track issues that plague slot one FXO's */ b = wcfxs_getreg(wc, card, 5); if ((b & 0x2) || !(b & 0x8)) { /* Not good -- don't look at anything else */ + if (debug) + printk("Poopy (%02x) on card %d!\n", b, card + 1); return; } b &= 0x9; -- cgit v1.2.3