Lines Matching full:hdl
2309 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err) in handler_set_err() argument
2311 if (hdl->error == 0) in handler_set_err()
2312 hdl->error = err; in handler_set_err()
2317 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
2321 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
2322 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
2323 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
2324 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
2325 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
2326 INIT_LIST_HEAD(&hdl->requests); in v4l2_ctrl_handler_init_class()
2327 INIT_LIST_HEAD(&hdl->requests_queued); in v4l2_ctrl_handler_init_class()
2328 hdl->request_is_queued = false; in v4l2_ctrl_handler_init_class()
2329 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
2330 hdl->buckets = kvmalloc_array(hdl->nr_of_buckets, in v4l2_ctrl_handler_init_class()
2331 sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
2333 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
2334 media_request_object_init(&hdl->req_obj); in v4l2_ctrl_handler_init_class()
2335 return hdl->error; in v4l2_ctrl_handler_init_class()
2340 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
2346 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
2349 if (!hdl->req_obj.req && !list_empty(&hdl->requests)) { in v4l2_ctrl_handler_free()
2352 list_for_each_entry_safe(req, next_req, &hdl->requests, requests) { in v4l2_ctrl_handler_free()
2357 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
2359 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
2364 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
2370 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
2371 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
2372 hdl->cached = NULL; in v4l2_ctrl_handler_free()
2373 hdl->error = 0; in v4l2_ctrl_handler_free()
2374 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
2375 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
2386 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
2391 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
2407 static struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
2416 return find_private_ref(hdl, id); in find_ref()
2417 bucket = id % hdl->nr_of_buckets; in find_ref()
2420 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
2421 return hdl->cached; in find_ref()
2424 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
2429 hdl->cached = ref; /* cache it! */ in find_ref()
2435 struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
2439 if (hdl) { in find_ref_lock()
2440 mutex_lock(hdl->lock); in find_ref_lock()
2441 ref = find_ref(hdl, id); in find_ref_lock()
2442 mutex_unlock(hdl->lock); in find_ref_lock()
2448 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
2450 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
2457 static int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
2466 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
2477 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
2478 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
2479 return hdl->error; in handler_new_ref()
2481 if (hdl->error) in handler_new_ref()
2482 return hdl->error; in handler_new_ref()
2488 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
2496 mutex_lock(hdl->lock); in handler_new_ref()
2502 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
2503 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
2508 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
2522 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
2523 hdl->buckets[bucket] = new_ref; in handler_new_ref()
2526 if (ctrl->handler == hdl) { in handler_new_ref()
2537 mutex_unlock(hdl->lock); in handler_new_ref()
2542 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
2562 if (hdl->error) in v4l2_ctrl_new()
2644 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
2649 handler_set_err(hdl, err); in v4l2_ctrl_new()
2655 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
2676 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
2682 ctrl->handler = hdl; in v4l2_ctrl_new()
2728 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
2732 mutex_lock(hdl->lock); in v4l2_ctrl_new()
2733 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2734 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
2738 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
2766 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
2770 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2782 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
2794 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
2797 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
2804 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
2827 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
2830 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
2837 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
2853 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2859 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2862 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
2870 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
2881 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
2884 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
2891 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
2905 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
2908 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
2915 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
2924 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
2926 if (hdl->error) in v4l2_ctrl_add_handler()
2927 return hdl->error; in v4l2_ctrl_add_handler()
2941 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
3087 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
3094 if (hdl == NULL) in v4l2_ctrl_handler_log_status()
3101 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
3102 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
3105 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
3117 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
3122 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
3125 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
3127 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
3130 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
3156 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
3160 if (hdl == NULL) in v4l2_ctrl_handler_setup()
3163 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
3164 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
3165 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
3172 int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctrl *qc) in v4l2_query_ext_ctrl() argument
3179 if (hdl == NULL) in v4l2_query_ext_ctrl()
3182 mutex_lock(hdl->lock); in v4l2_query_ext_ctrl()
3185 ref = find_ref(hdl, id); in v4l2_query_ext_ctrl()
3187 if ((qc->id & next_flags) && !list_empty(&hdl->ctrl_refs)) { in v4l2_query_ext_ctrl()
3204 if (id >= node2id(hdl->ctrl_refs.prev)) { in v4l2_query_ext_ctrl()
3209 list_for_each_entry_continue(ref, &hdl->ctrl_refs, node) { in v4l2_query_ext_ctrl()
3216 if (&ref->node == &hdl->ctrl_refs) in v4l2_query_ext_ctrl()
3223 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_query_ext_ctrl()
3230 if (&ref->node == &hdl->ctrl_refs) in v4l2_query_ext_ctrl()
3234 mutex_unlock(hdl->lock); in v4l2_query_ext_ctrl()
3265 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc) in v4l2_queryctrl() argument
3270 rc = v4l2_query_ext_ctrl(hdl, &qec); in v4l2_queryctrl()
3302 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm) in v4l2_querymenu() argument
3307 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
3344 static int v4l2_ctrl_request_clone(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_request_clone() argument
3350 if (WARN_ON(!hdl || hdl == from)) in v4l2_ctrl_request_clone()
3353 if (hdl->error) in v4l2_ctrl_request_clone()
3354 return hdl->error; in v4l2_ctrl_request_clone()
3356 WARN_ON(hdl->lock != &hdl->_lock); in v4l2_ctrl_request_clone()
3369 err = handler_new_ref(hdl, ctrl, &new_ref, false, true); in v4l2_ctrl_request_clone()
3379 struct v4l2_ctrl_handler *hdl = in v4l2_ctrl_request_queue() local
3392 * Note: prev_hdl and hdl must contain the same list of control in v4l2_ctrl_request_queue()
3399 list_for_each_entry(ref_ctrl, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_queue()
3415 list_add_tail(&hdl->requests_queued, &main_hdl->requests_queued); in v4l2_ctrl_request_queue()
3416 hdl->request_is_queued = true; in v4l2_ctrl_request_queue()
3422 struct v4l2_ctrl_handler *hdl = in v4l2_ctrl_request_unbind() local
3426 list_del_init(&hdl->requests); in v4l2_ctrl_request_unbind()
3428 if (hdl->request_is_queued) { in v4l2_ctrl_request_unbind()
3429 list_del_init(&hdl->requests_queued); in v4l2_ctrl_request_unbind()
3430 hdl->request_is_queued = false; in v4l2_ctrl_request_unbind()
3437 struct v4l2_ctrl_handler *hdl = in v4l2_ctrl_request_release() local
3440 v4l2_ctrl_handler_free(hdl); in v4l2_ctrl_request_release()
3441 kfree(hdl); in v4l2_ctrl_request_release()
3467 v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_request_hdl_ctrl_find() argument
3469 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_request_hdl_ctrl_find()
3476 struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_request_bind() argument
3481 ret = v4l2_ctrl_request_clone(hdl, from); in v4l2_ctrl_request_bind()
3485 from, false, &hdl->req_obj); in v4l2_ctrl_request_bind()
3487 list_add_tail(&hdl->requests, &from->requests); in v4l2_ctrl_request_bind()
3533 static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, in prepare_ext_ctrls() argument
3568 ref = find_ref_lock(hdl, id); in prepare_ext_ctrls()
3583 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
3620 mutex_lock(hdl->lock); in prepare_ext_ctrls()
3642 mutex_unlock(hdl->lock); in prepare_ext_ctrls()
3649 static int class_check(struct v4l2_ctrl_handler *hdl, u32 which) in class_check() argument
3654 return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; in class_check()
3658 static int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl, in v4l2_g_ext_ctrls_common() argument
3673 if (hdl == NULL) in v4l2_g_ext_ctrls_common()
3677 return class_check(hdl, cs->which); in v4l2_g_ext_ctrls_common()
3686 ret = prepare_ext_ctrls(hdl, cs, helpers, vdev, true); in v4l2_g_ext_ctrls_common()
3742 v4l2_ctrls_find_req_obj(struct v4l2_ctrl_handler *hdl, in v4l2_ctrls_find_req_obj() argument
3755 obj = media_request_object_find(req, &req_ops, hdl); in v4l2_ctrls_find_req_obj()
3766 ret = v4l2_ctrl_handler_init(new_hdl, (hdl->nr_of_buckets - 1) * 8); in v4l2_ctrls_find_req_obj()
3768 ret = v4l2_ctrl_request_bind(req, new_hdl, hdl); in v4l2_ctrls_find_req_obj()
3779 int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev, in v4l2_g_ext_ctrls() argument
3805 obj = v4l2_ctrls_find_req_obj(hdl, req, false); in v4l2_g_ext_ctrls()
3812 hdl = container_of(obj, struct v4l2_ctrl_handler, in v4l2_g_ext_ctrls()
3816 ret = v4l2_g_ext_ctrls_common(hdl, cs, vdev); in v4l2_g_ext_ctrls()
3858 int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *control) in v4l2_g_ctrl() argument
3860 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl()
4026 struct v4l2_ctrl_handler *hdl, in try_set_ext_ctrls_common() argument
4046 if (hdl == NULL) { in try_set_ext_ctrls_common()
4053 return class_check(hdl, cs->which); in try_set_ext_ctrls_common()
4061 ret = prepare_ext_ctrls(hdl, cs, helpers, vdev, false); in try_set_ext_ctrls_common()
4120 !hdl->req_obj.req && set, 0); in try_set_ext_ctrls_common()
4121 if (!ret && hdl->req_obj.req && set) { in try_set_ext_ctrls_common()
4124 find_ref(hdl, master->cluster[j]->id); in try_set_ext_ctrls_common()
4148 struct v4l2_ctrl_handler *hdl, in try_set_ext_ctrls() argument
4185 obj = v4l2_ctrls_find_req_obj(hdl, req, set); in try_set_ext_ctrls()
4195 hdl = container_of(obj, struct v4l2_ctrl_handler, in try_set_ext_ctrls()
4199 ret = try_set_ext_ctrls_common(fh, hdl, cs, vdev, set); in try_set_ext_ctrls()
4214 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, in v4l2_try_ext_ctrls() argument
4219 return try_set_ext_ctrls(NULL, hdl, vdev, mdev, cs, false); in v4l2_try_ext_ctrls()
4224 struct v4l2_ctrl_handler *hdl, in v4l2_s_ext_ctrls() argument
4229 return try_set_ext_ctrls(fh, hdl, vdev, mdev, cs, true); in v4l2_s_ext_ctrls()
4275 int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, in v4l2_s_ctrl() argument
4278 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl()
4348 struct v4l2_ctrl_handler *hdl; in v4l2_ctrl_request_complete() local
4362 hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj); in v4l2_ctrl_request_complete()
4364 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_complete()
4400 WARN_ON(!hdl->request_is_queued); in v4l2_ctrl_request_complete()
4401 list_del_init(&hdl->requests_queued); in v4l2_ctrl_request_complete()
4402 hdl->request_is_queued = false; in v4l2_ctrl_request_complete()
4413 struct v4l2_ctrl_handler *hdl; in v4l2_ctrl_request_setup() local
4435 hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj); in v4l2_ctrl_request_setup()
4437 list_for_each_entry(ref, &hdl->ctrl_refs, node) in v4l2_ctrl_request_setup()
4440 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_setup()
4458 find_ref(hdl, master->cluster[i]->id); in v4l2_ctrl_request_setup()
4474 find_ref(hdl, master->cluster[i]->id); in v4l2_ctrl_request_setup()
4687 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
4707 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
4711 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
4715 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
4719 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
4722 return hdl->error; in v4l2_ctrl_new_fwnode_properties()