diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-01-07 18:53:09 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-01-07 18:53:09 +0000 |
commit | 87d140e30b0e037e08ccd43ed01340ebdf7b6256 (patch) | |
tree | 43c2ae0d13741a27b400f90dbf4d1bd19876e0b5 | |
parent | 6ac94c3f3bab4d78056af33fff4a30c2157022cb (diff) |
Version 0.1.5 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@47 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-x | wcfxo.c | 69 |
1 files changed, 38 insertions, 31 deletions
@@ -245,6 +245,10 @@ static void wcfxo_interrupt(int irq, void *dev_id, struct pt_regs *regs) struct wcfxo *wc = dev_id; unsigned char ints; unsigned char b; +#ifdef DEBUG_RING + static int oldb = 0; + static int oldcnt = 0; +#endif ints = inb(wc->ioaddr + WC_INTSTAT); outb(ints, wc->ioaddr + WC_INTSTAT); @@ -269,42 +273,47 @@ static void wcfxo_interrupt(int irq, void *dev_id, struct pt_regs *regs) } if (1 /* !(wc->report % 0xf) */) { - /* Check RING from register and debounce for 8ms */ + /* Check RING from register and debounce. This is actually + fairly challenging to do, because the ring behavior + seems to differ from one system to another. */ b = wc->readregs[0x5] & 0x60; +#ifdef DEBUG_RING + if (b != oldb) { + printk("RING Change from %02x to %02x after %d (ringdebounce = %d)\n", oldb, b, oldcnt, wc->ringdebounce); + oldb = b; + oldcnt = 0; + } else + oldcnt++; +#endif if (!b) { + /* No ring -- subtract one from our counter. We need + a whole bunch of no-rings in a row before we consider + the real ring actually over */ + if (wc->ringdebounce > 0) + wc->ringdebounce -= 1; if (wc->ring && !wc->ringdebounce) { - if (wc->ring == 2) { - if (debug) - printk("NO RING!\n"); - zt_hooksig(&wc->chan, ZT_RXSIG_OFFHOOK); - } +#ifndef DEBUG_RING + if (debug) +#endif + printk("NO RING!\n"); + zt_hooksig(&wc->chan, ZT_RXSIG_OFFHOOK); wc->ring = 0; - wc->ringdebounce = RING_DEBOUNCE; } } else { - /* RING */ - if ((wc->ring < 2) && !wc->ringdebounce) { - if (wc->ring == 1) { - /* It's read as ringing for at least 8ms */ - if (debug) - printk("RING!\n"); - zt_hooksig(&wc->chan, ZT_RXSIG_RING); - wc->ring = 2; - } else { - /* Ooh, we saw a ring, now lets see if it hangs around - or is just someone plugging the phone in or something - along those lines */ - wc->ring = 1; - } - wc->ringdebounce = RING_DEBOUNCE; - } else if (wc->ring == 2) { /* Reset debounce if we're ringing */ - wc->ringdebounce = RING_DEBOUNCE; - } -#if 0 - else if (wc->ring == 1) { - printk("Ring1: Debounce: %d\n", wc->ringdebounce); + /* Ring detected... Increment our counter by a bunch */ + wc->ringdebounce += 5; + /* Max out at 200. */ + if (wc->ringdebounce > 200) + wc->ringdebounce = 200; + if (!wc->ring && (wc->ringdebounce >= 200)) { + /* Trigger the ring */ +#ifndef DEBUG_RING + if (debug) +#endif + printk("RING!\n"); + zt_hooksig(&wc->chan, ZT_RXSIG_RING); + wc->ring = 1; } -#endif } /* Check for BATTERY from register and debounce for 8 ms */ @@ -336,8 +345,6 @@ static void wcfxo_interrupt(int irq, void *dev_id, struct pt_regs *regs) wc->battdebounce = BATT_DEBOUNCE; } - if (wc->ringdebounce) - wc->ringdebounce--; if (wc->battdebounce) wc->battdebounce--; } |