drivers/media/v4l2-core/v4l2-ctrls-core.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-ctrls-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/v4l2-ctrls-core.c- Extension
.c- Size
- 76843 bytes
- Lines
- 2844
- 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.
- 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/export.hlinux/mm.hlinux/slab.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/v4l2-fwnode.hv4l2-ctrls-priv.h
Detected Declarations
function fill_eventfunction send_initial_eventfunction send_eventfunction v4l2_ctrl_type_op_equalfunction std_init_compoundfunction std_min_compoundfunction std_max_compoundfunction __v4l2_ctrl_type_op_initfunction v4l2_ctrl_type_op_initfunction v4l2_ctrl_type_op_minimumfunction v4l2_ctrl_type_op_maximumfunction v4l2_ctrl_type_op_logfunction validate_vp9_lf_paramsfunction validate_vp9_quant_paramsfunction validate_vp9_seg_paramsfunction validate_vp9_compressed_hdrfunction validate_vp9_framefunction validate_av1_quantizationfunction validate_av1_segmentationfunction validate_av1_loop_filterfunction validate_av1_cdeffunction validate_av1_loop_restaurationfunction validate_av1_film_grainfunction validate_av1_framefunction validate_av1_sequencefunction std_validate_compoundfunction std_validate_elemfunction v4l2_ctrl_type_op_validatefunction v4l2_ctrl_notifyfunction ptr_to_ptrfunction new_to_curfunction cur_to_newfunction req_alloc_arrayfunction new_to_reqfunction cur_to_reqfunction req_to_newfunction check_rangefunction handler_set_errfunction v4l2_ctrl_handler_init_classfunction v4l2_ctrl_handler_freefunction handler_new_reffunction Ofunction v4l2_ctrl_add_handlerfunction v4l2_ctrl_radio_filterfunction v4l2_ctrl_clusterfunction v4l2_ctrl_auto_clusterfunction update_from_auto_clusterfunction cluster_changed
Annotated Snippet
if (value) {
for (i = from_idx; i < tot_elems; i++)
ptr.p_s64[i] = value;
} else {
memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64));
}
break;
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_INTEGER_MENU:
case V4L2_CTRL_TYPE_MENU:
case V4L2_CTRL_TYPE_BITMASK:
case V4L2_CTRL_TYPE_BOOLEAN:
if (value) {
for (i = from_idx; i < tot_elems; i++)
ptr.p_s32[i] = value;
} else {
memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32));
}
break;
case V4L2_CTRL_TYPE_BUTTON:
case V4L2_CTRL_TYPE_CTRL_CLASS:
memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32));
break;
case V4L2_CTRL_TYPE_U8:
memset(ptr.p_u8 + from_idx, value, elems);
break;
case V4L2_CTRL_TYPE_U16:
if (value) {
for (i = from_idx; i < tot_elems; i++)
ptr.p_u16[i] = value;
} else {
memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16));
}
break;
case V4L2_CTRL_TYPE_U32:
if (value) {
for (i = from_idx; i < tot_elems; i++)
ptr.p_u32[i] = value;
} else {
memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32));
}
break;
default:
for (i = from_idx; i < tot_elems; i++) {
switch (which) {
case V4L2_CTRL_WHICH_DEF_VAL:
std_init_compound(ctrl, i, ptr);
break;
case V4L2_CTRL_WHICH_MAX_VAL:
std_max_compound(ctrl, i, ptr);
break;
case V4L2_CTRL_WHICH_MIN_VAL:
std_min_compound(ctrl, i, ptr);
break;
}
}
break;
}
}
void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx,
union v4l2_ctrl_ptr ptr)
{
__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_DEF_VAL, ptr);
}
EXPORT_SYMBOL(v4l2_ctrl_type_op_init);
static void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl,
u32 from_idx, union v4l2_ctrl_ptr ptr)
{
__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MIN_VAL, ptr);
}
static void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl,
u32 from_idx, union v4l2_ctrl_ptr ptr)
{
__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MAX_VAL, ptr);
}
void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)
{
union v4l2_ctrl_ptr ptr = ctrl->p_cur;
if (ctrl->is_array) {
unsigned i;
for (i = 0; i < ctrl->nr_of_dims; i++)
pr_cont("[%u]", ctrl->dims[i]);
pr_cont(" ");
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/mm.h`, `linux/slab.h`, `media/v4l2-ctrls.h`, `media/v4l2-event.h`, `media/v4l2-fwnode.h`, `v4l2-ctrls-priv.h`.
- Detected declarations: `function fill_event`, `function send_initial_event`, `function send_event`, `function v4l2_ctrl_type_op_equal`, `function std_init_compound`, `function std_min_compound`, `function std_max_compound`, `function __v4l2_ctrl_type_op_init`, `function v4l2_ctrl_type_op_init`, `function v4l2_ctrl_type_op_minimum`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.