drivers/media/platform/amphion/venc.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/amphion/venc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/amphion/venc.c- Extension
.c- Size
- 36142 bytes
- Lines
- 1356
- 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.
- 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/init.hlinux/interconnect.hlinux/ioctl.hlinux/list.hlinux/kernel.hlinux/module.hlinux/delay.hlinux/videodev2.hlinux/ktime.hlinux/rational.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-mem2mem.hmedia/v4l2-ioctl.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hvpu.hvpu_defs.hvpu_core.hvpu_helpers.hvpu_v4l2.hvpu_cmds.hvpu_rpc.h
Detected Declarations
struct venc_tstruct venc_frame_tfunction venc_querycapfunction venc_enum_fmtfunction venc_enum_framesizesfunction venc_enum_frameintervalsfunction venc_g_fmtfunction venc_try_fmtfunction venc_s_fmtfunction venc_g_parmfunction venc_s_parmfunction venc_g_selectionfunction venc_valid_cropfunction venc_s_selectionfunction venc_drainfunction venc_request_eosfunction venc_encoder_cmdfunction venc_subscribe_eventfunction venc_op_s_ctrlfunction venc_ctrl_initfunction venc_check_readyfunction venc_get_enable_maskfunction venc_set_enablefunction venc_get_enablefunction venc_input_donefunction venc_precheck_encoded_framefunction venc_get_one_encoded_framefunction venc_get_encoded_framesfunction venc_frame_encodedfunction venc_set_last_buffer_dequeuedfunction venc_stop_donefunction venc_event_notifyfunction venc_start_sessionfunction venc_cleanup_mem_resourcefunction venc_request_mem_resourcefunction venc_cleanup_framesfunction list_for_each_entry_safefunction venc_stop_sessionfunction venc_process_outputfunction venc_process_capturefunction venc_on_queue_emptyfunction venc_get_debug_infofunction venc_initfunction venc_open
Annotated Snippet
struct venc_t {
struct vpu_encode_params params;
u32 request_key_frame;
u32 input_ready;
u32 cpb_size;
bool bitrate_change;
struct vpu_buffer enc[VENC_MAX_BUF_CNT];
struct vpu_buffer ref[VENC_MAX_BUF_CNT];
struct vpu_buffer act[VENC_MAX_BUF_CNT];
struct list_head frames;
u32 frame_count;
u32 encode_count;
u32 ready_count;
u32 enable;
u32 stopped;
u32 memory_resource_configured;
u32 skipped_count;
u32 skipped_bytes;
wait_queue_head_t wq;
};
struct venc_frame_t {
struct list_head list;
struct vpu_enc_pic_info info;
u32 bytesused;
s64 timestamp;
};
static const struct vpu_format venc_formats[] = {
{
.pixfmt = V4L2_PIX_FMT_NV12M,
.mem_planes = 2,
.comp_planes = 2,
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
.sibling = V4L2_PIX_FMT_NV12,
},
{
.pixfmt = V4L2_PIX_FMT_NV12,
.mem_planes = 1,
.comp_planes = 2,
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
.sibling = V4L2_PIX_FMT_NV12M,
},
{
.pixfmt = V4L2_PIX_FMT_H264,
.mem_planes = 1,
.comp_planes = 1,
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
.flags = V4L2_FMT_FLAG_COMPRESSED
},
{0, 0, 0, 0},
};
static int venc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
strscpy(cap->driver, "amphion-vpu", sizeof(cap->driver));
strscpy(cap->card, "amphion vpu encoder", sizeof(cap->card));
strscpy(cap->bus_info, "platform: amphion-vpu", sizeof(cap->bus_info));
return 0;
}
static int venc_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
struct vpu_inst *inst = to_inst(file);
const struct vpu_format *fmt;
memset(f->reserved, 0, sizeof(f->reserved));
fmt = vpu_helper_enum_format(inst, f->type, f->index);
if (!fmt)
return -EINVAL;
f->pixelformat = fmt->pixfmt;
f->flags = fmt->flags;
return 0;
}
static int venc_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize)
{
struct vpu_inst *inst = to_inst(file);
const struct vpu_core_resources *res;
if (!fsize || fsize->index)
return -EINVAL;
if (!vpu_helper_find_format(inst, 0, fsize->pixel_format))
Annotation
- Immediate include surface: `linux/init.h`, `linux/interconnect.h`, `linux/ioctl.h`, `linux/list.h`, `linux/kernel.h`, `linux/module.h`, `linux/delay.h`, `linux/videodev2.h`.
- Detected declarations: `struct venc_t`, `struct venc_frame_t`, `function venc_querycap`, `function venc_enum_fmt`, `function venc_enum_framesizes`, `function venc_enum_frameintervals`, `function venc_g_fmt`, `function venc_try_fmt`, `function venc_s_fmt`, `function venc_g_parm`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- 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.