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.
- 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/init.hlinux/interconnect.hlinux/ioctl.hlinux/list.hlinux/kernel.hlinux/module.hlinux/platform_device.hvpu.hvpu_defs.hvpu_core.hvpu_rpc.hvpu_helpers.h
Detected Declarations
struct codec_id_mappingfunction vpu_helper_find_in_array_u8function vpu_helper_check_typefunction vpu_helper_match_formatfunction vpu_helper_valid_frame_widthfunction vpu_helper_valid_frame_heightfunction get_nv12_plane_sizefunction get_tiled_8l128_plane_sizefunction get_default_plane_sizefunction vpu_helper_get_plane_sizefunction vpu_helper_copy_from_stream_bufferfunction vpu_helper_copy_to_stream_bufferfunction vpu_helper_memset_stream_bufferfunction vpu_helper_get_free_spacefunction vpu_helper_get_used_spacefunction vpu_helper_g_volatile_ctrlfunction vpu_helper_find_startcodefunction vpu_find_dst_by_srcfunction vpu_find_src_by_dstfunction vpu_find_v4l2_idfunction vpu_get_h264_v4l2_profilefunction vpu_get_h264_v4l2_levelfunction vpu_get_hevc_v4l2_profilefunction vpu_get_hevc_v4l2_level
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
- Immediate include surface: `linux/init.h`, `linux/interconnect.h`, `linux/ioctl.h`, `linux/list.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `vpu.h`.
- Detected declarations: `struct codec_id_mapping`, `function vpu_helper_find_in_array_u8`, `function vpu_helper_check_type`, `function vpu_helper_match_format`, `function vpu_helper_valid_frame_width`, `function vpu_helper_valid_frame_height`, `function get_nv12_plane_size`, `function get_tiled_8l128_plane_size`, `function get_default_plane_size`, `function vpu_helper_get_plane_size`.
- 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.