drivers/media/pci/mantis/mantis_dma.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/mantis/mantis_dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/mantis/mantis_dma.c- Extension
.c- Size
- 5770 bytes
- Lines
- 217
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hasm/page.hlinux/vmalloc.hlinux/pci.hasm/irq.hlinux/signal.hlinux/sched.hlinux/interrupt.hmedia/dmxdev.hmedia/dvbdev.hmedia/dvb_demux.hmedia/dvb_frontend.hmedia/dvb_net.hmantis_common.hmantis_reg.hmantis_dma.h
Detected Declarations
function Copyrightfunction mantis_alloc_buffersfunction mantis_dma_initfunction mantis_risc_programfunction mantis_dma_startfunction mantis_dma_stopfunction mantis_dma_xferexport mantis_dma_exitexport mantis_dma_init
Annotated Snippet
if (!mantis->buf_cpu) {
dprintk(MANTIS_ERROR, 1,
"DMA buffer allocation failed");
goto err;
}
dprintk(MANTIS_ERROR, 1,
"DMA=0x%lx cpu=0x%p size=%d",
(unsigned long) mantis->buf_dma,
mantis->buf_cpu, MANTIS_BUF_SIZE);
}
if (!mantis->risc_cpu) {
mantis->risc_cpu = dma_alloc_coherent(&mantis->pdev->dev,
MANTIS_RISC_SIZE,
&mantis->risc_dma, GFP_KERNEL);
if (!mantis->risc_cpu) {
dprintk(MANTIS_ERROR, 1,
"RISC program allocation failed");
mantis_dma_exit(mantis);
goto err;
}
dprintk(MANTIS_ERROR, 1,
"RISC=0x%lx cpu=0x%p size=%lx",
(unsigned long) mantis->risc_dma,
mantis->risc_cpu, MANTIS_RISC_SIZE);
}
return 0;
err:
dprintk(MANTIS_ERROR, 1, "Out of memory (?) .....");
return -ENOMEM;
}
int mantis_dma_init(struct mantis_pci *mantis)
{
int err;
dprintk(MANTIS_DEBUG, 1, "Mantis DMA init");
err = mantis_alloc_buffers(mantis);
if (err < 0) {
dprintk(MANTIS_ERROR, 1, "Error allocating DMA buffer");
/* Stop RISC Engine */
mmwrite(0, MANTIS_DMA_CTL);
return err;
}
return 0;
}
EXPORT_SYMBOL_GPL(mantis_dma_init);
static inline void mantis_risc_program(struct mantis_pci *mantis)
{
u32 buf_pos = 0;
u32 line, step;
u32 risc_pos;
dprintk(MANTIS_DEBUG, 1, "Mantis create RISC program");
RISC_FLUSH(risc_pos);
dprintk(MANTIS_DEBUG, 1, "risc len lines %u, bytes per line %u, bytes per DMA tr %u",
MANTIS_BLOCK_COUNT, MANTIS_BLOCK_BYTES, MANTIS_DMA_TR_BYTES);
for (line = 0; line < MANTIS_BLOCK_COUNT; line++) {
for (step = 0; step < MANTIS_DMA_TR_UNITS; step++) {
dprintk(MANTIS_DEBUG, 1, "RISC PROG line=[%d], step=[%d]", line, step);
if (step == 0) {
RISC_INSTR(risc_pos, RISC_WRITE |
RISC_IRQ |
RISC_STATUS(line) |
MANTIS_DMA_TR_BYTES);
} else {
RISC_INSTR(risc_pos, RISC_WRITE | MANTIS_DMA_TR_BYTES);
}
RISC_INSTR(risc_pos, mantis->buf_dma + buf_pos);
buf_pos += MANTIS_DMA_TR_BYTES;
}
}
RISC_INSTR(risc_pos, RISC_JUMP);
RISC_INSTR(risc_pos, mantis->risc_dma);
}
void mantis_dma_start(struct mantis_pci *mantis)
{
dprintk(MANTIS_DEBUG, 1, "Mantis Start DMA engine");
Annotation
- Immediate include surface: `linux/kernel.h`, `asm/page.h`, `linux/vmalloc.h`, `linux/pci.h`, `asm/irq.h`, `linux/signal.h`, `linux/sched.h`, `linux/interrupt.h`.
- Detected declarations: `function Copyright`, `function mantis_alloc_buffers`, `function mantis_dma_init`, `function mantis_risc_program`, `function mantis_dma_start`, `function mantis_dma_stop`, `function mantis_dma_xfer`, `export mantis_dma_exit`, `export mantis_dma_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.