drivers/comedi/drivers/dt2815.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/dt2815.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/dt2815.c- Extension
.c- Size
- 6299 bytes
- Lines
- 230
- Domain
- Driver Families
- Bucket
- drivers/comedi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.hlinux/delay.h
Detected Declarations
struct dt2815_privatefunction dt2815_ao_statusfunction dt2815_ao_insn_readfunction dt2815_ao_insnfunction dt2815_attachfunction bus
Annotated Snippet
struct dt2815_private {
const struct comedi_lrange *range_type_list[8];
unsigned int ao_readback[8];
};
static int dt2815_ao_status(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + DT2815_STATUS);
if (status == context)
return 0;
return -EBUSY;
}
static int dt2815_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct dt2815_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
for (i = 0; i < insn->n; i++)
data[i] = devpriv->ao_readback[chan];
return i;
}
static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct dt2815_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned int lo, hi;
int ret;
for (i = 0; i < insn->n; i++) {
/* FIXME: lo bit 0 chooses voltage output or current output */
lo = ((data[i] & 0x0f) << 4) | (chan << 1) | 0x01;
hi = (data[i] & 0xff0) >> 4;
ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x00);
if (ret)
return ret;
outb(lo, dev->iobase + DT2815_DATA);
ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x10);
if (ret)
return ret;
outb(hi, dev->iobase + DT2815_DATA);
devpriv->ao_readback[chan] = data[i];
}
return i;
}
/*
* options[0] Board base address
* options[1] IRQ (not applicable)
* options[2] Voltage unipolar/bipolar configuration
* 0 == unipolar 5V (0V -- +5V)
* 1 == bipolar 5V (-5V -- +5V)
* options[3] Current offset configuration
* 0 == disabled (0mA -- +32mAV)
* 1 == enabled (+4mA -- +20mAV)
* options[4] Firmware program configuration
* 0 == program 1 (see manual table 5-4)
* 1 == program 2 (see manual table 5-4)
* 2 == program 3 (see manual table 5-4)
* 3 == program 4 (see manual table 5-4)
* options[5] Analog output 0 range configuration
* 0 == voltage
* 1 == current
* options[6] Analog output 1 range configuration
* ...
* options[12] Analog output 7 range configuration
* 0 == voltage
* 1 == current
*/
static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct dt2815_private *devpriv;
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `linux/delay.h`.
- Detected declarations: `struct dt2815_private`, `function dt2815_ao_status`, `function dt2815_ao_insn_read`, `function dt2815_ao_insn`, `function dt2815_attach`, `function bus`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.