Lines Matching refs:hdl
1273 static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err) in handler_set_err() argument
1275 if (hdl->error == 0) in handler_set_err()
1276 hdl->error = err; in handler_set_err()
1281 int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_init_class() argument
1285 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
1286 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
1287 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
1288 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
1289 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
1290 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
1291 hdl->buckets = kvcalloc(hdl->nr_of_buckets, sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
1293 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
1294 v4l2_ctrl_handler_init_request(hdl); in v4l2_ctrl_handler_init_class()
1295 return hdl->error; in v4l2_ctrl_handler_init_class()
1300 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_free() argument
1306 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
1309 v4l2_ctrl_handler_free_request(hdl); in v4l2_ctrl_handler_free()
1311 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
1313 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
1320 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1327 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
1328 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
1329 hdl->cached = NULL; in v4l2_ctrl_handler_free()
1330 hdl->error = 0; in v4l2_ctrl_handler_free()
1331 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
1332 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
1343 struct v4l2_ctrl_handler *hdl, u32 id) in find_private_ref() argument
1348 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
1364 struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref() argument
1373 return find_private_ref(hdl, id); in find_ref()
1374 bucket = id % hdl->nr_of_buckets; in find_ref()
1377 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1378 return hdl->cached; in find_ref()
1381 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
1386 hdl->cached = ref; /* cache it! */ in find_ref()
1391 struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id) in find_ref_lock() argument
1395 if (hdl) { in find_ref_lock()
1396 mutex_lock(hdl->lock); in find_ref_lock()
1397 ref = find_ref(hdl, id); in find_ref_lock()
1398 mutex_unlock(hdl->lock); in find_ref_lock()
1404 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id) in v4l2_ctrl_find() argument
1406 struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id); in v4l2_ctrl_find()
1413 int handler_new_ref(struct v4l2_ctrl_handler *hdl, in handler_new_ref() argument
1422 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
1433 id != class_ctrl && find_ref_lock(hdl, class_ctrl) == NULL) in handler_new_ref()
1434 if (!v4l2_ctrl_new_std(hdl, NULL, class_ctrl, 0, 0, 0, 0)) in handler_new_ref()
1435 return hdl->error; in handler_new_ref()
1437 if (hdl->error) in handler_new_ref()
1438 return hdl->error; in handler_new_ref()
1444 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
1452 mutex_lock(hdl->lock); in handler_new_ref()
1458 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
1459 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
1464 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
1478 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
1479 hdl->buckets[bucket] = new_ref; in handler_new_ref()
1482 if (ctrl->handler == hdl) { in handler_new_ref()
1493 mutex_unlock(hdl->lock); in handler_new_ref()
1498 static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new() argument
1517 if (hdl->error) in v4l2_ctrl_new()
1619 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
1624 handler_set_err(hdl, err); in v4l2_ctrl_new()
1630 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1641 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
1666 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
1672 ctrl->handler = hdl; in v4l2_ctrl_new()
1731 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
1736 mutex_lock(hdl->lock); in v4l2_ctrl_new()
1737 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
1738 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
1742 struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_custom() argument
1770 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
1774 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
1786 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std() argument
1798 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
1801 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std()
1808 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu() argument
1831 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
1834 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu()
1841 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_menu_items() argument
1857 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1863 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
1866 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_menu_items()
1874 struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_std_compound() argument
1885 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
1888 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_std_compound()
1895 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_int_menu() argument
1909 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
1912 return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, in v4l2_ctrl_new_int_menu()
1919 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_add_handler() argument
1928 if (!hdl || !add || hdl == add) in v4l2_ctrl_add_handler()
1930 if (hdl->error) in v4l2_ctrl_add_handler()
1931 return hdl->error; in v4l2_ctrl_add_handler()
1945 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
2188 int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in __v4l2_ctrl_handler_setup() argument
2193 if (hdl == NULL) in __v4l2_ctrl_handler_setup()
2196 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
2198 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
2201 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
2227 int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) in v4l2_ctrl_handler_setup() argument
2231 if (hdl == NULL) in v4l2_ctrl_handler_setup()
2234 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
2235 ret = __v4l2_ctrl_handler_setup(hdl); in v4l2_ctrl_handler_setup()
2236 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
2269 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_handler_log_status() argument
2276 if (!hdl) in v4l2_ctrl_handler_log_status()
2283 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
2284 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2287 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
2291 int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, in v4l2_ctrl_new_fwnode_properties() argument
2311 if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2315 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2319 if (!v4l2_ctrl_new_std(hdl, ctrl_ops, in v4l2_ctrl_new_fwnode_properties()
2323 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
2326 return hdl->error; in v4l2_ctrl_new_fwnode_properties()