drivers/media/platform/qcom/venus/vdec.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/vdec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/venus/vdec.c- Extension
.c- Size
- 47018 bytes
- Lines
- 1892
- 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-ioctl.hmedia/v4l2-event.hmedia/v4l2-ctrls.hmedia/v4l2-mem2mem.hmedia/videobuf2-dma-contig.hhfi_venus_io.hhfi_parser.hcore.hhelpers.hvdec.hpm_helpers.h
Detected Declarations
function find_formatfunction find_format_by_indexfunction vdec_try_fmt_commonfunction vdec_try_fmtfunction vdec_check_src_changefunction vdec_g_fmtfunction vdec_s_fmtfunction vdec_g_selectionfunction vdec_querycapfunction vdec_enum_fmtfunction vdec_s_parmfunction vdec_enum_framesizesfunction vdec_subscribe_eventfunction vdec_decoder_cmdfunction vdec_pm_getfunction vdec_pm_putfunction vdec_pm_get_putfunction vdec_pm_touchfunction vdec_set_propertiesfunction vdec_set_work_routefunction vdec_output_conffunction vdec_session_initfunction vdec_num_buffersfunction vdec_queue_setupfunction vdec_verify_conffunction vdec_start_capturefunction vdec_start_outputfunction vdec_start_streamingfunction vdec_cancel_dst_buffersfunction vdec_stop_capturefunction vdec_stop_outputfunction vdec_stop_streamingfunction vdec_session_releasefunction vdec_buf_initfunction vdec_buf_cleanupfunction vdec_vb2_buf_queuefunction vdec_buf_donefunction vdec_event_changefunction vdec_event_notifyfunction vdec_flush_donefunction vdec_inst_initfunction vdec_m2m_device_runfunction m2m_queue_initfunction vdec_openfunction vdec_closefunction vdec_probefunction vdec_removefunction vdec_runtime_suspend
Annotated Snippet
if (V4L2_TYPE_IS_OUTPUT(type)) {
valid = venus_helper_check_codec(inst, fmt[i].pixfmt);
} else {
valid = venus_helper_check_format(inst, fmt[i].pixfmt);
if (fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
!(inst->bit_depth == VIDC_BITDEPTH_10))
valid = false;
}
if (k == index && valid)
break;
if (valid)
k++;
}
if (i == size)
return NULL;
return &fmt[i];
}
static const struct venus_format *
vdec_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 szimage;
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_NV12;
else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
pixmp->pixelformat = V4L2_PIX_FMT_H264;
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));
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
pixmp->height = ALIGN(pixmp->height, 32);
if (pixmp->field == V4L2_FIELD_ANY)
pixmp->field = V4L2_FIELD_NONE;
pixmp->num_planes = fmt->num_planes;
pixmp->flags = 0;
szimage = venus_helper_get_framesz(pixmp->pixelformat, pixmp->width,
pixmp->height);
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
unsigned int stride = pixmp->width;
if (pixmp->pixelformat == V4L2_PIX_FMT_P010)
stride *= 2;
pfmt[0].sizeimage = szimage;
pfmt[0].bytesperline = ALIGN(stride, 128);
} else {
pfmt[0].sizeimage = clamp_t(u32, pfmt[0].sizeimage, 0, SZ_8M);
pfmt[0].sizeimage = max(pfmt[0].sizeimage, szimage);
pfmt[0].bytesperline = 0;
}
return fmt;
}
static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
struct venus_inst *inst = to_inst(file);
vdec_try_fmt_common(inst, f);
return 0;
}
static int vdec_check_src_change(struct venus_inst *inst)
{
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-ioctl.h`, `media/v4l2-event.h`.
- Detected declarations: `function find_format`, `function find_format_by_index`, `function vdec_try_fmt_common`, `function vdec_try_fmt`, `function vdec_check_src_change`, `function vdec_g_fmt`, `function vdec_s_fmt`, `function vdec_g_selection`, `function vdec_querycap`, `function vdec_enum_fmt`.
- 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.