Lines Matching +full:merge +full:- +full:mute
1 .. SPDX-License-Identifier: GPL-2.0
7 ------------
31 sub-device drivers.
35 ------------------------
48 Basic usage for V4L2 and sub-device drivers
49 -------------------------------------------
53 .. code-block:: c
55 #include <media/v4l2-ctrls.h>
57 1.1) Add the handler to your driver's top-level struct:
61 .. code-block:: c
71 For sub-device drivers:
73 .. code-block:: c
85 .. code-block:: c
87 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
97 .. code-block:: c
99 foo->v4l2_dev.ctrl_handler = &foo->ctrl_handler;
101 For sub-device drivers:
103 .. code-block:: c
105 foo->sd.ctrl_handler = &foo->ctrl_handler;
109 .. code-block:: c
111 v4l2_ctrl_handler_free(&foo->ctrl_handler);
117 You add non-menu controls by calling :c:func:`v4l2_ctrl_new_std`:
119 .. code-block:: c
128 .. code-block:: c
137 .. code-block:: c
147 .. code-block:: c
156 .. code-block:: c
165 .. code-block:: c
168 -2, -1, 0, 1, 2
177 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
178 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
180 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
182 v4l2_ctrl_new_std_menu(&foo->ctrl_handler, &foo_ctrl_ops,
186 v4l2_ctrl_new_int_menu(&foo->ctrl_handler, &foo_ctrl_ops,
188 ARRAY_SIZE(exp_bias_qmenu) - 1,
189 ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
191 v4l2_ctrl_new_std_menu_items(&foo->ctrl_handler, &foo_ctrl_ops,
192 V4L2_CID_TEST_PATTERN, ARRAY_SIZE(test_pattern) - 1, 0,
195 if (foo->ctrl_handler.error)
196 return v4l2_ctrl_handler_free(&foo->ctrl_handler);
214 integer menu control with driver-specific items in the menu. It differs
216 takes as the last argument an array of signed 64-bit integers that form an
228 set ctrl_handler->error to the error code. If ctrl_handler->error was already
240 .. code-block:: c
242 v4l2_ctrl_handler_setup(&foo->ctrl_handler);
251 .. code-block:: c
259 .. code-block:: c
263 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
265 switch (ctrl->id) {
267 write_reg(0x123, ctrl->val);
270 write_reg(0x456, ctrl->val);
291 Inheriting Sub-device Controls
292 ------------------------------
294 When a sub-device is registered with a V4L2 driver by calling
307 ------------------------
312 .. code-block:: c
324 .. code-block:: c
337 .. code-block:: c
339 &ctrl->val == ctrl->p_new.p_s32
340 &ctrl->cur.val == ctrl->p_cur.p_s32
342 For all other types use ctrl->p_cur.p<something>. Basically the val
347 ctrl->maximum + 1, and are always 0-terminated.
358 strength read-out that changes continuously. In that case you will need to
361 .. code-block:: c
365 switch (ctrl->id) {
367 ctrl->val = read_reg(0x123);
373 controls that need to implement g_volatile_ctrl are read-only controls. If they
379 .. code-block:: c
381 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
383 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
400 .. code-block:: c
411 .. code-block:: c
413 mutex_lock(&state->ctrl_handler.lock);
414 pr_info("String value is '%s'\n", ctrl1->p_cur.p_char);
415 pr_info("Integer value is '%s'\n", ctrl2->cur.val);
416 mutex_unlock(&state->ctrl_handler.lock);
420 -------------
424 .. code-block:: c
433 implementation where you can return -EINVAL if a certain menu item is not
448 ---------------
452 .. code-block:: c
464 ctrl = v4l2_ctrl_new_custom(&foo->ctrl_handler, &ctrl_filter, NULL);
466 The last argument is the priv pointer which can be set to driver-specific
476 ---------------------------
494 will return -EBUSY if an attempt is made to set this control. The
500 ----------------
506 .. code-block:: c
516 state->audio_cluster[AUDIO_CL_VOLUME] =
517 v4l2_ctrl_new_std(&state->ctrl_handler, ...);
518 state->audio_cluster[AUDIO_CL_MUTE] =
519 v4l2_ctrl_new_std(&state->ctrl_handler, ...);
520 v4l2_ctrl_cluster(ARRAY_SIZE(state->audio_cluster), state->audio_cluster);
530 .. code-block:: c
534 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
536 switch (ctrl->id) {
538 struct v4l2_ctrl *mute = ctrl->cluster[AUDIO_CL_MUTE];
540 write_reg(0x123, mute->val ? 0 : ctrl->val);
544 write_reg(0x456, ctrl->val);
552 .. code-block:: c
554 ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME]
555 ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE]
560 .. code-block:: c
565 struct v4l2_ctrl *mute;
572 .. code-block:: c
574 state->volume = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
575 state->mute = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
576 v4l2_ctrl_cluster(2, &state->volume);
578 And in foo_s_ctrl you can use these pointers directly: state->mute->val.
581 reason mute was never added (because the hardware doesn't support that
582 particular feature), then mute will be NULL. So in that case we have a
594 each control. For example, in the case of a volume/mute cluster the 'is_new'
595 flag of the mute control would be set if the user called VIDIOC_S_CTRL for
596 mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume
602 Handling autogain/gain-type Controls with Auto Clusters
603 -------------------------------------------------------
605 A common type of control cluster is one that handles 'auto-foo/foo'-type
628 .. code-block:: c
635 last argument will optionally set V4L2_CTRL_FLAG_VOLATILE for the non-auto controls.
648 -------------------------
658 --------------------------------------------
669 merge subdev controls.
672 manually to add the subdev's control handler (sd->ctrl_handler) to the desired
683 .. code-block:: c
697 .. code-block:: c
706 .. code-block:: c
711 This would be bad since muting the radio would not change the video mute
717 ----------------
727 .. code-block:: c
731 volume = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_AUDIO_VOLUME);
736 .. code-block:: c
745 .. code-block:: c
758 -------------------------------
762 have low-level controls that make sense for some advanced embedded system, but
763 not when it is used in consumer-level hardware. In that case you want to keep
764 those low-level controls local to the subdev. You can do this by simply
767 .. code-block:: c
779 ctrl = v4l2_ctrl_new_custom(&foo->ctrl_handler, &ctrl_private, NULL);
785 ----------------------------------
798 -----------------------
801 from a sub-device driver changes. You can set a notify callback by calling
804 .. code-block:: c
818 ---------------------------------------
820 .. kernel-doc:: include/media/v4l2-ctrls.h