Lines Matching refs:ctrl
1453 static u32 user_flags(const struct v4l2_ctrl *ctrl) in user_flags() argument
1455 u32 flags = ctrl->flags; in user_flags()
1457 if (ctrl->is_ptr) in user_flags()
1463 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1467 ev->id = ctrl->id; in fill_event()
1468 ev->u.ctrl.changes = changes; in fill_event()
1469 ev->u.ctrl.type = ctrl->type; in fill_event()
1470 ev->u.ctrl.flags = user_flags(ctrl); in fill_event()
1471 if (ctrl->is_ptr) in fill_event()
1472 ev->u.ctrl.value64 = 0; in fill_event()
1474 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1475 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1476 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1477 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1478 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1479 ev->u.ctrl.step = 1; in fill_event()
1481 ev->u.ctrl.step = ctrl->step; in fill_event()
1482 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1485 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1490 if (list_empty(&ctrl->ev_subs)) in send_event()
1492 fill_event(&ev, ctrl, changes); in send_event()
1494 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1500 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1504 switch (ctrl->type) { in std_equal()
1508 idx *= ctrl->elem_size; in std_equal()
1520 if (ctrl->is_int) in std_equal()
1522 idx *= ctrl->elem_size; in std_equal()
1523 return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); in std_equal()
1527 static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, in std_init_compound() argument
1531 void *p = ptr.p + idx * ctrl->elem_size; in std_init_compound()
1533 memset(p, 0, ctrl->elem_size); in std_init_compound()
1540 switch ((u32)ctrl->type) { in std_init_compound()
1553 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1556 switch (ctrl->type) { in std_init()
1558 idx *= ctrl->elem_size; in std_init()
1559 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1560 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1563 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1570 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1577 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1580 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1583 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1586 std_init_compound(ctrl, idx, ptr); in std_init()
1591 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1593 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1595 if (ctrl->is_array) { in std_log()
1598 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1599 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1603 switch (ctrl->type) { in std_log()
1611 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1614 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1635 pr_cont("unknown type %d", ctrl->type); in std_log()
1645 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1648 if ((ctrl)->maximum >= 0 && \
1649 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1650 val = (ctrl)->maximum; \
1652 val += (s32)((ctrl)->step / 2); \
1654 (ctrl)->minimum, (ctrl)->maximum); \
1655 offset = (val) - (ctrl)->minimum; \
1656 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1657 val = (ctrl)->minimum + offset; \
1670 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate_compound() argument
1675 void *p = ptr.p + idx * ctrl->elem_size; in std_validate_compound()
1677 switch ((u32)ctrl->type) { in std_validate_compound()
1758 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1765 switch ((u32)ctrl->type) { in std_validate()
1767 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1774 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1775 val = ctrl->maximum; in std_validate()
1777 val += (s64)(ctrl->step / 2); in std_validate()
1778 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1779 offset = val - ctrl->minimum; in std_validate()
1780 do_div(offset, ctrl->step); in std_validate()
1781 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1784 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1786 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1788 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1796 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1798 if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) in std_validate()
1800 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1801 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1806 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
1815 idx *= ctrl->elem_size; in std_validate()
1817 if (len < ctrl->minimum) in std_validate()
1819 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
1824 return std_validate_compound(ctrl, idx, ptr); in std_validate()
1837 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
1842 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
1846 switch (ctrl->type) { in ptr_to_user()
1850 c->size = ctrl->elem_size; in ptr_to_user()
1867 struct v4l2_ctrl *ctrl) in cur_to_user() argument
1869 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
1874 struct v4l2_ctrl *ctrl) in new_to_user() argument
1876 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
1883 return ptr_to_user(c, ref->ctrl, ref->p_req); in req_to_user()
1887 static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) in def_to_user() argument
1891 for (idx = 0; idx < ctrl->elems; idx++) in def_to_user()
1892 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in def_to_user()
1894 return ptr_to_user(c, ctrl, ctrl->p_new); in def_to_user()
1899 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
1905 ctrl->is_new = 1; in user_to_ptr()
1906 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
1910 if (ret || !ctrl->is_array) in user_to_ptr()
1912 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
1913 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
1917 switch (ctrl->type) { in user_to_ptr()
1925 if (size > ctrl->maximum + 1) in user_to_ptr()
1926 size = ctrl->maximum + 1; in user_to_ptr()
1934 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
1947 struct v4l2_ctrl *ctrl) in user_to_new() argument
1949 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
1953 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
1956 if (ctrl == NULL) in ptr_to_ptr()
1958 memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
1962 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
1966 if (ctrl == NULL) in new_to_cur()
1970 changed = ctrl->has_changed; in new_to_cur()
1972 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
1976 ctrl->flags &= in new_to_cur()
1978 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
1979 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
1980 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
1981 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
1988 if (!ctrl->is_new) in new_to_cur()
1990 send_event(fh, ctrl, in new_to_cur()
1992 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
1993 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
1998 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
2000 if (ctrl == NULL) in cur_to_new()
2002 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
2010 ptr_to_ptr(ref->ctrl, ref->ctrl->p_new, ref->p_req); in new_to_req()
2020 ptr_to_ptr(ref->ctrl, ref->req->p_req, ref->ctrl->p_new); in req_to_new()
2022 ptr_to_ptr(ref->ctrl, ref->ctrl->p_cur, ref->ctrl->p_new); in req_to_new()
2034 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
2037 if (ctrl == NULL) in cluster_changed()
2040 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
2047 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
2048 ctrl->has_changed = false; in cluster_changed()
2052 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
2053 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
2054 ctrl->p_cur, ctrl->p_new); in cluster_changed()
2055 ctrl->has_changed = ctrl_changed; in cluster_changed()
2056 changed |= ctrl->has_changed; in cluster_changed()
2101 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
2106 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
2107 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
2113 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
2151 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
2172 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
2173 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
2174 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
2176 kvfree(ctrl); in v4l2_ctrl_handler_free()
2202 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
2203 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
2204 if (!ref->ctrl->is_int) in find_private_ref()
2228 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
2233 while (ref && ref->ctrl->id != id) in find_ref()
2260 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
2266 struct v4l2_ctrl *ctrl, in handler_new_ref() argument
2272 u32 id = ctrl->id; in handler_new_ref()
2284 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
2293 size_extra_req = ctrl->elems * ctrl->elem_size; in handler_new_ref()
2297 new_ref->ctrl = ctrl; in handler_new_ref()
2317 if (ref->ctrl->id < id) in handler_new_ref()
2320 if (ref->ctrl->id == id) { in handler_new_ref()
2334 if (ctrl->handler == hdl) { in handler_new_ref()
2340 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
2341 ctrl->ncontrols = 1; in handler_new_ref()
2359 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
2463 ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
2464 if (ctrl == NULL) { in v4l2_ctrl_new()
2469 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2470 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2471 ctrl->handler = hdl; in v4l2_ctrl_new()
2472 ctrl->ops = ops; in v4l2_ctrl_new()
2473 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2474 ctrl->id = id; in v4l2_ctrl_new()
2475 ctrl->name = name; in v4l2_ctrl_new()
2476 ctrl->type = type; in v4l2_ctrl_new()
2477 ctrl->flags = flags; in v4l2_ctrl_new()
2478 ctrl->minimum = min; in v4l2_ctrl_new()
2479 ctrl->maximum = max; in v4l2_ctrl_new()
2480 ctrl->step = step; in v4l2_ctrl_new()
2481 ctrl->default_value = def; in v4l2_ctrl_new()
2482 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2483 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2484 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2485 ctrl->is_array = is_array; in v4l2_ctrl_new()
2486 ctrl->elems = elems; in v4l2_ctrl_new()
2487 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2489 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2490 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2492 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2494 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2495 ctrl->priv = priv; in v4l2_ctrl_new()
2496 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2497 data = &ctrl[1]; in v4l2_ctrl_new()
2499 if (!ctrl->is_int) { in v4l2_ctrl_new()
2500 ctrl->p_new.p = data; in v4l2_ctrl_new()
2501 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2503 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2504 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2507 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2508 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2511 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
2512 kvfree(ctrl); in v4l2_ctrl_new()
2516 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2518 return ctrl; in v4l2_ctrl_new()
2525 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2553 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2558 if (ctrl) in v4l2_ctrl_new_custom()
2559 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2560 return ctrl; in v4l2_ctrl_new_custom()
2679 bool (*filter)(const struct v4l2_ctrl *ctrl), in v4l2_ctrl_add_handler() argument
2692 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2695 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2698 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2701 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2703 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
2712 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2714 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2716 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2718 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2782 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
2788 if (ctrl == NULL) in v4l2_ctrl_activate()
2793 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2796 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2798 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
2802 void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in __v4l2_ctrl_grab() argument
2806 if (ctrl == NULL) in __v4l2_ctrl_grab()
2809 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_grab()
2813 old = test_and_set_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
2816 old = test_and_clear_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
2818 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in __v4l2_ctrl_grab()
2823 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
2826 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
2828 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
2831 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
2833 ctrl->type_ops->log(ctrl); in log_ctrl()
2835 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
2838 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
2840 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
2842 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
2852 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
2864 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2865 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
2866 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
2881 struct v4l2_ctrl *ctrl; in __v4l2_ctrl_handler_setup() local
2889 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
2890 ctrl->done = false; in __v4l2_ctrl_handler_setup()
2892 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
2893 struct v4l2_ctrl *master = ctrl->cluster[0]; in __v4l2_ctrl_handler_setup()
2898 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in __v4l2_ctrl_handler_setup()
2899 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in __v4l2_ctrl_handler_setup()
2939 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
2972 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2973 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2974 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2986 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2987 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2988 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
3001 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
3006 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
3007 strscpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
3008 qc->flags = user_flags(ctrl); in v4l2_query_ext_ctrl()
3009 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
3010 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
3011 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
3012 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
3013 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
3014 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
3015 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
3016 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
3017 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
3018 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
3021 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
3066 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
3069 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
3070 if (!ctrl) in v4l2_querymenu()
3075 switch (ctrl->type) { in v4l2_querymenu()
3077 if (ctrl->qmenu == NULL) in v4l2_querymenu()
3081 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
3088 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
3092 if (ctrl->menu_skip_mask & (1ULL << i)) in v4l2_querymenu()
3095 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
3096 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
3098 strscpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
3100 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
3122 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_clone() local
3129 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON) in v4l2_ctrl_request_clone()
3131 err = handler_new_ref(hdl, ctrl, &new_ref, false, true); in v4l2_ctrl_request_clone()
3163 while (ref_ctrl_prev->ctrl->id < ref_ctrl->ctrl->id) { in v4l2_ctrl_request_queue()
3170 if (WARN_ON(ref_ctrl_prev->ctrl->id != ref_ctrl->ctrl->id)) in v4l2_ctrl_request_queue()
3228 return (ref && ref->req == ref) ? ref->ctrl : NULL; in v4l2_ctrl_request_hdl_ctrl_find()
3303 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
3331 ctrl = ref->ctrl; in prepare_ext_ctrls()
3332 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) { in prepare_ext_ctrls()
3337 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
3339 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
3340 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
3341 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
3342 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
3447 if (helpers[i].ref->ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls_common()
3452 struct v4l2_ctrl *ctrl); in v4l2_g_ext_ctrls_common()
3460 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls_common()
3486 helpers[idx].ref->ctrl); in v4l2_g_ext_ctrls_common()
3585 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
3587 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
3595 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
3598 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
3603 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
3607 new_to_user(c, ctrl); in get_ctrl()
3609 cur_to_user(c, ctrl); in get_ctrl()
3617 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
3621 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
3623 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
3629 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
3634 WARN_ON(!ctrl->is_int); in v4l2_ctrl_g_ctrl()
3636 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
3641 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
3646 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in v4l2_ctrl_g_ctrl_int64()
3648 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
3669 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
3671 if (ctrl == NULL) in try_or_set_cluster()
3674 if (!ctrl->is_new) { in try_or_set_cluster()
3675 cur_to_new(ctrl); in try_or_set_cluster()
3680 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3725 struct v4l2_ctrl *ctrl = helpers[i].ref->ctrl; in validate_ctrls() local
3730 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) { in validate_ctrls()
3733 ctrl->id); in validate_ctrls()
3742 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) { in validate_ctrls()
3745 ctrl->id); in validate_ctrls()
3752 if (ctrl->is_ptr) in validate_ctrls()
3754 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
3758 ret = validate_new(ctrl, p_new); in validate_ctrls()
3829 master = helpers[i].mref->ctrl; in try_set_ext_ctrls_common()
3852 if (helpers[tmp_idx].ref->ctrl == master) in try_set_ext_ctrls_common()
3865 struct v4l2_ctrl *ctrl = helpers[idx].ref->ctrl; in try_set_ext_ctrls_common() local
3867 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls_common()
3868 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls_common()
3869 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls_common()
3890 helpers[idx].ref->ctrl); in try_set_ext_ctrls_common()
3989 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
3991 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
4000 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
4007 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
4008 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
4011 ctrl->is_new = 1; in set_ctrl()
4016 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
4021 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
4022 user_to_new(c, ctrl); in set_ctrl_lock()
4023 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
4025 cur_to_user(c, ctrl); in set_ctrl_lock()
4026 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
4033 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
4037 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
4040 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
4044 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
4050 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
4052 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
4055 WARN_ON(!ctrl->is_int); in __v4l2_ctrl_s_ctrl()
4056 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
4057 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
4061 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
4063 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
4066 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in __v4l2_ctrl_s_ctrl_int64()
4067 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
4068 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
4072 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
4074 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
4077 WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); in __v4l2_ctrl_s_ctrl_string()
4078 strscpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
4079 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
4104 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_complete() local
4105 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_complete()
4108 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in v4l2_ctrl_request_complete()
4123 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_request_complete()
4125 ptr_to_ptr(ctrl, ref->req->p_req, ref->p_req); in v4l2_ctrl_request_complete()
4127 ptr_to_ptr(ctrl, ctrl->p_cur, ref->p_req); in v4l2_ctrl_request_complete()
4128 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_request_complete()
4171 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_setup() local
4172 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_setup()
4180 if (ref->req_done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_request_setup()
4181 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_request_setup()
4243 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
4245 if (ctrl == NULL) in v4l2_ctrl_notify()
4248 ctrl->call_notify = 0; in v4l2_ctrl_notify()
4251 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
4253 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
4254 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
4255 ctrl->call_notify = 1; in v4l2_ctrl_notify()
4259 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
4266 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
4268 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
4278 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
4280 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
4287 if ((ctrl->minimum != min) || (ctrl->maximum != max) || in __v4l2_ctrl_modify_range()
4288 (ctrl->step != step) || ctrl->default_value != def) { in __v4l2_ctrl_modify_range()
4290 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
4291 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
4292 ctrl->step = step; in __v4l2_ctrl_modify_range()
4293 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
4295 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
4296 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
4297 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4298 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
4300 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
4303 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4304 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
4306 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
4308 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
4310 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
4317 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
4319 if (ctrl == NULL) in v4l2_ctrl_add_event()
4322 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
4323 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
4324 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
4329 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
4331 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
4337 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
4343 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
4345 if (ctrl == NULL) in v4l2_ctrl_del_event()
4348 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
4350 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
4355 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
4357 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
4358 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
4364 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()