drivers/comedi/drivers/pcl711.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/pcl711.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/pcl711.c- Extension
.c- Size
- 12795 bytes
- Lines
- 516
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/delay.hlinux/interrupt.hlinux/comedi/comedidev.hlinux/comedi/comedi_8254.h
Detected Declarations
struct pcl711_boardfunction pcl711_ai_set_modefunction pcl711_ai_get_samplefunction pcl711_ai_cancelfunction pcl711_interruptfunction pcl711_set_changainfunction pcl711_ai_eocfunction pcl711_ai_insn_readfunction pcl711_ai_cmdtestfunction pcl711_ai_cmdfunction pcl711_ao_writefunction pcl711_ao_insn_writefunction pcl711_di_insn_bitsfunction pcl711_do_insn_bitsfunction pcl711_attach
Annotated Snippet
struct pcl711_board {
const char *name;
int n_aichan;
int n_aochan;
int maxirq;
unsigned int min_io_start;
const struct comedi_lrange *ai_range_type;
};
static const struct pcl711_board boardtypes[] = {
{
.name = "pcl711",
.n_aichan = 8,
.n_aochan = 1,
.ai_range_type = &range_bipolar5,
}, {
.name = "pcl711b",
.n_aichan = 8,
.n_aochan = 1,
.maxirq = 7,
.ai_range_type = &range_pcl711b_ai,
}, {
.name = "acl8112hg",
.n_aichan = 16,
.n_aochan = 2,
.maxirq = 15,
.min_io_start = 0x200,
.ai_range_type = &range_acl8112hg_ai,
}, {
.name = "acl8112dg",
.n_aichan = 16,
.n_aochan = 2,
.maxirq = 15,
.min_io_start = 0x200,
.ai_range_type = &range_acl8112dg_ai,
},
};
static void pcl711_ai_set_mode(struct comedi_device *dev, unsigned int mode)
{
/*
* The pcl711b board uses bits in the mode register to select the
* interrupt. The other boards supported by this driver all use
* jumpers on the board.
*
* Enables the interrupt when needed on the pcl711b board. These
* bits do nothing on the other boards.
*/
if (mode == PCL711_MODE_EXT_IRQ || mode == PCL711_MODE_PACER_IRQ)
mode |= PCL711_MODE_IRQ(dev->irq);
outb(mode, dev->iobase + PCL711_MODE_REG);
}
static unsigned int pcl711_ai_get_sample(struct comedi_device *dev,
struct comedi_subdevice *s)
{
unsigned int val;
val = inb(dev->iobase + PCL711_AI_MSB_REG) << 8;
val |= inb(dev->iobase + PCL711_AI_LSB_REG);
return val & s->maxdata;
}
static int pcl711_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG);
return 0;
}
static irqreturn_t pcl711_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned short data;
if (!dev->attached) {
dev_err(dev->class_dev, "spurious interrupt\n");
return IRQ_HANDLED;
}
data = pcl711_ai_get_sample(dev, s);
outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
comedi_buf_write_samples(s, &data, 1);
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8254.h`.
- Detected declarations: `struct pcl711_board`, `function pcl711_ai_set_mode`, `function pcl711_ai_get_sample`, `function pcl711_ai_cancel`, `function pcl711_interrupt`, `function pcl711_set_changain`, `function pcl711_ai_eoc`, `function pcl711_ai_insn_read`, `function pcl711_ai_cmdtest`, `function pcl711_ai_cmd`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.