summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-09-30 15:19:45 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-09-30 15:19:45 +0000
commitf0c3f11388d96bd0dbb0756db65b3fa3cdce561f (patch)
tree1abe5d86c33e409c5502765f23f1b7eb4b70052a
parentec5266823ae51101c4ae91fe86fffd5418f865ee (diff)
optionally support flash events on FXS signaling (work done by Jim Dixon)
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@786 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xzaptel.c60
-rwxr-xr-xzaptel.h4
-rwxr-xr-xzconfig.h8
3 files changed, 50 insertions, 22 deletions
diff --git a/zaptel.c b/zaptel.c
index d86f3dc..2f717e4 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -1906,7 +1906,7 @@ who cares what the sig bits are as long as they are stable */
set_txtone(chan,0,0,0);
}
}
- chan->otimer = timeout * 8; /* Otimer is timer in samples */
+ chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */
return;
}
if (chan->span->hooksig) {
@@ -1914,7 +1914,7 @@ who cares what the sig bits are as long as they are stable */
chan->txhooksig = txsig;
chan->span->hooksig(chan, txsig);
}
- chan->otimer = timeout * 8; /* Otimer is timer in samples */
+ chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */
return;
} else {
for (x=0;x<NUM_SIGS;x++) {
@@ -1925,7 +1925,7 @@ who cares what the sig bits are as long as they are stable */
chan->txhooksig = txsig;
chan->txsig = outs[x][txsig+1];
chan->span->rbsbits(chan, chan->txsig);
- chan->otimer = timeout * 8; /* Otimer is timer in samples */
+ chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */
return;
}
}
@@ -3346,17 +3346,17 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd
if ((tdp.mfv1_tonelen > 4000) || (tdp.mfv1_tonelen < 10))
return -EINVAL;
for (i=0;i<16;i++)
- dtmf_tones[i].tonesamples = tdp.dtmf_tonelen * 8;
- dtmf_silence.tonesamples = tdp.dtmf_tonelen * 8;
+ dtmf_tones[i].tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
+ dtmf_silence.tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
for (i=0;i<15;i++)
- mfv1_tones[i].tonesamples = tdp.mfv1_tonelen * 8;
- mfv1_silence.tonesamples = tdp.mfv1_tonelen * 8;
+ mfv1_tones[i].tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
+ mfv1_silence.tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
/* Special case for K/P tone */
- mfv1_tones[10].tonesamples = tdp.mfv1_tonelen * 8 * 5 / 3;
+ mfv1_tones[10].tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE * 5 / 3;
break;
case ZT_GET_DIALPARAMS:
- tdp.dtmf_tonelen = dtmf_tones[0].tonesamples / 8;
- tdp.mfv1_tonelen = mfv1_tones[0].tonesamples / 8;
+ tdp.dtmf_tonelen = dtmf_tones[0].tonesamples / ZT_CHUNKSIZE;
+ tdp.mfv1_tonelen = mfv1_tones[0].tonesamples / ZT_CHUNKSIZE;
tdp.reserved[0] = 0;
tdp.reserved[1] = 0;
tdp.reserved[2] = 0;
@@ -3391,7 +3391,7 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break;
case ZT_MAINT_LOOPUP:
case ZT_MAINT_LOOPDOWN:
- spans[maint.spanno]->mainttimer = ZT_LOOPCODE_TIME * 8;
+ spans[maint.spanno]->mainttimer = ZT_LOOPCODE_TIME * ZT_CHUNKSIZE;
rv = spans[maint.spanno]->maint(spans[maint.spanno], maint.command);
spin_unlock_irqrestore(&spans[maint.spanno]->lock, flags);
if (rv) return rv;
@@ -5015,10 +5015,10 @@ out in the later versions, and is put back now. */
static inline void rbs_itimer_expire(struct zt_chan *chan)
{
/* the only way this could have gotten here, is if a channel
- went off hook longer then the wink or flash detect timeout */
+ went onf hook longer then the wink or flash detect timeout */
/* Called with chan->lock held */
switch(chan->sig)
- {
+ {
case ZT_SIG_FXOLS: /* if FXO, its definitely on hook */
case ZT_SIG_FXOGS:
case ZT_SIG_FXOKS:
@@ -5032,13 +5032,21 @@ static inline void rbs_itimer_expire(struct zt_chan *chan)
__qevent(chan,ZT_EVENT_ONHOOK);
break;
}
- /* intentionally fall thru */
+ __qevent(chan,ZT_EVENT_RINGOFFHOOK);
+ break;
+#endif
+#ifdef FXSFLASH
+ case ZT_SIG_FXSKS:
+ if (chan->rxhooksig == ZT_RXSIG_ONHOOK) {
+ __qevent(chan, ZT_EVENT_ONHOOK);
+ break;
+ }
#endif
+ /* fall thru intentionally */
default: /* otherwise, its definitely off hook */
__qevent(chan,ZT_EVENT_RINGOFFHOOK);
break;
- }
-
+ }
}
static inline void __rbs_otimer_expire(struct zt_chan *chan)
@@ -5116,7 +5124,7 @@ static inline void __rbs_otimer_expire(struct zt_chan *chan)
zt_rbs_sethook(chan, ZT_TXSIG_OFFHOOK, ZT_TXSTATE_OFFHOOK, 0);
/* See if we've gone back on hook */
if ((chan->rxhooksig == ZT_RXSIG_ONHOOK) && (chan->rxflashtime > 2))
- chan->itimerset = chan->itimer = chan->rxflashtime * 8;
+ chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE;
wake_up_interruptible(&chan->txstateq);
break;
@@ -5158,7 +5166,7 @@ static inline void __rbs_otimer_expire(struct zt_chan *chan)
break;
}
chan->txstate = ZT_TXSTATE_PULSEAFTER;
- chan->otimer = chan->pulseaftertime * 8;
+ chan->otimer = chan->pulseaftertime * ZT_CHUNKSIZE;
wake_up_interruptible(&chan->txstateq);
break;
@@ -5204,7 +5212,7 @@ static void __zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
}
#endif
/* set wink timer */
- chan->itimerset = chan->itimer = chan->rxwinktime * 8;
+ chan->itimerset = chan->itimer = chan->rxwinktime * ZT_CHUNKSIZE;
break;
case ZT_RXSIG_ONHOOK: /* went on hook */
/* This interface is now going on hook.
@@ -5213,7 +5221,7 @@ static void __zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
__qevent(chan,ZT_EVENT_WINKFLASH);
#ifdef EMFLASH
else {
- chan->itimerset = chan->itimer = chan->rxflashtime * 8;
+ chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE;
chan->gotgs = 0;
break;
}
@@ -5232,6 +5240,16 @@ static void __zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
case ZT_SIG_FXSKS: /* FXS Kewlstart */
/* ignore a bit poopy if loop not closed and stable */
if (chan->txstate != ZT_TXSTATE_OFFHOOK) break;
+#ifdef FXSFLASH
+ if (rxsig == ZT_RXSIG_ONHOOK) {
+ chan->itimer = ZT_FXSFLASHTIME * ZT_CHUNKSIZE;
+ break;
+ } else if (rxsig == ZT_RXSIG_OFFHOOK) {
+ if (chan->itimer) __qevent(chan, ZT_EVENT_WINKFLASH);
+ chan->itimer = 0;
+ break;
+ }
+#endif
/* fall through intentionally */
case ZT_SIG_FXSGS: /* FXS Groundstart */
if (rxsig == ZT_RXSIG_ONHOOK) {
@@ -5294,7 +5312,7 @@ static void __zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
if ((chan->txstate != ZT_TXSTATE_DEBOUNCE) &&
(chan->txstate != ZT_TXSTATE_KEWL) &&
(chan->txstate != ZT_TXSTATE_AFTERKEWL)) {
- chan->itimerset = chan->itimer = chan->rxflashtime * 8;
+ chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE;
}
if (chan->txstate == ZT_TXSTATE_KEWL)
chan->kewlonhook = 1;
diff --git a/zaptel.h b/zaptel.h
index 6a64b3f..1d39be6 100755
--- a/zaptel.h
+++ b/zaptel.h
@@ -905,6 +905,10 @@ struct zt_tone_def { /* Structure for zone programming */
#define ZT_MAX_CHANNELS 1024 /* Max, 1024 channels */
#define ZT_MAX_CONF 1024 /* Max, 1024 conferences */
+#ifdef FXSFLASH
+#define ZT_FXSFLASHTIME 550 /* max 550ms */
+#endif
+
#ifdef __KERNEL__
#include <linux/types.h>
diff --git a/zconfig.h b/zconfig.h
index 9a5ce3f..368ed9c 100755
--- a/zconfig.h
+++ b/zconfig.h
@@ -137,9 +137,15 @@
/*
* Comment out the following if you dont want events to indicate the
- * beginning of an incomming ring. Most non-asterisk applications will
+ * beginning of an incoming ring. Most non-Asterisk applications will
* want this commented out.
*/
#define RINGBEGIN
+/*
+ * Uncomment the following if you need to support FXS Flash events.
+ * Most applications will want this commented out.
+ */
+/* #define FXSFLASH */
+
#endif