drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c- Extension
.c- Size
- 14094 bytes
- Lines
- 515
- 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/math64.hmedia/v4l2-common.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hmtk-mdp3-core.hmtk-mdp3-regs.hmtk-mdp3-m2m.h
Detected Declarations
function Copyrightfunction mdp_map_ycbcr_prof_mplanefunction mdp_bound_align_imagefunction mdp_clamp_alignfunction mdp_enum_fmt_mplanefunction mdp_clamp_startfunction mdp_clamp_endfunction mdp_try_cropfunction mdp_check_scaling_ratiofunction mdp_check_pp_enablefunction mdp_fmt_get_stridefunction mdp_fmt_get_stride_contigfunction mdp_fmt_get_plane_sizefunction mdp_prepare_bufferfunction mdp_set_src_configfunction mdp_to_fixedfunction mdp_set_src_cropfunction mdp_set_orientationfunction mdp_set_dst_configfunction mdp_frameparam_init
Annotated Snippet
if (!fmt) {
dev_dbg(dev, "%d: pixelformat %c%c%c%c invalid", ctx_id,
(pix_mp->pixelformat & 0xff),
(pix_mp->pixelformat >> 8) & 0xff,
(pix_mp->pixelformat >> 16) & 0xff,
(pix_mp->pixelformat >> 24) & 0xff);
return NULL;
}
}
pix_mp->field = V4L2_FIELD_NONE;
pix_mp->flags = 0;
pix_mp->pixelformat = fmt->pixelformat;
if (V4L2_TYPE_IS_CAPTURE(f->type)) {
pix_mp->colorspace = param->colorspace;
pix_mp->xfer_func = param->xfer_func;
pix_mp->ycbcr_enc = param->ycbcr_enc;
pix_mp->quantization = param->quant;
}
pix_limit = V4L2_TYPE_IS_OUTPUT(f->type) ? ¶m->limit->out_limit :
¶m->limit->cap_limit;
s.min_width = pix_limit->wmin;
s.max_width = pix_limit->wmax;
s.step_width = fmt->walign;
s.min_height = pix_limit->hmin;
s.max_height = pix_limit->hmax;
s.step_height = fmt->halign;
org_w = pix_mp->width;
org_h = pix_mp->height;
mdp_bound_align_image(&pix_mp->width, &pix_mp->height, &s, fmt->salign);
if (org_w != pix_mp->width || org_h != pix_mp->height)
dev_dbg(dev, "%d: size change: %ux%u to %ux%u", ctx_id,
org_w, org_h, pix_mp->width, pix_mp->height);
if (pix_mp->num_planes && pix_mp->num_planes != fmt->num_planes)
dev_dbg(dev, "%d num of planes change: %u to %u", ctx_id,
pix_mp->num_planes, fmt->num_planes);
pix_mp->num_planes = fmt->num_planes;
for (i = 0; i < pix_mp->num_planes; ++i) {
u32 min_bpl = (pix_mp->width * fmt->row_depth[i]) >> 3;
u32 max_bpl = (pix_limit->wmax * fmt->row_depth[i]) >> 3;
u32 bpl = pix_mp->plane_fmt[i].bytesperline;
u32 min_si, max_si;
u32 si = pix_mp->plane_fmt[i].sizeimage;
u64 di;
bpl = clamp(bpl, min_bpl, max_bpl);
pix_mp->plane_fmt[i].bytesperline = bpl;
di = (u64)bpl * pix_mp->height * fmt->depth[i];
min_si = (u32)div_u64(di, fmt->row_depth[i]);
di = (u64)bpl * s.max_height * fmt->depth[i];
max_si = (u32)div_u64(di, fmt->row_depth[i]);
si = clamp(si, min_si, max_si);
pix_mp->plane_fmt[i].sizeimage = si;
dev_dbg(dev, "%d: p%u, bpl:%u [%u, %u], sizeimage:%u [%u, %u]",
ctx_id, i, bpl, min_bpl, max_bpl, si, min_si, max_si);
}
return fmt;
}
static int mdp_clamp_start(s32 *x, int min, int max, unsigned int align,
u32 flags)
{
if (flags & V4L2_SEL_FLAG_GE)
max = *x;
if (flags & V4L2_SEL_FLAG_LE)
min = *x;
return mdp_clamp_align(x, min, max, align);
}
static int mdp_clamp_end(s32 *x, int min, int max, unsigned int align,
u32 flags)
{
if (flags & V4L2_SEL_FLAG_GE)
min = *x;
if (flags & V4L2_SEL_FLAG_LE)
max = *x;
return mdp_clamp_align(x, min, max, align);
}
int mdp_try_crop(struct mdp_m2m_ctx *ctx, struct v4l2_rect *r,
const struct v4l2_selection *s, struct mdp_frame *frame)
{
Annotation
- Immediate include surface: `linux/math64.h`, `media/v4l2-common.h`, `media/videobuf2-v4l2.h`, `media/videobuf2-dma-contig.h`, `mtk-mdp3-core.h`, `mtk-mdp3-regs.h`, `mtk-mdp3-m2m.h`.
- Detected declarations: `function Copyright`, `function mdp_map_ycbcr_prof_mplane`, `function mdp_bound_align_image`, `function mdp_clamp_align`, `function mdp_enum_fmt_mplane`, `function mdp_clamp_start`, `function mdp_clamp_end`, `function mdp_try_crop`, `function mdp_check_scaling_ratio`, `function mdp_check_pp_enable`.
- 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.