drivers/media/pci/pt3/pt3_dma.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/pt3/pt3_dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/pt3/pt3_dma.c- Extension
.c- Size
- 4997 bytes
- Lines
- 217
- Domain
- Driver Families
- Bucket
- drivers/media
- 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/dma-mapping.hlinux/kernel.hlinux/pci.hpt3.h
Detected Declarations
function Copyrightfunction pt3_stop_dmafunction pt3_start_dmafunction pt3_proc_dmafunction pt3_init_dmabuffunction pt3_free_dmabuffunction pt3_alloc_dmabuf
Annotated Snippet
else if (adap->buf_ofs + PT3_ACCESS_UNIT > DATA_BUF_SZ) {
dvb_dmx_swfilter_packets(&adap->demux, p,
(DATA_BUF_SZ - adap->buf_ofs) / TS_PACKET_SZ);
dvb_dmx_swfilter_packets(&adap->demux,
adap->buffer[idx].data, ofs / TS_PACKET_SZ);
} else
dvb_dmx_swfilter_packets(&adap->demux, p,
PT3_ACCESS_UNIT / TS_PACKET_SZ);
*p = PT3_BUF_CANARY;
adap->buf_idx = idx;
adap->buf_ofs = ofs;
}
return 0;
}
void pt3_init_dmabuf(struct pt3_adapter *adap)
{
int idx, ofs;
u8 *p;
idx = 0;
ofs = 0;
p = adap->buffer[0].data;
/* mark the whole buffers as "not written yet" */
while (idx < adap->num_bufs) {
p[ofs] = PT3_BUF_CANARY;
ofs += PT3_ACCESS_UNIT;
if (ofs >= DATA_BUF_SZ) {
ofs -= DATA_BUF_SZ;
idx++;
p = adap->buffer[idx].data;
}
}
adap->buf_idx = 0;
adap->buf_ofs = 0;
}
void pt3_free_dmabuf(struct pt3_adapter *adap)
{
struct pt3_board *pt3;
int i;
pt3 = adap->dvb_adap.priv;
for (i = 0; i < adap->num_bufs; i++)
dma_free_coherent(&pt3->pdev->dev, DATA_BUF_SZ,
adap->buffer[i].data, adap->buffer[i].b_addr);
adap->num_bufs = 0;
for (i = 0; i < adap->num_desc_bufs; i++)
dma_free_coherent(&pt3->pdev->dev, PAGE_SIZE,
adap->desc_buf[i].descs, adap->desc_buf[i].b_addr);
adap->num_desc_bufs = 0;
}
int pt3_alloc_dmabuf(struct pt3_adapter *adap)
{
struct pt3_board *pt3;
void *p;
int i, j;
int idx, ofs;
int num_desc_bufs;
dma_addr_t data_addr, desc_addr;
struct xfer_desc *d;
pt3 = adap->dvb_adap.priv;
adap->num_bufs = 0;
adap->num_desc_bufs = 0;
for (i = 0; i < pt3->num_bufs; i++) {
p = dma_alloc_coherent(&pt3->pdev->dev, DATA_BUF_SZ,
&adap->buffer[i].b_addr, GFP_KERNEL);
if (p == NULL)
goto failed;
adap->buffer[i].data = p;
adap->num_bufs++;
}
pt3_init_dmabuf(adap);
/* build circular-linked pointers (xfer_desc) to the data buffers*/
idx = 0;
ofs = 0;
num_desc_bufs =
DIV_ROUND_UP(adap->num_bufs * DATA_BUF_XFERS, DESCS_IN_PAGE);
for (i = 0; i < num_desc_bufs; i++) {
p = dma_alloc_coherent(&pt3->pdev->dev, PAGE_SIZE,
&desc_addr, GFP_KERNEL);
if (p == NULL)
goto failed;
adap->num_desc_bufs++;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/kernel.h`, `linux/pci.h`, `pt3.h`.
- Detected declarations: `function Copyright`, `function pt3_stop_dma`, `function pt3_start_dma`, `function pt3_proc_dma`, `function pt3_init_dmabuf`, `function pt3_free_dmabuf`, `function pt3_alloc_dmabuf`.
- Atlas domain: Driver Families / drivers/media.
- 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.