drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c- Extension
.c- Size
- 2121 bytes
- Lines
- 100
- 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
linux/interrupt.hlinux/kernel.hlinux/slab.hvenc_drv_base.hvenc_drv_if.hmtk_vcodec_enc.hmtk_vcodec_enc_pm.h
Detected Declarations
function Copyrightfunction venc_if_set_paramfunction venc_if_encodefunction venc_if_deinit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2016 MediaTek Inc.
* Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
* Jungchang Tsao <jungchang.tsao@mediatek.com>
* Tiffany Lin <tiffany.lin@mediatek.com>
*/
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include "venc_drv_base.h"
#include "venc_drv_if.h"
#include "mtk_vcodec_enc.h"
#include "mtk_vcodec_enc_pm.h"
int venc_if_init(struct mtk_vcodec_enc_ctx *ctx, unsigned int fourcc)
{
int ret = 0;
switch (fourcc) {
case V4L2_PIX_FMT_VP8:
ctx->enc_if = &venc_vp8_if;
break;
case V4L2_PIX_FMT_H264:
ctx->enc_if = &venc_h264_if;
break;
default:
return -EINVAL;
}
mtk_venc_lock(ctx);
ret = ctx->enc_if->init(ctx);
mtk_venc_unlock(ctx);
return ret;
}
int venc_if_set_param(struct mtk_vcodec_enc_ctx *ctx,
enum venc_set_param_type type, struct venc_enc_param *in)
{
int ret = 0;
mtk_venc_lock(ctx);
ret = ctx->enc_if->set_param(ctx->drv_handle, type, in);
mtk_venc_unlock(ctx);
return ret;
}
int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx,
enum venc_start_opt opt, struct venc_frm_buf *frm_buf,
struct mtk_vcodec_mem *bs_buf,
struct venc_done_result *result)
{
int ret = 0;
unsigned long flags;
mtk_venc_lock(ctx);
spin_lock_irqsave(&ctx->dev->irqlock, flags);
ctx->dev->curr_ctx = ctx;
spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
ret = mtk_vcodec_enc_pw_on(&ctx->dev->pm);
if (ret)
goto venc_if_encode_pw_on_err;
mtk_vcodec_enc_clock_on(&ctx->dev->pm);
ret = ctx->enc_if->encode(ctx->drv_handle, opt, frm_buf,
bs_buf, result);
mtk_vcodec_enc_clock_off(&ctx->dev->pm);
mtk_vcodec_enc_pw_off(&ctx->dev->pm);
spin_lock_irqsave(&ctx->dev->irqlock, flags);
ctx->dev->curr_ctx = NULL;
spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
venc_if_encode_pw_on_err:
mtk_venc_unlock(ctx);
return ret;
}
int venc_if_deinit(struct mtk_vcodec_enc_ctx *ctx)
{
int ret = 0;
if (!ctx->drv_handle)
return 0;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/slab.h`, `venc_drv_base.h`, `venc_drv_if.h`, `mtk_vcodec_enc.h`, `mtk_vcodec_enc_pm.h`.
- Detected declarations: `function Copyright`, `function venc_if_set_param`, `function venc_if_encode`, `function venc_if_deinit`.
- 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.