[Asterisk-cvs] zaptel wct4xxp.c,1.20,1.21

markster at lists.digium.com markster at lists.digium.com
Wed Mar 31 13:56:09 CST 2004


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

Modified Files:
	wct4xxp.c 
Log Message:
Correct the handling of sync sources


Index: wct4xxp.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wct4xxp.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- wct4xxp.c	19 Mar 2004 04:44:03 -0000	1.20
+++ wct4xxp.c	31 Mar 2004 18:54:51 -0000	1.21
@@ -142,6 +142,7 @@
 static int t4_maint(struct zt_span *span, int cmd);
 static int t4_reset_dma(struct t4 *wc);
 static int t4_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data);
+static void t4_set_timing_source_auto(struct t4 *wc);
 
 #define WC_RDADDR	0
 #define WC_WRADDR	1
@@ -480,7 +481,6 @@
 	span->lineconfig = lc->lineconfig;
 	span->txlevel = lc->lbo;
 	span->rxlevel = 0;
-	span->syncsrc = wc->syncsrc;
 	if (lc->sync < 0)
 		lc->sync = 0;
 	if (lc->sync > 4)
@@ -502,6 +502,7 @@
 	/* If we're already running, then go ahead and apply the changes */
 	if (span->flags & ZT_FLAG_RUNNING)
 		return t4_startup(span);
+	t4_set_timing_source_auto(wc);
 	return 0;
 }
 
@@ -644,7 +645,13 @@
 		t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit));	
 	} else
 		t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
-	printk("TE410P: Timing from source %d\n", unit);
+	if (unit != wc->syncsrc) {
+		if ((unit > -1) && (unit < 4))
+			printk("TE410P: Timing from source %d\n", unit);
+		else
+			printk("TE410P: Timing from internal timer\n");
+	}
+	wc->syncsrc = unit;
 }
 
 static void t4_set_timing_source_auto(struct t4 *wc)
@@ -1151,6 +1158,7 @@
 		if (wc->alarmtimer[span]) {
 			if (!--wc->alarmtimer[span]) {
 				wc->spans[span].alarms &= ~(ZT_ALARM_RECOVER);
+				t4_set_timing_source_auto(wc);
 				zt_alarm_notify(&wc->spans[span]);
 			}
 		}
@@ -1160,7 +1168,7 @@
 static void __t4_check_alarms(struct t4 *wc, int span)
 {
 	unsigned char c,d;
-	int alarms;
+	int alarms, oldalarms;
 	int x,j;
 
 	if (!(wc->spans[span].flags & ZT_FLAG_RUNNING))
@@ -1232,8 +1240,9 @@
 	if (c & 0x4)
 		alarms |= ZT_ALARM_BLUE;
 	/* Keep track of recovering */
-	if ((!alarms) && wc->spans[span].alarms)
+	if ((!alarms) && wc->spans[span].alarms) 
 		wc->alarmtimer[span] = ZT_ALARMSETTLE_TIME;
+	
 
 	/* If receiving alarms, go into Yellow alarm state */
 	if (alarms && (!wc->spans[span].alarms)) {
@@ -1274,7 +1283,11 @@
 	if (wc->spans[span].mainttimer || wc->spans[span].maintstat) 
 		alarms |= ZT_ALARM_LOOPBACK;
 
+	oldalarms = wc->spans[span].alarms;
 	wc->spans[span].alarms = alarms;
+	/* Re-check the timing source when we enter alarm */
+	if (!oldalarms && alarms)
+		t4_set_timing_source_auto(wc);
 
 	zt_alarm_notify(&wc->spans[span]);
 }




More information about the svn-commits mailing list