drivers/media/platform/qcom/venus/venc.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/venc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/venus/venc.c- Extension
.c- Size
- 42332 bytes
- Lines
- 1668
- 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.
- 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/clk.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hmedia/v4l2-mem2mem.hmedia/videobuf2-dma-contig.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/v4l2-ctrls.hhfi_venus_io.hhfi_parser.hcore.hhelpers.hvenc.hpm_helpers.h
Detected Declarations
function find_formatfunction find_format_by_indexfunction venc_v4l2_to_hfifunction venc_querycapfunction venc_enum_fmtfunction venc_try_fmt_commonfunction venc_try_fmtfunction venc_s_fmtfunction venc_g_fmtfunction venc_g_selectionfunction venc_s_selectionfunction venc_s_parmfunction venc_g_parmfunction venc_enum_framesizesfunction venc_enum_frameintervalsfunction venc_subscribe_eventfunction venc_encoder_cmdfunction venc_pm_getfunction venc_pm_putfunction venc_pm_get_putfunction venc_pm_touchfunction venc_set_propertiesfunction venc_init_sessionfunction venc_out_num_buffersfunction venc_queue_setupfunction venc_buf_initfunction venc_release_sessionfunction venc_buf_cleanupfunction venc_verify_conffunction venc_start_streamingfunction venc_vb2_buf_queuefunction venc_buf_donefunction venc_event_notifyfunction m2m_queue_initfunction venc_inst_initfunction venc_openfunction venc_closefunction venc_probefunction venc_removefunction venc_runtime_suspendfunction venc_runtime_resume
Annotated Snippet
switch (value) {
case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC:
default:
return HFI_H264_ENTROPY_CAVLC;
case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC:
return HFI_H264_ENTROPY_CABAC;
}
case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
switch (value) {
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED:
default:
return HFI_H264_DB_MODE_ALL_BOUNDARY;
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED:
return HFI_H264_DB_MODE_DISABLE;
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY:
return HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY;
}
}
return 0;
}
static int
venc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
struct venus_inst *inst = to_inst(file);
struct venus_core *core = inst->core;
strscpy(cap->driver, "qcom-venus", sizeof(cap->driver));
strscpy(cap->card, "Qualcomm Venus video encoder", sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
"plat:%s:enc", dev_name(core->dev));
return 0;
}
static int venc_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
struct venus_inst *inst = to_inst(file);
const struct venus_format *fmt;
fmt = find_format_by_index(inst, f->index, f->type);
memset(f->reserved, 0, sizeof(f->reserved));
if (!fmt)
return -EINVAL;
f->pixelformat = fmt->pixfmt;
return 0;
}
static const struct venus_format *
venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt;
const struct venus_format *fmt;
u32 sizeimage;
memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
fmt = find_format(inst, pixmp->pixelformat, f->type);
if (!fmt) {
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
pixmp->pixelformat = V4L2_PIX_FMT_H264;
else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
pixmp->pixelformat = V4L2_PIX_FMT_NV12;
else
return NULL;
fmt = find_format(inst, pixmp->pixelformat, f->type);
if (!fmt)
return NULL;
}
pixmp->width = clamp(pixmp->width, frame_width_min(inst),
frame_width_max(inst));
pixmp->height = clamp(pixmp->height, frame_height_min(inst),
frame_height_max(inst));
pixmp->width = ALIGN(pixmp->width, 128);
pixmp->height = ALIGN(pixmp->height, 32);
pixmp->width = ALIGN(pixmp->width, 2);
pixmp->height = ALIGN(pixmp->height, 2);
if (pixmp->field == V4L2_FIELD_ANY)
pixmp->field = V4L2_FIELD_NONE;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/slab.h`, `media/v4l2-mem2mem.h`, `media/videobuf2-dma-contig.h`.
- Detected declarations: `function find_format`, `function find_format_by_index`, `function venc_v4l2_to_hfi`, `function venc_querycap`, `function venc_enum_fmt`, `function venc_try_fmt_common`, `function venc_try_fmt`, `function venc_s_fmt`, `function venc_g_fmt`, `function venc_g_selection`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.