Lines Matching refs:ctrl

40 	struct v4l2_ctrl *ctrl;  member
1201 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1205 ev->id = ctrl->id; in fill_event()
1206 ev->u.ctrl.changes = changes; in fill_event()
1207 ev->u.ctrl.type = ctrl->type; in fill_event()
1208 ev->u.ctrl.flags = ctrl->flags; in fill_event()
1209 if (ctrl->is_ptr) in fill_event()
1210 ev->u.ctrl.value64 = 0; in fill_event()
1212 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1213 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1214 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1215 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1216 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1217 ev->u.ctrl.step = 1; in fill_event()
1219 ev->u.ctrl.step = ctrl->step; in fill_event()
1220 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1223 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1228 if (list_empty(&ctrl->ev_subs)) in send_event()
1230 fill_event(&ev, ctrl, changes); in send_event()
1232 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1238 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1242 switch (ctrl->type) { in std_equal()
1246 idx *= ctrl->elem_size; in std_equal()
1258 if (ctrl->is_int) in std_equal()
1260 idx *= ctrl->elem_size; in std_equal()
1261 return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); in std_equal()
1265 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1268 switch (ctrl->type) { in std_init()
1270 idx *= ctrl->elem_size; in std_init()
1271 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1272 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1275 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1282 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1285 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1288 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1291 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1294 idx *= ctrl->elem_size; in std_init()
1295 memset(ptr.p + idx, 0, ctrl->elem_size); in std_init()
1300 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1302 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1304 if (ctrl->is_array) { in std_log()
1307 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1308 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1312 switch (ctrl->type) { in std_log()
1320 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1323 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1344 pr_cont("unknown type %d", ctrl->type); in std_log()
1354 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1357 if ((ctrl)->maximum >= 0 && \
1358 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1359 val = (ctrl)->maximum; \
1361 val += (s32)((ctrl)->step / 2); \
1363 (ctrl)->minimum, (ctrl)->maximum); \
1364 offset = (val) - (ctrl)->minimum; \
1365 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1366 val = (ctrl)->minimum + offset; \
1371 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1378 switch (ctrl->type) { in std_validate()
1380 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1387 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1388 val = ctrl->maximum; in std_validate()
1390 val += (s64)(ctrl->step / 2); in std_validate()
1391 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1392 offset = val - ctrl->minimum; in std_validate()
1393 do_div(offset, ctrl->step); in std_validate()
1394 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1397 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1399 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1401 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1409 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1411 if (ctrl->menu_skip_mask & (1 << ptr.p_s32[idx])) in std_validate()
1413 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1414 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1419 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
1428 idx *= ctrl->elem_size; in std_validate()
1430 if (len < ctrl->minimum) in std_validate()
1432 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
1450 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
1455 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
1459 switch (ctrl->type) { in ptr_to_user()
1463 c->size = ctrl->elem_size; in ptr_to_user()
1480 struct v4l2_ctrl *ctrl) in cur_to_user() argument
1482 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
1487 struct v4l2_ctrl *ctrl) in new_to_user() argument
1489 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
1494 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
1500 ctrl->is_new = 1; in user_to_ptr()
1501 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
1505 if (ret || !ctrl->is_array) in user_to_ptr()
1507 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
1508 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
1512 switch (ctrl->type) { in user_to_ptr()
1520 if (size > ctrl->maximum + 1) in user_to_ptr()
1521 size = ctrl->maximum + 1; in user_to_ptr()
1529 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
1542 struct v4l2_ctrl *ctrl) in user_to_new() argument
1544 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
1548 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
1551 if (ctrl == NULL) in ptr_to_ptr()
1553 memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
1557 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
1561 if (ctrl == NULL) in new_to_cur()
1565 changed = ctrl->has_changed; in new_to_cur()
1567 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
1571 ctrl->flags &= in new_to_cur()
1573 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
1574 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
1575 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
1576 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
1583 if (!ctrl->is_new) in new_to_cur()
1585 send_event(fh, ctrl, in new_to_cur()
1587 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
1588 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
1593 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
1595 if (ctrl == NULL) in cur_to_new()
1597 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
1609 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
1612 if (ctrl == NULL) in cluster_changed()
1615 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
1622 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
1623 ctrl->has_changed = false; in cluster_changed()
1627 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
1628 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
1629 ctrl->p_cur, ctrl->p_new); in cluster_changed()
1630 ctrl->has_changed = ctrl_changed; in cluster_changed()
1631 changed |= ctrl->has_changed; in cluster_changed()
1676 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
1681 if (!ctrl->is_ptr) { in validate_new()
1682 switch (ctrl->type) { in validate_new()
1691 return ctrl->type_ops->validate(ctrl, 0, p_new); in validate_new()
1696 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
1697 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
1703 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
1736 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
1749 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1750 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
1751 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
1753 kfree(ctrl); in v4l2_ctrl_handler_free()
1778 if (V4L2_CTRL_ID2CLASS(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
1779 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
1780 if (!ref->ctrl->is_int) in find_private_ref()
1804 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1809 while (ref && ref->ctrl->id != id) in find_ref()
1836 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
1842 struct v4l2_ctrl *ctrl) in handler_new_ref() argument
1846 u32 id = ctrl->id; in handler_new_ref()
1854 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
1865 new_ref->ctrl = ctrl; in handler_new_ref()
1866 if (ctrl->handler == hdl) { in handler_new_ref()
1871 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
1872 ctrl->ncontrols = 1; in handler_new_ref()
1890 if (ref->ctrl->id < id) in handler_new_ref()
1893 if (ref->ctrl->id == id) { in handler_new_ref()
1921 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
2002 ctrl = kzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
2003 if (ctrl == NULL) { in v4l2_ctrl_new()
2008 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2009 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2010 ctrl->handler = hdl; in v4l2_ctrl_new()
2011 ctrl->ops = ops; in v4l2_ctrl_new()
2012 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2013 ctrl->id = id; in v4l2_ctrl_new()
2014 ctrl->name = name; in v4l2_ctrl_new()
2015 ctrl->type = type; in v4l2_ctrl_new()
2016 ctrl->flags = flags; in v4l2_ctrl_new()
2017 ctrl->minimum = min; in v4l2_ctrl_new()
2018 ctrl->maximum = max; in v4l2_ctrl_new()
2019 ctrl->step = step; in v4l2_ctrl_new()
2020 ctrl->default_value = def; in v4l2_ctrl_new()
2021 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2022 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2023 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2024 ctrl->is_array = is_array; in v4l2_ctrl_new()
2025 ctrl->elems = elems; in v4l2_ctrl_new()
2026 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2028 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2029 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2031 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2033 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2034 ctrl->priv = priv; in v4l2_ctrl_new()
2035 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2036 data = &ctrl[1]; in v4l2_ctrl_new()
2038 if (!ctrl->is_int) { in v4l2_ctrl_new()
2039 ctrl->p_new.p = data; in v4l2_ctrl_new()
2040 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2042 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2043 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2046 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2047 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2050 if (handler_new_ref(hdl, ctrl)) { in v4l2_ctrl_new()
2051 kfree(ctrl); in v4l2_ctrl_new()
2055 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2057 return ctrl; in v4l2_ctrl_new()
2064 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2093 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2098 if (ctrl) in v4l2_ctrl_new_custom()
2099 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2100 return ctrl; in v4l2_ctrl_new_custom()
2218 struct v4l2_ctrl *ctrl) in v4l2_ctrl_add_ctrl() argument
2222 if (ctrl == NULL) { in v4l2_ctrl_add_ctrl()
2226 if (ctrl->handler == hdl) in v4l2_ctrl_add_ctrl()
2227 return ctrl; in v4l2_ctrl_add_ctrl()
2228 return handler_new_ref(hdl, ctrl) ? NULL : ctrl; in v4l2_ctrl_add_ctrl()
2235 bool (*filter)(const struct v4l2_ctrl *ctrl)) in v4l2_ctrl_add_handler() argument
2247 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2250 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2253 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2256 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2258 ret = handler_new_ref(hdl, ctrl); in v4l2_ctrl_add_handler()
2267 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2269 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2271 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2273 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2337 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
2343 if (ctrl == NULL) in v4l2_ctrl_activate()
2348 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2351 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2353 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
2363 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in v4l2_ctrl_grab() argument
2367 if (ctrl == NULL) in v4l2_ctrl_grab()
2370 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_grab()
2373 old = test_and_set_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2376 old = test_and_clear_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2378 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_grab()
2379 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_grab()
2384 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
2387 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
2389 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
2392 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
2394 ctrl->type_ops->log(ctrl); in log_ctrl()
2396 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
2399 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
2401 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
2403 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
2413 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
2425 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2426 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
2427 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
2442 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_setup() local
2448 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_setup()
2449 ctrl->done = false; in v4l2_ctrl_handler_setup()
2451 list_for_each_entry(ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_setup()
2452 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_handler_setup()
2457 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_handler_setup()
2458 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_handler_setup()
2483 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
2517 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2518 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2531 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2532 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2545 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
2550 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
2551 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
2552 qc->flags = ctrl->flags; in v4l2_query_ext_ctrl()
2553 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
2554 if (ctrl->is_ptr) in v4l2_query_ext_ctrl()
2556 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
2557 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
2558 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
2559 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
2560 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
2561 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
2562 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
2563 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
2564 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
2567 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
2620 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
2623 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
2624 if (!ctrl) in v4l2_querymenu()
2629 switch (ctrl->type) { in v4l2_querymenu()
2631 if (ctrl->qmenu == NULL) in v4l2_querymenu()
2635 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
2642 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
2646 if (ctrl->menu_skip_mask & (1 << i)) in v4l2_querymenu()
2649 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
2650 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
2652 strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
2654 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
2721 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
2736 ctrl = ref->ctrl; in prepare_ext_ctrls()
2737 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) in prepare_ext_ctrls()
2740 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
2742 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
2743 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
2744 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
2745 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
2758 h->ctrl = ctrl; in prepare_ext_ctrls()
2840 if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls()
2845 struct v4l2_ctrl *ctrl) = cur_to_user; in v4l2_g_ext_ctrls()
2851 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls()
2872 helpers[idx].ctrl); in v4l2_g_ext_ctrls()
2892 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
2894 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
2902 if (!ctrl->is_int) in get_ctrl()
2905 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
2910 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
2914 new_to_user(c, ctrl); in get_ctrl()
2916 cur_to_user(c, ctrl); in get_ctrl()
2924 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
2928 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
2930 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
2942 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
2947 WARN_ON(!ctrl->is_int); in v4l2_ctrl_g_ctrl()
2949 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
2954 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
2959 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in v4l2_ctrl_g_ctrl_int64()
2961 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
2982 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
2984 if (ctrl == NULL) in try_or_set_cluster()
2987 if (!ctrl->is_new) { in try_or_set_cluster()
2988 cur_to_new(ctrl); in try_or_set_cluster()
2993 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3023 struct v4l2_ctrl *ctrl = helpers[i].ctrl; in validate_ctrls() local
3028 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in validate_ctrls()
3036 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in validate_ctrls()
3042 if (ctrl->is_ptr) in validate_ctrls()
3044 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
3048 ret = validate_new(ctrl, p_new); in validate_ctrls()
3107 master = helpers[i].mref->ctrl; in try_set_ext_ctrls()
3130 if (helpers[tmp_idx].ctrl == master) in try_set_ext_ctrls()
3143 struct v4l2_ctrl *ctrl = helpers[idx].ctrl; in try_set_ext_ctrls() local
3145 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls()
3146 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls()
3147 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls()
3159 helpers[idx].ctrl); in try_set_ext_ctrls()
3197 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
3199 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
3208 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
3215 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
3216 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
3219 ctrl->is_new = 1; in set_ctrl()
3224 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
3229 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
3230 user_to_new(c, ctrl); in set_ctrl_lock()
3231 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
3233 cur_to_user(c, ctrl); in set_ctrl_lock()
3234 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
3241 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
3245 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
3248 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
3252 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
3264 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
3266 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
3269 WARN_ON(!ctrl->is_int); in __v4l2_ctrl_s_ctrl()
3270 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
3271 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
3275 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
3277 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
3280 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in __v4l2_ctrl_s_ctrl_int64()
3281 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
3282 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
3286 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
3288 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
3291 WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); in __v4l2_ctrl_s_ctrl_string()
3292 strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
3293 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
3297 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
3299 if (ctrl == NULL) in v4l2_ctrl_notify()
3302 ctrl->call_notify = 0; in v4l2_ctrl_notify()
3305 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
3307 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
3308 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
3309 ctrl->call_notify = 1; in v4l2_ctrl_notify()
3313 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
3319 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
3321 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
3331 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
3333 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
3340 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
3341 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
3342 ctrl->step = step; in __v4l2_ctrl_modify_range()
3343 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
3344 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
3345 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
3346 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3347 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
3349 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
3352 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3353 changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
3355 changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
3357 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3359 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3366 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
3368 if (ctrl == NULL) in v4l2_ctrl_add_event()
3371 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
3372 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
3373 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
3378 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
3380 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
3386 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
3392 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
3394 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
3396 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
3401 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
3403 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
3404 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
3410 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()