Lines Matching refs:ctrl
40 struct v4l2_ctrl *ctrl; member
1203 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1207 ev->id = ctrl->id; in fill_event()
1208 ev->u.ctrl.changes = changes; in fill_event()
1209 ev->u.ctrl.type = ctrl->type; in fill_event()
1210 ev->u.ctrl.flags = ctrl->flags; in fill_event()
1211 if (ctrl->is_ptr) in fill_event()
1212 ev->u.ctrl.value64 = 0; in fill_event()
1214 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1215 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1216 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1217 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1218 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1219 ev->u.ctrl.step = 1; in fill_event()
1221 ev->u.ctrl.step = ctrl->step; in fill_event()
1222 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1225 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1230 if (list_empty(&ctrl->ev_subs)) in send_event()
1232 fill_event(&ev, ctrl, changes); in send_event()
1234 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1240 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1244 switch (ctrl->type) { in std_equal()
1248 idx *= ctrl->elem_size; in std_equal()
1260 if (ctrl->is_int) in std_equal()
1262 idx *= ctrl->elem_size; in std_equal()
1263 return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); in std_equal()
1267 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1270 switch (ctrl->type) { in std_init()
1272 idx *= ctrl->elem_size; in std_init()
1273 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1274 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1277 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1284 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1287 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1290 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1293 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1296 idx *= ctrl->elem_size; in std_init()
1297 memset(ptr.p + idx, 0, ctrl->elem_size); in std_init()
1302 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1304 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1306 if (ctrl->is_array) { in std_log()
1309 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1310 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1314 switch (ctrl->type) { in std_log()
1322 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1325 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1346 pr_cont("unknown type %d", ctrl->type); in std_log()
1356 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1359 if ((ctrl)->maximum >= 0 && \
1360 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1361 val = (ctrl)->maximum; \
1363 val += (s32)((ctrl)->step / 2); \
1365 (ctrl)->minimum, (ctrl)->maximum); \
1366 offset = (val) - (ctrl)->minimum; \
1367 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1368 val = (ctrl)->minimum + offset; \
1373 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1380 switch (ctrl->type) { in std_validate()
1382 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1389 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1390 val = ctrl->maximum; in std_validate()
1392 val += (s64)(ctrl->step / 2); in std_validate()
1393 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1394 offset = val - ctrl->minimum; in std_validate()
1395 do_div(offset, ctrl->step); in std_validate()
1396 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1399 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1401 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1403 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1411 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1413 if (ctrl->menu_skip_mask & (1 << ptr.p_s32[idx])) in std_validate()
1415 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1416 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1421 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
1430 idx *= ctrl->elem_size; in std_validate()
1432 if (len < ctrl->minimum) in std_validate()
1434 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
1452 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
1457 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
1461 switch (ctrl->type) { in ptr_to_user()
1465 c->size = ctrl->elem_size; in ptr_to_user()
1482 struct v4l2_ctrl *ctrl) in cur_to_user() argument
1484 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
1489 struct v4l2_ctrl *ctrl) in new_to_user() argument
1491 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
1496 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
1502 ctrl->is_new = 1; in user_to_ptr()
1503 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
1507 if (ret || !ctrl->is_array) in user_to_ptr()
1509 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
1510 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
1514 switch (ctrl->type) { in user_to_ptr()
1522 if (size > ctrl->maximum + 1) in user_to_ptr()
1523 size = ctrl->maximum + 1; in user_to_ptr()
1531 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
1544 struct v4l2_ctrl *ctrl) in user_to_new() argument
1546 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
1550 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
1553 if (ctrl == NULL) in ptr_to_ptr()
1555 memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
1559 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
1563 if (ctrl == NULL) in new_to_cur()
1567 changed = ctrl->has_changed; in new_to_cur()
1569 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
1573 ctrl->flags &= in new_to_cur()
1575 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
1576 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
1577 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
1578 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
1585 if (!ctrl->is_new) in new_to_cur()
1587 send_event(fh, ctrl, in new_to_cur()
1589 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
1590 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
1595 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
1597 if (ctrl == NULL) in cur_to_new()
1599 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
1611 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
1614 if (ctrl == NULL) in cluster_changed()
1617 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
1624 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
1625 ctrl->has_changed = false; in cluster_changed()
1629 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
1630 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
1631 ctrl->p_cur, ctrl->p_new); in cluster_changed()
1632 ctrl->has_changed = ctrl_changed; in cluster_changed()
1633 changed |= ctrl->has_changed; in cluster_changed()
1678 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
1683 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
1684 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
1690 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
1723 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
1736 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1737 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
1738 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
1740 kfree(ctrl); in v4l2_ctrl_handler_free()
1765 if (V4L2_CTRL_ID2CLASS(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
1766 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
1767 if (!ref->ctrl->is_int) in find_private_ref()
1791 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1796 while (ref && ref->ctrl->id != id) in find_ref()
1823 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
1829 struct v4l2_ctrl *ctrl) in handler_new_ref() argument
1833 u32 id = ctrl->id; in handler_new_ref()
1841 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
1852 new_ref->ctrl = ctrl; in handler_new_ref()
1853 if (ctrl->handler == hdl) { in handler_new_ref()
1858 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
1859 ctrl->ncontrols = 1; in handler_new_ref()
1877 if (ref->ctrl->id < id) in handler_new_ref()
1880 if (ref->ctrl->id == id) { in handler_new_ref()
1908 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
1989 ctrl = kzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
1990 if (ctrl == NULL) { in v4l2_ctrl_new()
1995 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
1996 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
1997 ctrl->handler = hdl; in v4l2_ctrl_new()
1998 ctrl->ops = ops; in v4l2_ctrl_new()
1999 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2000 ctrl->id = id; in v4l2_ctrl_new()
2001 ctrl->name = name; in v4l2_ctrl_new()
2002 ctrl->type = type; in v4l2_ctrl_new()
2003 ctrl->flags = flags; in v4l2_ctrl_new()
2004 ctrl->minimum = min; in v4l2_ctrl_new()
2005 ctrl->maximum = max; in v4l2_ctrl_new()
2006 ctrl->step = step; in v4l2_ctrl_new()
2007 ctrl->default_value = def; in v4l2_ctrl_new()
2008 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2009 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2010 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2011 ctrl->is_array = is_array; in v4l2_ctrl_new()
2012 ctrl->elems = elems; in v4l2_ctrl_new()
2013 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2015 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2016 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2018 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2020 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2021 ctrl->priv = priv; in v4l2_ctrl_new()
2022 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2023 data = &ctrl[1]; in v4l2_ctrl_new()
2025 if (!ctrl->is_int) { in v4l2_ctrl_new()
2026 ctrl->p_new.p = data; in v4l2_ctrl_new()
2027 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2029 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2030 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2033 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2034 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2037 if (handler_new_ref(hdl, ctrl)) { in v4l2_ctrl_new()
2038 kfree(ctrl); in v4l2_ctrl_new()
2042 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2044 return ctrl; in v4l2_ctrl_new()
2051 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2080 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2085 if (ctrl) in v4l2_ctrl_new_custom()
2086 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2087 return ctrl; in v4l2_ctrl_new_custom()
2205 struct v4l2_ctrl *ctrl) in v4l2_ctrl_add_ctrl() argument
2209 if (ctrl == NULL) { in v4l2_ctrl_add_ctrl()
2213 if (ctrl->handler == hdl) in v4l2_ctrl_add_ctrl()
2214 return ctrl; in v4l2_ctrl_add_ctrl()
2215 return handler_new_ref(hdl, ctrl) ? NULL : ctrl; in v4l2_ctrl_add_ctrl()
2222 bool (*filter)(const struct v4l2_ctrl *ctrl)) in v4l2_ctrl_add_handler() argument
2234 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2237 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2240 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2243 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2245 ret = handler_new_ref(hdl, ctrl); in v4l2_ctrl_add_handler()
2254 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2256 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2258 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2260 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2324 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
2330 if (ctrl == NULL) in v4l2_ctrl_activate()
2335 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2338 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2340 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
2350 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in v4l2_ctrl_grab() argument
2354 if (ctrl == NULL) in v4l2_ctrl_grab()
2357 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_grab()
2360 old = test_and_set_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2363 old = test_and_clear_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2365 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_grab()
2366 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_grab()
2371 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
2374 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
2376 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
2379 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
2381 ctrl->type_ops->log(ctrl); in log_ctrl()
2383 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
2386 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
2388 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
2390 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
2400 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
2412 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2413 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
2414 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
2429 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_setup() local
2435 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_setup()
2436 ctrl->done = false; in v4l2_ctrl_handler_setup()
2438 list_for_each_entry(ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_setup()
2439 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_handler_setup()
2444 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_handler_setup()
2445 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_handler_setup()
2470 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
2503 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2504 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2505 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2517 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2518 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2519 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2532 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
2537 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
2538 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
2539 qc->flags = ctrl->flags; in v4l2_query_ext_ctrl()
2540 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
2541 if (ctrl->is_ptr) in v4l2_query_ext_ctrl()
2543 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
2544 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
2545 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
2546 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
2547 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
2548 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
2549 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
2550 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
2551 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
2554 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
2607 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
2610 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
2611 if (!ctrl) in v4l2_querymenu()
2616 switch (ctrl->type) { in v4l2_querymenu()
2618 if (ctrl->qmenu == NULL) in v4l2_querymenu()
2622 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
2629 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
2633 if (ctrl->menu_skip_mask & (1 << i)) in v4l2_querymenu()
2636 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
2637 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
2639 strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
2641 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
2708 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
2723 ctrl = ref->ctrl; in prepare_ext_ctrls()
2724 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) in prepare_ext_ctrls()
2727 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
2729 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
2730 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
2731 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
2732 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
2745 h->ctrl = ctrl; in prepare_ext_ctrls()
2827 if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls()
2832 struct v4l2_ctrl *ctrl) = cur_to_user; in v4l2_g_ext_ctrls()
2838 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls()
2859 helpers[idx].ctrl); in v4l2_g_ext_ctrls()
2879 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
2881 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
2889 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
2892 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
2897 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
2901 new_to_user(c, ctrl); in get_ctrl()
2903 cur_to_user(c, ctrl); in get_ctrl()
2911 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
2915 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
2917 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
2929 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
2934 WARN_ON(!ctrl->is_int); in v4l2_ctrl_g_ctrl()
2936 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
2941 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
2946 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in v4l2_ctrl_g_ctrl_int64()
2948 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
2969 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
2971 if (ctrl == NULL) in try_or_set_cluster()
2974 if (!ctrl->is_new) { in try_or_set_cluster()
2975 cur_to_new(ctrl); in try_or_set_cluster()
2980 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3010 struct v4l2_ctrl *ctrl = helpers[i].ctrl; in validate_ctrls() local
3015 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in validate_ctrls()
3023 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in validate_ctrls()
3029 if (ctrl->is_ptr) in validate_ctrls()
3031 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
3035 ret = validate_new(ctrl, p_new); in validate_ctrls()
3094 master = helpers[i].mref->ctrl; in try_set_ext_ctrls()
3117 if (helpers[tmp_idx].ctrl == master) in try_set_ext_ctrls()
3130 struct v4l2_ctrl *ctrl = helpers[idx].ctrl; in try_set_ext_ctrls() local
3132 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls()
3133 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls()
3134 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls()
3146 helpers[idx].ctrl); in try_set_ext_ctrls()
3184 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
3186 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
3195 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
3202 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
3203 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
3206 ctrl->is_new = 1; in set_ctrl()
3211 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
3216 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
3217 user_to_new(c, ctrl); in set_ctrl_lock()
3218 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
3220 cur_to_user(c, ctrl); in set_ctrl_lock()
3221 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
3228 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
3232 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
3235 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
3239 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
3251 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
3253 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
3256 WARN_ON(!ctrl->is_int); in __v4l2_ctrl_s_ctrl()
3257 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
3258 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
3262 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
3264 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
3267 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in __v4l2_ctrl_s_ctrl_int64()
3268 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
3269 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
3273 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
3275 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
3278 WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); in __v4l2_ctrl_s_ctrl_string()
3279 strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
3280 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
3284 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
3286 if (ctrl == NULL) in v4l2_ctrl_notify()
3289 ctrl->call_notify = 0; in v4l2_ctrl_notify()
3292 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
3294 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
3295 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
3296 ctrl->call_notify = 1; in v4l2_ctrl_notify()
3300 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
3306 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
3308 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
3318 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
3320 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
3327 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
3328 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
3329 ctrl->step = step; in __v4l2_ctrl_modify_range()
3330 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
3331 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
3332 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
3333 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3334 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
3336 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
3339 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3340 changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
3342 changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
3344 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3346 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3353 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
3355 if (ctrl == NULL) in v4l2_ctrl_add_event()
3358 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
3359 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
3360 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
3365 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
3367 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
3373 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
3379 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
3381 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
3383 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
3388 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
3390 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
3391 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
3397 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()