drivers/comedi/drivers/ni_labpc.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_labpc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_labpc.c- Extension
.c- Size
- 3490 bytes
- Lines
- 117
- 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.hni_labpc.hni_labpc_isadma.h
Detected Declarations
function labpc_attachfunction labpc_detach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* comedi/drivers/ni_labpc.c
* Driver for National Instruments Lab-PC series boards and compatibles
* Copyright (C) 2001-2003 Frank Mori Hess <fmhess@users.sourceforge.net>
*/
/*
* Driver: ni_labpc
* Description: National Instruments Lab-PC (& compatibles)
* Devices: [National Instruments] Lab-PC-1200 (lab-pc-1200),
* Lab-PC-1200AI (lab-pc-1200ai), Lab-PC+ (lab-pc+)
* Author: Frank Mori Hess <fmhess@users.sourceforge.net>
* Status: works
*
* Configuration options - ISA boards:
* [0] - I/O port base address
* [1] - IRQ (optional, required for timed or externally triggered
* conversions)
* [2] - DMA channel (optional)
*
* Tested with lab-pc-1200. For the older Lab-PC+, not all input
* ranges and analog references will work, the available ranges/arefs
* will depend on how you have configured the jumpers on your board
* (see your owner's manual).
*
* Kernel-level ISA plug-and-play support for the lab-pc-1200 boards
* has not yet been added to the driver, mainly due to the fact that
* I don't know the device id numbers. If you have one of these boards,
* please file a bug report at https://comedi.org/ so I can get the
* necessary information from you.
*
* The 1200 series boards have onboard calibration dacs for correcting
* analog input/output offsets and gains. The proper settings for these
* caldacs are stored on the board's eeprom. To read the caldac values
* from the eeprom and store them into a file that can be then be used
* by comedilib, use the comedi_calibrate program.
*
* The Lab-pc+ has quirky chanlist requirements when scanning multiple
* channels. Multiple channel scan sequence must start at highest channel,
* then decrement down to channel 0. The rest of the cards can scan down
* like lab-pc+ or scan up from channel zero. Chanlists consisting of all
* one channel are also legal, and allow you to pace conversions in bursts.
*
* NI manuals:
* 341309a (labpc-1200 register manual)
* 320502b (lab-pc+)
*/
#include <linux/module.h>
#include <linux/comedi/comedidev.h>
#include "ni_labpc.h"
#include "ni_labpc_isadma.h"
static const struct labpc_boardinfo labpc_boards[] = {
{
.name = "lab-pc-1200",
.ai_speed = 10000,
.ai_scan_up = 1,
.has_ao = 1,
.is_labpc1200 = 1,
}, {
.name = "lab-pc-1200ai",
.ai_speed = 10000,
.ai_scan_up = 1,
.is_labpc1200 = 1,
}, {
.name = "lab-pc+",
.ai_speed = 12000,
.has_ao = 1,
},
};
static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned int irq = it->options[1];
unsigned int dma_chan = it->options[2];
int ret;
ret = comedi_check_request_region(dev, it->options[0], 0x20,
0, 0x3ff, 32);
if (ret)
return ret;
ret = labpc_common_attach(dev, irq, 0);
if (ret)
return ret;
if (dev->irq)
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `ni_labpc.h`, `ni_labpc_isadma.h`.
- Detected declarations: `function labpc_attach`, `function labpc_detach`.
- 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.