drivers/media/v4l2-core/v4l2-ioctl.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/v4l2-ioctl.c- Extension
.c- Size
- 117633 bytes
- Lines
- 3535
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/compat.hlinux/mm.hlinux/module.hlinux/slab.hlinux/types.hlinux/kernel.hlinux/version.hlinux/v4l2-subdev.hlinux/videodev2.hmedia/media-device.hmedia/v4l2-common.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-fh.hmedia/v4l2-event.hmedia/v4l2-device.hmedia/videobuf2-v4l2.hmedia/v4l2-mc.hmedia/v4l2-mem2mem.htrace/events/v4l2.h
Detected Declarations
struct std_descrstruct v4l2_ioctl_infofunction v4l2_video_std_frame_periodfunction v4l2_video_std_constructfunction v4l_video_std_enumstdfunction v4l_print_querycapfunction v4l_print_enuminputfunction v4l_print_enumoutputfunction v4l_print_audiofunction v4l_print_audiooutfunction v4l_print_fmtdescfunction v4l_print_formatfunction v4l_print_framebufferfunction v4l_print_buftypefunction v4l_print_modulatorfunction v4l_print_tunerfunction v4l_print_frequencyfunction v4l_print_standardfunction v4l_print_stdfunction v4l_print_hw_freq_seekfunction v4l_print_requestbuffersfunction v4l_print_bufferfunction v4l_print_exportbufferfunction v4l_print_create_buffersfunction v4l_print_remove_buffersfunction v4l_print_streamparmfunction v4l_print_queryctrlfunction v4l_print_query_ext_ctrlfunction v4l_print_querymenufunction v4l_print_controlfunction v4l_print_ext_controlsfunction v4l_print_cropcapfunction v4l_print_cropfunction v4l_print_selectionfunction v4l_print_jpegcompressionfunction v4l_print_enc_idxfunction v4l_print_encoder_cmdfunction v4l_print_decoder_cmdfunction v4l_print_dbg_chip_infofunction v4l_print_dbg_registerfunction v4l_print_dv_timingsfunction v4l_print_enum_dv_timingsfunction v4l_print_dv_timings_capfunction v4l_print_frmsizeenumfunction v4l_print_frmivalenumfunction v4l_print_eventfunction v4l_print_event_subscriptionfunction v4l_print_sliced_vbi_cap
Annotated Snippet
struct std_descr {
v4l2_std_id std;
const char *descr;
};
static const struct std_descr standards[] = {
{ V4L2_STD_NTSC, "NTSC" },
{ V4L2_STD_NTSC_M, "NTSC-M" },
{ V4L2_STD_NTSC_M_JP, "NTSC-M-JP" },
{ V4L2_STD_NTSC_M_KR, "NTSC-M-KR" },
{ V4L2_STD_NTSC_443, "NTSC-443" },
{ V4L2_STD_PAL, "PAL" },
{ V4L2_STD_PAL_BG, "PAL-BG" },
{ V4L2_STD_PAL_B, "PAL-B" },
{ V4L2_STD_PAL_B1, "PAL-B1" },
{ V4L2_STD_PAL_G, "PAL-G" },
{ V4L2_STD_PAL_H, "PAL-H" },
{ V4L2_STD_PAL_I, "PAL-I" },
{ V4L2_STD_PAL_DK, "PAL-DK" },
{ V4L2_STD_PAL_D, "PAL-D" },
{ V4L2_STD_PAL_D1, "PAL-D1" },
{ V4L2_STD_PAL_K, "PAL-K" },
{ V4L2_STD_PAL_M, "PAL-M" },
{ V4L2_STD_PAL_N, "PAL-N" },
{ V4L2_STD_PAL_Nc, "PAL-Nc" },
{ V4L2_STD_PAL_60, "PAL-60" },
{ V4L2_STD_SECAM, "SECAM" },
{ V4L2_STD_SECAM_B, "SECAM-B" },
{ V4L2_STD_SECAM_G, "SECAM-G" },
{ V4L2_STD_SECAM_H, "SECAM-H" },
{ V4L2_STD_SECAM_DK, "SECAM-DK" },
{ V4L2_STD_SECAM_D, "SECAM-D" },
{ V4L2_STD_SECAM_K, "SECAM-K" },
{ V4L2_STD_SECAM_K1, "SECAM-K1" },
{ V4L2_STD_SECAM_L, "SECAM-L" },
{ V4L2_STD_SECAM_LC, "SECAM-Lc" },
{ 0, "Unknown" }
};
/* video4linux standard ID conversion to standard name
*/
const char *v4l2_norm_to_name(v4l2_std_id id)
{
u32 myid = id;
int i;
/* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
64 bit comparisons. So, on that architecture, with some gcc
variants, compilation fails. Currently, the max value is 30bit wide.
*/
BUG_ON(myid != id);
for (i = 0; standards[i].std; i++)
if (myid == standards[i].std)
break;
return standards[i].descr;
}
EXPORT_SYMBOL(v4l2_norm_to_name);
/* Returns frame period for the given standard */
void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod)
{
if (id & V4L2_STD_525_60) {
frameperiod->numerator = 1001;
frameperiod->denominator = 30000;
} else {
frameperiod->numerator = 1;
frameperiod->denominator = 25;
}
}
EXPORT_SYMBOL(v4l2_video_std_frame_period);
/* Fill in the fields of a v4l2_standard structure according to the
'id' and 'transmission' parameters. Returns negative on error. */
int v4l2_video_std_construct(struct v4l2_standard *vs,
int id, const char *name)
{
vs->id = id;
v4l2_video_std_frame_period(id, &vs->frameperiod);
vs->framelines = (id & V4L2_STD_525_60) ? 525 : 625;
strscpy(vs->name, name, sizeof(vs->name));
return 0;
}
EXPORT_SYMBOL(v4l2_video_std_construct);
/* Fill in the fields of a v4l2_standard structure according to the
* 'id' and 'vs->index' parameters. Returns negative on error. */
int v4l_video_std_enumstd(struct v4l2_standard *vs, v4l2_std_id id)
{
v4l2_std_id curr_id = 0;
Annotation
- Immediate include surface: `linux/compat.h`, `linux/mm.h`, `linux/module.h`, `linux/slab.h`, `linux/types.h`, `linux/kernel.h`, `linux/version.h`, `linux/v4l2-subdev.h`.
- Detected declarations: `struct std_descr`, `struct v4l2_ioctl_info`, `function v4l2_video_std_frame_period`, `function v4l2_video_std_construct`, `function v4l_video_std_enumstd`, `function v4l_print_querycap`, `function v4l_print_enuminput`, `function v4l_print_enumoutput`, `function v4l_print_audio`, `function v4l_print_audioout`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.