drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c- Extension
.c- Size
- 3633 bytes
- Lines
- 133
- 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.
- 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
../decoder/mtk_vcodec_dec_drv.h../encoder/mtk_vcodec_enc_drv.hmtk_vcodec_fw_priv.h
Detected Declarations
function mtk_vcodec_vpu_load_firmwarefunction mtk_vcodec_vpu_get_vdec_capafunction mtk_vcodec_vpu_get_venc_capafunction mtk_vcodec_vpu_set_ipi_registerfunction mtk_vcodec_vpu_ipi_sendfunction mtk_vcodec_vpu_releasefunction mtk_vcodec_vpu_reset_dec_handlerfunction mtk_vcodec_vpu_reset_enc_handler
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include "../decoder/mtk_vcodec_dec_drv.h"
#include "../encoder/mtk_vcodec_enc_drv.h"
#include "mtk_vcodec_fw_priv.h"
static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
{
return vpu_load_firmware(fw->pdev);
}
static unsigned int mtk_vcodec_vpu_get_vdec_capa(struct mtk_vcodec_fw *fw)
{
return vpu_get_vdec_hw_capa(fw->pdev);
}
static unsigned int mtk_vcodec_vpu_get_venc_capa(struct mtk_vcodec_fw *fw)
{
return vpu_get_venc_hw_capa(fw->pdev);
}
static void *mtk_vcodec_vpu_map_dm_addr(struct mtk_vcodec_fw *fw,
u32 dtcm_dmem_addr)
{
return vpu_mapping_dm_addr(fw->pdev, dtcm_dmem_addr);
}
static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
mtk_vcodec_ipi_handler handler,
const char *name, void *priv)
{
return vpu_ipi_register(fw->pdev, id, handler, name, priv);
}
static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
unsigned int len, unsigned int wait)
{
return vpu_ipi_send(fw->pdev, id, buf, len);
}
static void mtk_vcodec_vpu_release(struct mtk_vcodec_fw *fw)
{
put_device(&fw->pdev->dev);
}
static void mtk_vcodec_vpu_reset_dec_handler(void *priv)
{
struct mtk_vcodec_dec_dev *dev = priv;
struct mtk_vcodec_dec_ctx *ctx;
unsigned long flags;
dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
spin_lock_irqsave(&dev->dev_ctx_lock, flags);
list_for_each_entry(ctx, &dev->ctx_list, list) {
ctx->state = MTK_STATE_ABORT;
mtk_v4l2_vdec_dbg(0, ctx, "[%d] Change to state MTK_STATE_ABORT", ctx->id);
}
spin_unlock_irqrestore(&dev->dev_ctx_lock, flags);
}
static void mtk_vcodec_vpu_reset_enc_handler(void *priv)
{
struct mtk_vcodec_enc_dev *dev = priv;
struct mtk_vcodec_enc_ctx *ctx;
unsigned long flags;
dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
spin_lock_irqsave(&dev->dev_ctx_lock, flags);
list_for_each_entry(ctx, &dev->ctx_list, list) {
ctx->state = MTK_STATE_ABORT;
mtk_v4l2_vdec_dbg(0, ctx, "[%d] Change to state MTK_STATE_ABORT", ctx->id);
}
spin_unlock_irqrestore(&dev->dev_ctx_lock, flags);
}
static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = {
.load_firmware = mtk_vcodec_vpu_load_firmware,
.get_vdec_capa = mtk_vcodec_vpu_get_vdec_capa,
.get_venc_capa = mtk_vcodec_vpu_get_venc_capa,
.map_dm_addr = mtk_vcodec_vpu_map_dm_addr,
.ipi_register = mtk_vcodec_vpu_set_ipi_register,
.ipi_send = mtk_vcodec_vpu_ipi_send,
.release = mtk_vcodec_vpu_release,
};
struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(void *priv, enum mtk_vcodec_fw_use fw_use)
{
struct platform_device *fw_pdev;
Annotation
- Immediate include surface: `../decoder/mtk_vcodec_dec_drv.h`, `../encoder/mtk_vcodec_enc_drv.h`, `mtk_vcodec_fw_priv.h`.
- Detected declarations: `function mtk_vcodec_vpu_load_firmware`, `function mtk_vcodec_vpu_get_vdec_capa`, `function mtk_vcodec_vpu_get_venc_capa`, `function mtk_vcodec_vpu_set_ipi_register`, `function mtk_vcodec_vpu_ipi_send`, `function mtk_vcodec_vpu_release`, `function mtk_vcodec_vpu_reset_dec_handler`, `function mtk_vcodec_vpu_reset_enc_handler`.
- 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.
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.