[zaptel-commits] mattf: trunk r1310 - in /trunk: zaptel.c zaptel.h

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Tue Aug 15 11:42:22 MST 2006


Author: mattf
Date: Tue Aug 15 13:42:22 2006
New Revision: 1310

URL: http://svn.digium.com/view/zaptel?rev=1310&view=rev
Log:
Add support for looping back a single channel

Modified:
    trunk/zaptel.c
    trunk/zaptel.h

Modified: trunk/zaptel.c
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.c?rev=1310&r1=1309&r2=1310&view=diff
==============================================================================
--- trunk/zaptel.c (original)
+++ trunk/zaptel.c Tue Aug 15 13:42:22 2006
@@ -1031,7 +1031,7 @@
 	chan->txgain = defgain;
 	chan->gainalloc = 0;
 	chan->eventinidx = chan->eventoutidx = 0;
-	chan->flags &= ~(ZT_FLAG_LINEAR | ZT_FLAG_PPP | ZT_FLAG_SIGFREEZE);
+	chan->flags &= ~(ZT_FLAG_LOOPED | ZT_FLAG_LINEAR | ZT_FLAG_PPP | ZT_FLAG_SIGFREEZE);
 
 	zt_set_law(chan,0);
 
@@ -4371,6 +4371,16 @@
 		put_user(chan->rxsig, (int *)data);
 		rv = 0;
 		break;
+	case ZT_LOOPBACK:
+		get_user(j, (int *)data);
+		spin_lock_irqsave(&chan->lock, flags);
+		if (j)
+			chan->flags |= ZT_FLAG_LOOPED;
+		else
+			chan->flags &= ~ZT_FLAG_LOOPED;
+		spin_unlock_irqrestore(&chan->lock, flags);
+		rv = 0;
+		break;
 	case ZT_HOOK:
 		get_user(j,(int *)data);
 		if (chan->flags & ZT_FLAG_CLEAR)
@@ -5163,6 +5173,10 @@
 						zt_init_tone_state(&ms->ts, ms->curtone);
 				}
 			}
+		} else if (ms->flags & ZT_FLAG_LOOPED) {
+			for (x = 0; x < bytes; x++)
+				txb[x] = ms->readchunk[x];
+			bytes = 0;
 		} else if (ms->flags & ZT_FLAG_HDLC) {
 			for (x=0;x<bytes;x++) {
 				/* Okay, if we're HDLC, then transmit a flag by default */

Modified: trunk/zaptel.h
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.h?rev=1310&r1=1309&r2=1310&view=diff
==============================================================================
--- trunk/zaptel.h (original)
+++ trunk/zaptel.h Tue Aug 15 13:42:22 2006
@@ -612,6 +612,12 @@
  * of the compiled-in echo canceller (if any)
  */
 #define ZT_GETVERSION _IOR(ZT_CODE, 57, struct zt_versioninfo)
+
+/*
+ * Put the channel in loopback mode (receive from the channel is
+ * transmitted back on the interface)
+ */
+#define ZT_LOOPBACK _IOW(ZT_CODE, 58, int)
 
 /*
  *  60-80 are reserved for private drivers
@@ -1070,7 +1076,7 @@
 	u_char swritechunk[ZT_MAX_CHUNKSIZE];	/* Buffer to be written */
 	u_char *readchunk;						/* Actual place to read from */
 	u_char sreadchunk[ZT_MAX_CHUNKSIZE];	/* Preallocated static area */
-	
+
 	/* Pointer to tx and rx gain tables */
 	u_char *rxgain;
 	u_char *txgain;
@@ -1281,6 +1287,7 @@
 #define ZT_FLAG_T1PPP			(1 << 15)
 #define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */
 #define ZT_FLAG_NOSTDTXRX		(1 << 17)	/* Do NOT do standard transmit and receive on every interrupt */
+#define ZT_FLAG_LOOPED			(1 << 18)	/* Loopback the receive data from the channel to the transmit */
 
 struct zt_span {
 	spinlock_t lock;



More information about the zaptel-commits mailing list