From 2c9d7b02cc552a0a999777db7e05152d21fca001 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 13 Apr 2002 15:49:35 +0000 Subject: [PATCH] converted some drivers to use comedi_buf_put_array --- comedi/drivers/cb_pcidas.c | 30 +++++++++++++++--------------- comedi/drivers/cb_pcidas64.c | 1 - comedi/drivers/das16.c | 2 +- comedi/drivers/das16m1.c | 7 ++++--- comedi/drivers/ni_at_a2150.c | 9 ++++++--- comedi/drivers/ni_labpc.c | 10 +++------- include/linux/comedidev.h | 1 + 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/comedi/drivers/cb_pcidas.c b/comedi/drivers/cb_pcidas.c index 7a9dcbed..6ed0d80f 100644 --- a/comedi/drivers/cb_pcidas.c +++ b/comedi/drivers/cb_pcidas.c @@ -1285,7 +1285,7 @@ static void cb_pcidas_interrupt(int irq, void *d, struct pt_regs *regs) int half_fifo = thisboard->fifo_size / 2; static const int max_half_fifo = 512; // maximum possible half-fifo size sampl_t data[max_half_fifo]; - int i; + unsigned int num_samples, i; static const int timeout = 10000; if(dev->attached == 0) @@ -1332,23 +1332,23 @@ static void cb_pcidas_interrupt(int irq, void *d, struct pt_regs *regs) if(status & ADHFI) { // read data - insw(devpriv->adc_fifo + ADCDATA, data, half_fifo); - for(i = 0; i < half_fifo; i++) + num_samples = half_fifo; + if(async->cmd.stop_src == TRIG_COUNT && + num_samples > devpriv->count) { - comedi_buf_put(async, data[i]); - if(async->cmd.stop_src == TRIG_COUNT) - { - if(--devpriv->count == 0) - { /* end of acquisition */ - cb_pcidas_cancel(dev, s); - async->events |= COMEDI_CB_EOA; - break; - } - } + num_samples = devpriv->count; + } + insw(devpriv->adc_fifo + ADCDATA, data, num_samples); + comedi_buf_put_array(async, data, num_samples); + devpriv->count -= num_samples; + if(async->cmd.stop_src == TRIG_COUNT && + devpriv->count == 0) + { + async->events |= COMEDI_CB_EOA; + cb_pcidas_cancel(dev, s); } // clear half-full interrupt latch outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO); - async->events |= COMEDI_CB_BLOCK; // else if fifo not empty }else if(status & (ADNEI | EOBI)) { @@ -1367,9 +1367,9 @@ static void cb_pcidas_interrupt(int irq, void *d, struct pt_regs *regs) break; } } + async->events |= COMEDI_CB_BLOCK; // clear not-empty interrupt latch outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO); - async->events |= COMEDI_CB_BLOCK; }else if(status & EOAI) { comedi_error(dev, "bug! encountered end of aquisition interrupt?"); diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index 15a2cf14..0c99ebd4 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -1754,7 +1754,6 @@ static void drain_dma_buffers(comedi_device *dev, unsigned int channel) DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr); } // XXX check for buffer overrun somehow - async->events |= COMEDI_CB_BLOCK; } static void handle_interrupt(int irq, void *d, struct pt_regs *regs) diff --git a/comedi/drivers/das16.c b/comedi/drivers/das16.c index cefe4589..3810daf4 100644 --- a/comedi/drivers/das16.c +++ b/comedi/drivers/das16.c @@ -439,7 +439,7 @@ static struct das16_board_struct das16_boards[]={ name: "pc104-das16jr", // pc104-das16jr_xx.pdf ai: das16_ai_rinsn, ai_nbits: 12, - ai_speed: 6667, + ai_speed: 3300, ai_pg: das16_pg_16jr, ao: NULL, di: das16_di_rbits, diff --git a/comedi/drivers/das16m1.c b/comedi/drivers/das16m1.c index bbb09886..d2e21e6d 100644 --- a/comedi/drivers/das16m1.c +++ b/comedi/drivers/das16m1.c @@ -538,9 +538,11 @@ static void das16m1_handler(comedi_device *dev, unsigned int status) insw(dev->iobase, data, num_samples); for(i = 0; i < num_samples; i++) { - comedi_buf_put(async, AI_DATA(data[i])); - devpriv->adc_count++; + data[i] = AI_DATA(data[i]); } + comedi_buf_put_array(async, data, num_samples); + devpriv->adc_count += num_samples; + if(cmd->stop_src == TRIG_COUNT) { if(devpriv->adc_count >= cmd->stop_arg * cmd->chanlist_len) @@ -559,7 +561,6 @@ static void das16m1_handler(comedi_device *dev, unsigned int status) comedi_error(dev, "fifo overflow"); } - async->events |= COMEDI_CB_BLOCK; comedi_event(dev, s, async->events); } diff --git a/comedi/drivers/ni_at_a2150.c b/comedi/drivers/ni_at_a2150.c index b6233f37..c95cef2a 100644 --- a/comedi/drivers/ni_at_a2150.c +++ b/comedi/drivers/ni_at_a2150.c @@ -311,9 +311,12 @@ static void a2150_interrupt(int irq, void *d, struct pt_regs *regs) } } // re-enable dma - set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); - set_dma_count(devpriv->dma, leftover * sample_size); - enable_dma(devpriv->dma); + if(leftover) + { + set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); + set_dma_count(devpriv->dma, leftover * sample_size); + enable_dma(devpriv->dma); + } release_dma_lock(flags); async->events |= COMEDI_CB_BLOCK; diff --git a/comedi/drivers/ni_labpc.c b/comedi/drivers/ni_labpc.c index 08d2fb4f..1200f4b2 100644 --- a/comedi/drivers/ni_labpc.c +++ b/comedi/drivers/ni_labpc.c @@ -1405,7 +1405,6 @@ static void labpc_drain_dma(comedi_device *dev) { comedi_subdevice *s = dev->read_subdev; comedi_async *async = s->async; - int i; int status; unsigned long flags; unsigned int max_points, num_points, residue, leftover; @@ -1442,12 +1441,9 @@ static void labpc_drain_dma(comedi_device *dev) leftover = max_points; } - for(i = 0; i < num_points; i++) - { - /* write data point to comedi buffer */ - comedi_buf_put(async, devpriv->dma_buffer[i]); - if(async->cmd.stop_src == TRIG_COUNT) devpriv->count--; - } + /* write data to comedi buffer */ + comedi_buf_put_array(async, devpriv->dma_buffer, num_points); + if(async->cmd.stop_src == TRIG_COUNT) devpriv->count -= num_points; // set address and count for next transfer set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer)); diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index cf73eccd..d59dd372 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -349,6 +349,7 @@ static inline void comedi_buf_put_array(comedi_async *async, sampl_t* array, uns async->buf_int_count += num_bytes; xfer_count += num_bytes; } + async->events |= COMEDI_CB_BLOCK; } /* Reads a data point from comedi's buffer, used for output. -- 2.26.2