summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-07-27 22:26:55 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-07-27 22:26:55 +0000
commit02baa6db8e92ae755f7b49a39dbdbe0a991e2601 (patch)
tree459c102a01e8bc6d1c3f2fcffd7893f13114518b
parent4c061ca58bf7cbedb5d4079a056734c02b9fef27 (diff)
make memory layout of private structures a little more sensible
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@711 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xwctdm.c318
1 files changed, 162 insertions, 156 deletions
diff --git a/wctdm.c b/wctdm.c
index ed73f3e..463c36f 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -292,42 +292,41 @@ struct wctdm {
int freeregion;
int alt;
int curcard;
- int cards;
+/* int cards; */
int cardflag; /* Bit-map of present cards */
spinlock_t lock;
- /* FXO Stuff */
union {
struct {
#ifdef AUDIO_RINGCHECK
- unsigned int pegtimer[NUM_CARDS];
- int pegcount[NUM_CARDS];
- int peg[NUM_CARDS];
- int ring[NUM_CARDS];
+ unsigned int pegtimer;
+ int pegcount;
+ int peg;
+ int ring;
#else
- int wasringing[NUM_CARDS];
+ int wasringing;
#endif
- int ringdebounce[NUM_CARDS];
- int offhook[NUM_CARDS];
- int battdebounce[NUM_CARDS];
- int nobatttimer[NUM_CARDS];
- int battery[NUM_CARDS];
- int lastpol[NUM_CARDS];
- int polarity[NUM_CARDS];
- int polaritydebounce[NUM_CARDS];
+ int ringdebounce;
+ int offhook;
+ int battdebounce;
+ int nobatttimer;
+ int battery;
+ int lastpol;
+ int polarity;
+ int polaritydebounce;
} fxo;
struct {
- int oldrxhook[NUM_CARDS];
- int debouncehook[NUM_CARDS];
- int lastrxhook[NUM_CARDS];
- int debounce[NUM_CARDS];
- int ohttimer[NUM_CARDS];
- int idletxhookstate[NUM_CARDS]; /* IDLE changing hook state */
- int lasttxhook[NUM_CARDS];
- int palarms[NUM_CARDS];
- struct calregs calregs[NUM_CARDS];
+ int oldrxhook;
+ int debouncehook;
+ int lastrxhook;
+ int debounce;
+ int ohttimer;
+ int idletxhookstate; /* IDLE changing hook state */
+ int lasttxhook;
+ int palarms;
+ struct calregs calregs;
} fxs;
- } mod;
+ } mod[NUM_CARDS];
/* Receive hook state and debouncing */
int modtype[NUM_CARDS];
@@ -415,46 +414,46 @@ static inline void ring_check(struct wctdm *wc, int card)
short sample;
if (wc->modtype[card] != MOD_TYPE_FXO)
return;
- wc->mod.fxo.pegtimer[card] += ZT_CHUNKSIZE;
+ wc->mod[card].fxo.pegtimer += ZT_CHUNKSIZE;
for (x=0;x<ZT_CHUNKSIZE;x++) {
/* Look for pegging to indicate ringing */
sample = ZT_XLAW(wc->chans[card].readchunk[x], (&(wc->chans[card])));
- if ((sample > 10000) && (wc->mod.fxo.peg[card] != 1)) {
+ if ((sample > 10000) && (wc->mod[card].fxo.peg != 1)) {
if (debug > 1) printk("High peg!\n");
- if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME))
- wc->mod.fxo.pegcount[card]++;
- wc->mod.fxo.pegtimer[card] = 0;
- wc->mod.fxo.peg[card] = 1;
- } else if ((sample < -10000) && (wc->mod.fxo.peg[card] != -1)) {
+ if ((wc->mod[card].fxo.pegtimer < PEGTIME) && (wc->mod[card].fxo.pegtimer > MINPEGTIME))
+ wc->mod[card].fxo.pegcount++;
+ wc->mod[card].fxo.pegtimer = 0;
+ wc->mod[card].fxo.peg = 1;
+ } else if ((sample < -10000) && (wc->mod[card].fxo.peg != -1)) {
if (debug > 1) printk("Low peg!\n");
- if ((wc->mod.fxo.pegtimer[card] < (PEGTIME >> 2)) && (wc->mod.fxo.pegtimer[card] > (MINPEGTIME >> 2)))
- wc->mod.fxo.pegcount[card]++;
- wc->mod.fxo.pegtimer[card] = 0;
- wc->mod.fxo.peg[card] = -1;
+ if ((wc->mod[card].fxo.pegtimer < (PEGTIME >> 2)) && (wc->mod[card].fxo.pegtimer > (MINPEGTIME >> 2)))
+ wc->mod[card].fxo.pegcount++;
+ wc->mod[card].fxo.pegtimer = 0;
+ wc->mod[card].fxo.peg = -1;
}
}
- if (wc->mod.fxo.pegtimer[card] > PEGTIME) {
+ if (wc->mod[card].fxo.pegtimer > PEGTIME) {
/* Reset pegcount if our timer expires */
- wc->mod.fxo.pegcount[card] = 0;
+ wc->mod[card].fxo.pegcount = 0;
}
/* Decrement debouncer if appropriate */
- if (wc->mod.fxo.ringdebounce[card])
- wc->mod.fxo.ringdebounce[card]--;
- if (!wc->mod.fxo.offhook[card] && !wc->mod.fxo.ringdebounce[card]) {
- if (!wc->mod.fxo.ring[card] && (wc->mod.fxo.pegcount[card] > PEGCOUNT)) {
+ if (wc->mod[card].fxo.ringdebounce)
+ wc->mod[card].fxo.ringdebounce--;
+ if (!wc->mod[card].fxo.offhook && !wc->mod[card].fxo.ringdebounce) {
+ if (!wc->mod[card].fxo.ring && (wc->mod[card].fxo.pegcount > PEGCOUNT)) {
/* It's ringing */
if (debug)
printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
- if (!wc->mod.fxo.offhook[card])
+ if (!wc->mod[card].fxo.offhook)
zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
- wc->mod.fxo.ring[card] = 1;
+ wc->mod[card].fxo.ring = 1;
}
- if (wc->mod.fxo.ring[card] && !wc->mod.fxo.pegcount[card]) {
+ if (wc->mod[card].fxo.ring && !wc->mod[card].fxo.pegcount) {
/* No more ring */
if (debug)
printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
- wc->mod.fxo.ring[card] = 0;
+ wc->mod[card].fxo.ring = 0;
}
}
}
@@ -495,7 +494,7 @@ static inline void wctdm_receiveprep(struct wctdm *wc, unsigned char ints)
ring_check(wc, x);
#endif
/* XXX We're wasting 8 taps. We should get closer :( */
- for (x=0;x<wc->cards;x++) {
+ for (x = 0; x < NUM_CARDS; x++) {
if (wc->cardflag & (1 << x))
zt_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, wc->chans[x].writechunk);
}
@@ -802,14 +801,14 @@ static inline void wctdm_proslic_recheck_sanity(struct wctdm *wc, int card)
wctdm_init_proslic(wc, card, 1, 0, 1);
} else {
res = wctdm_getreg(wc, card, 64);
- if (!res && (res != wc->mod.fxs.lasttxhook[card])) {
- if (wc->mod.fxs.palarms[card]++ < MAX_ALARMS) {
+ if (!res && (res != wc->mod[card].fxs.lasttxhook)) {
+ if (wc->mod[card].fxs.palarms++ < MAX_ALARMS) {
printk("Power alarm on module %d, resetting!\n", card + 1);
- if (wc->mod.fxs.lasttxhook[card] == 4)
- wc->mod.fxs.lasttxhook[card] = 1;
- wctdm_setreg(wc, card, 64, wc->mod.fxs.lasttxhook[card]);
+ if (wc->mod[card].fxs.lasttxhook == 4)
+ wc->mod[card].fxs.lasttxhook = 1;
+ wctdm_setreg(wc, card, 64, wc->mod[card].fxs.lasttxhook);
} else {
- if (wc->mod.fxs.palarms[card] == MAX_ALARMS)
+ if (wc->mod[card].fxs.palarms == MAX_ALARMS)
printk("Too many power alarms on card %d, NOT resetting!\n", card + 1);
}
}
@@ -832,7 +831,7 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
poopy++;
}
b &= 0x9b;
- if (wc->mod.fxo.offhook[card]) {
+ if (wc->mod[card].fxo.offhook) {
if (b != 0x9)
wctdm_setreg(wc, card, 5, 0x9);
} else {
@@ -842,29 +841,29 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
if (poopy)
return;
#ifndef AUDIO_RINGCHECK
- if (!wc->mod.fxo.offhook[card]) {
+ if (!wc->mod[card].fxo.offhook) {
res = wctdm_getreg(wc, card, 5);
- if ((res & 0x60) && wc->mod.fxo.battery[card]) {
- wc->mod.fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4);
- if (wc->mod.fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 64) {
- if (!wc->mod.fxo.wasringing[card]) {
- wc->mod.fxo.wasringing[card] = 1;
+ if ((res & 0x60) && wc->mod[card].fxo.battery) {
+ wc->mod[card].fxo.ringdebounce += (ZT_CHUNKSIZE * 4);
+ if (wc->mod[card].fxo.ringdebounce >= ZT_CHUNKSIZE * 64) {
+ 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);
}
- wc->mod.fxo.ringdebounce[card] = ZT_CHUNKSIZE * 64;
+ wc->mod[card].fxo.ringdebounce = ZT_CHUNKSIZE * 64;
}
} else {
- wc->mod.fxo.ringdebounce[card] -= ZT_CHUNKSIZE;
- if (wc->mod.fxo.ringdebounce[card] <= 0) {
- if (wc->mod.fxo.wasringing[card]) {
- wc->mod.fxo.wasringing[card] =0;
+ wc->mod[card].fxo.ringdebounce -= ZT_CHUNKSIZE;
+ if (wc->mod[card].fxo.ringdebounce <= 0) {
+ if (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);
}
- wc->mod.fxo.ringdebounce[card] = 0;
+ wc->mod[card].fxo.ringdebounce = 0;
}
}
@@ -876,20 +875,20 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
static int count = 0;
if (!(count++ % 100)) {
printk("Card %d: Voltage: %d Debounce %d\n", card + 1,
- b, wc->mod.fxo.battdebounce[card]);
+ b, wc->mod[card].fxo.battdebounce);
}
}
#endif
if (abs(b) < battthresh) {
- wc->mod.fxo.nobatttimer[card]++;
+ wc->mod[card].fxo.nobatttimer++;
#if 0
- if (wc->mod.fxo.battery[card])
- printk("Battery loss: %d (%d debounce)\n", b, wc->mod.fxo.battdebounce[card]);
+ if (wc->mod[card].fxo.battery)
+ printk("Battery loss: %d (%d debounce)\n", b, wc->mod[card].fxo.battdebounce);
#endif
- if (wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
+ if (wc->mod[card].fxo.battery && !wc->mod[card].fxo.battdebounce) {
if (debug)
printk("NO BATTERY on %d/%d!\n", wc->span.spanno, card + 1);
- wc->mod.fxo.battery[card] = 0;
+ wc->mod[card].fxo.battery = 0;
#ifdef JAPAN
if ((!wc->ohdebounce) && wc->offhook) {
zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
@@ -902,11 +901,11 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
#else
zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
#endif
- wc->mod.fxo.battdebounce[card] = battdebounce;
- } else if (!wc->mod.fxo.battery[card])
- wc->mod.fxo.battdebounce[card] = battdebounce;
+ 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.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
+ if (!wc->mod[card].fxo.battery && !wc->mod[card].fxo.battdebounce) {
if (debug)
printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1,
(b < 0) ? "-" : "+");
@@ -920,41 +919,41 @@ static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
#else
zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
#endif
- wc->mod.fxo.battery[card] = 1;
- wc->mod.fxo.nobatttimer[card] = 0;
- wc->mod.fxo.battdebounce[card] = battdebounce;
- } else if (wc->mod.fxo.battery[card])
- wc->mod.fxo.battdebounce[card] = battdebounce;
+ 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)
+ wc->mod[card].fxo.battdebounce = battdebounce;
- if (wc->mod.fxo.lastpol[card] >= 0) {
+ if (wc->mod[card].fxo.lastpol >= 0) {
if (b < 0) {
- wc->mod.fxo.lastpol[card] = -1;
- wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
+ wc->mod[card].fxo.lastpol = -1;
+ wc->mod[card].fxo.polaritydebounce = POLARITY_DEBOUNCE;
}
}
- if (wc->mod.fxo.lastpol[card] <= 0) {
+ if (wc->mod[card].fxo.lastpol <= 0) {
if (b > 0) {
- wc->mod.fxo.lastpol[card] = 1;
- wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
+ wc->mod[card].fxo.lastpol = 1;
+ wc->mod[card].fxo.polaritydebounce = POLARITY_DEBOUNCE;
}
}
} else {
/* It's something else... */
- wc->mod.fxo.battdebounce[card] = battdebounce;
- }
- if (wc->mod.fxo.battdebounce[card])
- wc->mod.fxo.battdebounce[card]--;
- if (wc->mod.fxo.polaritydebounce[card]) {
- wc->mod.fxo.polaritydebounce[card]--;
- if (wc->mod.fxo.polaritydebounce[card] < 1) {
- if (wc->mod.fxo.lastpol[card] != wc->mod.fxo.polarity[card]) {
+ wc->mod[card].fxo.battdebounce = battdebounce;
+ }
+ if (wc->mod[card].fxo.battdebounce)
+ wc->mod[card].fxo.battdebounce--;
+ if (wc->mod[card].fxo.polaritydebounce) {
+ wc->mod[card].fxo.polaritydebounce--;
+ if (wc->mod[card].fxo.polaritydebounce < 1) {
+ if (wc->mod[card].fxo.lastpol != wc->mod[card].fxo.polarity) {
if (debug)
printk("%lu Polarity reversed (%d -> %d)\n", jiffies,
- wc->mod.fxo.polarity[card],
- wc->mod.fxo.lastpol[card]);
- if (wc->mod.fxo.polarity[card])
+ wc->mod[card].fxo.polarity,
+ wc->mod[card].fxo.lastpol);
+ if (wc->mod[card].fxo.polarity)
zt_qevent_lock(&wc->chans[card], ZT_EVENT_POLARITY);
- wc->mod.fxo.polarity[card] = wc->mod.fxo.lastpol[card];
+ wc->mod[card].fxo.polarity = wc->mod[card].fxo.lastpol;
}
}
}
@@ -970,25 +969,25 @@ static inline void wctdm_proslic_check_hook(struct wctdm *wc, int card)
res = wctdm_getreg(wc, card, 68);
hook = (res & 1);
- if (hook != wc->mod.fxs.lastrxhook[card]) {
+ if (hook != wc->mod[card].fxs.lastrxhook) {
/* Reset the debounce (must be multiple of 4ms) */
- wc->mod.fxs.debounce[card] = 8 * (4 * 8);
+ wc->mod[card].fxs.debounce = 8 * (4 * 8);
#if 0
- printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->mod.fxs.debounce[card]);
+ printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->mod[card].fxs.debounce);
#endif
} else {
- if (wc->mod.fxs.debounce[card] > 0) {
- wc->mod.fxs.debounce[card]-= 4 * ZT_CHUNKSIZE;
+ if (wc->mod[card].fxs.debounce > 0) {
+ wc->mod[card].fxs.debounce-= 4 * ZT_CHUNKSIZE;
#if 0
- printk("Sustaining hook %d, %d\n", hook, wc->mod.fxs.debounce[card]);
+ printk("Sustaining hook %d, %d\n", hook, wc->mod[card].fxs.debounce);
#endif
- if (!wc->mod.fxs.debounce[card]) {
+ if (!wc->mod[card].fxs.debounce) {
#if 0
printk("Counted down debounce, newhook: %d...\n", hook);
#endif
- wc->mod.fxs.debouncehook[card] = hook;
+ wc->mod[card].fxs.debouncehook = hook;
}
- if (!wc->mod.fxs.oldrxhook[card] && wc->mod.fxs.debouncehook[card]) {
+ if (!wc->mod[card].fxs.oldrxhook && wc->mod[card].fxs.debouncehook) {
/* Off hook */
#if 1
if (debug)
@@ -997,20 +996,20 @@ static inline void wctdm_proslic_check_hook(struct wctdm *wc, int card)
zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
if (robust)
wctdm_init_proslic(wc, card, 1, 0, 1);
- wc->mod.fxs.oldrxhook[card] = 1;
+ wc->mod[card].fxs.oldrxhook = 1;
- } else if (wc->mod.fxs.oldrxhook[card] && !wc->mod.fxs.debouncehook[card]) {
+ } else if (wc->mod[card].fxs.oldrxhook && !wc->mod[card].fxs.debouncehook) {
/* On hook */
#if 1
if (debug)
#endif
printk("wctdm: Card %d Going on hook\n", card);
zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
- wc->mod.fxs.oldrxhook[card] = 0;
+ wc->mod[card].fxs.oldrxhook = 0;
}
}
}
- wc->mod.fxs.lastrxhook[card] = hook;
+ wc->mod[card].fxs.lastrxhook = hook;
}
#ifdef LINUX26
@@ -1054,21 +1053,21 @@ static void wctdm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
}
for (x=0;x<4;x++) {
- if ((x < wc->cards) && (wc->cardflag & (1 << x)) &&
- (wc->modtype[x] == MOD_TYPE_FXS)) {
- if (wc->mod.fxs.lasttxhook[x] == 0x4) {
+ if (wc->cardflag & (1 << x) &&
+ (wc->modtype[x] == MOD_TYPE_FXS)) {
+ if (wc->mod[x].fxs.lasttxhook == 0x4) {
/* RINGing, prepare for OHT */
- wc->mod.fxs.ohttimer[x] = OHT_TIMER << 3;
- wc->mod.fxs.idletxhookstate[x] = 0x2; /* OHT mode when idle */
+ wc->mod[x].fxs.ohttimer = OHT_TIMER << 3;
+ wc->mod[x].fxs.idletxhookstate = 0x2; /* OHT mode when idle */
} else {
- if (wc->mod.fxs.ohttimer[x]) {
- wc->mod.fxs.ohttimer[x]-= ZT_CHUNKSIZE;
- if (!wc->mod.fxs.ohttimer[x]) {
- wc->mod.fxs.idletxhookstate[x] = 0x1; /* Switch to active */
- if (wc->mod.fxs.lasttxhook[x] == 0x2) {
+ if (wc->mod[x].fxs.ohttimer) {
+ wc->mod[x].fxs.ohttimer-= ZT_CHUNKSIZE;
+ if (!wc->mod[x].fxs.ohttimer) {
+ wc->mod[x].fxs.idletxhookstate = 0x1; /* Switch to active */
+ if (wc->mod[x].fxs.lasttxhook == 0x2) {
/* Apply the change if appropriate */
- wc->mod.fxs.lasttxhook[x] = 0x1;
- wctdm_setreg(wc, x, 64, wc->mod.fxs.lasttxhook[x]);
+ wc->mod[x].fxs.lasttxhook = 0x1;
+ wctdm_setreg(wc, x, 64, wc->mod[x].fxs.lasttxhook);
}
}
}
@@ -1079,7 +1078,7 @@ static void wctdm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
if (ints & 0x0f) {
wc->intcount++;
x = wc->intcount % 4;
- if ((x < wc->cards) && (wc->cardflag & (1 << x))) {
+ if (wc->cardflag & (1 << x)) {
if (wc->modtype[x] == MOD_TYPE_FXS) {
wctdm_proslic_check_hook(wc, x);
if (!(wc->intcount & 0xfc))
@@ -1092,8 +1091,8 @@ static void wctdm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/* Accept an alarm once per 10 seconds */
for (x=0;x<4;x++)
if (wc->modtype[x] == MOD_TYPE_FXS) {
- if (wc->mod.fxs.palarms[x])
- wc->mod.fxs.palarms[x]--;
+ if (wc->mod[x].fxs.palarms)
+ wc->mod[x].fxs.palarms--;
}
}
wctdm_receiveprep(wc, ints);
@@ -1475,7 +1474,7 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual,
int fxsmode=0;
/* By default, don't send on hook */
- wc->mod.fxs.idletxhookstate [card] = 1;
+ wc->mod[card].fxs.idletxhookstate = 1;
/* Sanity check the ProSLIC */
if (!sane && wctdm_proslic_insane(wc, card))
@@ -1563,13 +1562,13 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual,
/* Save calibration vectors */
for (x=0;x<NUM_CAL_REGS;x++)
- wc->mod.fxs.calregs[card].vals[x] = wctdm_getreg(wc, card, 96 + x);
+ wc->mod[card].fxs.calregs.vals[x] = wctdm_getreg(wc, card, 96 + x);
#endif
} else {
/* Restore calibration registers */
for (x=0;x<NUM_CAL_REGS;x++)
- wctdm_setreg(wc, card, 96 + x, wc->mod.fxs.calregs[card].vals[x]);
+ wctdm_setreg(wc, card, 96 + x, wc->mod[card].fxs.calregs.vals[x]);
}
/* Calibration complete, restore original values */
for (x=0;x<5;x++) {
@@ -1662,12 +1661,12 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
return -EINVAL;
if (get_user(x, (int *)data))
return -EFAULT;
- wc->mod.fxs.ohttimer[chan->chanpos - 1] = x << 3;
- wc->mod.fxs.idletxhookstate[chan->chanpos - 1] = 0x2; /* OHT mode when idle */
- if (wc->mod.fxs.lasttxhook[chan->chanpos - 1] == 0x1) {
+ wc->mod[chan->chanpos - 1].fxs.ohttimer = x << 3;
+ wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 0x2; /* OHT mode when idle */
+ if (wc->mod[chan->chanpos - 1].fxs.lasttxhook == 0x1) {
/* Apply the change if appropriate */
- wc->mod.fxs.lasttxhook[chan->chanpos - 1] = 0x2;
- wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
+ wc->mod[chan->chanpos - 1].fxs.lasttxhook = 0x2;
+ wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod[chan->chanpos - 1].fxs.lasttxhook);
}
break;
case ZT_SETPOLARITY:
@@ -1676,15 +1675,15 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
return -EINVAL;
/* Can't change polarity while ringing or when open */
- if ((wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x04) ||
- (wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x00))
+ if ((wc->mod[chan->chanpos -1 ].fxs.lasttxhook == 0x04) ||
+ (wc->mod[chan->chanpos -1 ].fxs.lasttxhook == 0x00))
return -EINVAL;
if (x)
- wc->mod.fxs.lasttxhook[chan->chanpos - 1] |= 0x04;
+ wc->mod[chan->chanpos - 1].fxs.lasttxhook |= 0x04;
else
- wc->mod.fxs.lasttxhook[chan->chanpos - 1] &= ~0x04;
- wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
+ wc->mod[chan->chanpos - 1].fxs.lasttxhook &= ~0x04;
+ wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod[chan->chanpos - 1].fxs.lasttxhook);
break;
case WCTDM_GET_STATS:
if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
@@ -1795,7 +1794,7 @@ static int wctdm_close(struct zt_chan *chan)
module_put(THIS_MODULE);
#endif
if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS)
- wc->mod.fxs.idletxhookstate[chan->chanpos - 1] = 1;
+ wc->mod[chan->chanpos - 1].fxs.idletxhookstate = 1;
/* If we're dead, release us now */
if (!wc->usecount && wc->dead)
@@ -1812,11 +1811,11 @@ static int wctdm_hooksig(struct zt_chan *chan, zt_txsig_t txsig)
switch(txsig) {
case ZT_TXSIG_START:
case ZT_TXSIG_OFFHOOK:
- wc->mod.fxo.offhook[chan->chanpos - 1] = 1;
+ wc->mod[chan->chanpos - 1].fxo.offhook = 1;
wctdm_setreg(wc, chan->chanpos - 1, 5, 0x9);
break;
case ZT_TXSIG_ONHOOK:
- wc->mod.fxo.offhook[chan->chanpos - 1] = 0;
+ wc->mod[chan->chanpos - 1].fxo.offhook = 0;
wctdm_setreg(wc, chan->chanpos - 1, 5, 0x8);
break;
default:
@@ -1829,28 +1828,28 @@ static int wctdm_hooksig(struct zt_chan *chan, zt_txsig_t txsig)
case ZT_SIG_EM:
case ZT_SIG_FXOKS:
case ZT_SIG_FXOLS:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = wc->mod.fxs.idletxhookstate[chan->chanpos-1];
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = wc->mod[chan->chanpos-1].fxs.idletxhookstate;
break;
case ZT_SIG_FXOGS:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = 3;
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = 3;
break;
}
break;
case ZT_TXSIG_OFFHOOK:
switch(chan->sig) {
case ZT_SIG_EM:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = 5;
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = 5;
break;
default:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = wc->mod.fxs.idletxhookstate[chan->chanpos-1];
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = wc->mod[chan->chanpos-1].fxs.idletxhookstate;
break;
}
break;
case ZT_TXSIG_START:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = 4;
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = 4;
break;
case ZT_TXSIG_KEWL:
- wc->mod.fxs.lasttxhook[chan->chanpos-1] = 0;
+ wc->mod[chan->chanpos-1].fxs.lasttxhook = 0;
break;
default:
printk("wctdm: Can't set tx state to %d\n", txsig);
@@ -1859,7 +1858,7 @@ static int wctdm_hooksig(struct zt_chan *chan, zt_txsig_t txsig)
printk("Setting FXS hook state to %d (%02x)\n", txsig, reg);
#if 1
- wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos-1]);
+ wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod[chan->chanpos-1].fxs.lasttxhook);
#endif
}
return 0;
@@ -1877,7 +1876,7 @@ static int wctdm_initialize(struct wctdm *wc)
wc->span.deflaw = ZT_LAW_ALAW;
} else
wc->span.deflaw = ZT_LAW_MULAW;
- for (x=0;x<wc->cards;x++) {
+ for (x = 0; x < NUM_CARDS; x++) {
sprintf(wc->chans[x].name, "WCTDM/%d/%d", wc->pos, x);
wc->chans[x].sigcap = ZT_SIG_FXOKS | ZT_SIG_FXOLS | ZT_SIG_FXOGS | ZT_SIG_SF | ZT_SIG_EM | ZT_SIG_CLEAR;
wc->chans[x].sigcap |= ZT_SIG_FXSKS | ZT_SIG_FXSLS | ZT_SIG_SF | ZT_SIG_CLEAR;
@@ -1885,7 +1884,7 @@ static int wctdm_initialize(struct wctdm *wc)
wc->chans[x].pvt = wc;
}
wc->span.chans = wc->chans;
- wc->span.channels = wc->cards;
+ wc->span.channels = NUM_CARDS;
wc->span.hooksig = wctdm_hooksig;
wc->span.open = wctdm_open;
wc->span.close = wctdm_close;
@@ -1906,7 +1905,7 @@ static void wctdm_post_initialize(struct wctdm *wc)
{
int x;
/* Finalize signalling */
- for (x=0;x<wc->cards;x++) {
+ for (x = 0; x < NUM_CARDS; x++) {
if (wc->cardflag & (1 << x)) {
if (wc->modtype[x] == MOD_TYPE_FXO)
wc->chans[x].sigcap = ZT_SIG_FXSKS | ZT_SIG_FXSLS | ZT_SIG_SF | ZT_SIG_CLEAR;
@@ -2002,7 +2001,7 @@ static int wctdm_hardware_init(struct wctdm *wc)
/* Wait 1/4 of a second more */
wait_just_a_bit(HZ/4);
- for (x=0;x<wc->cards;x++) {
+ for (x = 0; x < NUM_CARDS; x++) {
int sane=0,ret=0,readi=0;
#if 1
/* Init with Auto Calibration */
@@ -2112,11 +2111,12 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic
} else {
wc = kmalloc(sizeof(struct wctdm), GFP_KERNEL);
if (wc) {
+ int cardcount = 0;
+
ifaces[x] = wc;
memset(wc, 0, sizeof(struct wctdm));
spin_lock_init(&wc->lock);
wc->curcard = -1;
- wc->cards = 4;
wc->ioaddr = pci_resource_start(pdev, 0);
wc->dev = pdev;
wc->pos = x;
@@ -2173,6 +2173,7 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic
if (wctdm_hardware_init(wc)) {
unsigned char x;
+
/* Set Reset Low */
x=inb(wc->ioaddr + WC_CNTL);
outb((~0x1)&x, wc->ioaddr + WC_CNTL);
@@ -2198,7 +2199,12 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic
/* Start DMA */
wctdm_start_dma(wc);
- printk("Found a Wildcard TDM: %s (%d modules)\n", wc->variety, wc->cards);
+ for (x = 0; x < NUM_CARDS; x++) {
+ if (wc->cardflag & (1 << x))
+ cardcount++;
+ }
+
+ printk("Found a Wildcard TDM: %s (%d modules)\n", wc->variety, cardcount);
res = 0;
} else
res = -ENOMEM;