drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c- Extension
.c- Size
- 3103 bytes
- Lines
- 129
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/kernel.hlinux/slab.hvdec_drv_if.hmtk_vcodec_dec.hvdec_drv_base.hmtk_vcodec_dec_pm.h
Detected Declarations
function Copyrightfunction vdec_if_decodefunction vdec_if_get_paramfunction vdec_if_deinit
Annotated Snippet
if (!ctx->dev->vdec_pdata->is_subdev_supported) {
ctx->dec_if = &vdec_h264_slice_if;
ctx->hw_id = MTK_VDEC_CORE;
} else {
ctx->dec_if = &vdec_h264_slice_multi_if;
ctx->hw_id = IS_VDEC_LAT_ARCH(hw_arch) ? MTK_VDEC_LAT0 : MTK_VDEC_CORE;
}
break;
case V4L2_PIX_FMT_H264:
ctx->dec_if = &vdec_h264_if;
ctx->hw_id = MTK_VDEC_CORE;
break;
case V4L2_PIX_FMT_VP8_FRAME:
ctx->dec_if = &vdec_vp8_slice_if;
ctx->hw_id = MTK_VDEC_CORE;
break;
case V4L2_PIX_FMT_VP8:
ctx->dec_if = &vdec_vp8_if;
ctx->hw_id = MTK_VDEC_CORE;
break;
case V4L2_PIX_FMT_VP9:
ctx->dec_if = &vdec_vp9_if;
ctx->hw_id = MTK_VDEC_CORE;
break;
case V4L2_PIX_FMT_VP9_FRAME:
ctx->dec_if = &vdec_vp9_slice_lat_if;
ctx->hw_id = IS_VDEC_LAT_ARCH(hw_arch) ? MTK_VDEC_LAT0 : MTK_VDEC_CORE;
break;
case V4L2_PIX_FMT_HEVC_SLICE:
ctx->dec_if = &vdec_hevc_slice_multi_if;
ctx->hw_id = MTK_VDEC_LAT0;
break;
case V4L2_PIX_FMT_AV1_FRAME:
ctx->dec_if = &vdec_av1_slice_lat_if;
ctx->hw_id = MTK_VDEC_LAT0;
break;
default:
return -EINVAL;
}
mtk_vcodec_dec_enable_hardware(ctx, ctx->hw_id);
ret = ctx->dec_if->init(ctx);
mtk_vcodec_dec_disable_hardware(ctx, ctx->hw_id);
return ret;
}
int vdec_if_decode(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_mem *bs,
struct vdec_fb *fb, bool *res_chg)
{
int ret = 0;
if (bs) {
if ((bs->dma_addr & 63) != 0) {
mtk_v4l2_vdec_err(ctx, "bs dma_addr should 64 byte align");
return -EINVAL;
}
}
if (fb) {
if (((fb->base_y.dma_addr & 511) != 0) ||
((fb->base_c.dma_addr & 511) != 0)) {
mtk_v4l2_vdec_err(ctx, "frame buffer dma_addr should 512 byte align");
return -EINVAL;
}
}
if (!ctx->drv_handle)
return -EIO;
mtk_vcodec_dec_enable_hardware(ctx, ctx->hw_id);
mtk_vcodec_set_curr_ctx(ctx->dev, ctx, ctx->hw_id);
ret = ctx->dec_if->decode(ctx->drv_handle, bs, fb, res_chg);
mtk_vcodec_set_curr_ctx(ctx->dev, NULL, ctx->hw_id);
mtk_vcodec_dec_disable_hardware(ctx, ctx->hw_id);
return ret;
}
int vdec_if_get_param(struct mtk_vcodec_dec_ctx *ctx, enum vdec_get_param_type type,
void *out)
{
int ret = 0;
if (!ctx->drv_handle)
return -EIO;
mtk_vdec_lock(ctx);
ret = ctx->dec_if->get_param(ctx->drv_handle, type, out);
mtk_vdec_unlock(ctx);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/slab.h`, `vdec_drv_if.h`, `mtk_vcodec_dec.h`, `vdec_drv_base.h`, `mtk_vcodec_dec_pm.h`.
- Detected declarations: `function Copyright`, `function vdec_if_decode`, `function vdec_if_get_param`, `function vdec_if_deinit`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.