drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c- Extension
.c- Size
- 4688 bytes
- Lines
- 175
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/of.hlinux/regmap.h../decoder/mtk_vcodec_dec_drv.h../encoder/mtk_vcodec_enc_drv.h../decoder/mtk_vcodec_dec_hw.h
Detected Declarations
function mtk_vcodec_write_vdecsysfunction mtk_vcodec_mem_allocfunction mtk_vcodec_mem_freefunction mtk_vcodec_set_curr_ctxexport mtk_vcodec_dbgexport mtk_v4l2_dbg_levelexport mtk_vcodec_get_reg_addrexport mtk_vcodec_write_vdecsysexport mtk_vcodec_mem_allocexport mtk_vcodec_mem_freeexport mtk_vcodec_get_hw_devexport mtk_vcodec_set_curr_ctxexport mtk_vcodec_get_curr_ctx
Annotated Snippet
if (!subdev_dev) {
dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev");
spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
return;
}
subdev_dev->curr_ctx = ctx;
} else {
vdec_dev->curr_ctx = ctx;
}
spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
}
EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
unsigned int hw_idx)
{
unsigned long flags;
struct mtk_vcodec_dec_ctx *ctx;
struct mtk_vdec_hw_dev *subdev_dev;
spin_lock_irqsave(&vdec_dev->irqlock, flags);
if (vdec_dev->vdec_pdata->is_subdev_supported) {
subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
if (!subdev_dev) {
dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev");
spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
return NULL;
}
ctx = subdev_dev->curr_ctx;
} else {
ctx = vdec_dev->curr_ctx;
}
spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
return ctx;
}
EXPORT_SYMBOL(mtk_vcodec_get_curr_ctx);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Mediatek video codec driver");
Annotation
- Immediate include surface: `linux/module.h`, `linux/of.h`, `linux/regmap.h`, `../decoder/mtk_vcodec_dec_drv.h`, `../encoder/mtk_vcodec_enc_drv.h`, `../decoder/mtk_vcodec_dec_hw.h`.
- Detected declarations: `function mtk_vcodec_write_vdecsys`, `function mtk_vcodec_mem_alloc`, `function mtk_vcodec_mem_free`, `function mtk_vcodec_set_curr_ctx`, `export mtk_vcodec_dbg`, `export mtk_v4l2_dbg_level`, `export mtk_vcodec_get_reg_addr`, `export mtk_vcodec_write_vdecsys`, `export mtk_vcodec_mem_alloc`, `export mtk_vcodec_mem_free`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.