summaryrefslogtreecommitdiff
path: root/wct4xxp.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-03-31 18:54:51 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-03-31 18:54:51 +0000
commitfab2d465b2e6f6001c5371dcd6a5e49f00a369ea (patch)
tree1675274c9b2db6eed353d7389d7e38558d3c0988 /wct4xxp.c
parent1dadd6de6595f902d0aa5ee201f377ef1cc310de (diff)
Correct the handling of sync sources
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@334 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wct4xxp.c')
-rwxr-xr-xwct4xxp.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/wct4xxp.c b/wct4xxp.c
index 474e70f..950b859 100755
--- a/wct4xxp.c
+++ b/wct4xxp.c
@@ -142,6 +142,7 @@ static int t4_rbsbits(struct zt_chan *chan, int bits);
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 @@ static int t4_spanconfig(struct zt_span *span, struct zt_lineconfig *lc)
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 @@ static int t4_spanconfig(struct zt_span *span, struct zt_lineconfig *lc)
/* 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 @@ static void t4_set_timing_source(struct t4 *wc, int unit)
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 @@ static void __t4_do_counters(struct t4 *wc)
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_do_counters(struct t4 *wc)
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 @@ static void __t4_check_alarms(struct t4 *wc, int span)
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 @@ static void __t4_check_alarms(struct t4 *wc, int span)
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]);
}