Lines Matching refs:ctrl
41 struct v4l2_ctrl *ctrl; member
1370 static u32 user_flags(const struct v4l2_ctrl *ctrl) in user_flags() argument
1372 u32 flags = ctrl->flags; in user_flags()
1374 if (ctrl->is_ptr) in user_flags()
1380 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1384 ev->id = ctrl->id; in fill_event()
1385 ev->u.ctrl.changes = changes; in fill_event()
1386 ev->u.ctrl.type = ctrl->type; in fill_event()
1387 ev->u.ctrl.flags = user_flags(ctrl); in fill_event()
1388 if (ctrl->is_ptr) in fill_event()
1389 ev->u.ctrl.value64 = 0; in fill_event()
1391 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1392 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1393 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1394 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1395 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1396 ev->u.ctrl.step = 1; in fill_event()
1398 ev->u.ctrl.step = ctrl->step; in fill_event()
1399 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1402 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1407 if (list_empty(&ctrl->ev_subs)) in send_event()
1409 fill_event(&ev, ctrl, changes); in send_event()
1411 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1417 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1421 switch (ctrl->type) { in std_equal()
1425 idx *= ctrl->elem_size; in std_equal()
1437 if (ctrl->is_int) in std_equal()
1439 idx *= ctrl->elem_size; in std_equal()
1440 return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); in std_equal()
1444 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1447 switch (ctrl->type) { in std_init()
1449 idx *= ctrl->elem_size; in std_init()
1450 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1451 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1454 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1461 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1464 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1467 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1470 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1473 idx *= ctrl->elem_size; in std_init()
1474 memset(ptr.p + idx, 0, ctrl->elem_size); in std_init()
1479 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1481 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1483 if (ctrl->is_array) { in std_log()
1486 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1487 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1491 switch (ctrl->type) { in std_log()
1499 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1502 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1523 pr_cont("unknown type %d", ctrl->type); in std_log()
1533 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1536 if ((ctrl)->maximum >= 0 && \
1537 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1538 val = (ctrl)->maximum; \
1540 val += (s32)((ctrl)->step / 2); \
1542 (ctrl)->minimum, (ctrl)->maximum); \
1543 offset = (val) - (ctrl)->minimum; \
1544 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1545 val = (ctrl)->minimum + offset; \
1550 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1557 switch (ctrl->type) { in std_validate()
1559 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1566 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1567 val = ctrl->maximum; in std_validate()
1569 val += (s64)(ctrl->step / 2); in std_validate()
1570 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1571 offset = val - ctrl->minimum; in std_validate()
1572 do_div(offset, ctrl->step); in std_validate()
1573 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1576 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1578 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1580 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1588 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1590 if (ctrl->menu_skip_mask & (1 << ptr.p_s32[idx])) in std_validate()
1592 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1593 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1598 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
1607 idx *= ctrl->elem_size; in std_validate()
1609 if (len < ctrl->minimum) in std_validate()
1611 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
1629 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
1634 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
1638 switch (ctrl->type) { in ptr_to_user()
1642 c->size = ctrl->elem_size; in ptr_to_user()
1659 struct v4l2_ctrl *ctrl) in cur_to_user() argument
1661 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
1666 struct v4l2_ctrl *ctrl) in new_to_user() argument
1668 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
1672 static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) in def_to_user() argument
1676 for (idx = 0; idx < ctrl->elems; idx++) in def_to_user()
1677 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in def_to_user()
1679 return ptr_to_user(c, ctrl, ctrl->p_new); in def_to_user()
1684 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
1690 ctrl->is_new = 1; in user_to_ptr()
1691 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
1695 if (ret || !ctrl->is_array) in user_to_ptr()
1697 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
1698 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
1702 switch (ctrl->type) { in user_to_ptr()
1710 if (size > ctrl->maximum + 1) in user_to_ptr()
1711 size = ctrl->maximum + 1; in user_to_ptr()
1719 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
1732 struct v4l2_ctrl *ctrl) in user_to_new() argument
1734 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
1738 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
1741 if (ctrl == NULL) in ptr_to_ptr()
1743 memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
1747 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
1751 if (ctrl == NULL) in new_to_cur()
1755 changed = ctrl->has_changed; in new_to_cur()
1757 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
1761 ctrl->flags &= in new_to_cur()
1763 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
1764 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
1765 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
1766 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
1773 if (!ctrl->is_new) in new_to_cur()
1775 send_event(fh, ctrl, in new_to_cur()
1777 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
1778 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
1783 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
1785 if (ctrl == NULL) in cur_to_new()
1787 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
1799 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
1802 if (ctrl == NULL) in cluster_changed()
1805 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
1812 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
1813 ctrl->has_changed = false; in cluster_changed()
1817 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
1818 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
1819 ctrl->p_cur, ctrl->p_new); in cluster_changed()
1820 ctrl->has_changed = ctrl_changed; in cluster_changed()
1821 changed |= ctrl->has_changed; in cluster_changed()
1866 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
1871 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
1872 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
1878 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
1912 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
1925 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1926 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
1927 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
1929 kvfree(ctrl); in v4l2_ctrl_handler_free()
1955 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
1956 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
1957 if (!ref->ctrl->is_int) in find_private_ref()
1981 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1986 while (ref && ref->ctrl->id != id) in find_ref()
2013 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
2019 struct v4l2_ctrl *ctrl) in handler_new_ref() argument
2023 u32 id = ctrl->id; in handler_new_ref()
2031 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
2042 new_ref->ctrl = ctrl; in handler_new_ref()
2043 if (ctrl->handler == hdl) { in handler_new_ref()
2048 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
2049 ctrl->ncontrols = 1; in handler_new_ref()
2067 if (ref->ctrl->id < id) in handler_new_ref()
2070 if (ref->ctrl->id == id) { in handler_new_ref()
2098 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
2175 ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
2176 if (ctrl == NULL) { in v4l2_ctrl_new()
2181 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2182 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2183 ctrl->handler = hdl; in v4l2_ctrl_new()
2184 ctrl->ops = ops; in v4l2_ctrl_new()
2185 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2186 ctrl->id = id; in v4l2_ctrl_new()
2187 ctrl->name = name; in v4l2_ctrl_new()
2188 ctrl->type = type; in v4l2_ctrl_new()
2189 ctrl->flags = flags; in v4l2_ctrl_new()
2190 ctrl->minimum = min; in v4l2_ctrl_new()
2191 ctrl->maximum = max; in v4l2_ctrl_new()
2192 ctrl->step = step; in v4l2_ctrl_new()
2193 ctrl->default_value = def; in v4l2_ctrl_new()
2194 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2195 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2196 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2197 ctrl->is_array = is_array; in v4l2_ctrl_new()
2198 ctrl->elems = elems; in v4l2_ctrl_new()
2199 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2201 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2202 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2204 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2206 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2207 ctrl->priv = priv; in v4l2_ctrl_new()
2208 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2209 data = &ctrl[1]; in v4l2_ctrl_new()
2211 if (!ctrl->is_int) { in v4l2_ctrl_new()
2212 ctrl->p_new.p = data; in v4l2_ctrl_new()
2213 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2215 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2216 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2219 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2220 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2223 if (handler_new_ref(hdl, ctrl)) { in v4l2_ctrl_new()
2224 kvfree(ctrl); in v4l2_ctrl_new()
2228 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2230 return ctrl; in v4l2_ctrl_new()
2237 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2266 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2271 if (ctrl) in v4l2_ctrl_new_custom()
2272 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2273 return ctrl; in v4l2_ctrl_new_custom()
2392 bool (*filter)(const struct v4l2_ctrl *ctrl)) in v4l2_ctrl_add_handler() argument
2404 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2407 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2410 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2413 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2415 ret = handler_new_ref(hdl, ctrl); in v4l2_ctrl_add_handler()
2424 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2426 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2428 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2430 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2494 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
2500 if (ctrl == NULL) in v4l2_ctrl_activate()
2505 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2508 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2510 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
2520 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in v4l2_ctrl_grab() argument
2524 if (ctrl == NULL) in v4l2_ctrl_grab()
2527 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_grab()
2530 old = test_and_set_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2533 old = test_and_clear_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2535 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_grab()
2536 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_grab()
2541 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
2544 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
2546 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
2549 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
2551 ctrl->type_ops->log(ctrl); in log_ctrl()
2553 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
2556 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
2558 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
2560 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
2570 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
2582 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2583 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
2584 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
2599 struct v4l2_ctrl *ctrl; in __v4l2_ctrl_handler_setup() local
2607 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
2608 ctrl->done = false; in __v4l2_ctrl_handler_setup()
2610 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
2611 struct v4l2_ctrl *master = ctrl->cluster[0]; in __v4l2_ctrl_handler_setup()
2616 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in __v4l2_ctrl_handler_setup()
2617 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in __v4l2_ctrl_handler_setup()
2657 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
2690 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2691 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2692 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2704 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2705 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2706 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2719 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
2724 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
2725 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
2726 qc->flags = user_flags(ctrl); in v4l2_query_ext_ctrl()
2727 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
2728 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
2729 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
2730 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
2731 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
2732 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
2733 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
2734 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
2735 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
2736 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
2739 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
2784 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
2787 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
2788 if (!ctrl) in v4l2_querymenu()
2793 switch (ctrl->type) { in v4l2_querymenu()
2795 if (ctrl->qmenu == NULL) in v4l2_querymenu()
2799 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
2806 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
2810 if (ctrl->menu_skip_mask & (1 << i)) in v4l2_querymenu()
2813 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
2814 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
2816 strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
2818 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
2878 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
2895 ctrl = ref->ctrl; in prepare_ext_ctrls()
2896 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) in prepare_ext_ctrls()
2899 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
2901 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
2902 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
2903 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
2904 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
2917 h->ctrl = ctrl; in prepare_ext_ctrls()
3002 if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls()
3007 struct v4l2_ctrl *ctrl); in v4l2_g_ext_ctrls()
3015 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls()
3037 helpers[idx].ctrl); in v4l2_g_ext_ctrls()
3051 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
3053 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
3061 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
3064 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
3069 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
3073 new_to_user(c, ctrl); in get_ctrl()
3075 cur_to_user(c, ctrl); in get_ctrl()
3083 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
3087 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
3089 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
3095 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
3100 WARN_ON(!ctrl->is_int); in v4l2_ctrl_g_ctrl()
3102 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
3107 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
3112 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in v4l2_ctrl_g_ctrl_int64()
3114 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
3135 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
3137 if (ctrl == NULL) in try_or_set_cluster()
3140 if (!ctrl->is_new) { in try_or_set_cluster()
3141 cur_to_new(ctrl); in try_or_set_cluster()
3146 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3189 struct v4l2_ctrl *ctrl = helpers[i].ctrl; in validate_ctrls() local
3194 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in validate_ctrls()
3202 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in validate_ctrls()
3208 if (ctrl->is_ptr) in validate_ctrls()
3210 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
3214 ret = validate_new(ctrl, p_new); in validate_ctrls()
3278 master = helpers[i].mref->ctrl; in try_set_ext_ctrls()
3301 if (helpers[tmp_idx].ctrl == master) in try_set_ext_ctrls()
3314 struct v4l2_ctrl *ctrl = helpers[idx].ctrl; in try_set_ext_ctrls() local
3316 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls()
3317 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls()
3318 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls()
3330 helpers[idx].ctrl); in try_set_ext_ctrls()
3356 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
3358 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
3367 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
3374 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
3375 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
3378 ctrl->is_new = 1; in set_ctrl()
3383 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
3388 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
3389 user_to_new(c, ctrl); in set_ctrl_lock()
3390 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
3392 cur_to_user(c, ctrl); in set_ctrl_lock()
3393 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
3400 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
3404 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
3407 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
3411 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
3417 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
3419 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
3422 WARN_ON(!ctrl->is_int); in __v4l2_ctrl_s_ctrl()
3423 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
3424 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
3428 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
3430 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
3433 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in __v4l2_ctrl_s_ctrl_int64()
3434 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
3435 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
3439 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
3441 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
3444 WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); in __v4l2_ctrl_s_ctrl_string()
3445 strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
3446 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
3450 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
3452 if (ctrl == NULL) in v4l2_ctrl_notify()
3455 ctrl->call_notify = 0; in v4l2_ctrl_notify()
3458 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
3460 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
3461 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
3462 ctrl->call_notify = 1; in v4l2_ctrl_notify()
3466 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
3473 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
3475 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
3485 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
3487 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
3494 if ((ctrl->minimum != min) || (ctrl->maximum != max) || in __v4l2_ctrl_modify_range()
3495 (ctrl->step != step) || ctrl->default_value != def) { in __v4l2_ctrl_modify_range()
3497 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
3498 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
3499 ctrl->step = step; in __v4l2_ctrl_modify_range()
3500 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
3502 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
3503 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
3504 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3505 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
3507 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
3510 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3511 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
3513 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
3515 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3517 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3524 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
3526 if (ctrl == NULL) in v4l2_ctrl_add_event()
3529 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
3530 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
3531 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
3536 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
3538 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
3544 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
3550 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
3552 if (ctrl == NULL) in v4l2_ctrl_del_event()
3555 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
3557 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
3562 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
3564 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
3565 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
3571 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()