drivers/media/platform/st/sti/hva/hva-v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/st/sti/hva/hva-v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/st/sti/hva/hva-v4l2.c- Extension
.c- Size
- 37839 bytes
- Lines
- 1472
- 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.
- 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/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/slab.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.hhva.hhva-hw.h
Detected Declarations
function Copyrightfunction frame_sizefunction frame_stridefunction frame_alignmentfunction estimated_stream_sizefunction set_default_paramsfunction register_formatfunction register_formatsfunction register_encodersfunction hva_open_encoderfunction hva_dbg_summaryfunction hva_querycapfunction hva_enum_fmt_streamfunction hva_enum_fmt_framefunction hva_g_fmt_streamfunction hva_g_fmt_framefunction hva_try_fmt_streamfunction hva_try_fmt_framefunction hva_s_fmt_streamfunction hva_s_fmt_framefunction hva_g_parmfunction hva_s_parmfunction hva_qbuffunction hva_s_ctrlfunction hva_ctrls_setupfunction hva_run_workfunction hva_device_runfunction hva_job_abortfunction hva_job_readyfunction hva_queue_setupfunction hva_buf_preparefunction hva_buf_queuefunction hva_start_streamingfunction hva_stop_streamingfunction queue_initfunction hva_queue_initfunction hva_openfunction hva_releasefunction hva_register_devicefunction hva_unregister_devicefunction hva_probefunction hva_remove
Annotated Snippet
if (format == formats[i]) {
found = true;
break;
}
}
if (!found)
formats[(*nb_of_formats)++] = format;
}
static void register_formats(struct hva_dev *hva)
{
unsigned int i;
for (i = 0; i < hva->nb_of_encoders; i++) {
register_format(hva->encoders[i]->pixelformat,
hva->pixelformats,
&hva->nb_of_pixelformats);
register_format(hva->encoders[i]->streamformat,
hva->streamformats,
&hva->nb_of_streamformats);
}
}
static void register_encoders(struct hva_dev *hva)
{
struct device *dev = hva_to_dev(hva);
unsigned int i;
for (i = 0; i < ARRAY_SIZE(hva_encoders); i++) {
if (hva->nb_of_encoders >= HVA_MAX_ENCODERS) {
dev_dbg(dev,
"%s failed to register %s encoder (%d maximum reached)\n",
HVA_PREFIX, hva_encoders[i]->name,
HVA_MAX_ENCODERS);
return;
}
hva->encoders[hva->nb_of_encoders++] = hva_encoders[i];
dev_info(dev, "%s %s encoder registered\n", HVA_PREFIX,
hva_encoders[i]->name);
}
}
static int hva_open_encoder(struct hva_ctx *ctx, u32 streamformat,
u32 pixelformat, struct hva_enc **penc)
{
struct hva_dev *hva = ctx_to_hdev(ctx);
struct device *dev = ctx_to_dev(ctx);
struct hva_enc *enc;
int ret;
/* find an encoder which can deal with these formats */
enc = (struct hva_enc *)hva_find_encoder(ctx, pixelformat,
streamformat);
if (!enc) {
dev_err(dev, "%s no encoder found matching %4.4s => %4.4s\n",
ctx->name, (char *)&pixelformat, (char *)&streamformat);
return -EINVAL;
}
dev_dbg(dev, "%s one encoder matching %4.4s => %4.4s\n",
ctx->name, (char *)&pixelformat, (char *)&streamformat);
/* update instance name */
snprintf(ctx->name, sizeof(ctx->name), "[%3d:%4.4s]",
hva->instance_id, (char *)&streamformat);
/* open encoder instance */
ret = enc->open(ctx);
if (ret) {
dev_err(dev, "%s failed to open encoder instance (%d)\n",
ctx->name, ret);
return ret;
}
dev_dbg(dev, "%s %s encoder opened\n", ctx->name, enc->name);
*penc = enc;
return ret;
}
static void hva_dbg_summary(struct hva_ctx *ctx)
{
struct device *dev = ctx_to_dev(ctx);
struct hva_streaminfo *stream = &ctx->streaminfo;
struct hva_frameinfo *frame = &ctx->frameinfo;
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/slab.h`, `media/v4l2-event.h`, `media/v4l2-ioctl.h`, `media/videobuf2-dma-contig.h`, `hva.h`.
- Detected declarations: `function Copyright`, `function frame_size`, `function frame_stride`, `function frame_alignment`, `function estimated_stream_size`, `function set_default_params`, `function register_format`, `function register_formats`, `function register_encoders`, `function hva_open_encoder`.
- 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.
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.