diff options
Diffstat (limited to 'zaptel.c')
-rwxr-xr-x | zaptel.c | 73 |
1 files changed, 60 insertions, 13 deletions
@@ -820,7 +820,9 @@ static void close_channel(struct zt_chan *chan) chan->curzone = NULL; chan->cadencepos = 0; zt_hangup(chan); - chan->itimer = 0; + chan->itimerset = chan->itimer = 0; + chan->pulsecount = 0; + chan->pulsetimer = 0; chan->ringdebtimer = 0; init_waitqueue_head(&chan->sel); init_waitqueue_head(&chan->readbufq); @@ -1666,8 +1668,13 @@ static int zt_hangup(struct zt_chan *chan) chan->readn[x]= chan->readidx[x] = 0; } - chan->inreadbuf = 0; - chan->inwritebuf = 0; + if (chan->readbuf[0]) { + chan->inreadbuf = 0; + chan->inwritebuf = 0; + } else { + chan->inreadbuf = -1; + chan->inwritebuf = -1; + } chan->outreadbuf = -1; chan->outwritebuf = -1; chan->dialing = 0; @@ -1726,7 +1733,7 @@ static int initialize_channel(struct zt_chan *chan) chan->debouncetime = ZT_DEFAULT_DEBOUNCETIME; /* Initialize RBS timers */ - chan->itimer = chan->otimer = 0; + chan->itimerset = chan->itimer = chan->otimer = 0; chan->ringdebtimer = 0; init_waitqueue_head(&chan->sel); @@ -2371,6 +2378,7 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c span.bpvcount = spans[i]->bpvcount; /* get BPV count */ span.rxlevel = spans[i]->rxlevel; /* get rx level */ span.txlevel = spans[i]->txlevel; /* get tx level */ + span.irqmisses = spans[i]->irqmisses; /* get BPV count */ span.syncsrc = spans[i]->syncsrc; /* get active sync source */ span.totalchans = spans[i]->channels; span.numchans = 0; @@ -3006,7 +3014,7 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); if (conf.confmode && ((conf.confmode & ZT_CONF_MODE_MASK) < 4)) { /* Monitor mode -- it's a channel */ - if ((conf.confno < 0) || (conf.confno >= ZT_MAX_CHANNELS)) return(-EINVAL); + if ((conf.confno < 0) || (conf.confno >= ZT_MAX_CHANNELS) || !chans[conf.confno]) return(-EINVAL); } else { /* make sure conf number makes sense, too */ if ((conf.confno < -1) || (conf.confno > ZT_MAX_CONF)) return(-EINVAL); @@ -4198,7 +4206,7 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig) case ZT_RXSIG_OFFHOOK: /* went off hook */ /* The interface is going off hook */ /* set wink timer */ - chan->itimer = chan->rxwinktime * 8; + chan->itimerset = chan->itimer = chan->rxwinktime * 8; break; case ZT_RXSIG_ONHOOK: /* went on hook */ /* This interface is now going on hook. @@ -4209,7 +4217,7 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig) qevent(chan,ZT_EVENT_ONHOOK); chan->gotgs = 0; } - chan->itimer = 0; + chan->itimerset = chan->itimer = 0; break; default: break; @@ -4265,24 +4273,37 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig) #if 0 printk("Off hook on channel %d, itimer = %d, gotgs = %d\n", chan->channo, chan->itimer, chan->gotgs); #endif - if (chan->itimer) { /* if timer still running */ - qevent(chan,ZT_EVENT_WINKFLASH); + if (chan->itimer) /* if timer still running */ + { + int plen = chan->itimerset - chan->itimer; + if (plen <= ZT_MAXPULSETIME) + { + if (plen >= ZT_MINPULSETIME) + { + chan->pulsecount++; + chan->pulsetimer = ZT_PULSETIMEOUT; + chan->itimer = chan->itimerset; + if (chan->pulsecount == 1) + qevent(chan,ZT_EVENT_PULSE_START); + } + } else + qevent(chan,ZT_EVENT_WINKFLASH); } else { /* if havent got GS detect */ if (!chan->gotgs) { qevent(chan,ZT_EVENT_RINGOFFHOOK); chan->gotgs = 1; - chan->itimer = 0; + chan->itimerset = chan->itimer = 0; } } - chan->itimer = 0; + chan->itimerset = chan->itimer = 0; break; case ZT_RXSIG_ONHOOK: /* went on hook */ /* if not during offhook debounce time */ if ((chan->txstate != ZT_TXSTATE_DEBOUNCE) && (chan->txstate != ZT_TXSTATE_KEWL) && (chan->txstate != ZT_TXSTATE_AFTERKEWL)) { - chan->itimer = chan->rxflashtime * 8; + chan->itimerset = chan->itimer = chan->rxflashtime * 8; } if (chan->txstate == ZT_TXSTATE_KEWL) chan->kewlonhook = 1; @@ -4557,9 +4578,9 @@ static inline void zt_putbuf_chunk(struct zt_chan *ss, unsigned char *rxb) while(bytes) { #if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP) skb = NULL; +#endif abort = 0; eof = 0; -#endif /* Next, figure out if we've got a buffer to receive into */ if (ms->inreadbuf > -1) { /* Read into the current buffer */ @@ -5013,6 +5034,32 @@ int zt_receive(struct zt_span *span) } if (span->chans[x].ringdebtimer) span->chans[x].ringdebtimer--; + if (span->chans[x].pulsetimer) + { + span->chans[x].pulsetimer--; + if (span->chans[x].pulsetimer <= 0) + { + if (span->chans[x].pulsecount) + { + if (span->chans[x].pulsecount > 12) { + + printk("Got pulse digit %d on %s???\n", + span->chans[x].pulsecount, + span->chans[x].name); + } else if (span->chans[x].pulsecount > 11) { + qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '#'); + } else if (span->chans[x].pulsecount > 10) { + qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '*'); + } else if (span->chans[x].pulsecount > 9) { + qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '0'); + } else { + qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | ('0' + + span->chans[x].pulsecount)); + } + span->chans[x].pulsecount = 0; + } + } + } spin_unlock_irqrestore(&span->chans[x].lock, flags); } } |