drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c- Extension
.c- Size
- 9910 bytes
- Lines
- 378
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
mtk_vcodec_enc_drv.hvenc_ipi_msg.hvenc_vpu_if.h
Detected Declarations
function Copyrightfunction handle_enc_encode_msgfunction vpu_enc_check_ap_instfunction vpu_enc_ipi_handlerfunction vpu_enc_send_msgfunction vpu_enc_initfunction venc_enc_param_crop_rightfunction venc_enc_param_crop_bottomfunction venc_enc_param_num_mbfunction vpu_enc_set_paramfunction vpu_enc_encode_32bitsfunction vpu_enc_encode_34bitsfunction vpu_enc_encodefunction vpu_enc_deinit
Annotated Snippet
if (!IS_ERR_OR_NULL(ctx) && ctx->vpu_inst == vpu) {
ret = true;
break;
}
}
spin_unlock_irqrestore(&enc_dev->dev_ctx_lock, flags);
return ret;
}
static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
{
struct mtk_vcodec_enc_dev *enc_dev;
const struct venc_vpu_ipi_msg_common *msg = data;
struct venc_vpu_inst *vpu;
enc_dev = (struct mtk_vcodec_enc_dev *)priv;
vpu = (struct venc_vpu_inst *)(unsigned long)msg->venc_inst;
if (!priv || !vpu) {
pr_err(MTK_DBG_V4L2_STR "venc_inst is NULL, did the SCP hang or crash?");
return;
}
mtk_venc_debug(vpu->ctx, "msg_id %x inst %p status %d", msg->msg_id, vpu, msg->status);
if (!vpu_enc_check_ap_inst(enc_dev, vpu) || msg->msg_id < VPU_IPIMSG_ENC_INIT_DONE ||
msg->msg_id > VPU_IPIMSG_ENC_DEINIT_DONE) {
mtk_v4l2_venc_err(vpu->ctx, "venc msg id not correctly => 0x%x", msg->msg_id);
vpu->failure = -EINVAL;
goto error;
}
vpu->failure = (msg->status != VENC_IPI_MSG_STATUS_OK);
if (vpu->failure) {
mtk_venc_err(vpu->ctx, "vpu enc status failure %d", vpu->failure);
goto error;
}
switch (msg->msg_id) {
case VPU_IPIMSG_ENC_INIT_DONE:
handle_enc_init_msg(vpu, data);
break;
case VPU_IPIMSG_ENC_SET_PARAM_DONE:
break;
case VPU_IPIMSG_ENC_ENCODE_DONE:
handle_enc_encode_msg(vpu, data);
break;
case VPU_IPIMSG_ENC_DEINIT_DONE:
break;
default:
mtk_venc_err(vpu->ctx, "unknown msg id %x", msg->msg_id);
break;
}
error:
vpu->signaled = 1;
}
static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void *msg,
int len)
{
int status;
if (!vpu->ctx->dev->fw_handler) {
mtk_venc_err(vpu->ctx, "inst dev is NULL");
return -EINVAL;
}
status = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, vpu->id, msg,
len, 2000);
if (status) {
mtk_venc_err(vpu->ctx, "vpu_ipi_send msg_id %x len %d fail %d",
*(uint32_t *)msg, len, status);
return -EINVAL;
}
if (vpu->failure)
return -EINVAL;
return 0;
}
int vpu_enc_init(struct venc_vpu_inst *vpu)
{
int status;
struct venc_ap_ipi_msg_init out = { };
init_waitqueue_head(&vpu->wq_hd);
vpu->signaled = 0;
vpu->failure = 0;
vpu->ctx->vpu_inst = vpu;
Annotation
- Immediate include surface: `mtk_vcodec_enc_drv.h`, `venc_ipi_msg.h`, `venc_vpu_if.h`.
- Detected declarations: `function Copyright`, `function handle_enc_encode_msg`, `function vpu_enc_check_ap_inst`, `function vpu_enc_ipi_handler`, `function vpu_enc_send_msg`, `function vpu_enc_init`, `function venc_enc_param_crop_right`, `function venc_enc_param_crop_bottom`, `function venc_enc_param_num_mb`, `function vpu_enc_set_param`.
- 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.