--- wctdm.c.svn 2009-02-01 09:04:29.000000000 +1300 +++ wctdm.c 2009-02-06 23:32:29.000000000 +1300 @@ -1057,14 +1057,21 @@ DAHDI_IRQ_HANDLER(wctdm_interrupt) wc->mod[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x6 : 0x2;/* OHT mode when idle */ } else { if (wc->mod[x].fxs.ohttimer) { - wc->mod[x].fxs.ohttimer-= DAHDI_CHUNKSIZE; - if (!wc->mod[x].fxs.ohttimer) { - wc->mod[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x5 : 0x1; /* Switch to Active : Reverse Forward */ - if ((wc->mod[x].fxs.lasttxhook == 0x2) || (wc->mod[x].fxs.lasttxhook == 0x6)) { - /* Apply the change if appropriate */ - wc->mod[x].fxs.lasttxhook = POLARITY_XOR(x) ? 0x5 : 0x1; - wctdm_setreg(wc, x, 64, wc->mod[x].fxs.lasttxhook); + if (!wc->mod[x].fxs.oldrxhook) { + /* OnHook */ + wc->mod[x].fxs.ohttimer-= DAHDI_CHUNKSIZE; + if (!wc->mod[x].fxs.ohttimer) { + wc->mod[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x5 : 0x1; /* Switch to Active : Reverse Forward */ + if ((wc->mod[x].fxs.lasttxhook == 0x2) || (wc->mod[x].fxs.lasttxhook == 0x6)) { + /* Apply the change if appropriate */ + wc->mod[x].fxs.lasttxhook = POLARITY_XOR(x) ? 0x5 : 0x1; + wctdm_setreg(wc, x, 64, wc->mod[x].fxs.lasttxhook); + } } + } else { + /* Off Hook */ + wc->mod[x].fxs.ohttimer = 0; + wc->mod[x].fxs.idletxhookstate = POLARITY_XOR(x) ? 0x5 : 0x1; /* Switch to Active : Reverse Forward */ } } }