drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
Extension
.c
Size
83894 bytes
Lines
2714
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 (IS_MFCV12(dev)) {
			lcu_width = S5P_MFC_LCU_WIDTH(ctx->img_width);
			lcu_height = S5P_MFC_LCU_HEIGHT(ctx->img_height);
			if (ctx->codec_mode == S5P_FIMV_CODEC_HEVC_ENC && ctx->is_10bit) {
				ctx->luma_dpb_size =
					width64 * height32 +
					ALIGN(DIV_ROUND_UP(lcu_width * 32, 4), 16) * height32 + 128;
				if (ctx->is_422)
					ctx->chroma_dpb_size =
						ctx->luma_dpb_size;
				else
					ctx->chroma_dpb_size =
						width64 * height32 / 2 +
						ALIGN(DIV_ROUND_UP(lcu_width *
							32, 4), 16) * height32 / 2 + 128;
			} else if (ctx->codec_mode == S5P_FIMV_CODEC_VP9_ENC &&	ctx->is_10bit) {
				ctx->luma_dpb_size =
					ALIGN(ctx->img_width * 2, 128) * height32 + 64;
				ctx->chroma_dpb_size =
					ALIGN(ctx->img_width * 2, 128) * height32 / 2 + 64;
			} else {
				ctx->luma_dpb_size =
					width64 * height32 + 64;
				if (ctx->is_422)
					ctx->chroma_dpb_size =
						ctx->luma_dpb_size;
				else
					ctx->chroma_dpb_size =
						width64 * height32 / 2 + 64;
			}
			ctx->luma_dpb_size = ALIGN(ctx->luma_dpb_size + 256, SZ_2K);
			ctx->chroma_dpb_size = ALIGN(ctx->chroma_dpb_size + 256, SZ_2K);
		} else if (IS_MFCV10_PLUS(dev)) {
			lcu_width = S5P_MFC_LCU_WIDTH(ctx->img_width);
			lcu_height = S5P_MFC_LCU_HEIGHT(ctx->img_height);
			if (ctx->codec_mode != S5P_FIMV_CODEC_HEVC_ENC) {
				ctx->luma_dpb_size =
					ALIGN((mb_width * 16), 64)
					* ALIGN((mb_height * 16), 32)
						+ 64;
				ctx->chroma_dpb_size =
					ALIGN((mb_width * 16), 64)
							* (mb_height * 8)
							+ 64;
			} else {
				ctx->luma_dpb_size =
					ALIGN((lcu_width * 32), 64)
					* ALIGN((lcu_height * 32), 32)
						+ 64;
				ctx->chroma_dpb_size =
					ALIGN((lcu_width * 32), 64)
							* (lcu_height * 16)
							+ 64;
			}
		} else {
			ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
					S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
					S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
			ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
					S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
					S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
		}
		if (IS_MFCV8_PLUS(dev))
			ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V8(
						ctx->img_width, ctx->img_height,
						mb_width, mb_height),
						S5P_FIMV_ME_BUFFER_ALIGN_V6);
		else
			ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V6(
						ctx->img_width, ctx->img_height,
						mb_width, mb_height),
						S5P_FIMV_ME_BUFFER_ALIGN_V6);

		mfc_debug(2, "recon luma size: %zu chroma size: %zu\n",
			  ctx->luma_dpb_size, ctx->chroma_dpb_size);
	} else {
		return -EINVAL;
	}

	/* Codecs have different memory requirements */
	switch (ctx->codec_mode) {
	case S5P_MFC_CODEC_H264_DEC:
	case S5P_MFC_CODEC_H264_MVC_DEC:
		if (IS_MFCV10_PLUS(dev))
			mfc_debug(2, "Use min scratch buffer size\n");
		else if (IS_MFCV8_PLUS(dev))
			ctx->scratch_buf_size =
				S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V8(
					mb_width,
					mb_height);

Annotation

Implementation Notes