Lines Matching refs:hdl

1528 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err)  in handler_set_err()  argument
1530 if (hdl->error == 0) in handler_set_err()
1531 hdl->error = err; in handler_set_err()
1536 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
1540 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
1541 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
1542 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
1543 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
1544 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
1545 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
1546 hdl->buckets = kvcalloc(hdl->nr_of_buckets, sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
1548 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
1549 v4l2_ctrl_handler_init_request(hdl); in v4l2_ctrl_handler_init_class()
1550 return hdl->error; in v4l2_ctrl_handler_init_class()
1555 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
1561 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
1564 v4l2_ctrl_handler_free_request(hdl); in v4l2_ctrl_handler_free()
1566 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
1568 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
1575 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1582 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
1583 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
1584 hdl->cached = NULL; in v4l2_ctrl_handler_free()
1585 hdl->error = 0; in v4l2_ctrl_handler_free()
1586 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
1587 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
1598 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
1603 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
1619 struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
1628 return find_private_ref(hdl, id); in find_ref()
1629 bucket = id % hdl->nr_of_buckets; in find_ref()
1632 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1633 return hdl->cached; in find_ref()
1636 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
1641 hdl->cached = ref; /* cache it! */ in find_ref()
1646 struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
1650 if (hdl) { in find_ref_lock()
1651 mutex_lock(hdl->lock); in find_ref_lock()
1652 ref = find_ref(hdl, id); in find_ref_lock()
1653 mutex_unlock(hdl->lock); in find_ref_lock()
1659 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
1661 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
1668 int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
1677 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
1688 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
1689 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
1690 return hdl->error; in handler_new_ref()
1692 if (hdl->error) in handler_new_ref()
1693 return hdl->error; in handler_new_ref()
1699 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
1707 mutex_lock(hdl->lock); in handler_new_ref()
1713 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
1714 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
1719 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
1733 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
1734 hdl->buckets[bucket] = new_ref; in handler_new_ref()
1737 if (ctrl->handler == hdl) { in handler_new_ref()
1748 mutex_unlock(hdl->lock); in handler_new_ref()
1753 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
1772 if (hdl->error) in v4l2_ctrl_new()
1886 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
1891 handler_set_err(hdl, err); in v4l2_ctrl_new()
1897 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1908 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1933 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
1939 ctrl->handler = hdl; in v4l2_ctrl_new()
1998 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
2003 mutex_lock(hdl->lock); in v4l2_ctrl_new()
2004 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2005 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
2009 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
2037 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
2041 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2053 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
2065 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
2068 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
2075 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
2098 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
2101 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
2108 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
2124 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2130 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2133 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
2141 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
2152 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
2155 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
2162 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
2176 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
2179 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
2186 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
2195 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
2197 if (hdl->error) in v4l2_ctrl_add_handler()
2198 return hdl->error; in v4l2_ctrl_add_handler()
2212 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
2455 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
2460 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
2463 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
2465 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
2468 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
2494 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
2498 if (hdl == NULL) in v4l2_ctrl_handler_setup()
2501 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
2502 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
2503 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
2536 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
2543 if (!hdl) in v4l2_ctrl_handler_log_status()
2550 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
2551 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2554 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
2558 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
2562 if (hdl->error) in v4l2_ctrl_new_fwnode_properties()
2563 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2581 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2585 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2589 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2593 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2596 return hdl->error; in v4l2_ctrl_new_fwnode_properties()