Commit 40d948be authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: amplc_pci224: factor out the 'start pacer' code

To clarify the analog output (*do_cmd) function, factor out the
code that starts the pacer.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5aae1901
......@@ -901,65 +901,11 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
return 0;
}
/*
* 'do_cmd' function for AO subdevice.
*/
static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
static void pci224_ao_start_pacer(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int range;
unsigned int i, j;
unsigned int ch;
unsigned int rank;
unsigned long flags;
/* Cannot handle null/empty chanlist. */
if (cmd->chanlist == NULL || cmd->chanlist_len == 0)
return -EINVAL;
/* Determine which channels are enabled and their load order. */
devpriv->ao_enab = 0;
for (i = 0; i < cmd->chanlist_len; i++) {
ch = CR_CHAN(cmd->chanlist[i]);
devpriv->ao_enab |= 1U << ch;
rank = 0;
for (j = 0; j < cmd->chanlist_len; j++) {
if (CR_CHAN(cmd->chanlist[j]) < ch)
rank++;
}
devpriv->ao_scan_order[rank] = i;
}
/* Set enabled channels. */
outw(devpriv->ao_enab, dev->iobase + PCI224_DACCEN);
/* Determine range and polarity. All channels the same. */
range = CR_RANGE(cmd->chanlist[0]);
/*
* Set DAC range and polarity.
* Set DAC scan trigger source to 'none'.
* Set DAC FIFO interrupt trigger level to 'not half full'.
* Reset DAC FIFO.
*
* N.B. DAC FIFO interrupts are currently disabled.
*/
devpriv->daccon = COMBINE(devpriv->daccon,
(devpriv->
hwrange[range] | PCI224_DACCON_TRIG_NONE |
PCI224_DACCON_FIFOINTR_NHALF),
(PCI224_DACCON_POLAR_MASK |
PCI224_DACCON_VREF_MASK |
PCI224_DACCON_TRIG_MASK |
PCI224_DACCON_FIFOINTR_MASK));
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
dev->iobase + PCI224_DACCON);
if (cmd->scan_begin_src == TRIG_TIMER) {
unsigned int div1, div2, round;
unsigned int ns = cmd->scan_begin_arg;
int round_mode = cmd->flags & TRIG_ROUND_MASK;
......@@ -1024,7 +970,65 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
/* Load Z2-0 mode (2) and counter (div2). */
i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2);
}
static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int range;
unsigned int i, j;
unsigned int ch;
unsigned int rank;
unsigned long flags;
/* Cannot handle null/empty chanlist. */
if (cmd->chanlist == NULL || cmd->chanlist_len == 0)
return -EINVAL;
/* Determine which channels are enabled and their load order. */
devpriv->ao_enab = 0;
for (i = 0; i < cmd->chanlist_len; i++) {
ch = CR_CHAN(cmd->chanlist[i]);
devpriv->ao_enab |= 1U << ch;
rank = 0;
for (j = 0; j < cmd->chanlist_len; j++) {
if (CR_CHAN(cmd->chanlist[j]) < ch)
rank++;
}
devpriv->ao_scan_order[rank] = i;
}
/* Set enabled channels. */
outw(devpriv->ao_enab, dev->iobase + PCI224_DACCEN);
/* Determine range and polarity. All channels the same. */
range = CR_RANGE(cmd->chanlist[0]);
/*
* Set DAC range and polarity.
* Set DAC scan trigger source to 'none'.
* Set DAC FIFO interrupt trigger level to 'not half full'.
* Reset DAC FIFO.
*
* N.B. DAC FIFO interrupts are currently disabled.
*/
devpriv->daccon = COMBINE(devpriv->daccon,
(devpriv->
hwrange[range] | PCI224_DACCON_TRIG_NONE |
PCI224_DACCON_FIFOINTR_NHALF),
(PCI224_DACCON_POLAR_MASK |
PCI224_DACCON_VREF_MASK |
PCI224_DACCON_TRIG_MASK |
PCI224_DACCON_FIFOINTR_MASK));
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
dev->iobase + PCI224_DACCON);
if (cmd->scan_begin_src == TRIG_TIMER)
pci224_ao_start_pacer(dev, s);
/*
* Sort out end of acquisition.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment