Lines Matching +full:cluster +full:- +full:mode
5 ------------
28 for V4L2 drivers and struct v4l2_subdev for sub-device drivers.
32 ------------------------
44 Basic usage for V4L2 and sub-device drivers
45 -------------------------------------------
49 1.1) Add the handler to your driver's top-level struct:
51 .. code-block:: none
63 .. code-block:: none
65 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
75 .. code-block:: none
85 foo->v4l2_dev.ctrl_handler = &foo->ctrl_handler;
87 Where foo->v4l2_dev is of type struct v4l2_device.
94 1.3.2) For sub-device drivers do this:
96 .. code-block:: none
106 foo->sd.ctrl_handler = &foo->ctrl_handler;
108 Where foo->sd is of type struct v4l2_subdev.
112 .. code-block:: none
114 v4l2_ctrl_handler_free(&foo->ctrl_handler);
119 You add non-menu controls by calling v4l2_ctrl_new_std:
121 .. code-block:: none
129 .. code-block:: none
138 .. code-block:: none
148 .. code-block:: none
156 .. code-block:: none
159 -2, -1, 0, 1, 2
168 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
169 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
171 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
173 v4l2_ctrl_new_std_menu(&foo->ctrl_handler, &foo_ctrl_ops,
177 v4l2_ctrl_new_int_menu(&foo->ctrl_handler, &foo_ctrl_ops,
179 ARRAY_SIZE(exp_bias_qmenu) - 1,
180 ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
182 v4l2_ctrl_new_std_menu_items(&foo->ctrl_handler, &foo_ctrl_ops,
183 V4L2_CID_TEST_PATTERN, ARRAY_SIZE(test_pattern) - 1, 0,
186 if (foo->ctrl_handler.error) {
187 int err = foo->ctrl_handler.error;
189 v4l2_ctrl_handler_free(&foo->ctrl_handler);
209 control with driver-specific items in the menu. It differs from
211 as the last argument an array of signed 64-bit integers that form an exact
222 set ctrl_handler->error to the error code. If ctrl_handler->error was already
234 .. code-block:: none
236 v4l2_ctrl_handler_setup(&foo->ctrl_handler);
245 .. code-block:: none
253 .. code-block:: none
257 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
259 switch (ctrl->id) {
261 write_reg(0x123, ctrl->val);
264 write_reg(0x456, ctrl->val);
286 -------------------
288 When a sub-device is registered with a V4L2 driver by calling
301 ------------------------
306 .. code-block:: none
318 .. code-block:: none
331 .. code-block:: none
333 &ctrl->val == ctrl->p_new.p_s32
334 &ctrl->cur.val == ctrl->p_cur.p_s32
336 For all other types use ctrl->p_cur.p<something>. Basically the val
341 ctrl->maximum + 1, and are always 0-terminated.
352 strength read-out that changes continuously. In that case you will need to
355 .. code-block:: none
359 switch (ctrl->id) {
361 ctrl->val = read_reg(0x123);
367 controls that need to implement g_volatile_ctrl are read-only controls. If they
373 .. code-block:: none
375 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
377 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
394 .. code-block:: none
405 .. code-block:: none
407 mutex_lock(&state->ctrl_handler.lock);
408 pr_info("String value is '%s'\n", ctrl1->p_cur.p_char);
409 pr_info("Integer value is '%s'\n", ctrl2->cur.val);
410 mutex_unlock(&state->ctrl_handler.lock);
414 -------------
418 .. code-block:: none
427 implementation where you can return -EINVAL if a certain menu item is not
442 ---------------
446 .. code-block:: none
458 ctrl = v4l2_ctrl_new_custom(&foo->ctrl_handler, &ctrl_filter, NULL);
460 The last argument is the priv pointer which can be set to driver-specific
470 ---------------------------
488 will return -EBUSY if an attempt is made to set this control. The
494 ----------------
498 In that case you need to 'cluster' them:
500 .. code-block:: none
510 state->audio_cluster[AUDIO_CL_VOLUME] =
511 v4l2_ctrl_new_std(&state->ctrl_handler, ...);
512 state->audio_cluster[AUDIO_CL_MUTE] =
513 v4l2_ctrl_new_std(&state->ctrl_handler, ...);
514 v4l2_ctrl_cluster(ARRAY_SIZE(state->audio_cluster), state->audio_cluster);
517 cluster is set (or 'gotten', or 'tried'), only the control ops of the first
524 .. code-block:: none
528 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
530 switch (ctrl->id) {
532 struct v4l2_ctrl *mute = ctrl->cluster[AUDIO_CL_MUTE];
534 write_reg(0x123, mute->val ? 0 : ctrl->val);
538 write_reg(0x456, ctrl->val);
546 .. code-block:: none
548 ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME]
549 ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE]
551 In practice using cluster arrays like this becomes very tiresome. So instead
554 .. code-block:: none
557 /* audio cluster */
562 The anonymous struct is used to clearly 'cluster' these two control pointers,
566 .. code-block:: none
568 state->volume = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
569 state->mute = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
570 v4l2_ctrl_cluster(2, &state->volume);
572 And in foo_s_ctrl you can use these pointers directly: state->mute->val.
574 Note that controls in a cluster may be NULL. For example, if for some
577 cluster of 2 controls, of which only 1 is actually instantiated. The
578 only restriction is that the first control of the cluster must always be
579 present, since that is the 'master' control of the cluster. The master
580 control is the one that identifies the cluster and that provides the
581 pointer to the v4l2_ctrl_ops struct that is used for that cluster.
583 Obviously, all controls in the cluster array must be initialized to either
586 In rare cases you might want to know which controls of a cluster actually
588 each control. For example, in the case of a volume/mute cluster the 'is_new'
596 Handling autogain/gain-type Controls with Auto Clusters
597 -------------------------------------------------------
599 A common type of control cluster is one that handles 'auto-foo/foo'-type
605 If the cluster is in automatic mode, then the manual controls should be
608 mode set up automatically.
610 If the cluster is put in manual mode, then the manual controls should become
612 called while in manual mode). In addition just before switching to manual mode
613 the current values as determined by the auto mode are copied as the new manual
622 .. code-block:: none
628 tells the framework which value switches the cluster into manual mode. The
629 last argument will optionally set V4L2_CTRL_FLAG_VOLATILE for the non-auto controls.
632 determined by the auto mode (e.g. if autogain is on, the hardware doesn't allow
635 The first control of the cluster is assumed to be the 'auto' control.
642 -------------------------
652 --------------------------------------------
666 manually to add the subdev's control handler (sd->ctrl_handler) to the desired
677 .. code-block:: none
691 .. code-block:: none
700 .. code-block:: none
711 ----------------
721 .. code-block:: none
725 volume = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_AUDIO_VOLUME);
730 .. code-block:: none
739 .. code-block:: none
752 -------------------
756 have low-level controls that make sense for some advanced embedded system, but
757 not when it is used in consumer-level hardware. In that case you want to keep
758 those low-level controls local to the subdev. You can do this by simply
761 .. code-block:: none
773 ctrl = v4l2_ctrl_new_custom(&foo->ctrl_handler, &ctrl_private, NULL);
779 ----------------------------------
792 -----------------------
795 from a sub-device driver changes. You can set a notify callback by calling
798 .. code-block:: none
812 ---------------------------------------
814 .. kernel-doc:: include/media/v4l2-ctrls.h