summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-06-06 02:47:53 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-06-06 02:47:53 +0000
commit21224b4ad18a623fbfc481242048e28fdbfaea86 (patch)
tree9648dec8ba91fdb90a2df80b781226c0a3516d94
parentb4b9c88ccd625d7840111159f42b72bcda883227 (diff)
FXS fixes, ring debounce
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@191 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xwcfxs.c19
-rwxr-xr-xwctdm.c19
-rwxr-xr-xzaptel.c29
-rwxr-xr-xzaptel.h6
4 files changed, 35 insertions, 38 deletions
diff --git a/wcfxs.c b/wcfxs.c
index 2e81dd9..7afb82a 100755
--- a/wcfxs.c
+++ b/wcfxs.c
@@ -560,12 +560,12 @@ static int wcfxs_powerleak_test(struct wcfxs *wc, int card)
/* Wait for one second */
origjiffies = jiffies;
- while((vbat = wcfxs_getreg(wc, card, 82)) > 0x3) {
- if ((jiffies - origjiffies) >= HZ)
+ while((vbat = wcfxs_getreg(wc, card, 82)) > 0x6) {
+ if ((jiffies - origjiffies) >= (HZ/2))
break;;
}
- if (vbat < 0x04) {
+ if (vbat < 0x06) {
printk("Excessive leakage detected on module %d: %d volts (%02x) after %d ms\n", card,
376 * vbat / 1000, vbat, (int)((jiffies - origjiffies) * 1000 / HZ));
return -1;
@@ -581,10 +581,10 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
unsigned long origjiffies;
/* Set period of DC-DC converter to 1/64 khz */
- wcfxs_setreg(wc, card, 92, 0xff);
+ wcfxs_setreg(wc, card, 92, 0x7f /* was 0xff */);
/* Engage DC-DC converter */
- wcfxs_setreg(wc, card, 93, 0x19);
+ wcfxs_setreg(wc, card, 93, 0x99 /* was 0x19 */);
/* Wait for VBat to powerup */
origjiffies = jiffies;
@@ -599,10 +599,6 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
}
}
-#if 0
- printk("jiffies - origjiffies: %d\n", ((int)(jiffies - origjiffies)));
-#endif
-
if (vbat < 0xc0) {
printk("ProSLIC on module %d failed to powerup within %d ms\n",
card, (int)(((jiffies - origjiffies) * 1000 / HZ)));
@@ -611,8 +607,10 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
printk("ProSLIC on module %d powered up to -%d volts (%02x) in %d ms\n",
card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
}
+
+#if 0
/* Perform DC-DC calibration */
- wcfxs_setreg(wc, card, 93, 0x80);
+ /* wcfxs_setreg(wc, card, 93, 0x80); */
origjiffies = jiffies;
while(0x80 & wcfxs_getreg(wc, card, 93)) {
@@ -631,6 +629,7 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
printk("ProSLIC on module %d powered up to -%d volts (%02x) in %d ms\n",
card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
#endif
+#endif
return 0;
}
diff --git a/wctdm.c b/wctdm.c
index 2e81dd9..7afb82a 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -560,12 +560,12 @@ static int wcfxs_powerleak_test(struct wcfxs *wc, int card)
/* Wait for one second */
origjiffies = jiffies;
- while((vbat = wcfxs_getreg(wc, card, 82)) > 0x3) {
- if ((jiffies - origjiffies) >= HZ)
+ while((vbat = wcfxs_getreg(wc, card, 82)) > 0x6) {
+ if ((jiffies - origjiffies) >= (HZ/2))
break;;
}
- if (vbat < 0x04) {
+ if (vbat < 0x06) {
printk("Excessive leakage detected on module %d: %d volts (%02x) after %d ms\n", card,
376 * vbat / 1000, vbat, (int)((jiffies - origjiffies) * 1000 / HZ));
return -1;
@@ -581,10 +581,10 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
unsigned long origjiffies;
/* Set period of DC-DC converter to 1/64 khz */
- wcfxs_setreg(wc, card, 92, 0xff);
+ wcfxs_setreg(wc, card, 92, 0x7f /* was 0xff */);
/* Engage DC-DC converter */
- wcfxs_setreg(wc, card, 93, 0x19);
+ wcfxs_setreg(wc, card, 93, 0x99 /* was 0x19 */);
/* Wait for VBat to powerup */
origjiffies = jiffies;
@@ -599,10 +599,6 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
}
}
-#if 0
- printk("jiffies - origjiffies: %d\n", ((int)(jiffies - origjiffies)));
-#endif
-
if (vbat < 0xc0) {
printk("ProSLIC on module %d failed to powerup within %d ms\n",
card, (int)(((jiffies - origjiffies) * 1000 / HZ)));
@@ -611,8 +607,10 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
printk("ProSLIC on module %d powered up to -%d volts (%02x) in %d ms\n",
card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
}
+
+#if 0
/* Perform DC-DC calibration */
- wcfxs_setreg(wc, card, 93, 0x80);
+ /* wcfxs_setreg(wc, card, 93, 0x80); */
origjiffies = jiffies;
while(0x80 & wcfxs_getreg(wc, card, 93)) {
@@ -631,6 +629,7 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card)
printk("ProSLIC on module %d powered up to -%d volts (%02x) in %d ms\n",
card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
#endif
+#endif
return 0;
}
diff --git a/zaptel.c b/zaptel.c
index 24dd095..fdb7be0 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -4467,8 +4467,6 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
{
- int oldrxsig = chan->rxhooksig;
-
/* State machines for receive hookstate transitions */
if ((chan->rxhooksig) == rxsig) return;
@@ -4497,29 +4495,14 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
break;
}
break;
- case ZT_SIG_FXSLS: /* FXS loopstart */
- if ((oldrxsig == ZT_RXSIG_RING) &&
- (rxsig == ZT_RXSIG_OFFHOOK)) {
- if (!chan->ringdebtimer) qevent(chan,ZT_EVENT_RINGOFFHOOK);
- }
- break;
case ZT_SIG_FXSKS: /* FXS Kewlstart */
- if ((oldrxsig == ZT_RXSIG_RING) &&
- (rxsig == ZT_RXSIG_OFFHOOK)) {
- if (!chan->ringdebtimer) qevent(chan,ZT_EVENT_RINGOFFHOOK);
- break;
- }
/* ignore a bit poopy if loop not closed and stable */
if (chan->txstate != ZT_TXSTATE_OFFHOOK) break;
/* fall through intentionally */
case ZT_SIG_FXSGS: /* FXS Groundstart */
- if ((oldrxsig == ZT_RXSIG_RING) &&
- (rxsig == ZT_RXSIG_OFFHOOK)) {
- if (!chan->ringdebtimer) qevent(chan,ZT_EVENT_RINGOFFHOOK);
- break;
- }
if (rxsig == ZT_RXSIG_ONHOOK) {
chan->ringdebtimer = RING_DEBOUNCE_TIME;
+ chan->ringtrailer = 0;
if (chan->txstate != ZT_TXSTATE_DEBOUNCE) {
chan->gotgs = 0;
qevent(chan,ZT_EVENT_ONHOOK);
@@ -5436,6 +5419,16 @@ int zt_receive(struct zt_span *span)
}
if (span->chans[x].ringdebtimer)
span->chans[x].ringdebtimer--;
+ if (span->chans[x].sig & __ZT_SIG_FXS) {
+ if (span->chans[x].rxhooksig == ZT_RXSIG_RING)
+ span->chans[x].ringtrailer = ZT_RINGTRAILER;
+ else if (span->chans[x].ringtrailer) {
+ span->chans[x].ringtrailer-= ZT_CHUNKSIZE;
+ /* See if RING trailer is expired */
+ if (!span->chans[x].ringtrailer && !span->chans[x].ringdebtimer)
+ qevent(&span->chans[x],ZT_EVENT_RINGOFFHOOK);
+ }
+ }
if (span->chans[x].pulsetimer)
{
span->chans[x].pulsetimer--;
diff --git a/zaptel.h b/zaptel.h
index 9d60353..a2b8f82 100755
--- a/zaptel.h
+++ b/zaptel.h
@@ -788,6 +788,9 @@ struct zt_tone_def { /* Structure for zone programming */
#define ZT_MAXPULSETIME (150 * 8) /* 150 ms maximum */
#define ZT_PULSETIMEOUT ((ZT_MAXPULSETIME / 8) + 50)
+#define ZT_RINGTRAILER (150 * 8) /* Don't consider a ring "gone" until it's been gone at least this
+ much time */
+
#define ZT_LOOPCODE_TIME 10000 /* send loop codes for 10 secs */
#define ZT_ALARMSETTLE_TIME 5000 /* allow alarms to settle for 5 secs */
#define ZT_AFTERSTART_TIME 500 /* 500ms after start */
@@ -999,6 +1002,9 @@ struct zt_chan {
/* RING debounce timer */
int ringdebtimer;
+
+ /* RING trailing detector to make sure a RING is really over */
+ int ringtrailer;
/* PULSE digit receiver stuff */
int pulsecount;