drivers/media/v4l2-core/v4l2-ctrls-request.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-ctrls-request.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/v4l2-ctrls-request.c- Extension
.c- Size
- 12814 bytes
- Lines
- 506
- 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/slab.hmedia/v4l2-ctrls.hmedia/v4l2-dev.hmedia/v4l2-ioctl.hv4l2-ctrls-priv.h
Detected Declarations
function Copyrightfunction v4l2_ctrl_handler_free_requestfunction v4l2_ctrl_request_clonefunction v4l2_ctrl_request_queuefunction v4l2_ctrl_request_unbindfunction v4l2_ctrl_request_releasefunction v4l2_ctrl_request_hdl_ctrl_findfunction v4l2_ctrl_request_bindfunction v4l2_ctrls_find_req_objfunction v4l2_g_ext_ctrls_requestfunction try_set_ext_ctrls_requestfunction v4l2_ctrl_request_completefunction list_for_each_entryfunction v4l2_ctrl_request_setupfunction list_for_each_entryfunction valuesexport v4l2_ctrl_request_hdl_findexport v4l2_ctrl_request_hdl_ctrl_findexport v4l2_ctrl_request_completeexport v4l2_ctrl_request_setup
Annotated Snippet
if (!ret) {
mutex_lock(from->lock);
list_add_tail(&hdl->requests, &from->requests);
mutex_unlock(from->lock);
}
}
return ret;
}
static struct media_request_object *
v4l2_ctrls_find_req_obj(struct v4l2_ctrl_handler *hdl,
struct media_request *req, bool set)
{
struct media_request_object *obj;
struct v4l2_ctrl_handler *new_hdl;
int ret;
if (IS_ERR(req))
return ERR_CAST(req);
if (set && WARN_ON(req->state != MEDIA_REQUEST_STATE_UPDATING))
return ERR_PTR(-EBUSY);
obj = media_request_object_find(req, &req_ops, hdl);
if (obj)
return obj;
/*
* If there are no controls in this completed request,
* then that can only happen if:
*
* 1) no controls were present in the queued request, and
* 2) v4l2_ctrl_request_complete() could not allocate a
* control handler object to store the completed state in.
*
* So return ENOMEM to indicate that there was an out-of-memory
* error.
*/
if (!set)
return ERR_PTR(-ENOMEM);
new_hdl = kzalloc_obj(*new_hdl);
if (!new_hdl)
return ERR_PTR(-ENOMEM);
obj = &new_hdl->req_obj;
ret = v4l2_ctrl_handler_init(new_hdl, (hdl->nr_of_buckets - 1) * 8);
if (!ret)
ret = v4l2_ctrl_request_bind(req, new_hdl, hdl);
if (ret) {
v4l2_ctrl_handler_free(new_hdl);
kfree(new_hdl);
return ERR_PTR(ret);
}
media_request_object_get(obj);
return obj;
}
int v4l2_g_ext_ctrls_request(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
struct media_device *mdev, struct v4l2_ext_controls *cs)
{
struct media_request_object *obj = NULL;
struct media_request *req = NULL;
int ret;
if (!mdev || cs->request_fd < 0)
return -EINVAL;
req = media_request_get_by_fd(mdev, cs->request_fd);
if (IS_ERR(req))
return PTR_ERR(req);
if (req->state != MEDIA_REQUEST_STATE_COMPLETE) {
media_request_put(req);
return -EACCES;
}
ret = media_request_lock_for_access(req);
if (ret) {
media_request_put(req);
return ret;
}
obj = v4l2_ctrls_find_req_obj(hdl, req, false);
if (IS_ERR(obj)) {
media_request_unlock_for_access(req);
media_request_put(req);
return PTR_ERR(obj);
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/slab.h`, `media/v4l2-ctrls.h`, `media/v4l2-dev.h`, `media/v4l2-ioctl.h`, `v4l2-ctrls-priv.h`.
- Detected declarations: `function Copyright`, `function v4l2_ctrl_handler_free_request`, `function v4l2_ctrl_request_clone`, `function v4l2_ctrl_request_queue`, `function v4l2_ctrl_request_unbind`, `function v4l2_ctrl_request_release`, `function v4l2_ctrl_request_hdl_ctrl_find`, `function v4l2_ctrl_request_bind`, `function v4l2_ctrls_find_req_obj`, `function v4l2_g_ext_ctrls_request`.
- 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.