drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c- Extension
.c- Size
- 20247 bytes
- Lines
- 739
- 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
linux/platform_device.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/videobuf2-dma-contig.hmtk-mdp3-m2m.h
Detected Declarations
function Copyrightfunction mdp_m2m_ctx_set_statefunction mdp_m2m_ctx_is_state_setfunction mdp_m2m_process_donefunction mdp_m2m_device_runfunction mdp_m2m_start_streamingfunction mdp_m2m_stop_streamingfunction mdp_m2m_queue_setupfunction mdp_m2m_buf_preparefunction mdp_m2m_buf_out_validatefunction mdp_m2m_buf_queuefunction mdp_m2m_querycapfunction mdp_m2m_enum_fmt_mplanefunction mdp_m2m_g_fmt_mplanefunction mdp_m2m_s_fmt_mplanefunction mdp_m2m_try_fmt_mplanefunction mdp_m2m_g_selectionfunction mdp_m2m_s_selectionfunction mdp_m2m_queue_initfunction mdp_m2m_s_ctrlfunction mdp_m2m_ctrls_createfunction mdp_m2m_openfunction mdp_m2m_releasefunction mdp_m2m_device_registerfunction mdp_m2m_device_unregisterfunction mdp_m2m_job_finish
Annotated Snippet
if (ret == 0) {
dev_err(&ctx->mdp_dev->pdev->dev,
"%d jobs not yet done\n",
refcount_read(&ctx->mdp_dev->job_count));
goto worker_end;
}
}
ret = mdp_cmdq_send(ctx->mdp_dev, &task);
if (ret) {
dev_err(&ctx->mdp_dev->pdev->dev,
"CMDQ sendtask failed: %d\n", ret);
goto worker_end;
}
return;
worker_end:
mdp_m2m_process_done(ctx, vb_state);
}
static int mdp_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
{
struct mdp_m2m_ctx *ctx = vb2_get_drv_priv(q);
struct mdp_frame *capture;
struct vb2_queue *vq;
int ret;
bool out_streaming, cap_streaming;
if (V4L2_TYPE_IS_OUTPUT(q->type))
ctx->frame_count[MDP_M2M_SRC] = 0;
if (V4L2_TYPE_IS_CAPTURE(q->type))
ctx->frame_count[MDP_M2M_DST] = 0;
capture = ctx_get_frame(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
vq = v4l2_m2m_get_src_vq(ctx->m2m_ctx);
out_streaming = vb2_is_streaming(vq);
vq = v4l2_m2m_get_dst_vq(ctx->m2m_ctx);
cap_streaming = vb2_is_streaming(vq);
/* Check to see if scaling ratio is within supported range */
if ((V4L2_TYPE_IS_OUTPUT(q->type) && cap_streaming) ||
(V4L2_TYPE_IS_CAPTURE(q->type) && out_streaming)) {
ret = mdp_check_scaling_ratio(&capture->crop.c,
&capture->compose,
capture->rotation,
ctx->curr_param.limit);
if (ret) {
dev_err(&ctx->mdp_dev->pdev->dev,
"Out of scaling range\n");
return ret;
}
}
if (!mdp_m2m_ctx_is_state_set(ctx, MDP_VPU_INIT)) {
ret = mdp_vpu_get_locked(ctx->mdp_dev);
if (ret) {
dev_err(&ctx->mdp_dev->pdev->dev,
"VPU init failed %d\n", ret);
return -EINVAL;
}
mdp_m2m_ctx_set_state(ctx, MDP_VPU_INIT);
}
return 0;
}
static struct vb2_v4l2_buffer *mdp_m2m_buf_remove(struct mdp_m2m_ctx *ctx,
unsigned int type)
{
if (V4L2_TYPE_IS_OUTPUT(type))
return (struct vb2_v4l2_buffer *)
v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
else
return (struct vb2_v4l2_buffer *)
v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
}
static void mdp_m2m_stop_streaming(struct vb2_queue *q)
{
struct mdp_m2m_ctx *ctx = vb2_get_drv_priv(q);
struct vb2_v4l2_buffer *vb;
vb = mdp_m2m_buf_remove(ctx, q->type);
while (vb) {
v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
vb = mdp_m2m_buf_remove(ctx, q->type);
}
}
Annotation
- Immediate include surface: `linux/platform_device.h`, `media/v4l2-ioctl.h`, `media/v4l2-event.h`, `media/videobuf2-dma-contig.h`, `mtk-mdp3-m2m.h`.
- Detected declarations: `function Copyright`, `function mdp_m2m_ctx_set_state`, `function mdp_m2m_ctx_is_state_set`, `function mdp_m2m_process_done`, `function mdp_m2m_device_run`, `function mdp_m2m_start_streaming`, `function mdp_m2m_stop_streaming`, `function mdp_m2m_queue_setup`, `function mdp_m2m_buf_prepare`, `function mdp_m2m_buf_out_validate`.
- 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.