From: Tim Ousley Date: Fri, 18 May 2001 19:25:15 +0000 (+0000) Subject: MITE DMA data is now unsigned short instead of twos complement. Also fixed X-Git-Tag: r0_7_59~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4ad8fb2efb8647f5f4720b1e8b6c5b203d1e36bd;p=comedi.git MITE DMA data is now unsigned short instead of twos complement. Also fixed bug where the ISR would try to poll the STC fifo instead of letting the MITE retrieve the data. --- diff --git a/comedi/drivers/mite.c b/comedi/drivers/mite.c index cd1b498d..2173b550 100644 --- a/comedi/drivers/mite.c +++ b/comedi/drivers/mite.c @@ -469,11 +469,11 @@ void mite_setregs(struct mite_struct *mite,unsigned long ll_start,int chan,int d int mite_bytes_transferred(struct mite_struct *mite, int chan) { - int bytes; + int DAR, FCR; - bytes = readl(mite->mite_io_addr+MITE_DAR+CHAN_OFFSET(chan)); - bytes -= readl(mite->mite_io_addr+MITE_FCR+CHAN_OFFSET(chan)) & 0x000000FF; - return bytes; + DAR = readl(mite->mite_io_addr+MITE_DAR+CHAN_OFFSET(chan)); + FCR = readl(mite->mite_io_addr+MITE_FCR+CHAN_OFFSET(chan)) & 0x000000FF; + return DAR-FCR; } int mite_dma_tcr(struct mite_struct *mite) diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index c5966f71..84570d74 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -232,6 +232,7 @@ static void handle_b_interrupt(comedi_device *dev,unsigned short status); /*status must be long because the CHSR is 32 bits and the high bits are important to us */ static void mite_handle_interrupt(comedi_device *dev,unsigned long status); +void ni_munge(comedi_device *dev,comedi_subdevice *s,sampl_t *start, sampl_t *stop); #endif /* ni_set_bits( ) allows different parts of the ni_mio_common driver to @@ -330,15 +331,30 @@ static void mite_handle_interrupt(comedi_device *dev,unsigned long m_status) comedi_event(dev,s,COMEDI_CB_BLOCK); MDPRINTK("mite_handle_interrupt\n"); - MDPRINTK("MITE generated an int!!\n"); writel(CHOR_CLRLC, devpriv->mite->mite_io_addr+MITE_CHOR+CHAN_OFFSET(0)); +#if 0 + //Don't munge the data, just update the user's status variables s->async->buf_int_count=mite_bytes_transferred(devpriv->mite, 0); s->async->buf_int_ptr= s->async->buf_int_count % s->async->prealloc_bufsz; +#else + //Munge the ADC data to change its format from twos complement to unsigned int + //This is slow but makes it more compatible with other cards + { + unsigned int raw_ptr; + s->async->buf_int_count = mite_bytes_transferred(devpriv->mite, 0); + raw_ptr = s->async->buf_int_count % s->async->prealloc_bufsz; + if(s->async->buf_int_ptr > raw_ptr) { + ni_munge(dev,s,s->async->buf_int_ptr+s->async->prealloc_buf, + s->async->prealloc_buf+s->async->prealloc_bufsz); + s->async->buf_int_ptr = 0; + } + ni_munge(dev,s,s->async->buf_int_ptr+s->async->prealloc_buf, + raw_ptr+s->async->prealloc_buf); + s->async->buf_int_ptr = raw_ptr; + } +#endif MDPRINTK("CHSR is 0x%08lx, count is %d\n",m_status,s->async->buf_int_count); if(m_status&CHSR_DONE){ -#ifdef DEBUG_MITE - mite_dump_regs(devpriv->mite); -#endif writel(CHOR_CLRDONE, devpriv->mite->mite_io_addr+MITE_CHOR+CHAN_OFFSET(0)); //printk("buf_int_count is %d, buf_int_ptr is %d\n", // s->async->buf_int_count,s->async->buf_int_ptr); @@ -346,8 +362,9 @@ static void mite_handle_interrupt(comedi_device *dev,unsigned long m_status) } MDPRINTK("exit mite_handle_interrupt\n"); return; -} -#endif +} + +#endif //PCIDMA static void handle_a_interrupt(comedi_device *dev,unsigned short status) { @@ -420,9 +437,11 @@ static void handle_a_interrupt(comedi_device *dev,unsigned short status) ack|=AI_START1_Interrupt_Ack; } } +#ifndef PCIDMA if(status&AI_FIFO_Half_Full_St){ ni_handle_fifo_half_full(dev); } +#endif //PCIDMA if(devpriv->aimode==AIMODE_SCAN && status&AI_STOP_St){ ni_handle_fifo_dregs(dev); @@ -538,6 +557,24 @@ static void ni_ai_fifo_read(comedi_device *dev,comedi_subdevice *s, } #ifdef PCIDMA +void ni_munge(comedi_device *dev,comedi_subdevice *s,sampl_t *start, sampl_t *stop) +{ + comedi_async *async = s->async; + int j; + sampl_t *i; + unsigned int mask; + + mask=(1<cur_chan; + for(i=start;iai_xorlist[j]; + *i &=mask; + j++; + j %= async->cur_chanlist_len; + } + async->cur_chan=j; +} + static void ni_handle_block_dma(comedi_device *dev) { MDPRINTK("ni_handle_block_dma\n");