drivers/comedi/drivers/pcl816.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/pcl816.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/pcl816.c- Extension
.c- Size
- 18008 bytes
- Lines
- 696
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/gfp.hlinux/delay.hlinux/io.hlinux/interrupt.hlinux/comedi/comedidev.hlinux/comedi/comedi_8254.hlinux/comedi/comedi_isadma.h
Detected Declarations
struct pcl816_boardstruct pcl816_privatefunction pcl816_ai_setup_dmafunction pcl816_ai_set_chan_rangefunction pcl816_ai_set_chan_scanfunction pcl816_ai_setup_chanlistfunction pcl816_ai_clear_eocfunction pcl816_ai_soft_trigfunction pcl816_ai_get_samplefunction pcl816_ai_eocfunction pcl816_ai_next_chanfunction transfer_from_dma_buffunction pcl816_interruptfunction check_channel_listfunction pcl816_ai_cmdtestfunction pcl816_ai_cmdfunction pcl816_ai_pollfunction pcl816_ai_cancelfunction pcl816_ai_insn_readfunction pcl816_di_insn_bitsfunction pcl816_do_insn_bitsfunction pcl816_resetfunction pcl816_alloc_irq_and_dmafunction pcl816_free_dmafunction pcl816_attachfunction pcl816_detach
Annotated Snippet
struct pcl816_board {
const char *name;
int ai_maxdata;
int ai_chanlist;
};
static const struct pcl816_board boardtypes[] = {
{
.name = "pcl816",
.ai_maxdata = 0xffff,
.ai_chanlist = 1024,
}, {
.name = "pcl814b",
.ai_maxdata = 0x3fff,
.ai_chanlist = 1024,
},
};
struct pcl816_private {
struct comedi_isadma *dma;
unsigned int ai_poll_ptr; /* how many sampes transfer poll */
unsigned int ai_cmd_running:1;
unsigned int ai_cmd_canceled:1;
};
static void pcl816_ai_setup_dma(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int unread_samples)
{
struct pcl816_private *devpriv = dev->private;
struct comedi_isadma *dma = devpriv->dma;
struct comedi_isadma_desc *desc = &dma->desc[dma->cur_dma];
unsigned int max_samples = comedi_bytes_to_samples(s, desc->maxsize);
unsigned int nsamples;
comedi_isadma_disable(dma->chan);
/*
* Determine dma size based on the buffer maxsize plus the number of
* unread samples and the number of samples remaining in the command.
*/
nsamples = comedi_nsamples_left(s, max_samples + unread_samples);
if (nsamples > unread_samples) {
nsamples -= unread_samples;
desc->size = comedi_samples_to_bytes(s, nsamples);
comedi_isadma_program(desc);
}
}
static void pcl816_ai_set_chan_range(struct comedi_device *dev,
unsigned int chan,
unsigned int range)
{
outb(chan, dev->iobase + PCL816_MUX_REG);
outb(range, dev->iobase + PCL816_RANGE_REG);
}
static void pcl816_ai_set_chan_scan(struct comedi_device *dev,
unsigned int first_chan,
unsigned int last_chan)
{
outb(PCL816_MUX_SCAN(first_chan, last_chan),
dev->iobase + PCL816_MUX_REG);
}
static void pcl816_ai_setup_chanlist(struct comedi_device *dev,
unsigned int *chanlist,
unsigned int seglen)
{
unsigned int first_chan = CR_CHAN(chanlist[0]);
unsigned int last_chan;
unsigned int range;
unsigned int i;
/* store range list to card */
for (i = 0; i < seglen; i++) {
last_chan = CR_CHAN(chanlist[i]);
range = CR_RANGE(chanlist[i]);
pcl816_ai_set_chan_range(dev, last_chan, range);
}
udelay(1);
pcl816_ai_set_chan_scan(dev, first_chan, last_chan);
}
static void pcl816_ai_clear_eoc(struct comedi_device *dev)
{
/* writing any value clears the interrupt request */
Annotation
- Immediate include surface: `linux/module.h`, `linux/gfp.h`, `linux/delay.h`, `linux/io.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8254.h`, `linux/comedi/comedi_isadma.h`.
- Detected declarations: `struct pcl816_board`, `struct pcl816_private`, `function pcl816_ai_setup_dma`, `function pcl816_ai_set_chan_range`, `function pcl816_ai_set_chan_scan`, `function pcl816_ai_setup_chanlist`, `function pcl816_ai_clear_eoc`, `function pcl816_ai_soft_trig`, `function pcl816_ai_get_sample`, `function pcl816_ai_eoc`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.