drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_pm.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_pm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_pm.c- Extension
.c- Size
- 6591 bytes
- Lines
- 259
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/interrupt.hlinux/of.hlinux/pm_runtime.hmtk_vcodec_dec_hw.hmtk_vcodec_dec_pm.h
Detected Declarations
function Copyrightfunction mtk_vcodec_dec_pw_onfunction mtk_vcodec_dec_pw_offfunction mtk_vcodec_dec_clock_onfunction mtk_vcodec_dec_clock_offfunction mtk_vcodec_dec_enable_irqfunction mtk_vcodec_dec_disable_irqfunction mtk_vcodec_load_racing_infofunction mtk_vcodec_record_racing_infofunction mtk_vcodec_dec_child_dev_onfunction mtk_vcodec_dec_child_dev_offfunction mtk_vcodec_dec_enable_hardwarefunction mtk_vcodec_dec_disable_hardwareexport mtk_vcodec_init_dec_clkexport mtk_vcodec_dec_enable_hardwareexport mtk_vcodec_dec_disable_hardware
Annotated Snippet
if (ret) {
dev_err(&pdev->dev, "Failed to get clock name id = %d", i);
return ret;
}
clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
clk_info->clk_name);
if (IS_ERR(clk_info->vcodec_clk)) {
dev_err(&pdev->dev, "devm_clk_get (%d)%s fail", i, clk_info->clk_name);
return PTR_ERR(clk_info->vcodec_clk);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);
static int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
{
int ret;
ret = pm_runtime_resume_and_get(pm->dev);
if (ret)
dev_err(pm->dev, "pm_runtime_resume_and_get fail %d", ret);
return ret;
}
static void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
{
pm_runtime_put(pm->dev);
}
static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
{
struct mtk_vcodec_clk *dec_clk;
int ret, i;
dec_clk = &pm->vdec_clk;
for (i = 0; i < dec_clk->clk_num; i++) {
ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk);
if (ret) {
dev_err(pm->dev, "clk_prepare_enable %d %s fail %d", i,
dec_clk->clk_info[i].clk_name, ret);
goto error;
}
}
return;
error:
for (i -= 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
}
static void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
{
struct mtk_vcodec_clk *dec_clk;
int i;
dec_clk = &pm->vdec_clk;
for (i = dec_clk->clk_num - 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
}
static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dec_dev *vdec_dev, int hw_idx)
{
struct mtk_vdec_hw_dev *subdev_dev;
if (!test_bit(hw_idx, vdec_dev->subdev_bitmap))
return;
if (vdec_dev->vdec_pdata->is_subdev_supported) {
subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
if (subdev_dev)
enable_irq(subdev_dev->dec_irq);
else
dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
} else {
enable_irq(vdec_dev->dec_irq);
}
}
static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dec_dev *vdec_dev, int hw_idx)
{
struct mtk_vdec_hw_dev *subdev_dev;
if (!test_bit(hw_idx, vdec_dev->subdev_bitmap))
return;
if (vdec_dev->vdec_pdata->is_subdev_supported) {
subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/of.h`, `linux/pm_runtime.h`, `mtk_vcodec_dec_hw.h`, `mtk_vcodec_dec_pm.h`.
- Detected declarations: `function Copyright`, `function mtk_vcodec_dec_pw_on`, `function mtk_vcodec_dec_pw_off`, `function mtk_vcodec_dec_clock_on`, `function mtk_vcodec_dec_clock_off`, `function mtk_vcodec_dec_enable_irq`, `function mtk_vcodec_dec_disable_irq`, `function mtk_vcodec_load_racing_info`, `function mtk_vcodec_record_racing_info`, `function mtk_vcodec_dec_child_dev_on`.
- 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.
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.