Commit 843681c8 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das1800: introduce das1800_ai_chanspec_bits()

Introduce a helper function for the common code needed to set the
control c register bits for a channel specification.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 750bca65
......@@ -749,25 +749,32 @@ static int control_a_bits(const struct comedi_cmd *cmd)
return control_a;
}
/* returns appropriate bits for control register c, depending on command */
static int control_c_bits(struct comedi_subdevice *s,
const struct comedi_cmd *cmd)
static unsigned char das1800_ai_chanspec_bits(struct comedi_subdevice *s,
unsigned int chanspec)
{
unsigned int range = CR_RANGE(cmd->chanlist[0]);
unsigned int aref = CR_AREF(cmd->chanlist[0]);
int control_c;
unsigned int range = CR_RANGE(chanspec);
unsigned int aref = CR_AREF(chanspec);
unsigned char bits;
/* set clock source to internal or external, select analog reference,
* select unipolar / bipolar
*/
control_c = UQEN; /* enable upper qram addresses */
bits = UQEN;
if (aref != AREF_DIFF)
control_c |= SD;
bits |= SD;
if (aref == AREF_COMMON)
control_c |= CMEN;
bits |= CMEN;
if (comedi_range_is_unipolar(s, range))
control_c |= UB;
bits |= UB;
return bits;
}
static int control_c_bits(struct comedi_subdevice *s,
const struct comedi_cmd *cmd)
{
int control_c;
control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]);
/* set clock source to internal or external */
switch (cmd->scan_begin_src) {
case TRIG_FOLLOW: /* not in burst mode */
switch (cmd->convert_src) {
......@@ -955,25 +962,15 @@ static int das1800_ai_insn_read(struct comedi_device *dev,
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
bool is_unipolar = comedi_range_is_unipolar(s, range);
int i, n;
int chan_range;
int timeout = 1000;
unsigned short dpnt;
int conv_flags = 0;
unsigned long irq_flags;
/* set up analog reference and unipolar / bipolar mode */
conv_flags |= UQEN;
if (aref != AREF_DIFF)
conv_flags |= SD;
if (aref == AREF_COMMON)
conv_flags |= CMEN;
if (is_unipolar)
conv_flags |= UB;
outb(conv_flags, dev->iobase + DAS1800_CONTROL_C); /* software conversion enabled */
outb(das1800_ai_chanspec_bits(s, insn->chanspec),
dev->iobase + DAS1800_CONTROL_C); /* software pacer */
outb(CVEN, dev->iobase + DAS1800_STATUS); /* enable conversions */
outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* reset fifo */
outb(FFEN, dev->iobase + DAS1800_CONTROL_A);
......
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