diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2004-04-08 08:04:05 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2004-04-08 08:04:05 +0000 |
commit | 272eb4db7f97f6899caa64efa649fe1456d41336 (patch) | |
tree | 061433ba046daab44e3ee7a1bc09d2fc940b5647 /wcfxs.c | |
parent | 838f8a00a1cf12e5554905c669690d91a5751312 (diff) |
Ringing/battery enhancements and fix detect onhook during debounce when debounce is over.
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@349 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wcfxs.c')
-rwxr-xr-x | wcfxs.c | 49 |
1 files changed, 32 insertions, 17 deletions
@@ -175,13 +175,13 @@ struct wcfxs { int pegcount[NUM_CARDS]; int peg[NUM_CARDS]; int ring[NUM_CARDS]; - int ringdebounce[NUM_CARDS]; +#else + int wasringing[NUM_CARDS]; #endif + int ringdebounce[NUM_CARDS]; int offhook[NUM_CARDS]; - int wasringing[NUM_CARDS]; int battdebounce[NUM_CARDS]; int nobatttimer[NUM_CARDS]; - int ringdebounce[NUM_CARDS]; int battery[NUM_CARDS]; } fxo; struct { @@ -1186,32 +1186,47 @@ static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card) static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) { - unsigned char res, b; + unsigned char res; + signed char b; +#ifndef AUDIO_RINGCHECK if (!wc->fxo.offhook[card]) { res = wcfxs_getreg(wc, card, 5); if (res & 0x60) { - if (!wc->fxo.wasringing[card]) { - zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); - if (debug) - printk("RING!\n"); + wc->fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4); + if (wc->fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 32) { + if (!wc->fxo.wasringing[card]) { + wc->fxo.wasringing[card] = 1; + zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); + if (debug) + printk("RING!\n"); + } + wc->fxo.ringdebounce[card] = ZT_CHUNKSIZE * 32; } - wc->fxo.wasringing[card] = 100 * 8; } else { - if (wc->fxo.wasringing[card]) { - wc->fxo.wasringing[card] -= ZT_CHUNKSIZE; - if (wc->fxo.wasringing[card] < 0) - wc->fxo.wasringing[card] = 0; - if (!wc->fxo.wasringing[card]) { + wc->fxo.ringdebounce[card] -= ZT_CHUNKSIZE; + if (wc->fxo.ringdebounce[card] <= 0) { + if (wc->fxo.wasringing[card]) { + wc->fxo.wasringing[card] =0; zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK); if (debug) printk("NO RING!\n"); } + wc->fxo.ringdebounce[card] = 0; } } } - b = wcfxs_getreg(wc, card, 12) & 0x1f; - if (!b) { +#endif + b = wcfxs_getreg(wc, card, 29); +#if 0 + { + static int count = 0; + if (!(count++ % 100)) { + printk("Voltage: %d\n", b); + } + } +#endif + if (abs(b) < 2) { wc->fxo.nobatttimer[card]++; #if 0 if (wc->fxo.battery[card]) @@ -1236,7 +1251,7 @@ static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) wc->fxo.battdebounce[card] = BATT_DEBOUNCE; } else if (!wc->fxo.battery[card]) wc->fxo.battdebounce[card] = BATT_DEBOUNCE; - } else if (b >= 0x40) { + } else if (abs(b) > 1) { if (!wc->fxo.battery[card] && !wc->fxo.battdebounce[card]) { if (debug) printk("BATTERY!\n"); |