Skip to content

Commit ed87d33

Browse files
ian-abbottgregkh
authored andcommitted
staging: comedi: dt2815: fix writing hi byte of analog output
The DT2815 analog output command is 16 bits wide, consisting of the 12-bit sample value in bits 15 to 4, the channel number in bits 3 to 1, and a voltage or current selector in bit 0. Both bytes of the 16-bit command need to be written in turn to a single 8-bit data register. However, the driver currently only writes the low 8-bits. It is broken and appears to have always been broken. Electronic copies of the DT2815 User's Manual seem impossible to find online, but looking at the source code, a best guess for the sequence the driver intended to use to write the analog output command is as follows: 1. Wait for the status register to read 0x00. 2. Write the low byte of the command to the data register. 3. Wait for the status register to read 0x80. 4. Write the high byte of the command to the data register. Step 4 is missing from the driver. Add step 4 to (hopefully) fix the driver. Also add a "FIXME" comment about setting bit 0 of the low byte of the command. Supposedly, it is used to choose between voltage output and current output, but the current driver always sets it to 1. Signed-off-by: Ian Abbott <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9195d76 commit ed87d33

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/staging/comedi/drivers/dt2815.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
9292
int ret;
9393

9494
for (i = 0; i < insn->n; i++) {
95+
/* FIXME: lo bit 0 chooses voltage output or current output */
9596
lo = ((data[i] & 0x0f) << 4) | (chan << 1) | 0x01;
9697
hi = (data[i] & 0xff0) >> 4;
9798

@@ -105,6 +106,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
105106
if (ret)
106107
return ret;
107108

109+
outb(hi, dev->iobase + DT2815_DATA);
110+
108111
devpriv->ao_readback[chan] = data[i];
109112
}
110113
return i;

0 commit comments

Comments
 (0)