drivers/media/platform/qcom/venus/helpers.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/helpers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/venus/helpers.c- Extension
.c- Size
- 50157 bytes
- Lines
- 1863
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/idr.hlinux/list.hlinux/mutex.hlinux/slab.hlinux/kernel.hmedia/videobuf2-dma-contig.hmedia/v4l2-mem2mem.hasm/div64.hcore.hhelpers.hhfi_helper.hpm_helpers.hhfi_platform.hhfi_parser.h
Detected Declarations
struct intbufstruct id_mappingenum dpb_buf_ownerfunction venus_helper_check_codecfunction free_dpb_buffunction venus_helper_queue_dpb_bufsfunction list_for_each_entry_safefunction venus_helper_free_dpb_bufsfunction list_for_each_entry_safefunction venus_helper_alloc_dpb_bufsfunction intbufs_set_bufferfunction intbufs_unset_buffersfunction list_for_each_entry_safefunction venus_helper_intbufs_allocfunction venus_helper_intbufs_freefunction venus_helper_intbufs_reallocfunction list_for_each_entry_safefunction fill_buffer_descfunction return_buf_errorfunction put_ts_metadatafunction venus_helper_get_ts_metadatafunction session_process_buffunction is_dynamic_bufmodefunction venus_helper_unregister_bufsfunction list_for_each_entry_safefunction session_register_bufsfunction list_for_each_entryfunction to_hfi_raw_fmtfunction platform_get_bufreqfunction venus_helper_get_bufreqfunction find_v4l2_idfunction find_hfi_idfunction v4l2_id_profile_levelfunction hfi_id_profile_levelfunction venus_helper_get_profile_levelfunction venus_helper_set_profile_levelfunction get_framesize_raw_nv12function get_framesize_raw_nv12_ubwcfunction get_framesize_raw_p010function get_framesize_raw_p010_ubwcfunction get_framesize_raw_yuv420_tp10_ubwcfunction venus_helper_get_framesz_rawfunction venus_helper_get_frameszfunction venus_helper_set_input_resolutionfunction venus_helper_set_output_resolutionfunction venus_helper_get_work_modefunction venus_helper_set_work_modefunction venus_helper_set_format_constraints
Annotated Snippet
struct intbuf {
struct list_head list;
u32 type;
size_t size;
void *va;
dma_addr_t da;
unsigned long attrs;
enum dpb_buf_owner owned_by;
u32 dpb_out_tag;
};
bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt)
{
struct venus_core *core = inst->core;
u32 session_type = inst->session_type;
u32 codec;
switch (v4l2_pixfmt) {
case V4L2_PIX_FMT_H264:
codec = HFI_VIDEO_CODEC_H264;
break;
case V4L2_PIX_FMT_H263:
codec = HFI_VIDEO_CODEC_H263;
break;
case V4L2_PIX_FMT_MPEG1:
codec = HFI_VIDEO_CODEC_MPEG1;
break;
case V4L2_PIX_FMT_MPEG2:
codec = HFI_VIDEO_CODEC_MPEG2;
break;
case V4L2_PIX_FMT_MPEG4:
codec = HFI_VIDEO_CODEC_MPEG4;
break;
case V4L2_PIX_FMT_VC1_ANNEX_G:
case V4L2_PIX_FMT_VC1_ANNEX_L:
codec = HFI_VIDEO_CODEC_VC1;
break;
case V4L2_PIX_FMT_VP8:
codec = HFI_VIDEO_CODEC_VP8;
break;
case V4L2_PIX_FMT_VP9:
codec = HFI_VIDEO_CODEC_VP9;
break;
case V4L2_PIX_FMT_XVID:
codec = HFI_VIDEO_CODEC_DIVX;
break;
case V4L2_PIX_FMT_HEVC:
codec = HFI_VIDEO_CODEC_HEVC;
break;
default:
return false;
}
if (session_type == VIDC_SESSION_TYPE_ENC && core->enc_codecs & codec)
return true;
if (session_type == VIDC_SESSION_TYPE_DEC && core->dec_codecs & codec)
return true;
return false;
}
EXPORT_SYMBOL_GPL(venus_helper_check_codec);
static void free_dpb_buf(struct venus_inst *inst, struct intbuf *buf)
{
ida_free(&inst->dpb_ids, buf->dpb_out_tag);
list_del_init(&buf->list);
dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da,
buf->attrs);
kfree(buf);
}
int venus_helper_queue_dpb_bufs(struct venus_inst *inst)
{
struct intbuf *buf, *next;
unsigned int dpb_size = 0;
int ret = 0;
if (inst->dpb_buftype == HFI_BUFFER_OUTPUT)
dpb_size = inst->output_buf_size;
else if (inst->dpb_buftype == HFI_BUFFER_OUTPUT2)
dpb_size = inst->output2_buf_size;
list_for_each_entry_safe(buf, next, &inst->dpbbufs, list) {
struct hfi_frame_data fdata;
memset(&fdata, 0, sizeof(fdata));
fdata.alloc_len = buf->size;
fdata.device_addr = buf->da;
Annotation
- Immediate include surface: `linux/idr.h`, `linux/list.h`, `linux/mutex.h`, `linux/slab.h`, `linux/kernel.h`, `media/videobuf2-dma-contig.h`, `media/v4l2-mem2mem.h`, `asm/div64.h`.
- Detected declarations: `struct intbuf`, `struct id_mapping`, `enum dpb_buf_owner`, `function venus_helper_check_codec`, `function free_dpb_buf`, `function venus_helper_queue_dpb_bufs`, `function list_for_each_entry_safe`, `function venus_helper_free_dpb_bufs`, `function list_for_each_entry_safe`, `function venus_helper_alloc_dpb_bufs`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.