drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c

Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c

File Facts

System
Linux kernel
Corpus path
drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
Extension
.c
Size
11095 bytes
Lines
368
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_valid) {
			if (start_idx == 0)
				return v4l2_fwht_pixfmts + i;
			start_idx--;
		}
	}
	return NULL;
}

const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat)
{
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++)
		if (v4l2_fwht_pixfmts[i].id == pixelformat)
			return v4l2_fwht_pixfmts + i;
	return NULL;
}

const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx)
{
	if (idx >= ARRAY_SIZE(v4l2_fwht_pixfmts))
		return NULL;
	return v4l2_fwht_pixfmts + idx;
}

static int prepare_raw_frame(struct fwht_raw_frame *rf,
			 const struct v4l2_fwht_pixfmt_info *info, u8 *buf,
			 unsigned int size)
{
	rf->luma = buf;
	rf->width_div = info->width_div;
	rf->height_div = info->height_div;
	rf->luma_alpha_step = info->luma_alpha_step;
	rf->chroma_step = info->chroma_step;
	rf->alpha = NULL;
	rf->components_num = info->components_num;

	/*
	 * The buffer is NULL if it is the reference
	 * frame of an I-frame in the stateless decoder
	 */
	if (!buf) {
		rf->luma = NULL;
		rf->cb = NULL;
		rf->cr = NULL;
		rf->alpha = NULL;
		return 0;
	}
	switch (info->id) {
	case V4L2_PIX_FMT_GREY:
		rf->cb = NULL;
		rf->cr = NULL;
		break;
	case V4L2_PIX_FMT_YUV420:
		rf->cb = rf->luma + size;
		rf->cr = rf->cb + size / 4;
		break;
	case V4L2_PIX_FMT_YVU420:
		rf->cr = rf->luma + size;
		rf->cb = rf->cr + size / 4;
		break;
	case V4L2_PIX_FMT_YUV422P:
		rf->cb = rf->luma + size;
		rf->cr = rf->cb + size / 2;
		break;
	case V4L2_PIX_FMT_NV12:
	case V4L2_PIX_FMT_NV16:
	case V4L2_PIX_FMT_NV24:
		rf->cb = rf->luma + size;
		rf->cr = rf->cb + 1;
		break;
	case V4L2_PIX_FMT_NV21:
	case V4L2_PIX_FMT_NV61:
	case V4L2_PIX_FMT_NV42:
		rf->cr = rf->luma + size;
		rf->cb = rf->cr + 1;
		break;
	case V4L2_PIX_FMT_YUYV:
		rf->cb = rf->luma + 1;
		rf->cr = rf->cb + 2;
		break;
	case V4L2_PIX_FMT_YVYU:
		rf->cr = rf->luma + 1;
		rf->cb = rf->cr + 2;
		break;
	case V4L2_PIX_FMT_UYVY:
		rf->cb = rf->luma;
		rf->cr = rf->cb + 2;
		rf->luma++;

Annotation

Implementation Notes