drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c- Extension
.c- Size
- 5100 bytes
- Lines
- 202
- 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.
- 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/interrupt.hlinux/irq.hlinux/module.hlinux/of.hlinux/of_device.hlinux/pm_runtime.hlinux/slab.hmtk_vcodec_dec.hmtk_vcodec_dec_hw.hmtk_vcodec_dec_pm.h../common/mtk_vcodec_intr.h
Detected Declarations
function mtk_vdec_hw_prob_donefunction mtk_vdec_hw_irq_handlerfunction mtk_vdec_hw_init_irqfunction mtk_vdec_hw_probe
Annotated Snippet
if (!test_bit(hw_idx, vdec_dev->subdev_bitmap)) {
dev_err(&pdev->dev, "vdec %d is not ready", hw_idx);
return -EAGAIN;
}
}
return 0;
}
static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv)
{
struct mtk_vdec_hw_dev *dev = priv;
struct mtk_vcodec_dec_ctx *ctx;
u32 cg_status;
unsigned int dec_done_status;
void __iomem *vdec_misc_addr = dev->reg_base[VDEC_HW_MISC] +
VDEC_IRQ_CFG_REG;
ctx = mtk_vcodec_get_curr_ctx(dev->main_dev, dev->hw_idx);
/* check if HW active or not */
cg_status = readl(dev->reg_base[VDEC_HW_SYS] + VDEC_HW_ACTIVE_ADDR);
if (cg_status & VDEC_HW_ACTIVE_MASK) {
mtk_v4l2_vdec_err(ctx, "vdec active is not 0x0 (0x%08x)", cg_status);
return IRQ_HANDLED;
}
dec_done_status = readl(vdec_misc_addr);
if ((dec_done_status & MTK_VDEC_IRQ_STATUS_DEC_SUCCESS) !=
MTK_VDEC_IRQ_STATUS_DEC_SUCCESS)
return IRQ_HANDLED;
/* clear interrupt */
writel(dec_done_status | VDEC_IRQ_CFG, vdec_misc_addr);
writel(dec_done_status & ~VDEC_IRQ_CLR, vdec_misc_addr);
wake_up_dec_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);
mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x",
ctx->id, dec_done_status);
return IRQ_HANDLED;
}
static int mtk_vdec_hw_init_irq(struct mtk_vdec_hw_dev *dev)
{
struct platform_device *pdev = dev->plat_dev;
int ret;
dev->dec_irq = platform_get_irq(pdev, 0);
if (dev->dec_irq < 0)
return dev->dec_irq;
irq_set_status_flags(dev->dec_irq, IRQ_NOAUTOEN);
ret = devm_request_irq(&pdev->dev, dev->dec_irq,
mtk_vdec_hw_irq_handler, 0, pdev->name, dev);
if (ret) {
dev_err(&pdev->dev, "Failed to install dev->dec_irq %d (%d)",
dev->dec_irq, ret);
return ret;
}
return 0;
}
static int mtk_vdec_hw_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mtk_vdec_hw_dev *subdev_dev;
struct mtk_vcodec_dec_dev *main_dev;
const struct of_device_id *of_id;
int hw_idx;
int ret;
if (!dev->parent) {
dev_err(dev, "no parent for hardware devices.\n");
return -ENODEV;
}
main_dev = dev_get_drvdata(dev->parent);
if (!main_dev) {
dev_err(dev, "failed to get parent driver data");
return -EINVAL;
}
subdev_dev = devm_kzalloc(dev, sizeof(*subdev_dev), GFP_KERNEL);
if (!subdev_dev)
return -ENOMEM;
subdev_dev->plat_dev = pdev;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `linux/of.h`, `linux/of_device.h`, `linux/pm_runtime.h`, `linux/slab.h`, `mtk_vcodec_dec.h`.
- Detected declarations: `function mtk_vdec_hw_prob_done`, `function mtk_vdec_hw_irq_handler`, `function mtk_vdec_hw_init_irq`, `function mtk_vdec_hw_probe`.
- 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.