drivers/media/platform/qcom/iris/iris_venc.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/iris/iris_venc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/iris/iris_venc.c- Extension
.c- Size
- 16938 bytes
- Lines
- 613
- 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.
- 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
media/v4l2-event.hmedia/v4l2-mem2mem.hiris_buffer.hiris_common.hiris_ctrls.hiris_instance.hiris_power.hiris_venc.hiris_vpu_buffer.h
Detected Declarations
function Copyrightfunction check_formatfunction find_format_by_indexfunction iris_venc_enum_fmtfunction iris_venc_try_fmtfunction iris_venc_s_fmt_outputfunction iris_venc_s_fmt_inputfunction iris_venc_s_fmtfunction iris_venc_validate_formatfunction iris_venc_subscribe_eventfunction iris_venc_s_selectionfunction iris_venc_s_paramfunction iris_venc_g_paramfunction iris_venc_streamon_inputfunction iris_venc_streamon_outputfunction iris_venc_qbuffunction iris_venc_start_cmdfunction iris_venc_stop_cmd
Annotated Snippet
if (!supported) {
f_inst = inst->fmt_src;
f->fmt.pix_mp.width = f_inst->fmt.pix_mp.width;
f->fmt.pix_mp.height = f_inst->fmt.pix_mp.height;
f->fmt.pix_mp.pixelformat = f_inst->fmt.pix_mp.pixelformat;
}
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (!supported) {
f_inst = inst->fmt_dst;
f->fmt.pix_mp.width = f_inst->fmt.pix_mp.width;
f->fmt.pix_mp.height = f_inst->fmt.pix_mp.height;
f->fmt.pix_mp.pixelformat = f_inst->fmt.pix_mp.pixelformat;
}
break;
default:
return -EINVAL;
}
if (pixmp->field == V4L2_FIELD_ANY)
pixmp->field = V4L2_FIELD_NONE;
pixmp->num_planes = 1;
return 0;
}
static int iris_venc_s_fmt_output(struct iris_inst *inst, struct v4l2_format *f)
{
struct v4l2_format *fmt;
u32 codec_align;
bool supported;
iris_venc_try_fmt(inst, f);
supported = check_format(inst, f->fmt.pix_mp.pixelformat, f->type);
if (!supported)
return -EINVAL;
codec_align = (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC) ? 32 : 16;
fmt = inst->fmt_dst;
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
/*
* If output format size != input format size,
* it is considered a scaling case,
* and the scaled size needs to be saved.
*/
if (f->fmt.pix_mp.width != inst->fmt_src->fmt.pix_mp.width ||
f->fmt.pix_mp.height != inst->fmt_src->fmt.pix_mp.height) {
inst->enc_scale_width = f->fmt.pix_mp.width;
inst->enc_scale_height = f->fmt.pix_mp.height;
fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, codec_align);
fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, codec_align);
}
fmt->fmt.pix_mp.num_planes = 1;
fmt->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
fmt->fmt.pix_mp.plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
if (f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_DEFAULT &&
f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_REC709)
f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
fmt->fmt.pix_mp.xfer_func = f->fmt.pix_mp.xfer_func;
fmt->fmt.pix_mp.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization;
inst->buffers[BUF_OUTPUT].min_count = iris_vpu_buf_count(inst, BUF_OUTPUT);
inst->buffers[BUF_OUTPUT].size = fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
inst->codec = f->fmt.pix_mp.pixelformat;
memcpy(f, fmt, sizeof(struct v4l2_format));
return 0;
}
static int iris_venc_s_fmt_input(struct iris_inst *inst, struct v4l2_format *f)
{
struct v4l2_format *fmt, *output_fmt;
iris_venc_try_fmt(inst, f);
if (!check_format(inst, f->fmt.pix_mp.pixelformat, f->type))
return -EINVAL;
fmt = inst->fmt_src;
fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, 128);
fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 32);
fmt->fmt.pix_mp.num_planes = 1;
Annotation
- Immediate include surface: `media/v4l2-event.h`, `media/v4l2-mem2mem.h`, `iris_buffer.h`, `iris_common.h`, `iris_ctrls.h`, `iris_instance.h`, `iris_power.h`, `iris_venc.h`.
- Detected declarations: `function Copyright`, `function check_format`, `function find_format_by_index`, `function iris_venc_enum_fmt`, `function iris_venc_try_fmt`, `function iris_venc_s_fmt_output`, `function iris_venc_s_fmt_input`, `function iris_venc_s_fmt`, `function iris_venc_validate_format`, `function iris_venc_subscribe_event`.
- 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.