Lines Matching refs:ctrl
1545 static u32 user_flags(const struct v4l2_ctrl *ctrl) in user_flags() argument
1547 u32 flags = ctrl->flags; in user_flags()
1549 if (ctrl->is_ptr) in user_flags()
1555 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1559 ev->id = ctrl->id; in fill_event()
1560 ev->u.ctrl.changes = changes; in fill_event()
1561 ev->u.ctrl.type = ctrl->type; in fill_event()
1562 ev->u.ctrl.flags = user_flags(ctrl); in fill_event()
1563 if (ctrl->is_ptr) in fill_event()
1564 ev->u.ctrl.value64 = 0; in fill_event()
1566 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1567 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1568 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1569 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1570 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1571 ev->u.ctrl.step = 1; in fill_event()
1573 ev->u.ctrl.step = ctrl->step; in fill_event()
1574 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1577 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1582 if (list_empty(&ctrl->ev_subs)) in send_event()
1584 fill_event(&ev, ctrl, changes); in send_event()
1586 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1592 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1596 switch (ctrl->type) { in std_equal()
1600 idx *= ctrl->elem_size; in std_equal()
1612 if (ctrl->is_int) in std_equal()
1614 idx *= ctrl->elem_size; in std_equal()
1616 ctrl->elem_size); in std_equal()
1620 static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, in std_init_compound() argument
1624 void *p = ptr.p + idx * ctrl->elem_size; in std_init_compound()
1626 if (ctrl->p_def.p_const) in std_init_compound()
1627 memcpy(p, ctrl->p_def.p_const, ctrl->elem_size); in std_init_compound()
1629 memset(p, 0, ctrl->elem_size); in std_init_compound()
1636 switch ((u32)ctrl->type) { in std_init_compound()
1649 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1652 switch (ctrl->type) { in std_init()
1654 idx *= ctrl->elem_size; in std_init()
1655 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1656 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1659 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1666 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1673 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1676 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1679 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1682 std_init_compound(ctrl, idx, ptr); in std_init()
1687 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1689 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1691 if (ctrl->is_array) { in std_log()
1694 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1695 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1699 switch (ctrl->type) { in std_log()
1707 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1710 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1731 pr_cont("unknown type %d", ctrl->type); in std_log()
1741 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1744 if ((ctrl)->maximum >= 0 && \
1745 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1746 val = (ctrl)->maximum; \
1748 val += (s32)((ctrl)->step / 2); \
1750 (ctrl)->minimum, (ctrl)->maximum); \
1751 offset = (val) - (ctrl)->minimum; \
1752 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1753 val = (ctrl)->minimum + offset; \
1768 static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate_compound() argument
1779 void *p = ptr.p + idx * ctrl->elem_size; in std_validate_compound()
1782 switch ((u32)ctrl->type) { in std_validate_compound()
1950 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1957 switch ((u32)ctrl->type) { in std_validate()
1959 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1966 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1967 val = ctrl->maximum; in std_validate()
1969 val += (s64)(ctrl->step / 2); in std_validate()
1970 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1971 offset = val - ctrl->minimum; in std_validate()
1972 do_div(offset, ctrl->step); in std_validate()
1973 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1976 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1978 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1980 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1988 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1990 if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) in std_validate()
1992 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1993 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1998 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
2007 idx *= ctrl->elem_size; in std_validate()
2009 if (len < ctrl->minimum) in std_validate()
2011 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
2016 return std_validate_compound(ctrl, idx, ptr); in std_validate()
2029 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
2034 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
2038 switch (ctrl->type) { in ptr_to_user()
2042 c->size = ctrl->elem_size; in ptr_to_user()
2059 struct v4l2_ctrl *ctrl) in cur_to_user() argument
2061 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
2066 struct v4l2_ctrl *ctrl) in new_to_user() argument
2068 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
2075 return ptr_to_user(c, ref->ctrl, ref->p_req); in req_to_user()
2079 static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) in def_to_user() argument
2083 for (idx = 0; idx < ctrl->elems; idx++) in def_to_user()
2084 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in def_to_user()
2086 return ptr_to_user(c, ctrl, ctrl->p_new); in def_to_user()
2091 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
2097 ctrl->is_new = 1; in user_to_ptr()
2098 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
2102 if (ret || !ctrl->is_array) in user_to_ptr()
2104 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
2105 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
2109 switch (ctrl->type) { in user_to_ptr()
2117 if (size > ctrl->maximum + 1) in user_to_ptr()
2118 size = ctrl->maximum + 1; in user_to_ptr()
2126 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
2139 struct v4l2_ctrl *ctrl) in user_to_new() argument
2141 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
2145 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
2148 if (ctrl == NULL) in ptr_to_ptr()
2150 memcpy(to.p, from.p_const, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
2154 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
2158 if (ctrl == NULL) in new_to_cur()
2162 changed = ctrl->has_changed; in new_to_cur()
2164 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
2168 ctrl->flags &= in new_to_cur()
2170 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
2171 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
2172 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
2173 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
2180 if (!ctrl->is_new) in new_to_cur()
2182 send_event(fh, ctrl, in new_to_cur()
2184 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
2185 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
2190 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
2192 if (ctrl == NULL) in cur_to_new()
2194 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
2202 ptr_to_ptr(ref->ctrl, ref->ctrl->p_new, ref->p_req); in new_to_req()
2212 ptr_to_ptr(ref->ctrl, ref->req->p_req, ref->ctrl->p_new); in req_to_new()
2214 ptr_to_ptr(ref->ctrl, ref->ctrl->p_cur, ref->ctrl->p_new); in req_to_new()
2226 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
2229 if (ctrl == NULL) in cluster_changed()
2232 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
2239 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
2240 ctrl->has_changed = false; in cluster_changed()
2244 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
2245 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
2246 ctrl->p_cur, ctrl->p_new); in cluster_changed()
2247 ctrl->has_changed = ctrl_changed; in cluster_changed()
2248 changed |= ctrl->has_changed; in cluster_changed()
2293 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
2298 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
2299 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
2305 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
2343 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
2364 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
2365 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
2366 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
2368 kvfree(ctrl); in v4l2_ctrl_handler_free()
2394 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
2395 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
2396 if (!ref->ctrl->is_int) in find_private_ref()
2420 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
2425 while (ref && ref->ctrl->id != id) in find_ref()
2452 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
2458 struct v4l2_ctrl *ctrl, in handler_new_ref() argument
2464 u32 id = ctrl->id; in handler_new_ref()
2476 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
2485 size_extra_req = ctrl->elems * ctrl->elem_size; in handler_new_ref()
2489 new_ref->ctrl = ctrl; in handler_new_ref()
2509 if (ref->ctrl->id < id) in handler_new_ref()
2512 if (ref->ctrl->id == id) { in handler_new_ref()
2526 if (ctrl->handler == hdl) { in handler_new_ref()
2532 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
2533 ctrl->ncontrols = 1; in handler_new_ref()
2552 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
2674 ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
2675 if (ctrl == NULL) { in v4l2_ctrl_new()
2680 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2681 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2682 ctrl->handler = hdl; in v4l2_ctrl_new()
2683 ctrl->ops = ops; in v4l2_ctrl_new()
2684 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2685 ctrl->id = id; in v4l2_ctrl_new()
2686 ctrl->name = name; in v4l2_ctrl_new()
2687 ctrl->type = type; in v4l2_ctrl_new()
2688 ctrl->flags = flags; in v4l2_ctrl_new()
2689 ctrl->minimum = min; in v4l2_ctrl_new()
2690 ctrl->maximum = max; in v4l2_ctrl_new()
2691 ctrl->step = step; in v4l2_ctrl_new()
2692 ctrl->default_value = def; in v4l2_ctrl_new()
2693 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2694 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2695 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2696 ctrl->is_array = is_array; in v4l2_ctrl_new()
2697 ctrl->elems = elems; in v4l2_ctrl_new()
2698 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2700 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2701 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2703 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2705 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2706 ctrl->priv = priv; in v4l2_ctrl_new()
2707 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2708 data = &ctrl[1]; in v4l2_ctrl_new()
2710 if (!ctrl->is_int) { in v4l2_ctrl_new()
2711 ctrl->p_new.p = data; in v4l2_ctrl_new()
2712 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2714 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2715 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2719 ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size; in v4l2_ctrl_new()
2720 memcpy(ctrl->p_def.p, p_def.p_const, elem_size); in v4l2_ctrl_new()
2724 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2725 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2728 if (handler_new_ref(hdl, ctrl, NULL, false, false)) { in v4l2_ctrl_new()
2729 kvfree(ctrl); in v4l2_ctrl_new()
2733 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2735 return ctrl; in v4l2_ctrl_new()
2742 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2770 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2775 if (ctrl) in v4l2_ctrl_new_custom()
2776 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2777 return ctrl; in v4l2_ctrl_new_custom()
2917 bool (*filter)(const struct v4l2_ctrl *ctrl), in v4l2_ctrl_add_handler() argument
2930 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2933 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2936 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2939 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2941 ret = handler_new_ref(hdl, ctrl, NULL, from_other_dev, false); in v4l2_ctrl_add_handler()
2950 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2952 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2954 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2956 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
3020 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
3026 if (ctrl == NULL) in v4l2_ctrl_activate()
3031 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
3034 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
3036 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
3040 void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in __v4l2_ctrl_grab() argument
3044 if (ctrl == NULL) in __v4l2_ctrl_grab()
3047 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_grab()
3051 old = test_and_set_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
3054 old = test_and_clear_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
3056 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in __v4l2_ctrl_grab()
3061 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
3064 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
3066 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
3069 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
3071 ctrl->type_ops->log(ctrl); in log_ctrl()
3073 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
3076 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
3078 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
3080 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
3090 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
3102 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
3103 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
3104 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
3119 struct v4l2_ctrl *ctrl; in __v4l2_ctrl_handler_setup() local
3127 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
3128 ctrl->done = false; in __v4l2_ctrl_handler_setup()
3130 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
3131 struct v4l2_ctrl *master = ctrl->cluster[0]; in __v4l2_ctrl_handler_setup()
3136 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in __v4l2_ctrl_handler_setup()
3137 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in __v4l2_ctrl_handler_setup()
3177 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
3210 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
3211 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
3212 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
3224 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
3225 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
3226 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
3239 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
3244 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
3245 strscpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
3246 qc->flags = user_flags(ctrl); in v4l2_query_ext_ctrl()
3247 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
3248 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
3249 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
3250 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
3251 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
3252 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
3253 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
3254 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
3255 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
3256 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
3259 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
3304 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
3307 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
3308 if (!ctrl) in v4l2_querymenu()
3313 switch (ctrl->type) { in v4l2_querymenu()
3315 if (ctrl->qmenu == NULL) in v4l2_querymenu()
3319 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
3326 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
3330 if (ctrl->menu_skip_mask & (1ULL << i)) in v4l2_querymenu()
3333 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
3334 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
3336 strscpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
3338 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
3360 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_clone() local
3367 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON) in v4l2_ctrl_request_clone()
3369 err = handler_new_ref(hdl, ctrl, &new_ref, false, true); in v4l2_ctrl_request_clone()
3402 while (ref_ctrl_prev->ctrl->id < ref_ctrl->ctrl->id) { in v4l2_ctrl_request_queue()
3409 if (WARN_ON(ref_ctrl_prev->ctrl->id != ref_ctrl->ctrl->id)) in v4l2_ctrl_request_queue()
3471 return (ref && ref->req == ref) ? ref->ctrl : NULL; in v4l2_ctrl_request_hdl_ctrl_find()
3546 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
3574 ctrl = ref->ctrl; in prepare_ext_ctrls()
3575 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) { in prepare_ext_ctrls()
3580 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
3582 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
3583 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
3584 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
3585 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
3690 if (helpers[i].ref->ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls_common()
3695 struct v4l2_ctrl *ctrl); in v4l2_g_ext_ctrls_common()
3703 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls_common()
3729 helpers[idx].ref->ctrl); in v4l2_g_ext_ctrls_common()
3828 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
3830 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
3838 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
3841 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
3846 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
3850 new_to_user(c, ctrl); in get_ctrl()
3852 cur_to_user(c, ctrl); in get_ctrl()
3860 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
3864 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
3866 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
3872 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
3877 if (WARN_ON(!ctrl->is_int)) in v4l2_ctrl_g_ctrl()
3880 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
3885 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
3890 if (WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64)) in v4l2_ctrl_g_ctrl_int64()
3893 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
3914 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
3916 if (ctrl == NULL) in try_or_set_cluster()
3919 if (!ctrl->is_new) { in try_or_set_cluster()
3920 cur_to_new(ctrl); in try_or_set_cluster()
3925 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3970 struct v4l2_ctrl *ctrl = helpers[i].ref->ctrl; in validate_ctrls() local
3975 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) { in validate_ctrls()
3978 ctrl->id); in validate_ctrls()
3987 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) { in validate_ctrls()
3990 ctrl->id); in validate_ctrls()
3997 if (ctrl->is_ptr) in validate_ctrls()
3999 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
4003 ret = validate_new(ctrl, p_new); in validate_ctrls()
4074 master = helpers[i].mref->ctrl; in try_set_ext_ctrls_common()
4097 if (helpers[tmp_idx].ref->ctrl == master) in try_set_ext_ctrls_common()
4110 struct v4l2_ctrl *ctrl = helpers[idx].ref->ctrl; in try_set_ext_ctrls_common() local
4112 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls_common()
4113 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls_common()
4114 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls_common()
4135 helpers[idx].ref->ctrl); in try_set_ext_ctrls_common()
4234 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
4236 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
4245 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
4252 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
4253 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
4256 ctrl->is_new = 1; in set_ctrl()
4261 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
4266 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
4267 user_to_new(c, ctrl); in set_ctrl_lock()
4268 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
4270 cur_to_user(c, ctrl); in set_ctrl_lock()
4271 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
4278 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
4282 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
4285 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
4289 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
4295 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
4297 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
4300 if (WARN_ON(!ctrl->is_int)) in __v4l2_ctrl_s_ctrl()
4302 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
4303 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
4307 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
4309 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
4312 if (WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64)) in __v4l2_ctrl_s_ctrl_int64()
4314 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
4315 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
4319 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
4321 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
4324 if (WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING)) in __v4l2_ctrl_s_ctrl_string()
4326 strscpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
4327 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
4331 int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_s_ctrl_compound() argument
4334 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_compound()
4337 if (WARN_ON(ctrl->type != type)) in __v4l2_ctrl_s_ctrl_compound()
4339 memcpy(ctrl->p_new.p, p, ctrl->elems * ctrl->elem_size); in __v4l2_ctrl_s_ctrl_compound()
4340 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_compound()
4365 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_complete() local
4366 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_complete()
4369 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in v4l2_ctrl_request_complete()
4384 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_request_complete()
4386 ptr_to_ptr(ctrl, ref->req->p_req, ref->p_req); in v4l2_ctrl_request_complete()
4388 ptr_to_ptr(ctrl, ctrl->p_cur, ref->p_req); in v4l2_ctrl_request_complete()
4396 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_request_complete()
4441 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_setup() local
4442 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_setup()
4450 if (ref->req_done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_request_setup()
4451 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_request_setup()
4513 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
4515 if (ctrl == NULL) in v4l2_ctrl_notify()
4518 ctrl->call_notify = 0; in v4l2_ctrl_notify()
4521 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
4523 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
4524 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
4525 ctrl->call_notify = 1; in v4l2_ctrl_notify()
4529 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
4536 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
4538 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
4548 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
4550 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
4557 if ((ctrl->minimum != min) || (ctrl->maximum != max) || in __v4l2_ctrl_modify_range()
4558 (ctrl->step != step) || ctrl->default_value != def) { in __v4l2_ctrl_modify_range()
4560 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
4561 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
4562 ctrl->step = step; in __v4l2_ctrl_modify_range()
4563 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
4565 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
4566 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
4567 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4568 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
4570 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
4573 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4574 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
4576 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
4578 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
4580 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
4587 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
4589 if (ctrl == NULL) in v4l2_ctrl_add_event()
4592 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
4593 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
4594 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
4599 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
4601 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
4607 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
4613 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
4615 if (ctrl == NULL) in v4l2_ctrl_del_event()
4618 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
4620 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
4625 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
4627 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
4628 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
4634 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()