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.

Dependency Surface

Detected Declarations

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) ? &param->limit->out_limit :
						&param->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

Implementation Notes