Lines Matching refs:hdl

933 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err)  in handler_set_err()  argument
935 if (hdl->error == 0) in handler_set_err()
936 hdl->error = err; in handler_set_err()
941 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
945 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
946 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
947 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
948 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
949 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
950 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
951 hdl->buckets = kvmalloc_array(hdl->nr_of_buckets, in v4l2_ctrl_handler_init_class()
952 sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
954 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
955 v4l2_ctrl_handler_init_request(hdl); in v4l2_ctrl_handler_init_class()
956 return hdl->error; in v4l2_ctrl_handler_init_class()
961 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
967 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
970 v4l2_ctrl_handler_free_request(hdl); in v4l2_ctrl_handler_free()
972 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
974 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
979 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
985 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
986 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
987 hdl->cached = NULL; in v4l2_ctrl_handler_free()
988 hdl->error = 0; in v4l2_ctrl_handler_free()
989 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
990 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
1001 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
1006 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
1022 struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
1031 return find_private_ref(hdl, id); in find_ref()
1032 bucket = id % hdl->nr_of_buckets; in find_ref()
1035 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1036 return hdl->cached; in find_ref()
1039 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
1044 hdl->cached = ref; /* cache it! */ in find_ref()
1049 struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
1053 if (hdl) { in find_ref_lock()
1054 mutex_lock(hdl->lock); in find_ref_lock()
1055 ref = find_ref(hdl, id); in find_ref_lock()
1056 mutex_unlock(hdl->lock); in find_ref_lock()
1062 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
1064 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
1071 int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
1080 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
1091 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
1092 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
1093 return hdl->error; in handler_new_ref()
1095 if (hdl->error) in handler_new_ref()
1096 return hdl->error; in handler_new_ref()
1102 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
1110 mutex_lock(hdl->lock); in handler_new_ref()
1116 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
1117 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
1122 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
1136 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
1137 hdl->buckets[bucket] = new_ref; in handler_new_ref()
1140 if (ctrl->handler == hdl) { in handler_new_ref()
1151 mutex_unlock(hdl->lock); in handler_new_ref()
1156 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
1176 if (hdl->error) in v4l2_ctrl_new()
1273 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
1278 handler_set_err(hdl, err); in v4l2_ctrl_new()
1284 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1305 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
1311 ctrl->handler = hdl; in v4l2_ctrl_new()
1357 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
1361 mutex_lock(hdl->lock); in v4l2_ctrl_new()
1362 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
1363 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
1367 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
1395 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
1399 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
1411 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
1423 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
1426 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
1433 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
1456 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
1459 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
1466 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
1482 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1488 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1491 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
1499 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
1510 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
1513 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
1520 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
1534 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
1537 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
1544 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
1553 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
1555 if (hdl->error) in v4l2_ctrl_add_handler()
1556 return hdl->error; in v4l2_ctrl_add_handler()
1570 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
1812 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
1817 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
1820 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
1822 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
1825 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
1851 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
1855 if (hdl == NULL) in v4l2_ctrl_handler_setup()
1858 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
1859 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
1860 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
1893 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
1900 if (!hdl) in v4l2_ctrl_handler_log_status()
1907 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
1908 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
1911 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
1915 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
1935 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
1939 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
1943 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
1947 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
1950 return hdl->error; in v4l2_ctrl_new_fwnode_properties()