drivers/media/platform/verisilicon/hantro_v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/verisilicon/hantro_v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/verisilicon/hantro_v4l2.c- Extension
.c- Size
- 27650 bytes
- Lines
- 1032
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/io.hlinux/module.hlinux/pm_runtime.hlinux/videodev2.hlinux/workqueue.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/v4l2-mem2mem.hhantro.hhantro_hw.hhantro_v4l2.h
Detected Declarations
function hantro_get_formatsfunction hantro_get_postproc_formatsfunction hantro_get_format_depthfunction hantro_check_depth_matchfunction hantro_find_formatfunction hantro_set_reference_frames_formatfunction hantro_get_default_fmtfunction vidioc_querycapfunction vidioc_enum_framesizesfunction vidioc_enum_fmtfunction vidioc_enum_fmt_vid_capfunction vidioc_enum_fmt_vid_outfunction vidioc_g_fmt_out_mplanefunction vidioc_g_fmt_cap_mplanefunction hantro_try_fmtfunction vidioc_try_fmt_cap_mplanefunction vidioc_try_fmt_out_mplanefunction hantro_reset_fmtfunction hantro_reset_encoded_fmtfunction hantro_reset_raw_fmtfunction hantro_reset_fmtsfunction hantro_update_requires_requestfunction hantro_update_requires_hold_capture_buffunction hantro_set_fmt_outfunction hantro_set_fmt_capfunction vidioc_s_fmt_out_mplanefunction vidioc_s_fmt_cap_mplanefunction vidioc_g_selectionfunction vidioc_s_selectionfunction round_upfunction vidioc_encoder_cmdfunction hantro_queue_setupfunction hantro_buf_plane_checkfunction hantro_buf_preparefunction hantro_buf_queuefunction hantro_vq_is_codedfunction hantro_start_streamingfunction hantro_return_bufsfunction hantro_stop_streamingfunction hantro_buf_request_completefunction hantro_buf_out_validate
Annotated Snippet
if (j == index) {
f->pixelformat = fmt->fourcc;
return 0;
}
++j;
}
/*
* Enumerate post-processed formats. As per the specification,
* we enumerated these formats after natively decoded formats
* as a hint for applications on what's the preferred fomat.
*/
if (!capture)
return -EINVAL;
formats = hantro_get_postproc_formats(ctx, &num_fmts);
for (i = 0; i < num_fmts; i++) {
fmt = &formats[i];
if (!hantro_check_depth_match(fmt, ctx->bit_depth) && !enum_all_formats)
continue;
if (j == index) {
f->pixelformat = fmt->fourcc;
return 0;
}
++j;
}
return -EINVAL;
}
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
return vidioc_enum_fmt(file, priv, f, true);
}
static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
return vidioc_enum_fmt(file, priv, f, false);
}
static int vidioc_g_fmt_out_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
struct hantro_ctx *ctx = file_to_ctx(file);
vpu_debug(4, "f->type = %d\n", f->type);
*pix_mp = ctx->src_fmt;
return 0;
}
static int vidioc_g_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
struct hantro_ctx *ctx = file_to_ctx(file);
vpu_debug(4, "f->type = %d\n", f->type);
*pix_mp = ctx->dst_fmt;
return 0;
}
static int hantro_try_fmt(const struct hantro_ctx *ctx,
struct v4l2_pix_format_mplane *pix_mp,
enum v4l2_buf_type type)
{
const struct hantro_fmt *fmt;
const struct hantro_fmt *vpu_fmt;
bool capture = V4L2_TYPE_IS_CAPTURE(type);
bool coded;
coded = capture == ctx->is_encoder;
vpu_debug(4, "trying format %p4cc\n", &pix_mp->pixelformat);
fmt = hantro_find_format(ctx, pix_mp->pixelformat);
if (!fmt) {
fmt = hantro_get_default_fmt(ctx, coded, HANTRO_DEFAULT_BIT_DEPTH, HANTRO_AUTO_POSTPROC);
pix_mp->pixelformat = fmt->fourcc;
}
if (coded) {
pix_mp->num_planes = 1;
vpu_fmt = fmt;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/videodev2.h`, `linux/workqueue.h`, `media/v4l2-ctrls.h`, `media/v4l2-event.h`.
- Detected declarations: `function hantro_get_formats`, `function hantro_get_postproc_formats`, `function hantro_get_format_depth`, `function hantro_check_depth_match`, `function hantro_find_format`, `function hantro_set_reference_frames_format`, `function hantro_get_default_fmt`, `function vidioc_querycap`, `function vidioc_enum_framesizes`, `function vidioc_enum_fmt`.
- 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.