[Asterisk-cvs] zaptel wct4xxp.c,1.32,1.33

markster at lists.digium.com markster at lists.digium.com
Fri Apr 9 13:18:43 CDT 2004


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

Modified Files:
	wct4xxp.c 
Log Message:
Check once a second for a new timing source (bug #1397)


Index: wct4xxp.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wct4xxp.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- wct4xxp.c	7 Apr 2004 22:44:50 -0000	1.32
+++ wct4xxp.c	9 Apr 2004 17:19:57 -0000	1.33
@@ -143,7 +143,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);
+static void __t4_set_timing_source_auto(struct t4 *wc);
 
 #define WC_RDADDR	0
 #define WC_WRADDR	1
@@ -464,7 +464,9 @@
 		__t4_pci_out(wc, WC_DMACTRL, 0x00000000);
 		/* Acknowledge any pending interrupts */
 		__t4_pci_out(wc, WC_INTR, 0x00000000);
-	}
+		__t4_set_timing_source_auto(wc);
+	} else
+		wc->checktiming = 1;
 	spin_unlock_irqrestore(&wc->reglock, flags);
 	if (debug)
 		printk("Span %d (%s) shutdown\n", span->spanno, span->name);
@@ -629,10 +631,11 @@
 		printk("Successfully initialized serial bus for unit %d\n", unit);
 }
 
-static void t4_set_timing_source(struct t4 *wc, int unit)
+static void __t4_set_timing_source(struct t4 *wc, int unit)
 {
 	unsigned int timing;
 	int x;
+	int updated = 0;
 	wc->checktiming = 0;
 	timing = 0x34;		/* CMR1: RCLK unit, 8.192 Mhz TCLK, RCLK is 8.192 Mhz */
 	if (unit != wc->syncsrc) {
@@ -642,17 +645,14 @@
 			timing |= 0x1;	/* Use TCLK timing */
 		}
 		for (x=0;x<4;x++)
-			t4_framer_out(wc, x, 0x44, timing);
+			__t4_framer_out(wc, x, 0x44, timing);
 		if ((unit > -1) && (unit < 4)) {
-			t4_pci_out(wc, WC_DMACTRL, wc->dmactrl | (1 << 29));
+			__t4_pci_out(wc, WC_DMACTRL, wc->dmactrl | (1 << 29));
 			/* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from proper channel,  */
-			t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit));	
+			__t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit));	
 		} else
-			t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
-		if ((unit > -1) && (unit < 4))
-			printk("TE410P: Timing from span %d\n", unit + 1);
-		else
-			printk("TE410P: Timing from internal timer\n");
+			__t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
+		updated = 1;
 	}
 	wc->syncsrc = unit;
 	if ((unit < 0) || (unit > 3))
@@ -661,9 +661,15 @@
 		unit++;
 	for (x=0;x<4;x++) 
 		wc->spans[x].syncsrc = unit;
+	if (updated) {
+		if (unit)
+			printk("TE410P: Timing from span %d\n", unit);
+		else
+			printk("TE410P: Timing from internal timer\n");
+	}
 }
 
-static void t4_set_timing_source_auto(struct t4 *wc)
+static void __t4_set_timing_source_auto(struct t4 *wc)
 {
 	int x;
 	for (x=0;x<4;x++) {
@@ -671,12 +677,20 @@
 			if ((wc->spans[wc->syncs[x] - 1].flags & ZT_FLAG_RUNNING) && 
 				!(wc->spans[wc->syncs[x] - 1].alarms)) {
 					/* Valid timing sourc e*/
-					t4_set_timing_source(wc, wc->syncs[x] - 1);
+					__t4_set_timing_source(wc, wc->syncs[x] - 1);
 					return;
 			}
 		}
 	}
-	t4_set_timing_source(wc, 4);
+	__t4_set_timing_source(wc, 4);
+}
+
+static void t4_set_timing_source_auto(struct t4 *wc)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&wc->reglock, flags);
+	__t4_set_timing_source_auto(wc);
+	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static void __t4_configure_t1(struct t4 *wc, int unit, int lineconfig, int txlevel)
@@ -1451,10 +1465,14 @@
 		__t4_check_alarms(wc, x - 4);
 		break;
 	}
+	
+	/* periodically check timing */
+	if (!(wc->intcount % (8000/ZT_CHUNKSIZE)))
+		wc->checktiming = 1;
 
-	spin_unlock_irqrestore(&wc->reglock, flags);
 	if (wc->checktiming > 0)
-		t4_set_timing_source_auto(wc);
+		__t4_set_timing_source_auto(wc);
+	spin_unlock_irqrestore(&wc->reglock, flags);
 #ifdef LINUX26
 	return IRQ_RETVAL(1);
 #endif		




More information about the svn-commits mailing list