[Asterisk-cvs] zaptel wctdm.c,1.121,1.122

markster markster
Thu Aug 4 16:29:29 CDT 2005


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

Modified Files:
	wctdm.c 
Log Message:
Allow polarity on TDM card FXS interface to be reversed...


Index: wctdm.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wctdm.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- wctdm.c	27 Jul 2005 22:26:55 -0000	1.121
+++ wctdm.c	4 Aug 2005 20:33:33 -0000	1.122
@@ -55,6 +55,8 @@
 */
 static int loopcurrent = 20;
 
+static int reversepolarity = 0;
+
 static alpha  indirect_regs[] =
 {
 {0,255,"DTMF_ROW_0_PEAK",0x55C2},
@@ -1058,15 +1060,24 @@
 			if (wc->mod[x].fxs.lasttxhook == 0x4) {
 				/* RINGing, prepare for OHT */
 				wc->mod[x].fxs.ohttimer = OHT_TIMER << 3;
-				wc->mod[x].fxs.idletxhookstate = 0x2;	/* OHT mode when idle */
+				if (reversepolarity)
+					wc->mod[x].fxs.idletxhookstate = 0x6;	/* OHT mode when idle */
+				else
+					wc->mod[x].fxs.idletxhookstate = 0x2; 
 			} else {
 				if (wc->mod[x].fxs.ohttimer) {
 					wc->mod[x].fxs.ohttimer-= ZT_CHUNKSIZE;
 					if (!wc->mod[x].fxs.ohttimer) {
-						wc->mod[x].fxs.idletxhookstate = 0x1;	/* Switch to active */
-						if (wc->mod[x].fxs.lasttxhook == 0x2) {
+						if (reversepolarity)
+							wc->mod[x].fxs.idletxhookstate = 0x5;	/* Switch to active */
+						else
+							wc->mod[x].fxs.idletxhookstate = 0x1;
+						if ((wc->mod[x].fxs.lasttxhook == 0x2) || (wc->mod[x].fxs.lasttxhook = 0x6)) {
 							/* Apply the change if appropriate */
-							wc->mod[x].fxs.lasttxhook = 0x1;
+							if (reversepolarity) 
+								wc->mod[x].fxs.lasttxhook = 0x5;
+							else
+								wc->mod[x].fxs.lasttxhook = 0x1;
 							wctdm_setreg(wc, x, 64, wc->mod[x].fxs.lasttxhook);
 						}
 					}
@@ -1474,7 +1485,10 @@
 	int fxsmode=0;
 
 	/* By default, don't send on hook */
-	wc->mod[card].fxs.idletxhookstate  = 1;
+	if (reversepolarity)
+		wc->mod[card].fxs.idletxhookstate = 5;
+	else
+		wc->mod[card].fxs.idletxhookstate = 1;
 
 	/* Sanity check the ProSLIC */
 	if (!sane && wctdm_proslic_insane(wc, card))
@@ -1662,10 +1676,16 @@
 		if (get_user(x, (int *)data))
 			return -EFAULT;
 		wc->mod[chan->chanpos - 1].fxs.ohttimer = x << 3;
-		wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 0x2;	/* OHT mode when idle */
+		if (reversepolarity)
+			wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 0x6;	/* OHT mode when idle */
+		else
+			wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 0x2;
 		if (wc->mod[chan->chanpos - 1].fxs.lasttxhook == 0x1) {
 				/* Apply the change if appropriate */
-				wc->mod[chan->chanpos - 1].fxs.lasttxhook = 0x2;
+				if (reversepolarity)
+					wc->mod[chan->chanpos - 1].fxs.lasttxhook = 0x6;
+				else
+					wc->mod[chan->chanpos - 1].fxs.lasttxhook = 0x2;
 				wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod[chan->chanpos - 1].fxs.lasttxhook);
 		}
 		break;
@@ -1679,7 +1699,7 @@
 		    (wc->mod[chan->chanpos -1 ].fxs.lasttxhook == 0x00))
 			return -EINVAL;
 
-		if (x)
+		if ((x && !reversepolarity) || (!x && reversepolarity))
 			wc->mod[chan->chanpos - 1].fxs.lasttxhook |= 0x04;
 		else
 			wc->mod[chan->chanpos - 1].fxs.lasttxhook &= ~0x04;
@@ -1793,9 +1813,12 @@
 #else
 	module_put(THIS_MODULE);
 #endif
-	if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS)
-		wc->mod[chan->chanpos -  1].fxs.idletxhookstate = 1;
-
+	if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
+		if (reversepolarity)
+			wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 5;
+		else
+			wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 1;
+	}
 	/* If we're dead, release us now */
 	if (!wc->usecount && wc->dead) 
 		wctdm_release(wc);
@@ -2313,6 +2336,7 @@
 #ifdef LINUX26
 module_param(debug, int, 0600);
 module_param(loopcurrent, int, 0600);
+module_param(reversepolarity, int, 0600);
 module_param(robust, int, 0600);
 module_param(_opermode, int, 0600);
 module_param(opermode, charp, 0600);
@@ -2326,6 +2350,7 @@
 #else
 MODULE_PARM(debug, "i");
 MODULE_PARM(loopcurrent, "i");
+MODULE_PARM(reversepolarity, "i");
 MODULE_PARM(robust, "i");
 MODULE_PARM(_opermode, "i");
 MODULE_PARM(opermode, "s");




More information about the svn-commits mailing list