summaryrefslogtreecommitdiff
path: root/wctdm.c
diff options
context:
space:
mode:
authorsruffell <sruffell@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-04-03 21:11:24 +0000
committersruffell <sruffell@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-04-03 21:11:24 +0000
commitb88dcb40c9342fa0307e9c8d020db3fbba699c62 (patch)
tree8ea1c725ea4a909f0747a44f3959464e2f6ff345 /wctdm.c
parent18c27fc575b8195d5a850b885cc94459b21743c3 (diff)
svn merge -c3012 https://origsvn.digium.com/svn/zaptel/branches/1.4 .
svn merge -c3701 https://origsvn.digium.com/svn/zaptel/branches/1.4 . svn merge -c3703 https://origsvn.digium.com/svn/zaptel/branches/1.4 . svn merge -c4050 https://origsvn.digium.com/svn/zaptel/branches/1.4/kernel . git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@4128 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wctdm.c')
-rw-r--r--wctdm.c79
1 files changed, 59 insertions, 20 deletions
diff --git a/wctdm.c b/wctdm.c
index 6d7ef11..2cfcf00 100644
--- a/wctdm.c
+++ b/wctdm.c
@@ -311,6 +311,7 @@ struct wctdm {
int ring;
#else
int wasringing;
+ int lastrdtx;
#endif
int ringdebounce;
int offhook;
@@ -366,6 +367,7 @@ static void wctdm_release(struct wctdm *wc);
static int battdebounce = DEFAULT_BATT_DEBOUNCE;
static int battthresh = DEFAULT_BATT_THRESH;
static int ringdebounce = DEFAULT_RING_DEBOUNCE;
+static int fwringdetect = 0;
static int debug = 0;
static int robust = 0;
static int timingonly = 0;
@@ -852,30 +854,55 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
return;
#ifndef AUDIO_RINGCHECK
if (!wc->mod[card].fxo.offhook) {
- res = wc->reg0shadow[card];
- if ((res & 0x60) && wc->mod[card].fxo.battery) {
- wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
- if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
- if (!wc->mod[card].fxo.wasringing) {
- wc->mod[card].fxo.wasringing = 1;
- zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
- if (debug)
- printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+ if (fwringdetect) {
+ res = wc->reg0shadow[card] & 0x60;
+ if (wc->mod[card].fxo.ringdebounce--) {
+ if (res && (res != wc->mod[card].fxo.lastrdtx) && wc->mod[card].fxo.battery) {
+ if (!wc->mod[card].fxo.wasringing) {
+ wc->mod[card].fxo.wasringing = 1;
+ if (debug)
+ printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+ }
+ wc->mod[card].fxo.lastrdtx = res;
+ wc->mod[card].fxo.ringdebounce = 10;
+ } else if (!res) {
+ if ((wc->mod[card].fxo.ringdebounce == 0) && wc->mod[card].fxo.wasringing) {
+ wc->mod[card].fxo.wasringing = 0;
+ if (debug)
+ printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+ }
}
- wc->mod[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
+ } else if (res && wc->mod[card].fxo.battery) {
+ wc->mod[card].fxo.lastrdtx = res;
+ wc->mod[card].fxo.ringdebounce = 10;
}
} else {
- wc->mod[card].fxo.ringdebounce -= ZT_CHUNKSIZE * 4;
- if (wc->mod[card].fxo.ringdebounce <= 0) {
- if (wc->mod[card].fxo.wasringing) {
- wc->mod[card].fxo.wasringing = 0;
- zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
- if (debug)
- printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+ res = wc->reg0shadow[card];
+ if ((res & 0x60) && wc->mod[card].fxo.battery) {
+ wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
+ if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
+ if (!wc->mod[card].fxo.wasringing) {
+ wc->mod[card].fxo.wasringing = 1;
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+ if (debug)
+ printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+ }
+ wc->mod[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
+ }
+ } else {
+ wc->mod[card].fxo.ringdebounce -= ZT_CHUNKSIZE * 4;
+ if (wc->mod[card].fxo.ringdebounce <= 0) {
+ if (wc->mod[card].fxo.wasringing) {
+ wc->mod[card].fxo.wasringing = 0;
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+ if (debug)
+ printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+ }
+ wc->mod[card].fxo.ringdebounce = 0;
}
- wc->mod[card].fxo.ringdebounce = 0;
}
-
}
}
#endif
@@ -1455,7 +1482,17 @@ static int wctdm_init_voicedaa(struct wctdm *wc, int card, int fast, int manual,
reg16 |= (fxo_modes[_opermode].rz << 1);
reg16 |= (fxo_modes[_opermode].rt);
wctdm_setreg(wc, card, 16, reg16);
-
+
+ if(fwringdetect) {
+ /* Enable ring detector full-wave rectifier mode */
+ wctdm_setreg(wc, card, 18, 2);
+ wctdm_setreg(wc, card, 24, 0);
+ } else {
+ /* Set to the device defaults */
+ wctdm_setreg(wc, card, 18, 0);
+ wctdm_setreg(wc, card, 24, 0x19);
+ }
+
/* Set DC Termination:
Tip/Ring voltage adjust, minimum operational current, current limitation */
reg26 |= (fxo_modes[_opermode].dcv << 6);
@@ -2406,6 +2443,7 @@ module_param(fxshonormode, int, 0600);
module_param(battdebounce, int, 0600);
module_param(battthresh, int, 0600);
module_param(ringdebounce, int, 0600);
+module_param(fwringdetect, int, 0600);
module_param(alawoverride, int, 0600);
#else
MODULE_PARM(debug, "i");
@@ -2422,6 +2460,7 @@ MODULE_PARM(fxshonormode, "i");
MODULE_PARM(battdebounce, "i");
MODULE_PARM(battthresh, "i");
MODULE_PARM(ringdebounce, "i");
+MODULE_PARM(fwringdetect, "i");
MODULE_PARM(alawoverride, "i");
#endif
MODULE_DESCRIPTION("Wildcard TDM400P Zaptel Driver");