Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv20745

Modified Files:
        zaptel.c zaptel.h zconfig.h 
Log Message:
optionally support flash events on FXS signaling (work done by Jim Dixon)


Index: zaptel.c
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- zaptel.c    29 Sep 2005 03:03:33 -0000      1.121
+++ zaptel.c    30 Sep 2005 15:19:45 -0000      1.122
@@ -1906,7 +1906,7 @@
                                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 @@
                        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 @@
                                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 @@
                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 @@
                        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 @@
 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 @@
                        __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 @@
                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 @@
                        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 @@
                        }
 #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 @@
                                __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 @@
           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 @@
                        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;

Index: zaptel.h
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- zaptel.h    29 Sep 2005 02:29:16 -0000      1.47
+++ zaptel.h    30 Sep 2005 15:19:45 -0000      1.48
@@ -905,6 +905,10 @@
 #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>

Index: zconfig.h
===================================================================
RCS file: /usr/cvsroot/zaptel/zconfig.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- zconfig.h   12 Sep 2005 19:07:02 -0000      1.21
+++ zconfig.h   30 Sep 2005 15:19:45 -0000      1.22
@@ -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

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to