From 2a54508b0817ef7d930e15b5995c666c191356fd Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Sun, 24 Aug 2008 05:53:32 +0000 Subject: Add support for 56 KB HDLC as well as selectable rate via ioctl git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4817 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi-base.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'drivers/dahdi/dahdi-base.c') diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index c563d55..115a548 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -1515,8 +1515,8 @@ static int dahdi_net_open(hdlc_device *hdlc) if (res) return res; - fasthdlc_init(&ms->rxhdlc); - fasthdlc_init(&ms->txhdlc); + fasthdlc_init(&ms->rxhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + fasthdlc_init(&ms->txhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); ms->infcs = PPP_INITFCS; netif_start_queue(ztchan_to_dev(ms)); @@ -2373,8 +2373,8 @@ static int initialize_channel(struct dahdi_chan *chan) chan->firstcadencepos = 0; /* By default loop back to first cadence position */ /* HDLC & FCS stuff */ - fasthdlc_init(&chan->rxhdlc); - fasthdlc_init(&chan->txhdlc); + fasthdlc_init(&chan->rxhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + fasthdlc_init(&chan->txhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); chan->infcs = PPP_INITFCS; /* Timings for RBS */ @@ -5012,8 +5012,8 @@ static int dahdi_chan_ioctl(struct inode *inode, struct file *file, unsigned int chan->flags &= ~(DAHDI_FLAG_AUDIO | DAHDI_FLAG_HDLC | DAHDI_FLAG_FCS); if (j) { chan->flags |= DAHDI_FLAG_HDLC; - fasthdlc_init(&chan->rxhdlc); - fasthdlc_init(&chan->txhdlc); + fasthdlc_init(&chan->rxhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + fasthdlc_init(&chan->txhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); } break; case DAHDI_HDLCFCSMODE: @@ -5022,10 +5022,21 @@ static int dahdi_chan_ioctl(struct inode *inode, struct file *file, unsigned int chan->flags &= ~(DAHDI_FLAG_AUDIO | DAHDI_FLAG_HDLC | DAHDI_FLAG_FCS); if (j) { chan->flags |= DAHDI_FLAG_HDLC | DAHDI_FLAG_FCS; - fasthdlc_init(&chan->rxhdlc); - fasthdlc_init(&chan->txhdlc); + fasthdlc_init(&chan->rxhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + fasthdlc_init(&chan->txhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); } break; + case DAHDI_HDLC_RATE: + get_user(j, (int *) data); + if (j == 56) { + chan->flags |= DAHDI_FLAG_HDLC56; + } else { + chan->flags &= ~DAHDI_FLAG_HDLC56; + } + + fasthdlc_init(&chan->rxhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + fasthdlc_init(&chan->txhdlc, (chan->flags & DAHDI_FLAG_HDLC56) ? FASTHDLC_MODE_56 : FASTHDLC_MODE_64); + break; case DAHDI_ECHOCANCEL_PARAMS: { struct dahdi_echocanparams ecp; @@ -5860,7 +5871,7 @@ static inline void __dahdi_getbuf_chunk(struct dahdi_chan *ss, unsigned char *tx /* If this is an HDLC channel we only send a byte of HDLC. */ for(x=0;xtxhdlc.bits < 8) + if (fasthdlc_tx_need_data(&ms->txhdlc)) /* Load a byte of data only if needed */ fasthdlc_tx_load_nocheck(&ms->txhdlc, buf[ms->writeidx[ms->outwritebuf]++]); *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc); @@ -5971,7 +5982,7 @@ out in the later versions, and is put back now. */ } else if (ms->flags & DAHDI_FLAG_HDLC) { for (x=0;xtxhdlc.bits < 8) + if (fasthdlc_tx_need_data(&ms->txhdlc)) fasthdlc_tx_frame_nocheck(&ms->txhdlc); *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc); } -- cgit v1.2.3