[svn-commits] kpfleming: branch 1.4 r3674 - in /branches/1.4: ./ wctdm24xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jan 11 17:37:38 CST 2008


Author: kpfleming
Date: Fri Jan 11 17:37:37 2008
New Revision: 3674

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3674
Log:
Improve ring detection when polarity reversals are present.

(closes issue #9264)
Reported by: mjagdis
Patches:
      zaptel-ring.diff uploaded by mjagdis (modified by me to add support in wctdm24xxp as well)
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=3674&r1=3673&r2=3674
==============================================================================
--- branches/1.4/wctdm.c (original)
+++ branches/1.4/wctdm.c Fri Jan 11 17:37:37 2008
@@ -1,5 +1,5 @@
 /*
- * Wilcard TDM400P TDM FXS/FXO Interface Driver for Zapata Telephony interface
+ * Wildcard TDM400P TDM FXS/FXO Interface Driver for Zapata Telephony interface
  *
  * Written by Mark Spencer <markster at digium.com>
  *            Matthew Fredrickson <creslin at digium.com>
@@ -312,6 +312,7 @@
 #else			
 			int wasringing;
 #endif			
+			int lastrdtx;
 			int ringdebounce;
 			int offhook;
 			int battdebounce;
@@ -857,30 +858,28 @@
 		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) {
+		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;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
 					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.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
-			}
-		} 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.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;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
 					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 = 0;
 			}
-				
+		} else if (res && wc->mod[card].fxo.battery) {
+			wc->mod[card].fxo.lastrdtx = res;
+			wc->mod[card].fxo.ringdebounce = 10;
 		}
 	}
 #endif
@@ -1505,6 +1504,10 @@
 	reg16 |= (fxo_modes[_opermode].rz << 1);
 	reg16 |= (fxo_modes[_opermode].rt);
 	wctdm_setreg(wc, card, 16, reg16);
+
+	/* Enable ring detector full-wave rectifier mode */
+	wctdm_setreg(wc, card, 18, 2);
+	wctdm_setreg(wc, card, 24, 0);
 	
 	/* Set DC Termination:
 	   Tip/Ring voltage adjust, minimum operational current, current limitation */

Modified: branches/1.4/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/base.c?view=diff&rev=3674&r1=3673&r2=3674
==============================================================================
--- branches/1.4/wctdm24xxp/base.c (original)
+++ branches/1.4/wctdm24xxp/base.c Fri Jan 11 17:37:37 2008
@@ -1327,33 +1327,33 @@
 		if (b != 0x8)
 			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.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);
-					if (debug & DEBUG_CARD)
-						printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
 				}
-				wc->mods[card].fxo.ringdebounce = ZT_CHUNKSIZE * ringdebounce;
+				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);
+				}
 			}
-		} 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);
-				}
-				wc->mods[card].fxo.ringdebounce = 0;
-			}
-				
-		}
-	}
+		} else if (res && wc->mods[card].fxo.battery) {
+			wc->mods[card].fxo.lastrdtx = res;
+			wc->mods[card].fxo.ringdebounce = 10;
+		}
+	}
+
 	b = wc->cmdq[card].isrshadow[1]; /* Voltage */
 
 	if (fxovoltage) {
@@ -2096,6 +2096,10 @@
 	reg16 |= (fxo_modes[_opermode].rz << 1);
 	reg16 |= (fxo_modes[_opermode].rt);
 	wctdm_setreg(wc, card, 16, reg16);
+	
+	/* Enable ring detector full-wave rectifier mode */
+	wctdm_setreg(wc, card, 18, 2);
+	wctdm_setreg(wc, card, 24, 0);
 	
 	/* Set DC Termination:
 	   Tip/Ring voltage adjust, minimum operational current, current limitation */

Modified: branches/1.4/wctdm24xxp/wctdm24xxp.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/wctdm24xxp.h?view=diff&rev=3674&r1=3673&r2=3674
==============================================================================
--- branches/1.4/wctdm24xxp/wctdm24xxp.h (original)
+++ branches/1.4/wctdm24xxp/wctdm24xxp.h Fri Jan 11 17:37:37 2008
@@ -225,6 +225,7 @@
 			int lastpol;
 			int polarity;
 			int polaritydebounce;
+			int lastrdtx;
 		} fxo;
 		struct {
 			int oldrxhook;




More information about the svn-commits mailing list