drivers/media/platform/mediatek/mdp/mtk_mdp_regs.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/mdp/mtk_mdp_regs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/mdp/mtk_mdp_regs.c- Extension
.c- Size
- 4255 bytes
- Lines
- 149
- 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/platform_device.hmtk_mdp_core.hmtk_mdp_regs.h
Detected Declarations
enum MDP_COLOR_ENUMfunction mtk_mdp_map_color_formatfunction mtk_mdp_hw_set_input_addrfunction mtk_mdp_hw_set_output_addrfunction mtk_mdp_hw_set_in_sizefunction mtk_mdp_hw_set_in_image_formatfunction mtk_mdp_hw_set_out_sizefunction mtk_mdp_hw_set_out_image_formatfunction mtk_mdp_hw_set_rotationfunction mtk_mdp_hw_set_global_alpha
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015-2016 MediaTek Inc.
* Author: Houlong Wei <houlong.wei@mediatek.com>
* Ming Hsiu Tsai <minghsiu.tsai@mediatek.com>
*/
#include <linux/platform_device.h>
#include "mtk_mdp_core.h"
#include "mtk_mdp_regs.h"
#define MDP_COLORFMT_PACK(VIDEO, PLANE, COPLANE, HF, VF, BITS, GROUP, SWAP, ID)\
(((VIDEO) << 27) | ((PLANE) << 24) | ((COPLANE) << 22) |\
((HF) << 20) | ((VF) << 18) | ((BITS) << 8) | ((GROUP) << 6) |\
((SWAP) << 5) | ((ID) << 0))
enum MDP_COLOR_ENUM {
MDP_COLOR_UNKNOWN = 0,
MDP_COLOR_NV12 = MDP_COLORFMT_PACK(0, 2, 1, 1, 1, 8, 1, 0, 12),
MDP_COLOR_I420 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 0, 8),
MDP_COLOR_YV12 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 1, 8),
/* Mediatek proprietary format */
MDP_COLOR_420_MT21 = MDP_COLORFMT_PACK(5, 2, 1, 1, 1, 256, 1, 0, 12),
};
static int32_t mtk_mdp_map_color_format(int v4l2_format)
{
switch (v4l2_format) {
case V4L2_PIX_FMT_NV12M:
case V4L2_PIX_FMT_NV12:
return MDP_COLOR_NV12;
case V4L2_PIX_FMT_MT21C:
return MDP_COLOR_420_MT21;
case V4L2_PIX_FMT_YUV420M:
case V4L2_PIX_FMT_YUV420:
return MDP_COLOR_I420;
case V4L2_PIX_FMT_YVU420:
return MDP_COLOR_YV12;
}
mtk_mdp_err("Unknown format 0x%x", v4l2_format);
return MDP_COLOR_UNKNOWN;
}
void mtk_mdp_hw_set_input_addr(struct mtk_mdp_ctx *ctx,
struct mtk_mdp_addr *addr)
{
struct mdp_buffer *src_buf = &ctx->vpu.vsi->src_buffer;
int i;
for (i = 0; i < ARRAY_SIZE(addr->addr); i++)
src_buf->addr_mva[i] = (uint64_t)addr->addr[i];
}
void mtk_mdp_hw_set_output_addr(struct mtk_mdp_ctx *ctx,
struct mtk_mdp_addr *addr)
{
struct mdp_buffer *dst_buf = &ctx->vpu.vsi->dst_buffer;
int i;
for (i = 0; i < ARRAY_SIZE(addr->addr); i++)
dst_buf->addr_mva[i] = (uint64_t)addr->addr[i];
}
void mtk_mdp_hw_set_in_size(struct mtk_mdp_ctx *ctx)
{
struct mtk_mdp_frame *frame = &ctx->s_frame;
struct mdp_config *config = &ctx->vpu.vsi->src_config;
/* Set input pixel offset */
config->crop_x = frame->crop.left;
config->crop_y = frame->crop.top;
/* Set input cropped size */
config->crop_w = frame->crop.width;
config->crop_h = frame->crop.height;
/* Set input original size */
config->x = 0;
config->y = 0;
config->w = frame->width;
config->h = frame->height;
}
void mtk_mdp_hw_set_in_image_format(struct mtk_mdp_ctx *ctx)
{
unsigned int i;
Annotation
- Immediate include surface: `linux/platform_device.h`, `mtk_mdp_core.h`, `mtk_mdp_regs.h`.
- Detected declarations: `enum MDP_COLOR_ENUM`, `function mtk_mdp_map_color_format`, `function mtk_mdp_hw_set_input_addr`, `function mtk_mdp_hw_set_output_addr`, `function mtk_mdp_hw_set_in_size`, `function mtk_mdp_hw_set_in_image_format`, `function mtk_mdp_hw_set_out_size`, `function mtk_mdp_hw_set_out_image_format`, `function mtk_mdp_hw_set_rotation`, `function mtk_mdp_hw_set_global_alpha`.
- 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.