unsigned int num_bytes)
{
struct comedi_async *async = s->async;
+ struct comedi_cmd *cmd = &async->cmd;
unsigned int scan_length = comedi_bytes_per_scan(s);
+ /* track the 'cur_chan' for non-SDF_PACKED subdevices */
+ if (!(s->subdev_flags & SDF_PACKED)) {
+ async->cur_chan += comedi_bytes_to_samples(s, num_bytes);
+ async->cur_chan %= cmd->chanlist_len;
+ }
+
async->scan_progress += num_bytes;
if (async->scan_progress >= scan_length) {
async->scan_progress %= scan_length;
devpriv->ui_AiActualScan +=
(s->async->cur_chan + num_samples) / cmd->scan_end_arg;
- s->async->cur_chan += num_samples;
- s->async->cur_chan %= cmd->scan_end_arg;
comedi_buf_write_samples(s, dma_buffer, num_samples);
}
num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples);
devpriv->ai_act_scan +=
(s->async->cur_chan + num_samples) / cmd->scan_end_arg;
- s->async->cur_chan += num_samples;
- s->async->cur_chan %= cmd->scan_end_arg;
comedi_buf_write_samples(s, dma_buffer, num_samples);
}
sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG);
comedi_buf_write_samples(s, &sampl, 1);
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->scan_end_arg) {
- /* one scan done */
- s->async->cur_chan %= cmd->scan_end_arg;
+
+ if (s->async->cur_chan == 0) {
devpriv->ai_act_scan++;
if (!devpriv->ai_neverending) {
/* all data sampled? */
val &= s->maxdata;
comedi_buf_write_samples(s, &val, 1);
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->chanlist_len)
- s->async->cur_chan = 0;
-
-
if (s->async->cur_chan == 0) { /* one scan done */
devpriv->ai_act_scan++;
if (cmd->stop_src == TRIG_COUNT &&
struct comedi_subdevice *s, int n, int turn)
{
struct pci1710_private *devpriv = dev->private;
- struct comedi_cmd *cmd = &s->async->cmd;
unsigned int val;
int ret;
int i;
val &= s->maxdata;
comedi_buf_write_samples(s, &val, 1);
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->chanlist_len) {
- s->async->cur_chan = 0;
+ if (s->async->cur_chan == 0)
devpriv->ai_act_scan++;
- }
}
return 0;
}
struct comedi_subdevice *s, int n)
{
struct ni_private *devpriv = dev->private;
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
- int chan;
int i;
unsigned short d;
u32 packed_data;
- chan = async->cur_chan;
for (i = 0; i < n; i++) {
comedi_buf_read_samples(s, &d, 1);
/* 6711 only has 16 bit wide ao fifo */
if (!devpriv->is_6711) {
comedi_buf_read_samples(s, &d, 1);
- chan++;
i++;
packed_data |= (d << 16) & 0xffff0000;
}
} else {
ni_writew(dev, d, DAC_FIFO_Data);
}
- chan++;
- chan %= cmd->chanlist_len;
}
- async->cur_chan = chan;
}
/*
struct pcl812_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->chanlist_len) {
- s->async->cur_chan = 0;
+ if (s->async->cur_chan == 0)
devpriv->ai_act_scan++;
- s->async->events |= COMEDI_CB_EOS;
- }
if (cmd->stop_src == TRIG_COUNT &&
devpriv->ai_act_scan >= cmd->stop_arg) {
struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
+ unsigned int chan = s->async->cur_chan;
unsigned int next_chan;
unsigned short val;
comedi_buf_write_samples(s, &val, 1);
/* Set up next channel. Added by abbotti 2010-01-20, but untested. */
- next_chan = s->async->cur_chan + 1;
- if (next_chan >= cmd->chanlist_len)
- next_chan = 0;
- if (cmd->chanlist[s->async->cur_chan] != cmd->chanlist[next_chan])
+ next_chan = s->async->cur_chan;
+ if (cmd->chanlist[chan] != cmd->chanlist[next_chan])
pcl812_ai_set_chan_range(dev, cmd->chanlist[next_chan], 0);
pcl812_ai_next_chan(dev, s);
struct pcl816_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->chanlist_len) {
- s->async->cur_chan = 0;
+ if (s->async->cur_chan == 0)
devpriv->ai_act_scan++;
- s->async->events |= COMEDI_CB_EOS;
- }
if (cmd->stop_src == TRIG_COUNT &&
devpriv->ai_act_scan >= cmd->stop_arg) {
if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len)
devpriv->act_chanlist_pos = 0;
- s->async->cur_chan++;
- if (s->async->cur_chan >= cmd->chanlist_len) {
- s->async->cur_chan = 0;
+ if (s->async->cur_chan == 0)
devpriv->ai_act_scan--;
- s->async->events |= COMEDI_CB_EOS;
- }
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan == 0) {
/* all data sampled */
if (!comedi_buf_write_samples(s, &d, 1))
return -1;
- async->cur_chan++;
- async->cur_chan %= cmd->chanlist_len;
-
if (devpriv->ai_count > 0) /* < 0, means read forever */
devpriv->ai_count--;
}