drivers/media/platform/amphion/vpu_helpers.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/amphion/vpu_helpers.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/amphion/vpu_helpers.c
Extension
.c
Size
15674 bytes
Lines
635
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

struct codec_id_mapping {
	u32 id;
	u32 v4l2_id;
};

static struct codec_id_mapping h264_profiles[] = {
	{66,  V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE},
	{77,  V4L2_MPEG_VIDEO_H264_PROFILE_MAIN},
	{88,  V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED},
	{100, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH}
};

static struct codec_id_mapping h264_levels[] = {
	{10,  V4L2_MPEG_VIDEO_H264_LEVEL_1_0},
	{9,   V4L2_MPEG_VIDEO_H264_LEVEL_1B},
	{11,  V4L2_MPEG_VIDEO_H264_LEVEL_1_1},
	{12,  V4L2_MPEG_VIDEO_H264_LEVEL_1_2},
	{13,  V4L2_MPEG_VIDEO_H264_LEVEL_1_3},
	{20,  V4L2_MPEG_VIDEO_H264_LEVEL_2_0},
	{21,  V4L2_MPEG_VIDEO_H264_LEVEL_2_1},
	{22,  V4L2_MPEG_VIDEO_H264_LEVEL_2_2},
	{30,  V4L2_MPEG_VIDEO_H264_LEVEL_3_0},
	{31,  V4L2_MPEG_VIDEO_H264_LEVEL_3_1},
	{32,  V4L2_MPEG_VIDEO_H264_LEVEL_3_2},
	{40,  V4L2_MPEG_VIDEO_H264_LEVEL_4_0},
	{41,  V4L2_MPEG_VIDEO_H264_LEVEL_4_1},
	{42,  V4L2_MPEG_VIDEO_H264_LEVEL_4_2},
	{50,  V4L2_MPEG_VIDEO_H264_LEVEL_5_0},
	{51,  V4L2_MPEG_VIDEO_H264_LEVEL_5_1},
	{52,  V4L2_MPEG_VIDEO_H264_LEVEL_5_2},
	{60,  V4L2_MPEG_VIDEO_H264_LEVEL_6_0},
	{61,  V4L2_MPEG_VIDEO_H264_LEVEL_6_1},
	{62,  V4L2_MPEG_VIDEO_H264_LEVEL_6_2}
};

static struct codec_id_mapping hevc_profiles[] = {
	{1,   V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN},
	{2,   V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10}
};

static struct codec_id_mapping hevc_levels[] = {
	{30,  V4L2_MPEG_VIDEO_HEVC_LEVEL_1},
	{60,  V4L2_MPEG_VIDEO_HEVC_LEVEL_2},
	{63,  V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1},
	{90,  V4L2_MPEG_VIDEO_HEVC_LEVEL_3},
	{93,  V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1},
	{120, V4L2_MPEG_VIDEO_HEVC_LEVEL_4},
	{123, V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1},
	{150, V4L2_MPEG_VIDEO_HEVC_LEVEL_5},
	{153, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1},
	{156, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2},
	{180, V4L2_MPEG_VIDEO_HEVC_LEVEL_6},
	{183, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1},
	{186, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2}
};

static u32 vpu_find_v4l2_id(u32 id, struct codec_id_mapping *array, u32 array_sz)
{
	u32 i;

	if (!array || !array_sz)
		return 0;

	for (i = 0; i < array_sz; i++) {
		if (id == array[i].id)
			return array[i].v4l2_id;
	}

	return 0;
}

u32 vpu_get_h264_v4l2_profile(struct vpu_dec_codec_info *hdr)
{
	if (!hdr)
		return 0;

	/*
	 * In H.264 Document section A.2.1.1 Constrained Baseline profile
	 * Conformance of a bitstream to the Constrained Baseline profile is indicated by
	 * profile_idc being equal to 66 with constraint_set1_flag being equal to 1.
	 */
	if (hdr->profile_idc == 66 && hdr->constraint_set1_flag)
		return V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE;

	return vpu_find_v4l2_id(hdr->profile_idc, h264_profiles, ARRAY_SIZE(h264_profiles));
}

u32 vpu_get_h264_v4l2_level(struct vpu_dec_codec_info *hdr)
{
	if (!hdr)

Annotation

Implementation Notes