Lines Matching full:hdl
930 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err) in handler_set_err() argument
932 if (hdl->error == 0) in handler_set_err()
933 hdl->error = err; in handler_set_err()
938 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
942 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
943 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
944 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
945 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
946 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
947 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
948 hdl->buckets = kvmalloc_array(hdl->nr_of_buckets, in v4l2_ctrl_handler_init_class()
949 sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
951 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
952 v4l2_ctrl_handler_init_request(hdl); in v4l2_ctrl_handler_init_class()
953 return hdl->error; in v4l2_ctrl_handler_init_class()
958 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
964 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
967 v4l2_ctrl_handler_free_request(hdl); in v4l2_ctrl_handler_free()
969 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
971 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
976 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
982 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
983 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
984 hdl->cached = NULL; in v4l2_ctrl_handler_free()
985 hdl->error = 0; in v4l2_ctrl_handler_free()
986 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
987 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
998 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
1003 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
1019 struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
1028 return find_private_ref(hdl, id); in find_ref()
1029 bucket = id % hdl->nr_of_buckets; in find_ref()
1032 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1033 return hdl->cached; in find_ref()
1036 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
1041 hdl->cached = ref; /* cache it! */ in find_ref()
1046 struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
1050 if (hdl) { in find_ref_lock()
1051 mutex_lock(hdl->lock); in find_ref_lock()
1052 ref = find_ref(hdl, id); in find_ref_lock()
1053 mutex_unlock(hdl->lock); in find_ref_lock()
1059 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
1061 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
1068 int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
1077 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
1088 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
1089 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
1090 return hdl->error; in handler_new_ref()
1092 if (hdl->error) in handler_new_ref()
1093 return hdl->error; in handler_new_ref()
1099 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
1107 mutex_lock(hdl->lock); in handler_new_ref()
1113 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
1114 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
1119 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
1133 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
1134 hdl->buckets[bucket] = new_ref; in handler_new_ref()
1137 if (ctrl->handler == hdl) { in handler_new_ref()
1148 mutex_unlock(hdl->lock); in handler_new_ref()
1153 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
1173 if (hdl->error) in v4l2_ctrl_new()
1267 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
1272 handler_set_err(hdl, err); in v4l2_ctrl_new()
1278 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1299 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
1305 ctrl->handler = hdl; in v4l2_ctrl_new()
1351 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
1355 mutex_lock(hdl->lock); in v4l2_ctrl_new()
1356 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
1357 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
1361 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
1389 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
1393 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
1405 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
1417 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
1420 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
1427 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
1450 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
1453 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
1460 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
1476 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1482 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1485 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
1493 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
1504 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
1507 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
1514 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
1528 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
1531 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
1538 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
1547 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
1549 if (hdl->error) in v4l2_ctrl_add_handler()
1550 return hdl->error; in v4l2_ctrl_add_handler()
1564 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
1806 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
1811 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
1814 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
1816 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
1819 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
1845 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
1849 if (hdl == NULL) in v4l2_ctrl_handler_setup()
1852 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
1853 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
1854 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
1887 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
1894 if (!hdl) in v4l2_ctrl_handler_log_status()
1901 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
1902 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
1905 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
1909 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
1929 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
1933 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
1937 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
1941 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
1944 return hdl->error; in v4l2_ctrl_new_fwnode_properties()