drivers/media/platform/nvidia/tegra-vde/vde.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nvidia/tegra-vde/vde.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nvidia/tegra-vde/vde.c- Extension
.c- Size
- 13336 bytes
- Lines
- 558
- 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.
- 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.
- 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/clk.hlinux/dma-buf.hlinux/genalloc.hlinux/interrupt.hlinux/list.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/slab.hlinux/uaccess.hsoc/tegra/common.hsoc/tegra/pmc.hvde.htrace.h
Detected Declarations
function Copyrightfunction tegra_vde_readlfunction tegra_vde_set_bitsfunction tegra_vde_alloc_bofunction tegra_vde_free_bofunction tegra_vde_isrfunction tegra_vde_runtime_suspendfunction tegra_vde_runtime_resumefunction tegra_vde_probefunction tegra_vde_removefunction tegra_vde_shutdownfunction tegra_vde_pm_suspendfunction tegra_vde_pm_resume
Annotated Snippet
if (err) {
dev_err(dev, "Failed to map DMA buffer IOVA: %d\n", err);
goto unmap_sgtable;
}
bo->dma_addr = iova_dma_addr(&vde->iova, bo->iova);
} else {
bo->dma_addr = sg_dma_address(bo->sgt.sgl);
}
*ret_bo = bo;
return 0;
unmap_sgtable:
dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs);
free_table:
sg_free_table(&bo->sgt);
free_attrs:
dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle,
bo->dma_attrs);
free_bo:
kfree(bo);
return err;
}
void tegra_vde_free_bo(struct tegra_vde_bo *bo)
{
struct tegra_vde *vde = bo->vde;
struct device *dev = vde->dev;
if (vde->domain)
tegra_vde_iommu_unmap(vde, bo->iova);
dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs);
sg_free_table(&bo->sgt);
dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle,
bo->dma_attrs);
kfree(bo);
}
static irqreturn_t tegra_vde_isr(int irq, void *data)
{
struct tegra_vde *vde = data;
if (completion_done(&vde->decode_completion))
return IRQ_NONE;
tegra_vde_set_bits(vde, 0, vde->frameid, 0x208);
complete(&vde->decode_completion);
return IRQ_HANDLED;
}
static __maybe_unused int tegra_vde_runtime_suspend(struct device *dev)
{
struct tegra_vde *vde = dev_get_drvdata(dev);
int err;
if (!dev->pm_domain) {
err = tegra_pmc_powergate_power_off(vde->pmc,
TEGRA_POWERGATE_VDEC);
if (err) {
dev_err(dev, "Failed to power down HW: %d\n", err);
return err;
}
}
clk_disable_unprepare(vde->clk);
reset_control_release(vde->rst);
reset_control_release(vde->rst_mc);
return 0;
}
static __maybe_unused int tegra_vde_runtime_resume(struct device *dev)
{
struct tegra_vde *vde = dev_get_drvdata(dev);
int err;
err = reset_control_acquire(vde->rst_mc);
if (err) {
dev_err(dev, "Failed to acquire mc reset: %d\n", err);
return err;
}
err = reset_control_acquire(vde->rst);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-buf.h`, `linux/genalloc.h`, `linux/interrupt.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `function Copyright`, `function tegra_vde_readl`, `function tegra_vde_set_bits`, `function tegra_vde_alloc_bo`, `function tegra_vde_free_bo`, `function tegra_vde_isr`, `function tegra_vde_runtime_suspend`, `function tegra_vde_runtime_resume`, `function tegra_vde_probe`, `function tegra_vde_remove`.
- Atlas domain: Driver Families / drivers/media.
- 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.