drivers/comedi/drivers/pcm3724.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/pcm3724.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/pcm3724.c- Extension
.c- Size
- 5630 bytes
- Lines
- 227
- 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/comedi/comedi_8255.h
Detected Declarations
struct priv_pcm3724function compute_bufferfunction do_3724_configfunction enable_chanfunction subdev_3724_insn_configfunction pcm3724_attach
Annotated Snippet
struct priv_pcm3724 {
int dio_1;
int dio_2;
};
static int compute_buffer(int config, int devno, struct comedi_subdevice *s)
{
/* 1 in io_bits indicates output */
if (s->io_bits & 0x0000ff) {
if (devno == 0)
config |= PCM3724_DIO_DIR_A0_OUT;
else
config |= PCM3724_DIO_DIR_A1_OUT;
}
if (s->io_bits & 0x00ff00) {
if (devno == 0)
config |= PCM3724_DIO_DIR_B0_OUT;
else
config |= PCM3724_DIO_DIR_B1_OUT;
}
if (s->io_bits & 0xff0000) {
if (devno == 0)
config |= PCM3724_DIO_DIR_C0_OUT;
else
config |= PCM3724_DIO_DIR_C1_OUT;
}
return config;
}
static void do_3724_config(struct comedi_device *dev,
struct comedi_subdevice *s, int chanspec)
{
struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
struct comedi_subdevice *s_dio2 = &dev->subdevices[1];
int config;
int buffer_config;
unsigned long port_8255_cfg;
config = I8255_CTRL_CW;
/* 1 in io_bits indicates output, 1 in config indicates input */
if (!(s->io_bits & 0x0000ff))
config |= I8255_CTRL_A_IO;
if (!(s->io_bits & 0x00ff00))
config |= I8255_CTRL_B_IO;
if (!(s->io_bits & 0xff0000))
config |= I8255_CTRL_C_HI_IO | I8255_CTRL_C_LO_IO;
buffer_config = compute_buffer(0, 0, s_dio1);
buffer_config = compute_buffer(buffer_config, 1, s_dio2);
if (s == s_dio1)
port_8255_cfg = dev->iobase + I8255_CTRL_REG;
else
port_8255_cfg = dev->iobase + I8255_SIZE + I8255_CTRL_REG;
outb(buffer_config, dev->iobase + PCM3724_DIO_DIR_REG);
outb(config, port_8255_cfg);
}
static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
int chanspec)
{
struct priv_pcm3724 *priv = dev->private;
struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
unsigned int mask;
int gatecfg;
gatecfg = 0;
mask = 1 << CR_CHAN(chanspec);
if (s == s_dio1)
priv->dio_1 |= mask;
else
priv->dio_2 |= mask;
if (priv->dio_1 & 0xff0000)
gatecfg |= PCM3724_GATE_CTRL_C0_ENA;
if (priv->dio_1 & 0xff00)
gatecfg |= PCM3724_GATE_CTRL_B0_ENA;
if (priv->dio_1 & 0xff)
gatecfg |= PCM3724_GATE_CTRL_A0_ENA;
if (priv->dio_2 & 0xff0000)
gatecfg |= PCM3724_GATE_CTRL_C1_ENA;
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8255.h`.
- Detected declarations: `struct priv_pcm3724`, `function compute_buffer`, `function do_3724_config`, `function enable_chan`, `function subdev_3724_insn_config`, `function pcm3724_attach`.
- 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.