[svn-commits] dbailey: branch 1.4 r3701 - in /branches/1.4: ./ wctdm24xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jan 17 14:49:05 CST 2008


Author: dbailey
Date: Thu Jan 17 14:49:05 2008
New Revision: 3701

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3701
Log:
Added modified patch so that the ring detect method can be set using a module parameter.  
Setting fwringdetect=1 enables the method submitted by this user. 

(closes issue #9264)
Reported by: mjagdis
Tested by: benbrown

Modified:
    branches/1.4/wctdm.c
    branches/1.4/wctdm24xxp/base.c
    branches/1.4/wctdm24xxp/wctdm24xxp.h

Modified: branches/1.4/wctdm.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm.c?view=diff&rev=3701&r1=3700&r2=3701
==============================================================================
--- branches/1.4/wctdm.c (original)
+++ branches/1.4/wctdm.c Thu Jan 17 14:49:05 2008
@@ -311,6 +311,7 @@
 			int ring;
 #else			
 			int wasringing;
+			int lastrdtx;
 #endif			
 			int ringdebounce;
 			int offhook;
@@ -366,6 +367,7 @@
 static int battdebounce = DEFAULT_BATT_DEBOUNCE;
 static int battthresh = DEFAULT_BATT_THRESH;
 static int ringdebounce = DEFAULT_RING_DEBOUNCE;
+static int fwringdetect = 0;
 static int debug = 0;
 static int robust = 0;
 static int timingonly = 0;
@@ -857,30 +859,55 @@
 		return;
 #ifndef AUDIO_RINGCHECK
 	if (!wc->mod[card].fxo.offhook) {
-		res = wc->reg0shadow[card];
-		if ((res & 0x60) && wc->mod[card].fxo.battery) {
-			wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
-			if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
-				if (!wc->mod[card].fxo.wasringing) {
-					wc->mod[card].fxo.wasringing = 1;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
-					if (debug)
-						printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+		if (fwringdetect) {
+			res = wc->reg0shadow[card] & 0x60;
+			if (wc->mod[card].fxo.ringdebounce--) {
+				if (res && (res != wc->mod[card].fxo.lastrdtx) && wc->mod[card].fxo.battery) {
+					if (!wc->mod[card].fxo.wasringing) {
+						wc->mod[card].fxo.wasringing = 1;
+						if (debug)
+							printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+					}
+					wc->mod[card].fxo.lastrdtx = res;
+					wc->mod[card].fxo.ringdebounce = 10;
+				} else if (!res) {
+					if ((wc->mod[card].fxo.ringdebounce == 0) && wc->mod[card].fxo.wasringing) {
+						wc->mod[card].fxo.wasringing = 0;
+						if (debug)
+							printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+					}
 				}
-				wc->mod[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
+			} else if (res && wc->mod[card].fxo.battery) {
+				wc->mod[card].fxo.lastrdtx = res;
+				wc->mod[card].fxo.ringdebounce = 10;
 			}
 		} else {
-			wc->mod[card].fxo.ringdebounce -= ZT_CHUNKSIZE * 4;
-			if (wc->mod[card].fxo.ringdebounce <= 0) {
-				if (wc->mod[card].fxo.wasringing) {
-					wc->mod[card].fxo.wasringing = 0;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-					if (debug)
-						printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+			res = wc->reg0shadow[card];
+			if ((res & 0x60) && wc->mod[card].fxo.battery) {
+				wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
+				if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
+					if (!wc->mod[card].fxo.wasringing) {
+						wc->mod[card].fxo.wasringing = 1;
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+						if (debug)
+							printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+					}
+					wc->mod[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
 				}
-				wc->mod[card].fxo.ringdebounce = 0;
+			} else {
+				wc->mod[card].fxo.ringdebounce -= ZT_CHUNKSIZE * 4;
+				if (wc->mod[card].fxo.ringdebounce <= 0) {
+					if (wc->mod[card].fxo.wasringing) {
+						wc->mod[card].fxo.wasringing = 0;
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+						if (debug)
+							printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+					}
+					wc->mod[card].fxo.ringdebounce = 0;
+				}
 			}
-				
 		}
 	}
 #endif
@@ -1505,7 +1532,17 @@
 	reg16 |= (fxo_modes[_opermode].rz << 1);
 	reg16 |= (fxo_modes[_opermode].rt);
 	wctdm_setreg(wc, card, 16, reg16);
-	
+
+	if(fwringdetect) {
+		/* Enable ring detector full-wave rectifier mode */
+		wctdm_setreg(wc, card, 18, 2);
+		wctdm_setreg(wc, card, 24, 0);
+	} else { 
+		/* Set to the device defaults */
+		wctdm_setreg(wc, card, 18, 0);
+		wctdm_setreg(wc, card, 24, 0x19);
+	}
+
 	/* Set DC Termination:
 	   Tip/Ring voltage adjust, minimum operational current, current limitation */
 	reg26 |= (fxo_modes[_opermode].dcv << 6);
@@ -2517,6 +2554,7 @@
 module_param(battdebounce, int, 0600);
 module_param(battthresh, int, 0600);
 module_param(ringdebounce, int, 0600);
+module_param(fwringdetect, int, 0600);
 module_param(alawoverride, int, 0600);
 module_param(fastpickup, int, 0600);
 module_param(fxotxgain, int, 0600);
@@ -2538,6 +2576,7 @@
 MODULE_PARM(battdebounce, "i");
 MODULE_PARM(battthresh, "i");
 MODULE_PARM(ringdebounce, "i");
+MODULE_PARM(fwringdetect, "i");
 MODULE_PARM(alawoverride, "i");
 MODULE_PARM(fastpickup, "i");
 MODULE_PARM(fxotxgain, "i");

Modified: branches/1.4/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/base.c?view=diff&rev=3701&r1=3700&r2=3701
==============================================================================
--- branches/1.4/wctdm24xxp/base.c (original)
+++ branches/1.4/wctdm24xxp/base.c Thu Jan 17 14:49:05 2008
@@ -280,6 +280,7 @@
 static int fxsrxgain = 0;
 static int nativebridge = 0;
 static int ringdebounce = DEFAULT_RING_DEBOUNCE;
+static int fwringdetect = 0;
 #ifdef VPM_SUPPORT
 static int vpmsupport = 1;
 static int vpmdtmfsupport = 0;
@@ -1328,30 +1329,56 @@
 			wctdm_setreg_intr(wc, card, 5, 0x8);
 	}
 	if (!wc->mods[card].fxo.offhook) {
-		res = wc->cmdq[card].isrshadow[0];	/* Hook/Ring state */
-		if ((res & 0x60) && wc->mods[card].fxo.battery) {
-			wc->mods[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 4);
-			if (wc->mods[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
-				if (!wc->mods[card].fxo.wasringing) {
-					wc->mods[card].fxo.wasringing = 1;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
-					if (debug & DEBUG_CARD)
-						printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+		if (fwringdetect) {
+			res =  wc->cmdq[card].isrshadow[0] & 0x60;
+			if (wc->mods[card].fxo.ringdebounce--) {
+				if (res && (res != wc->mods[card].fxo.lastrdtx) && wc->mods[card].fxo.battery) {
+					if (!wc->mods[card].fxo.wasringing) {
+						wc->mods[card].fxo.wasringing = 1;
+						if (debug)
+							printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+					}
+					wc->mods[card].fxo.lastrdtx = res;
+					wc->mods[card].fxo.ringdebounce = 10;
+				} else if (!res) {
+					if ((wc->mods[card].fxo.ringdebounce == 0) && wc->mods[card].fxo.wasringing) {
+						wc->mods[card].fxo.wasringing = 0;
+						if (debug)
+							printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+					}
 				}
-				wc->mods[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
+			} else if (res && wc->mods[card].fxo.battery) {
+				wc->mods[card].fxo.lastrdtx = res;
+				wc->mods[card].fxo.ringdebounce = 10;
 			}
 		} else {
-			wc->mods[card].fxo.ringdebounce -= ZT_CHUNKSIZE;
-			if (wc->mods[card].fxo.ringdebounce <= 0) {
-				if (wc->mods[card].fxo.wasringing) {
-					wc->mods[card].fxo.wasringing = 0;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-					if (debug & DEBUG_CARD)
-						printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+			res =  wc->cmdq[card].isrshadow[0];
+			if ((res & 0x60) && wc->mods[card].fxo.battery) {
+				wc->mods[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
+				if (wc->mods[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
+					if (!wc->mods[card].fxo.wasringing) {
+						wc->mods[card].fxo.wasringing = 1;
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+						if (debug)
+							printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+					}
+					wc->mods[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
 				}
-				wc->mods[card].fxo.ringdebounce = 0;
+			} else {
+				wc->mods[card].fxo.ringdebounce -= ZT_CHUNKSIZE * 4;
+				if (wc->mods[card].fxo.ringdebounce <= 0) {
+					if (wc->mods[card].fxo.wasringing) {
+						wc->mods[card].fxo.wasringing = 0;
+						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+						if (debug)
+							printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+					}
+					wc->mods[card].fxo.ringdebounce = 0;
+				}
+					
 			}
-				
 		}
 	}
 	b = wc->cmdq[card].isrshadow[1]; /* Voltage */
@@ -2096,6 +2123,16 @@
 	reg16 |= (fxo_modes[_opermode].rz << 1);
 	reg16 |= (fxo_modes[_opermode].rt);
 	wctdm_setreg(wc, card, 16, reg16);
+
+	if(fwringdetect) {
+		/* Enable ring detector full-wave rectifier mode */
+		wctdm_setreg(wc, card, 18, 2);
+		wctdm_setreg(wc, card, 24, 0);
+	} else { 
+		/* Set to the device defaults */
+		wctdm_setreg(wc, card, 18, 0);
+		wctdm_setreg(wc, card, 24, 0x19);
+	}
 	
 	/* Set DC Termination:
 	   Tip/Ring voltage adjust, minimum operational current, current limitation */
@@ -4342,6 +4379,7 @@
 module_param(fxstxgain, int, 0600);
 module_param(fxsrxgain, int, 0600);
 module_param(ringdebounce, int, 0600);
+module_param(fwringdetect, int, 0600);
 #ifdef VPM_SUPPORT
 module_param(vpmsupport, int, 0600);
 module_param(vpmdtmfsupport, int, 0600);
@@ -4367,6 +4405,7 @@
 MODULE_PARM(fxstxgain, "i");
 MODULE_PARM(fxsrxgain, "i");
 MODULE_PARM(ringdebounce, "i");
+MODULE_PARM(fwringdetect, "i");
 #ifdef VPM_SUPPORT
 MODULE_PARM(vpmsupport, "i");
 MODULE_PARM(vpmdtmfsupport, "i");

Modified: branches/1.4/wctdm24xxp/wctdm24xxp.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/wctdm24xxp.h?view=diff&rev=3701&r1=3700&r2=3701
==============================================================================
--- branches/1.4/wctdm24xxp/wctdm24xxp.h (original)
+++ branches/1.4/wctdm24xxp/wctdm24xxp.h Thu Jan 17 14:49:05 2008
@@ -217,6 +217,7 @@
 	union {
 		struct {
 			int wasringing;
+			int lastrdtx;
 			int ringdebounce;
 			int offhook;
 			int battdebounce;




More information about the svn-commits mailing list