From 1dbaa50b377dd65a80b249a60af88dfb7c18b9bc Mon Sep 17 00:00:00 2001 From: Doug Bailey Date: Wed, 5 Aug 2009 14:40:45 +0000 Subject: Change proslic linefeed register setting Insure that proslic linefeed register is not transitioned from Active to On-Hook Transmission while the channel is off-hook. Replaced magic numbers assigned to linefeed associated variables with more descriptive constants. (issue #15352) Reported by: alecdavis Patches: wctdm_prevent_ohttimer_click.diff3.txt uploaded by dbailey (license 819) Tested by: alecdavis, dbailey, vmikhelson git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6941 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wctdm24xxp/base.c | 84 ++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 38 deletions(-) (limited to 'drivers/dahdi/wctdm24xxp') diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 7e442db..74284a8 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -1193,8 +1193,8 @@ static inline void wctdm_proslic_recheck_sanity(struct wctdm *wc, int card) wc->mods[card].fxs.palarms++; if (wc->mods[card].fxs.palarms < MAX_ALARMS) { printk(KERN_NOTICE "Power alarm (%02x) on module %d, resetting!\n", res, card + 1); - if (wc->mods[card].fxs.lasttxhook == 4) { - wc->mods[card].fxs.lasttxhook = POLARITY_XOR(card) ? 0x15 : 0x11; + if (wc->mods[card].fxs.lasttxhook == SLIC_LF_RINGING) { + wc->mods[card].fxs.lasttxhook = 0x10 | POLARITY_XOR(card) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD; } wc->sethook[card] = CMD_WR(19, res); #if 0 @@ -1223,8 +1223,8 @@ static inline void wctdm_proslic_recheck_sanity(struct wctdm *wc, int card) wc->mods[card].fxs.palarms++; if (wc->mods[card].fxs.palarms < MAX_ALARMS) { printk(KERN_NOTICE "Power alarm on module %d, resetting!\n", card + 1); - if (wc->mods[card].fxs.lasttxhook == 4) { - wc->mods[card].fxs.lasttxhook = POLARITY_XOR(card) ? 0x15 : 0x11;; + if (wc->mods[card].fxs.lasttxhook == SLIC_LF_RINGING) { + wc->mods[card].fxs.lasttxhook = POLARITY_XOR(card) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD;; } wc->mods[card].fxs.lasttxhook |= 0x10; wc->sethook[card] = CMD_WR(64, wc->mods[card].fxs.lasttxhook); @@ -1597,6 +1597,14 @@ static inline void wctdm_proslic_check_hook(struct wctdm *wc, int card) /* Off hook */ if (debug & DEBUG_CARD) printk(KERN_DEBUG "wctdm: Card %d Going off hook\n", card); + switch ( wc->mods[card].fxs.lasttxhook ) { + case SLIC_LF_RINGING: /* Ringing */ + case SLIC_LF_OHTRAN_FWD: /* Forward On Hook Transfer */ + case SLIC_LF_OHTRAN_REV: /* Reverse On Hook Transfer */ + /* just detected OffHook, during Ringing or OnHookTransfer */ + wc->mods[card].fxs.idletxhookstate = POLARITY_XOR(card) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD; /* Active */ + break; + } dahdi_hooksig(wc->chans[card], DAHDI_RXSIG_OFFHOOK); if (robust) wctdm_init_proslic(wc, card, 1, 0, 1); @@ -1725,23 +1733,23 @@ static inline void wctdm_isr_misc(struct wctdm *wc) wctdm_proslic_check_hook(wc, x); if (!(wc->intcount & 0xfc)) wctdm_proslic_recheck_sanity(wc, x); - if (wc->mods[x].fxs.lasttxhook == 0x4) { + if (wc->mods[x].fxs.lasttxhook == SLIC_LF_RINGING) { /* RINGing, prepare for OHT */ wc->mods[x].fxs.ohttimer = OHT_TIMER << 3; - wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x6 : 0x2; /* OHT mode when idle */ + wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? SLIC_LF_OHTRAN_REV : SLIC_LF_OHTRAN_FWD; /* OHT mode when idle */ } else { if (wc->mods[x].fxs.ohttimer) { wc->mods[x].fxs.ohttimer-= DAHDI_CHUNKSIZE; if (!wc->mods[x].fxs.ohttimer) { - wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x5 : 0x1; /* Switch to active */ - if (wc->mods[x].fxs.lasttxhook == 0x2) { + wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD; /* Switch to active */ + if (wc->mods[x].fxs.lasttxhook == SLIC_LF_OHTRAN_FWD) { /* Apply the change if appropriate */ - wc->mods[x].fxs.lasttxhook = 0x11; + wc->mods[x].fxs.lasttxhook = 0x10 | SLIC_LF_ACTIVE_FWD; wc->sethook[x] = CMD_WR(64, wc->mods[x].fxs.lasttxhook); /* Data enqueued here */ /* wctdm_setreg_intr(wc, x, 64, wc->mods[x].fxs.lasttxhook); */ - } else if (wc->mods[x].fxs.lasttxhook == 0x6) { + } else if (wc->mods[x].fxs.lasttxhook == SLIC_LF_OHTRAN_REV) { /* Apply the change if appropriate */ - wc->mods[x].fxs.lasttxhook = 0x15; + wc->mods[x].fxs.lasttxhook = 0x10 | SLIC_LF_ACTIVE_REV; wc->sethook[x] = CMD_WR(64, wc->mods[x].fxs.lasttxhook); /* Data enqueued here */ /* wctdm_setreg_intr(wc, x, 64, wc->mods[x].fxs.lasttxhook); */ } @@ -2124,20 +2132,20 @@ static int set_vmwi(struct wctdm *wc, int chan_idx) } /* Set line polarity for new VMWI state */ if (POLARITY_XOR(chan_idx)) { - wc->mods[chan_idx].fxs.idletxhookstate |= 0x14; + wc->mods[chan_idx].fxs.idletxhookstate |= 0x10 | SLIC_LF_REVMASK; /* Do not set while currently ringing or open */ - if (wc->mods[chan_idx].fxs.lasttxhook != 0x04 && - wc->mods[chan_idx].fxs.lasttxhook != 0x00) { - wc->mods[chan_idx].fxs.lasttxhook |= 0x14; + if (wc->mods[chan_idx].fxs.lasttxhook != SLIC_LF_RINGING && + wc->mods[chan_idx].fxs.lasttxhook != SLIC_LF_OPEN) { + wc->mods[chan_idx].fxs.lasttxhook |= 0x10 | SLIC_LF_REVMASK; wc->sethook[chan_idx] = CMD_WR(64, wc->mods[chan_idx].fxs.lasttxhook); - } + } } else { - wc->mods[chan_idx].fxs.idletxhookstate &= ~0x04; + wc->mods[chan_idx].fxs.idletxhookstate &= ~SLIC_LF_REVMASK; /* Do not set while currently ringing or open */ - if (wc->mods[chan_idx].fxs.lasttxhook != 0x04 && - wc->mods[chan_idx].fxs.lasttxhook != 0x00) { + if (wc->mods[chan_idx].fxs.lasttxhook != SLIC_LF_RINGING && + wc->mods[chan_idx].fxs.lasttxhook != SLIC_LF_OPEN) { x = wc->mods[chan_idx].fxs.lasttxhook; - x &= ~0x04; + x &= ~SLIC_LF_REVMASK; x |= 0x10; wc->mods[chan_idx].fxs.lasttxhook = x; wc->sethook[chan_idx] = CMD_WR(64, wc->mods[chan_idx].fxs.lasttxhook); @@ -2276,9 +2284,9 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, /* By default, don't send on hook */ if (!reversepolarity != !wc->mods[card].fxs.reversepolarity) { - wc->mods[card].fxs.idletxhookstate = 5; + wc->mods[card].fxs.idletxhookstate = SLIC_LF_ACTIVE_REV; } else { - wc->mods[card].fxs.idletxhookstate = 1; + wc->mods[card].fxs.idletxhookstate = SLIC_LF_ACTIVE_FWD; } wc->mods[card].fxs.lasttxhook = 0x10; @@ -2655,10 +2663,10 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long if (get_user(x, (__user int *) data)) return -EFAULT; wc->mods[chan->chanpos - 1].fxs.ohttimer = x << 3; - wc->mods[chan->chanpos - 1].fxs.idletxhookstate = 0x2; /* OHT mode when idle */ - if (wc->mods[chan->chanpos - 1].fxs.lasttxhook == 0x1 || wc->mods[chan->chanpos - 1].fxs.lasttxhook == 0x5) { + wc->mods[chan->chanpos - 1].fxs.idletxhookstate = POLARITY_XOR(chan->chanpos - 1) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD; /* Active mode when idle */ + if (wc->mods[chan->chanpos - 1].fxs.lasttxhook == SLIC_LF_ACTIVE_FWD || wc->mods[chan->chanpos - 1].fxs.lasttxhook == SLIC_LF_ACTIVE_REV) { /* Apply the change if appropriate */ - wc->mods[chan->chanpos - 1].fxs.lasttxhook = POLARITY_XOR(chan->chanpos -1) ? 0x16 : 0x12; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | POLARITY_XOR(chan->chanpos -1) ? SLIC_LF_OHTRAN_REV : SLIC_LF_OHTRAN_FWD; wc->sethook[chan->chanpos - 1] = CMD_WR(64, wc->mods[chan->chanpos - 1].fxs.lasttxhook); /* wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mods[chan->chanpos - 1].fxs.lasttxhook); */ } @@ -2777,8 +2785,8 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) return -EINVAL; /* Can't change polarity while ringing or when open */ - if ((wc->mods[chan->chanpos -1 ].fxs.lasttxhook == 0x04) || - (wc->mods[chan->chanpos -1 ].fxs.lasttxhook == 0x00)) + if ((wc->mods[chan->chanpos -1 ].fxs.lasttxhook == SLIC_LF_RINGING) || + (wc->mods[chan->chanpos -1 ].fxs.lasttxhook == SLIC_LF_OPEN)) return -EINVAL; if (x) { wc->mods[chan->chanpos -1 ].fxs.reversepolarity = 1; @@ -2786,12 +2794,12 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long wc->mods[chan->chanpos -1 ].fxs.reversepolarity = 0; } if (POLARITY_XOR(chan->chanpos -1)) { - wc->mods[chan->chanpos -1 ].fxs.idletxhookstate |= 0x14; - wc->mods[chan->chanpos -1 ].fxs.lasttxhook |= 0x14; + wc->mods[chan->chanpos -1 ].fxs.idletxhookstate |= SLIC_LF_REVMASK; + wc->mods[chan->chanpos -1 ].fxs.lasttxhook |= 0x10 | SLIC_LF_REVMASK; } else { - wc->mods[chan->chanpos -1 ].fxs.idletxhookstate &= ~0x04; + wc->mods[chan->chanpos -1 ].fxs.idletxhookstate &= ~SLIC_LF_REVMASK; x = wc->mods[chan->chanpos -1 ].fxs.lasttxhook; - x &= ~0x04; + x &= ~SLIC_LF_REVMASK; x |= 0x10; wc->mods[chan->chanpos -1 ].fxs.lasttxhook = x; } @@ -2976,7 +2984,7 @@ static int wctdm_close(struct dahdi_chan *chan) signed char reg; for (x=0;xcards;x++) { if (wc->modtype[x] == MOD_TYPE_FXS) { - wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 5 : 1; + wc->mods[x].fxs.idletxhookstate = POLARITY_XOR(x) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD; } if (wc->modtype[x] == MOD_TYPE_QRV) { @@ -3050,9 +3058,9 @@ static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) break; case DAHDI_SIG_FXOGS: if (POLARITY_XOR(chan->chanpos -1)) { - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x17; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_RING_OPEN; } else { - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x13; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_TIP_OPEN; } break; } @@ -3061,9 +3069,9 @@ static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) switch(chan->sig) { case DAHDI_SIG_EM: if (POLARITY_XOR(chan->chanpos -1)) { - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x11; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_ACTIVE_FWD; } else { - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x15; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_ACTIVE_REV; } break; default: @@ -3073,10 +3081,10 @@ static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) } break; case DAHDI_TXSIG_START: - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x14; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_RINGING; break; case DAHDI_TXSIG_KEWL: - wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10; + wc->mods[chan->chanpos - 1].fxs.lasttxhook = 0x10 | SLIC_LF_OPEN; break; default: printk(KERN_NOTICE "wctdm24xxp: Can't set tx state to %d\n", txsig); -- cgit v1.2.3