diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2004-05-25 15:07:52 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2004-05-25 15:07:52 +0000 |
commit | 13e607262480c596ffaddbe713219a9a2f6f351e (patch) | |
tree | e39d886789263af472129d6ea1338e155c736cc2 | |
parent | b4278508035f2518afb6f00fdac0aa6e11a2e20e (diff) |
Add Audio based RING detection
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@400 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-x | wcfxs.c | 24 | ||||
-rwxr-xr-x | wctdm.c | 24 |
2 files changed, 34 insertions, 14 deletions
@@ -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;x<ZT_CHUNKSIZE;x++) { /* Look for pegging to indicate ringing */ sample = ZT_XLAW(wc->chans[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; @@ -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;x<ZT_CHUNKSIZE;x++) { /* Look for pegging to indicate ringing */ sample = ZT_XLAW(wc->chans[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; |