drivers/comedi/drivers/das08.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/das08.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/das08.c- Extension
.c- Size
- 12923 bytes
- Lines
- 459
- Domain
- Driver Families
- Bucket
- drivers/comedi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.hlinux/comedi/comedi_8255.hlinux/comedi/comedi_8254.hdas08.h
Detected Declarations
function das08_ai_eocfunction das08_ai_insn_readfunction das08_di_insn_bitsfunction das08_do_insn_bitsfunction das08jr_di_insn_bitsfunction das08jr_do_insn_bitsfunction das08_ao_set_datafunction das08_ao_insn_writefunction das08_common_attachexport das08_common_attach
Annotated Snippet
if (board->ai_encoding == das08_encode12) {
data[n] = (lsb >> 4) | (msb << 4);
} else if (board->ai_encoding == das08_pcm_encode12) {
data[n] = (msb << 8) + lsb;
} else if (board->ai_encoding == das08_encode16) {
/*
* "JR" 16-bit boards are sign-magnitude.
*
* XXX The manual seems to imply that 0 is full-scale
* negative and 65535 is full-scale positive, but the
* original COMEDI patch to add support for the
* DAS08/JR/16 and DAS08/JR/16-AO boards have it
* encoded as sign-magnitude. Assume the original
* COMEDI code is correct for now.
*/
unsigned int magnitude = lsb | ((msb & 0x7f) << 8);
/*
* MSB bit 7 is 0 for negative, 1 for positive voltage.
* COMEDI 16-bit bipolar data value for 0V is 0x8000.
*/
if (msb & 0x80)
data[n] = BIT(15) + magnitude;
else
data[n] = BIT(15) - magnitude;
} else {
dev_err(dev->class_dev, "bug! unknown ai encoding\n");
return -1;
}
}
return n;
}
static int das08_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG));
return insn->n;
}
static int das08_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct das08_private_struct *devpriv = dev->private;
if (comedi_dio_update_state(s, data)) {
/* prevent race with setting of analog input mux */
spin_lock(&dev->spinlock);
devpriv->do_mux_bits &= ~DAS08_CONTROL_DO_MASK;
devpriv->do_mux_bits |= DAS08_CONTROL_DO(s->state);
outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG);
spin_unlock(&dev->spinlock);
}
data[1] = s->state;
return insn->n;
}
static int das08jr_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = inb(dev->iobase + DAS08JR_DI_REG);
return insn->n;
}
static int das08jr_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (comedi_dio_update_state(s, data))
outb(s->state, dev->iobase + DAS08JR_DO_REG);
data[1] = s->state;
return insn->n;
}
static void das08_ao_set_data(struct comedi_device *dev,
unsigned int chan, unsigned int data)
{
const struct das08_board_struct *board = dev->board_ptr;
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8255.h`, `linux/comedi/comedi_8254.h`, `das08.h`.
- Detected declarations: `function das08_ai_eoc`, `function das08_ai_insn_read`, `function das08_di_insn_bits`, `function das08_do_insn_bits`, `function das08jr_di_insn_bits`, `function das08jr_do_insn_bits`, `function das08_ao_set_data`, `function das08_ao_insn_write`, `function das08_common_attach`, `export das08_common_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.