• Home
  • Raw
  • Download

Lines Matching refs:ctrl

40 	struct v4l2_ctrl *ctrl;  member
1222 static u32 user_flags(const struct v4l2_ctrl *ctrl) in user_flags() argument
1224 u32 flags = ctrl->flags; in user_flags()
1226 if (ctrl->is_ptr) in user_flags()
1232 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) in fill_event() argument
1236 ev->id = ctrl->id; in fill_event()
1237 ev->u.ctrl.changes = changes; in fill_event()
1238 ev->u.ctrl.type = ctrl->type; in fill_event()
1239 ev->u.ctrl.flags = user_flags(ctrl); in fill_event()
1240 if (ctrl->is_ptr) in fill_event()
1241 ev->u.ctrl.value64 = 0; in fill_event()
1243 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1244 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1245 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1246 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1247 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1248 ev->u.ctrl.step = 1; in fill_event()
1250 ev->u.ctrl.step = ctrl->step; in fill_event()
1251 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1254 static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) in send_event() argument
1259 if (list_empty(&ctrl->ev_subs)) in send_event()
1261 fill_event(&ev, ctrl, changes); in send_event()
1263 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1269 static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, in std_equal() argument
1273 switch (ctrl->type) { in std_equal()
1277 idx *= ctrl->elem_size; in std_equal()
1289 if (ctrl->is_int) in std_equal()
1291 idx *= ctrl->elem_size; in std_equal()
1292 return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); in std_equal()
1296 static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, in std_init() argument
1299 switch (ctrl->type) { in std_init()
1301 idx *= ctrl->elem_size; in std_init()
1302 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1303 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1306 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1313 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1316 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1319 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1322 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1325 idx *= ctrl->elem_size; in std_init()
1326 memset(ptr.p + idx, 0, ctrl->elem_size); in std_init()
1331 static void std_log(const struct v4l2_ctrl *ctrl) in std_log() argument
1333 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1335 if (ctrl->is_array) { in std_log()
1338 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1339 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1343 switch (ctrl->type) { in std_log()
1351 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1354 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1375 pr_cont("unknown type %d", ctrl->type); in std_log()
1385 #define ROUND_TO_RANGE(val, offset_type, ctrl) \ argument
1388 if ((ctrl)->maximum >= 0 && \
1389 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1390 val = (ctrl)->maximum; \
1392 val += (s32)((ctrl)->step / 2); \
1394 (ctrl)->minimum, (ctrl)->maximum); \
1395 offset = (val) - (ctrl)->minimum; \
1396 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1397 val = (ctrl)->minimum + offset; \
1402 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, in std_validate() argument
1409 switch (ctrl->type) { in std_validate()
1411 return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); in std_validate()
1418 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1419 val = ctrl->maximum; in std_validate()
1421 val += (s64)(ctrl->step / 2); in std_validate()
1422 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1423 offset = val - ctrl->minimum; in std_validate()
1424 do_div(offset, ctrl->step); in std_validate()
1425 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1428 return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl); in std_validate()
1430 return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl); in std_validate()
1432 return ROUND_TO_RANGE(ptr.p_u32[idx], u32, ctrl); in std_validate()
1440 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1442 if (ctrl->menu_skip_mask & (1 << ptr.p_s32[idx])) in std_validate()
1444 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1445 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1450 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
1459 idx *= ctrl->elem_size; in std_validate()
1461 if (len < ctrl->minimum) in std_validate()
1463 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
1481 struct v4l2_ctrl *ctrl, in ptr_to_user() argument
1486 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
1490 switch (ctrl->type) { in ptr_to_user()
1494 c->size = ctrl->elem_size; in ptr_to_user()
1511 struct v4l2_ctrl *ctrl) in cur_to_user() argument
1513 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
1518 struct v4l2_ctrl *ctrl) in new_to_user() argument
1520 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
1524 static int def_to_user(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) in def_to_user() argument
1528 for (idx = 0; idx < ctrl->elems; idx++) in def_to_user()
1529 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in def_to_user()
1531 return ptr_to_user(c, ctrl, ctrl->p_new); in def_to_user()
1536 struct v4l2_ctrl *ctrl, in user_to_ptr() argument
1542 ctrl->is_new = 1; in user_to_ptr()
1543 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
1547 if (ret || !ctrl->is_array) in user_to_ptr()
1549 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
1550 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
1554 switch (ctrl->type) { in user_to_ptr()
1562 if (size > ctrl->maximum + 1) in user_to_ptr()
1563 size = ctrl->maximum + 1; in user_to_ptr()
1571 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
1584 struct v4l2_ctrl *ctrl) in user_to_new() argument
1586 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
1590 static void ptr_to_ptr(struct v4l2_ctrl *ctrl, in ptr_to_ptr() argument
1593 if (ctrl == NULL) in ptr_to_ptr()
1595 memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
1599 static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in new_to_cur() argument
1603 if (ctrl == NULL) in new_to_cur()
1607 changed = ctrl->has_changed; in new_to_cur()
1609 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
1613 ctrl->flags &= in new_to_cur()
1615 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
1616 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
1617 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
1618 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
1625 if (!ctrl->is_new) in new_to_cur()
1627 send_event(fh, ctrl, in new_to_cur()
1629 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
1630 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
1635 static void cur_to_new(struct v4l2_ctrl *ctrl) in cur_to_new() argument
1637 if (ctrl == NULL) in cur_to_new()
1639 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
1651 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed() local
1654 if (ctrl == NULL) in cluster_changed()
1657 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
1664 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
1665 ctrl->has_changed = false; in cluster_changed()
1669 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
1670 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
1671 ctrl->p_cur, ctrl->p_new); in cluster_changed()
1672 ctrl->has_changed = ctrl_changed; in cluster_changed()
1673 changed |= ctrl->has_changed; in cluster_changed()
1718 static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) in validate_new() argument
1723 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
1724 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
1730 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
1763 struct v4l2_ctrl *ctrl, *next_ctrl; in v4l2_ctrl_handler_free() local
1776 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
1777 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
1778 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
1780 kfree(ctrl); in v4l2_ctrl_handler_free()
1805 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
1806 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
1807 if (!ref->ctrl->is_int) in find_private_ref()
1831 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
1836 while (ref && ref->ctrl->id != id) in find_ref()
1863 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
1869 struct v4l2_ctrl *ctrl) in handler_new_ref() argument
1873 u32 id = ctrl->id; in handler_new_ref()
1881 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
1892 new_ref->ctrl = ctrl; in handler_new_ref()
1893 if (ctrl->handler == hdl) { in handler_new_ref()
1898 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
1899 ctrl->ncontrols = 1; in handler_new_ref()
1917 if (ref->ctrl->id < id) in handler_new_ref()
1920 if (ref->ctrl->id == id) { in handler_new_ref()
1948 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new() local
2029 ctrl = kzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); in v4l2_ctrl_new()
2030 if (ctrl == NULL) { in v4l2_ctrl_new()
2035 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2036 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2037 ctrl->handler = hdl; in v4l2_ctrl_new()
2038 ctrl->ops = ops; in v4l2_ctrl_new()
2039 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2040 ctrl->id = id; in v4l2_ctrl_new()
2041 ctrl->name = name; in v4l2_ctrl_new()
2042 ctrl->type = type; in v4l2_ctrl_new()
2043 ctrl->flags = flags; in v4l2_ctrl_new()
2044 ctrl->minimum = min; in v4l2_ctrl_new()
2045 ctrl->maximum = max; in v4l2_ctrl_new()
2046 ctrl->step = step; in v4l2_ctrl_new()
2047 ctrl->default_value = def; in v4l2_ctrl_new()
2048 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2049 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2050 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2051 ctrl->is_array = is_array; in v4l2_ctrl_new()
2052 ctrl->elems = elems; in v4l2_ctrl_new()
2053 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2055 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2056 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2058 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2060 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2061 ctrl->priv = priv; in v4l2_ctrl_new()
2062 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2063 data = &ctrl[1]; in v4l2_ctrl_new()
2065 if (!ctrl->is_int) { in v4l2_ctrl_new()
2066 ctrl->p_new.p = data; in v4l2_ctrl_new()
2067 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2069 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2070 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2073 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2074 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2077 if (handler_new_ref(hdl, ctrl)) { in v4l2_ctrl_new()
2078 kfree(ctrl); in v4l2_ctrl_new()
2082 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2084 return ctrl; in v4l2_ctrl_new()
2091 struct v4l2_ctrl *ctrl; in v4l2_ctrl_new_custom() local
2120 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2125 if (ctrl) in v4l2_ctrl_new_custom()
2126 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2127 return ctrl; in v4l2_ctrl_new_custom()
2246 bool (*filter)(const struct v4l2_ctrl *ctrl)) in v4l2_ctrl_add_handler() argument
2258 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler() local
2261 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2264 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2267 if (filter && !filter(ctrl)) in v4l2_ctrl_add_handler()
2269 ret = handler_new_ref(hdl, ctrl); in v4l2_ctrl_add_handler()
2278 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) in v4l2_ctrl_radio_filter() argument
2280 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2282 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2284 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2348 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active) in v4l2_ctrl_activate() argument
2354 if (ctrl == NULL) in v4l2_ctrl_activate()
2359 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2362 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
2364 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_activate()
2374 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) in v4l2_ctrl_grab() argument
2378 if (ctrl == NULL) in v4l2_ctrl_grab()
2381 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_grab()
2384 old = test_and_set_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2387 old = test_and_clear_bit(1, &ctrl->flags); in v4l2_ctrl_grab()
2389 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); in v4l2_ctrl_grab()
2390 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_grab()
2395 static void log_ctrl(const struct v4l2_ctrl *ctrl, in log_ctrl() argument
2398 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
2400 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
2403 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
2405 ctrl->type_ops->log(ctrl); in log_ctrl()
2407 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
2410 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
2412 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
2414 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
2424 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_log_status() local
2436 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
2437 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
2438 log_ctrl(ctrl, prefix, colon); in v4l2_ctrl_handler_log_status()
2453 struct v4l2_ctrl *ctrl; in v4l2_ctrl_handler_setup() local
2459 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_setup()
2460 ctrl->done = false; in v4l2_ctrl_handler_setup()
2462 list_for_each_entry(ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_setup()
2463 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_handler_setup()
2468 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_handler_setup()
2469 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_handler_setup()
2494 struct v4l2_ctrl *ctrl; in v4l2_query_ext_ctrl() local
2527 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2528 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2529 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2541 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
2542 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
2543 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
2556 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
2561 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
2562 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
2563 qc->flags = user_flags(ctrl); in v4l2_query_ext_ctrl()
2564 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
2565 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
2566 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
2567 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
2568 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
2569 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
2570 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
2571 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
2572 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
2573 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
2576 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
2621 struct v4l2_ctrl *ctrl; in v4l2_querymenu() local
2624 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
2625 if (!ctrl) in v4l2_querymenu()
2630 switch (ctrl->type) { in v4l2_querymenu()
2632 if (ctrl->qmenu == NULL) in v4l2_querymenu()
2636 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
2643 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
2647 if (ctrl->menu_skip_mask & (1 << i)) in v4l2_querymenu()
2650 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
2651 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
2653 strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
2655 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
2715 struct v4l2_ctrl *ctrl; in prepare_ext_ctrls() local
2732 ctrl = ref->ctrl; in prepare_ext_ctrls()
2733 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) in prepare_ext_ctrls()
2736 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
2738 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
2739 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
2740 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
2741 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
2754 h->ctrl = ctrl; in prepare_ext_ctrls()
2839 if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls()
2844 struct v4l2_ctrl *ctrl); in v4l2_g_ext_ctrls()
2852 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls()
2874 helpers[idx].ctrl); in v4l2_g_ext_ctrls()
2888 static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) in get_ctrl() argument
2890 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
2898 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
2901 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
2906 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
2910 new_to_user(c, ctrl); in get_ctrl()
2912 cur_to_user(c, ctrl); in get_ctrl()
2920 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl() local
2924 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
2926 ret = get_ctrl(ctrl, &c); in v4l2_g_ctrl()
2932 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl() argument
2937 WARN_ON(!ctrl->is_int); in v4l2_ctrl_g_ctrl()
2939 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl()
2944 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl) in v4l2_ctrl_g_ctrl_int64() argument
2949 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in v4l2_ctrl_g_ctrl_int64()
2951 get_ctrl(ctrl, &c); in v4l2_ctrl_g_ctrl_int64()
2972 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster() local
2974 if (ctrl == NULL) in try_or_set_cluster()
2977 if (!ctrl->is_new) { in try_or_set_cluster()
2978 cur_to_new(ctrl); in try_or_set_cluster()
2983 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3013 struct v4l2_ctrl *ctrl = helpers[i].ctrl; in validate_ctrls() local
3018 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in validate_ctrls()
3026 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in validate_ctrls()
3032 if (ctrl->is_ptr) in validate_ctrls()
3034 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
3038 ret = validate_new(ctrl, p_new); in validate_ctrls()
3102 master = helpers[i].mref->ctrl; in try_set_ext_ctrls()
3125 if (helpers[tmp_idx].ctrl == master) in try_set_ext_ctrls()
3138 struct v4l2_ctrl *ctrl = helpers[idx].ctrl; in try_set_ext_ctrls() local
3140 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls()
3141 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls()
3142 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls()
3154 helpers[idx].ctrl); in try_set_ext_ctrls()
3180 static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) in set_ctrl() argument
3182 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
3191 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
3198 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
3199 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
3202 ctrl->is_new = 1; in set_ctrl()
3207 static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, in set_ctrl_lock() argument
3212 v4l2_ctrl_lock(ctrl); in set_ctrl_lock()
3213 user_to_new(c, ctrl); in set_ctrl_lock()
3214 ret = set_ctrl(fh, ctrl, 0); in set_ctrl_lock()
3216 cur_to_user(c, ctrl); in set_ctrl_lock()
3217 v4l2_ctrl_unlock(ctrl); in set_ctrl_lock()
3224 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl() local
3228 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
3231 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
3235 ret = set_ctrl_lock(fh, ctrl, &c); in v4l2_s_ctrl()
3241 int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) in __v4l2_ctrl_s_ctrl() argument
3243 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
3246 WARN_ON(!ctrl->is_int); in __v4l2_ctrl_s_ctrl()
3247 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
3248 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl()
3252 int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) in __v4l2_ctrl_s_ctrl_int64() argument
3254 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
3257 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); in __v4l2_ctrl_s_ctrl_int64()
3258 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
3259 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_int64()
3263 int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) in __v4l2_ctrl_s_ctrl_string() argument
3265 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
3268 WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); in __v4l2_ctrl_s_ctrl_string()
3269 strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
3270 return set_ctrl(NULL, ctrl, 0); in __v4l2_ctrl_s_ctrl_string()
3274 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) in v4l2_ctrl_notify() argument
3276 if (ctrl == NULL) in v4l2_ctrl_notify()
3279 ctrl->call_notify = 0; in v4l2_ctrl_notify()
3282 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
3284 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
3285 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
3286 ctrl->call_notify = 1; in v4l2_ctrl_notify()
3290 int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, in __v4l2_ctrl_modify_range() argument
3297 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
3299 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
3309 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
3311 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
3318 if ((ctrl->minimum != min) || (ctrl->maximum != max) || in __v4l2_ctrl_modify_range()
3319 (ctrl->step != step) || ctrl->default_value != def) { in __v4l2_ctrl_modify_range()
3321 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
3322 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
3323 ctrl->step = step; in __v4l2_ctrl_modify_range()
3324 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
3326 cur_to_new(ctrl); in __v4l2_ctrl_modify_range()
3327 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
3328 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3329 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
3331 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
3334 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
3335 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
3337 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
3339 ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3341 send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); in __v4l2_ctrl_modify_range()
3348 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event() local
3350 if (ctrl == NULL) in v4l2_ctrl_add_event()
3353 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_add_event()
3354 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
3355 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
3360 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
3362 fill_event(&ev, ctrl, changes); in v4l2_ctrl_add_event()
3368 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_add_event()
3374 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event() local
3376 v4l2_ctrl_lock(ctrl); in v4l2_ctrl_del_event()
3378 v4l2_ctrl_unlock(ctrl); in v4l2_ctrl_del_event()
3383 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
3385 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
3386 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
3392 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()