Lines Matching full:hdl
1524 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err) in handler_set_err() argument
1526 if (hdl->error == 0) in handler_set_err()
1527 hdl->error = err; in handler_set_err()
1532 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
1536 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
1537 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
1538 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
1539 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
1540 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
1541 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
1542 hdl->buckets = kvcalloc(hdl->nr_of_buckets, sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
1544 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
1545 v4l2_ctrl_handler_init_request(hdl); in v4l2_ctrl_handler_init_class()
1546 return hdl->error; in v4l2_ctrl_handler_init_class()
1551 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
1557 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
1560 v4l2_ctrl_handler_free_request(hdl); in v4l2_ctrl_handler_free()
1562 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
1564 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
1571 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1578 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
1579 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
1580 hdl->cached = NULL; in v4l2_ctrl_handler_free()
1581 hdl->error = 0; in v4l2_ctrl_handler_free()
1582 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
1583 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
1594 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
1599 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
1615 struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
1624 return find_private_ref(hdl, id); in find_ref()
1625 bucket = id % hdl->nr_of_buckets; in find_ref()
1628 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1629 return hdl->cached; in find_ref()
1632 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
1637 hdl->cached = ref; /* cache it! */ in find_ref()
1642 struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
1646 if (hdl) { in find_ref_lock()
1647 mutex_lock(hdl->lock); in find_ref_lock()
1648 ref = find_ref(hdl, id); in find_ref_lock()
1649 mutex_unlock(hdl->lock); in find_ref_lock()
1655 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
1657 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
1664 int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
1673 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
1684 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
1685 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
1686 return hdl->error; in handler_new_ref()
1688 if (hdl->error) in handler_new_ref()
1689 return hdl->error; in handler_new_ref()
1695 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
1703 mutex_lock(hdl->lock); in handler_new_ref()
1709 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
1710 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
1715 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
1729 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
1730 hdl->buckets[bucket] = new_ref; in handler_new_ref()
1733 if (ctrl->handler == hdl) { in handler_new_ref()
1744 mutex_unlock(hdl->lock); in handler_new_ref()
1749 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
1768 if (hdl->error) in v4l2_ctrl_new()
1882 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
1887 handler_set_err(hdl, err); in v4l2_ctrl_new()
1893 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1904 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1929 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
1935 ctrl->handler = hdl; in v4l2_ctrl_new()
1994 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
1999 mutex_lock(hdl->lock); in v4l2_ctrl_new()
2000 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2001 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
2005 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
2033 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
2037 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2049 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
2061 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
2064 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
2071 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
2094 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
2097 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
2104 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
2120 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2126 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2129 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
2137 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
2148 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
2151 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
2158 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
2172 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
2175 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
2182 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
2191 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
2193 if (hdl->error) in v4l2_ctrl_add_handler()
2194 return hdl->error; in v4l2_ctrl_add_handler()
2208 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
2451 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
2456 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
2459 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
2461 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
2464 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
2490 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
2494 if (hdl == NULL) in v4l2_ctrl_handler_setup()
2497 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
2498 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
2499 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
2532 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
2539 if (!hdl) in v4l2_ctrl_handler_log_status()
2546 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
2547 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2550 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
2554 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
2574 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2578 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2582 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2586 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2589 return hdl->error; in v4l2_ctrl_new_fwnode_properties()