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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 22 11:11:15 CST 2008


Author: kpfleming
Date: Mon Jan 21 15:51:39 2008
New Revision: 3718

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3718
Log:
Report battery loss on FXO ports of analog cards as a 'red alarm' on the respective channel.

(closes issue #8290)
Reported by: tmarkov
Patches:
      8290-alarm-total_1_4_rev3705 uploaded by meneault
Tested by: flefoll


Modified:
    branches/1.4/wctdm.c
    branches/1.4/wctdm24xxp/base.c
    branches/1.4/zaptel-base.c

Change Statistics:
 0 files changed

Modified: branches/1.4/wctdm.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm.c?view=diff&rev=3718&r1=3717&r2=3718
==============================================================================
--- branches/1.4/wctdm.c (original)
+++ branches/1.4/wctdm.c Mon Jan 21 15:51:39 2008
@@ -862,7 +862,7 @@
 		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 (res && (res != wc->mod[card].fxo.lastrdtx) && (wc->mod[card].fxo.battery == 1)) {
 					if (!wc->mod[card].fxo.wasringing) {
 						wc->mod[card].fxo.wasringing = 1;
 						if (debug)
@@ -879,13 +879,13 @@
 						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
 					}
 				}
-			} else if (res && wc->mod[card].fxo.battery) {
+			} else if (res && (wc->mod[card].fxo.battery == 1)) {
 				wc->mod[card].fxo.lastrdtx = res;
 				wc->mod[card].fxo.ringdebounce = 10;
 			}
 		} else {
 			res = wc->reg0shadow[card];
-			if ((res & 0x60) && wc->mod[card].fxo.battery) {
+			if ((res & 0x60) && (wc->mod[card].fxo.battery == 1)) {
 				wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
 				if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
 					if (!wc->mod[card].fxo.wasringing) {
@@ -924,7 +924,7 @@
 	if (abs(b) < battthresh) {
 		wc->mod[card].fxo.nobatttimer++;
 #if 0
-		if (wc->mod[card].fxo.battery)
+		if (wc->mod[card].fxo.battery == 1)
 			printk("Battery loss: %d (%d debounce)\n", b, wc->mod[card].fxo.battdebounce);
 #endif
 		if (wc->mod[card].fxo.battery && !wc->mod[card].fxo.battdebounce) {
@@ -942,12 +942,13 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+			zt_alarm_channel(&wc->chans[card], ZT_ALARM_RED);
 #endif
 			wc->mod[card].fxo.battdebounce = battdebounce;
 		} else if (!wc->mod[card].fxo.battery)
 			wc->mod[card].fxo.battdebounce = battdebounce;
 	} else if (abs(b) > battthresh) {
-		if (!wc->mod[card].fxo.battery && !wc->mod[card].fxo.battdebounce) {
+		if ((wc->mod[card].fxo.battery < 1) && !wc->mod[card].fxo.battdebounce) {
 			if (debug)
 				printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1, 
 					(b < 0) ? "-" : "+");			    
@@ -960,11 +961,12 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+			zt_alarm_channel(&wc->chans[card], ZT_ALARM_NONE);
 #endif
 			wc->mod[card].fxo.battery = 1;
 			wc->mod[card].fxo.nobatttimer = 0;
 			wc->mod[card].fxo.battdebounce = battdebounce;
-		} else if (wc->mod[card].fxo.battery)
+		} else if (wc->mod[card].fxo.battery == 1)
 			wc->mod[card].fxo.battdebounce = battdebounce;
 
 		if (wc->mod[card].fxo.lastpol >= 0) {
@@ -1605,6 +1607,9 @@
 	if(debug)
 		printk("DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16)?-(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16)? -(wctdm_getreg(wc, card, 40) - 16):wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16)? -(wctdm_getreg(wc, card, 39) - 16) : wctdm_getreg(wc, card, 39),(wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16):wctdm_getreg(wc, card, 41));
 
+	/* battery state still unknown */
+	wc->mod[card].fxo.battery = -1;
+	
 	return 0;
 		
 }
@@ -1617,16 +1622,16 @@
 	int x;
 	int fxsmode=0;
 
+	/* Sanity check the ProSLIC */
+	if (!sane && wctdm_proslic_insane(wc, card))
+		return -2;
+		
 	/* By default, don't send on hook */
 	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))
-		return -2;
-		
 	if (sane) {
 		/* Make sure we turn off the DC->DC converter to prevent anything from blowing up */
 		wctdm_setreg(wc, card, 14, 0x10);

Modified: branches/1.4/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/base.c?view=diff&rev=3718&r1=3717&r2=3718
==============================================================================
--- branches/1.4/wctdm24xxp/base.c (original)
+++ branches/1.4/wctdm24xxp/base.c Mon Jan 21 15:51:39 2008
@@ -1332,7 +1332,7 @@
 		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 (res && (res != wc->mods[card].fxo.lastrdtx) && (wc->mods[card].fxo.battery == 1)) {
 					if (!wc->mods[card].fxo.wasringing) {
 						wc->mods[card].fxo.wasringing = 1;
 						if (debug)
@@ -1349,13 +1349,13 @@
 						zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
 					}
 				}
-			} else if (res && wc->mods[card].fxo.battery) {
+			} else if (res && (wc->mods[card].fxo.battery == 1)) {
 				wc->mods[card].fxo.lastrdtx = res;
 				wc->mods[card].fxo.ringdebounce = 10;
 			}
 		} else {
 			res =  wc->cmdq[card].isrshadow[0];
-			if ((res & 0x60) && wc->mods[card].fxo.battery) {
+			if ((res & 0x60) && (wc->mods[card].fxo.battery == 1)) {
 				wc->mods[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 16);
 				if (wc->mods[card].fxo.ringdebounce >= ZT_CHUNKSIZE * ringdebounce) {
 					if (!wc->mods[card].fxo.wasringing) {
@@ -1393,7 +1393,7 @@
 	if (abs(b) < battthresh) {
 		wc->mods[card].fxo.nobatttimer++;
 #if 0
-		if (wc->mods[card].fxo.battery)
+		if (wc->mods[card].fxo.battery == 1)
 			printk("Battery loss: %d (%d debounce)\n", b, wc->mods[card].fxo.battdebounce);
 #endif
 		if (wc->mods[card].fxo.battery && !wc->mods[card].fxo.battdebounce) {
@@ -1411,12 +1411,13 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+			zt_alarm_channel(&wc->chans[card], ZT_ALARM_RED);
 #endif
 			wc->mods[card].fxo.battdebounce = battdebounce;
 		} else if (!wc->mods[card].fxo.battery)
 			wc->mods[card].fxo.battdebounce = battdebounce;
 	} else if (abs(b) > battthresh) {
-		if (!wc->mods[card].fxo.battery && !wc->mods[card].fxo.battdebounce) {
+		if ((wc->mods[card].fxo.battery < 1) && !wc->mods[card].fxo.battdebounce) {
 			if (debug & DEBUG_CARD)
 				printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1, 
 					(b < 0) ? "-" : "+");			    
@@ -1429,11 +1430,12 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+			zt_alarm_channel(&wc->chans[card], ZT_ALARM_NONE);
 #endif
 			wc->mods[card].fxo.battery = 1;
 			wc->mods[card].fxo.nobatttimer = 0;
 			wc->mods[card].fxo.battdebounce = battdebounce;
-		} else if (wc->mods[card].fxo.battery)
+		} else if (wc->mods[card].fxo.battery == 1)
 			wc->mods[card].fxo.battdebounce = battdebounce;
 
 		if (wc->mods[card].fxo.lastpol >= 0) {
@@ -2183,6 +2185,9 @@
 	if(debug)
 		printk("DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16) ? -(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16) ? -(wctdm_getreg(wc, card, 40) - 16) : wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16) ? -(wctdm_getreg(wc, card, 39) - 16): wctdm_getreg(wc, card, 39), (wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16) : wctdm_getreg(wc, card, 41));
 	
+	/* battery state still unknown */
+	wc->mods[card].fxo.battery = -1;
+
 	return 0;
 		
 }
@@ -2197,14 +2202,14 @@
 
 	if (wc->modtype[card & 0xfc] == MOD_TYPE_QRV) return -2;
 
+	/* Sanity check the ProSLIC */
+	if (!sane && wctdm_proslic_insane(wc, card))
+		return -2;
+
 	/* By default, don't send on hook */
 	wc->mods[card].fxs.idletxhookstate = 1;
 	wc->mods[card].fxs.lasttxhook = 0x10;
 
-	/* Sanity check the ProSLIC */
-	if (!sane && wctdm_proslic_insane(wc, card))
-		return -2;
-		
 	if (sane) {
 		/* Make sure we turn off the DC->DC converter to prevent anything from blowing up */
 		wctdm_setreg(wc, card, 14, 0x10);

Modified: branches/1.4/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel-base.c?view=diff&rev=3718&r1=3717&r2=3718
==============================================================================
--- branches/1.4/zaptel-base.c (original)
+++ branches/1.4/zaptel-base.c Mon Jan 21 15:51:39 2008
@@ -2899,10 +2899,14 @@
 
 void zt_alarm_channel(struct zt_chan *chan, int alarms)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&chan->lock, flags);
 	if (chan->chan_alarms != alarms) {
 		chan->chan_alarms = alarms;
-		zt_qevent_lock(chan, alarms ? ZT_EVENT_ALARM : ZT_EVENT_NOALARM);
-	}
+		zt_qevent_nolock(chan, alarms ? ZT_EVENT_ALARM : ZT_EVENT_NOALARM);
+	}
+	spin_unlock_irqrestore(&chan->lock, flags);
 }
 
 void zt_alarm_notify(struct zt_span *span)




More information about the svn-commits mailing list