From cd0da1d15c640b4a63fe9e0222b216bebaf0b08f Mon Sep 17 00:00:00 2001 From: markster Date: Sat, 26 Oct 2002 18:25:29 +0000 Subject: Version 0.3.2 from FTP git-svn-id: http://svn.digium.com/svn/zaptel/trunk@123 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wcfxo.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'wcfxo.c') diff --git a/wcfxo.c b/wcfxo.c index 2d3ee1f..e00f4eb 100755 --- a/wcfxo.c +++ b/wcfxo.c @@ -42,6 +42,9 @@ /* #define ENABLE_TASKLETS */ +/* Un-comment the following for POTS line support for Japan */ +/* #define JAPAN */ + #define WC_MAX_IFACES 128 #define WC_CNTL 0x00 @@ -68,7 +71,12 @@ #define FLAG_READ 2 #define RING_DEBOUNCE 64 /* Ringer Debounce (in ms) */ +#ifdef JAPAN +#define BATT_DEBOUNCE 30 /* Battery debounce (in ms) */ +#define OH_DEBOUNCE 350 /* Off/On hook debounce (in ms) */ +#else #define BATT_DEBOUNCE 80 /* Battery debounce (in ms) */ +#endif #define MINPEGTIME 10 * 8 /* 30 ms peak to peak gets us no more than 100 Hz */ #define PEGTIME 50 * 8 /* 50ms peak to peak gets us rings of 10 Hz or more */ @@ -104,6 +112,10 @@ struct wcfxo { int pegcount; int battdebounce; int nobatttimer; + int ringdebounce; +#ifdef JAPAN + int ohdebounce; +#endif int allread; int regoffset; /* How far off our registers are from what we expect */ int alt; @@ -295,7 +307,10 @@ static inline void wcfxo_receiveprep(struct wcfxo *wc, unsigned char ints) /* Reset pegcount if our timer expires */ wc->pegcount = 0; } - if (!wc->offhook) { + /* Decrement debouncer if appropriate */ + if (wc->ringdebounce) + wc->ringdebounce--; + if (!wc->offhook && !wc->ringdebounce) { if (!wc->ring && (wc->pegcount > PEGCOUNT)) { /* It's ringing */ if (debug) @@ -393,7 +408,10 @@ static void wcfxo_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (debug) printk("NO BATTERY!\n"); wc->battery = 0; - zt_hooksig(&wc->chan, ZT_RXSIG_ONHOOK); +#ifdef JAPAN + if ((!wc->ohdebounce) && wc->offhook) +#endif + zt_hooksig(&wc->chan, ZT_RXSIG_ONHOOK); wc->battdebounce = BATT_DEBOUNCE; } else if (!wc->battery) wc->battdebounce = BATT_DEBOUNCE; @@ -423,6 +441,11 @@ static void wcfxo_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (wc->battdebounce) wc->battdebounce--; +#ifdef JAPAN + if (wc->ohdebounce) + wc->ohdebounce--; +#endif + } } @@ -477,6 +500,11 @@ static int wcfxo_hooksig(struct zt_chan *chan, zt_txsig_t txsig) reg = reg | 0x1; wcfxo_setreg(wc, 0x5, reg); wc->offhook = 1; +#ifdef JAPAN + wc->battery = 1; + wc->battdebounce = BATT_DEBOUNCE; + wc->ohdebounce = OH_DEBOUNCE; +#endif break; case ZT_TXSIG_ONHOOK: /* Put on hook and enable on hook line monitor */ @@ -486,6 +514,11 @@ static int wcfxo_hooksig(struct zt_chan *chan, zt_txsig_t txsig) reg = reg | 0x08; wcfxo_setreg(wc, 0x5, reg); wc->offhook = 0; + /* Don't accept a ring for another 1000 ms */ + wc->ringdebounce = 1000; +#ifdef JAPAN + wc->ohdebounce = OH_DEBOUNCE; +#endif break; default: printk("wcfxo: Can't set tx state to %d\n", txsig); @@ -499,7 +532,7 @@ static int wcfxo_initialize(struct wcfxo *wc) { /* Zapata stuff */ sprintf(wc->span.name, "WCFXO/%d", wc->pos); - sprintf(wc->span.desc, "%s Board %d\n", wc->variety, wc->pos + 1); + sprintf(wc->span.desc, "%s Board %d", wc->variety, wc->pos + 1); sprintf(wc->chan.name, "WCFXO/%d/%d", wc->pos, 0); wc->chan.sigcap = ZT_SIG_FXSKS | ZT_SIG_FXSLS; wc->chan.chanpos = 1; -- cgit v1.2.3