drivers/media/usb/uvc/uvc_ctrl.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/uvc/uvc_ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/uvc/uvc_ctrl.c- Extension
.c- Size
- 94670 bytes
- Lines
- 3657
- 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 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.
- 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
asm/barrier.hlinux/bitops.hlinux/kernel.hlinux/list.hlinux/module.hlinux/slab.hlinux/uaccess.hlinux/usb.hlinux/usb/uvc.hlinux/videodev2.hlinux/vmalloc.hlinux/wait.hlinux/workqueue.hlinux/atomic.hmedia/v4l2-ctrls.huvcvideo.h
Detected Declarations
struct uvc_ctrl_fixupstruct privacy_controlstruct uvc_ctrl_blacklistfunction uvc_ctrl_mapping_is_compoundfunction uvc_mapping_get_s32function uvc_mapping_set_s32function uvc_mapping_get_menu_valuefunction uvc_mapping_get_menu_namefunction uvc_ctrl_get_zoomfunction uvc_ctrl_set_zoomfunction uvc_ctrl_get_rel_speedfunction uvc_ctrl_set_rel_speedfunction uvc_get_rectfunction uvc_set_rectfunction uvc_test_bitfunction uvc_clear_bitfunction uvc_menu_to_v4l2_menufunction uvc_get_le_valuefunction uvc_set_le_valuefunction uvc_entity_match_guidfunction __uvc_find_controlfunction list_for_each_entryfunction uvc_ctrl_populate_cachefunction __uvc_ctrl_load_curfunction __uvc_ctrl_getfunction __uvc_query_v4l2_classfunction uvc_query_v4l2_classfunction uvc_ctrl_is_readablefunction uvc_ctrl_is_accessiblefunction uvc_get_ctrl_bitmapfunction uvc_ctrl_is_relative_ptzfunction __uvc_queryctrl_boundariesfunction uvc_mapping_v4l2_sizefunction __uvc_query_v4l2_ctrlfunction uvc_query_v4l2_ctrlfunction groupedfunction uvc_ctrl_fill_eventfunction uvc_ctrl_send_eventfunction list_for_each_entryfunction uvc_ctrl_send_slave_eventfunction uvc_ctrl_set_handlefunction uvc_ctrl_clear_handlefunction uvc_ctrl_status_eventfunction list_for_each_entryfunction uvc_ctrl_status_event_workfunction uvc_ctrl_status_event_asyncfunction uvc_ctrl_xctrls_has_controlfunction uvc_ctrl_send_events
Annotated Snippet
struct uvc_ctrl_fixup {
struct usb_device_id id;
u8 entity;
u8 selector;
u8 flags;
};
static const struct uvc_ctrl_fixup fixups[] = {
{ { USB_DEVICE(0x046d, 0x08c2) }, 9, 1,
UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX |
UVC_CTRL_FLAG_GET_DEF | UVC_CTRL_FLAG_SET_CUR |
UVC_CTRL_FLAG_AUTO_UPDATE },
{ { USB_DEVICE(0x046d, 0x08cc) }, 9, 1,
UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX |
UVC_CTRL_FLAG_GET_DEF | UVC_CTRL_FLAG_SET_CUR |
UVC_CTRL_FLAG_AUTO_UPDATE },
{ { USB_DEVICE(0x046d, 0x0994) }, 9, 1,
UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX |
UVC_CTRL_FLAG_GET_DEF | UVC_CTRL_FLAG_SET_CUR |
UVC_CTRL_FLAG_AUTO_UPDATE },
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(fixups); ++i) {
if (!usb_match_one_id(dev->intf, &fixups[i].id))
continue;
if (fixups[i].entity == ctrl->entity->id &&
fixups[i].selector == info->selector) {
info->flags = fixups[i].flags;
return;
}
}
}
/*
* Query control information (size and flags) for XU controls.
*/
static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
const struct uvc_control *ctrl, struct uvc_control_info *info)
{
u8 *data;
int ret;
data = kmalloc(2, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
memcpy(info->entity, ctrl->entity->guid, sizeof(info->entity));
info->index = ctrl->index;
info->selector = ctrl->index + 1;
/* Query and verify the control length (GET_LEN) */
ret = uvc_query_ctrl(dev, UVC_GET_LEN, ctrl->entity->id, dev->intfnum,
info->selector, data, 2);
if (ret < 0) {
uvc_dbg(dev, CONTROL,
"GET_LEN failed on control %pUl/%u (%d)\n",
info->entity, info->selector, ret);
goto done;
}
info->size = le16_to_cpup((__le16 *)data);
info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
| UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF;
ret = uvc_ctrl_get_flags(dev, ctrl, info);
if (ret < 0) {
uvc_dbg(dev, CONTROL,
"Failed to get flags for control %pUl/%u (%d)\n",
info->entity, info->selector, ret);
goto done;
}
uvc_ctrl_fixup_xu_info(dev, ctrl, info);
uvc_dbg(dev, CONTROL,
"XU control %pUl/%u queried: len %u, flags { get %u set %u auto %u }\n",
info->entity, info->selector, info->size,
(info->flags & UVC_CTRL_FLAG_GET_CUR) ? 1 : 0,
(info->flags & UVC_CTRL_FLAG_SET_CUR) ? 1 : 0,
(info->flags & UVC_CTRL_FLAG_AUTO_UPDATE) ? 1 : 0);
done:
kfree(data);
return ret;
}
Annotation
- Immediate include surface: `asm/barrier.h`, `linux/bitops.h`, `linux/kernel.h`, `linux/list.h`, `linux/module.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/usb.h`.
- Detected declarations: `struct uvc_ctrl_fixup`, `struct privacy_control`, `struct uvc_ctrl_blacklist`, `function uvc_ctrl_mapping_is_compound`, `function uvc_mapping_get_s32`, `function uvc_mapping_set_s32`, `function uvc_mapping_get_menu_value`, `function uvc_mapping_get_menu_name`, `function uvc_ctrl_get_zoom`, `function uvc_ctrl_set_zoom`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.
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.