converted some drivers to use comedi_buf_put_array
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 13 Apr 2002 15:49:35 +0000 (15:49 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 13 Apr 2002 15:49:35 +0000 (15:49 +0000)
comedi/drivers/cb_pcidas.c
comedi/drivers/cb_pcidas64.c
comedi/drivers/das16.c
comedi/drivers/das16m1.c
comedi/drivers/ni_at_a2150.c
comedi/drivers/ni_labpc.c
include/linux/comedidev.h

index 7a9dcbed220cd855ea32144cc1d72f03862e50fc..6ed0d80fb932ba3f2cce27c79e3917e8151e86eb 100644 (file)
@@ -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?");
index 15a2cf14a3c21dd216ed7d4e94ed2d6c1a1f3040..0c99ebd41d56c39c3e5c4204c83742e8ec395703 100644 (file)
@@ -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)
index cefe45890450c3ca18076e4ecc1d6bfed00b9606..3810daf40255d66a0642cdd226433cee047c56a2 100644 (file)
@@ -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,
index bbb09886ccfc9122123dc3cd5692beb353a02e17..d2e21e6db14386aeb0385df3b2dec8b20ae791ba 100644 (file)
@@ -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);
 
 }
index b6233f37df25322bc1a6d2595ce2d7de541e689d..c95cef2af34834982540c64505d2fad8af513adb 100644 (file)
@@ -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;
index 08d2fb4fb67a43c2afdc5f7b08baaf6b141939dd..1200f4b23828185514fadb9d3d83f7d2be540129 100644 (file)
@@ -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));
index cf73eccdd965ca9080bb5bb79c51d24d52a4f37b..d59dd372c20d62f13a562ea681f04e62b9947f57 100644 (file)
@@ -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.