diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-06-07 04:46:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:53:19 -0400 |
commit | c76cd635726beb3e1c73bbc4dc87e0cda48ac006 (patch) | |
tree | 018fe2459a1bb111a122eb0ab19aadbfcf474487 /Documentation | |
parent | 72d877cac07c8d996918977c3162dd78b8097ca8 (diff) |
[media] Documentation: Improve cluster documentation and document the new autoclusters
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/video4linux/v4l2-controls.txt | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt index 95a381309d08..9346fc8cbf2b 100644 --- a/Documentation/video4linux/v4l2-controls.txt +++ b/Documentation/video4linux/v4l2-controls.txt | |||
@@ -450,6 +450,25 @@ In the example above the following are equivalent for the VOLUME case: | |||
450 | ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME] | 450 | ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME] |
451 | ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE] | 451 | ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE] |
452 | 452 | ||
453 | In practice using cluster arrays like this becomes very tiresome. So instead | ||
454 | the following equivalent method is used: | ||
455 | |||
456 | struct { | ||
457 | /* audio cluster */ | ||
458 | struct v4l2_ctrl *volume; | ||
459 | struct v4l2_ctrl *mute; | ||
460 | }; | ||
461 | |||
462 | The anonymous struct is used to clearly 'cluster' these two control pointers, | ||
463 | but it serves no other purpose. The effect is the same as creating an | ||
464 | array with two control pointers. So you can just do: | ||
465 | |||
466 | state->volume = v4l2_ctrl_new_std(&state->ctrl_handler, ...); | ||
467 | state->mute = v4l2_ctrl_new_std(&state->ctrl_handler, ...); | ||
468 | v4l2_ctrl_cluster(2, &state->volume); | ||
469 | |||
470 | And in foo_s_ctrl you can use these pointers directly: state->mute->val. | ||
471 | |||
453 | Note that controls in a cluster may be NULL. For example, if for some | 472 | Note that controls in a cluster may be NULL. For example, if for some |
454 | reason mute was never added (because the hardware doesn't support that | 473 | reason mute was never added (because the hardware doesn't support that |
455 | particular feature), then mute will be NULL. So in that case we have a | 474 | particular feature), then mute will be NULL. So in that case we have a |
@@ -472,6 +491,43 @@ controls, then the 'is_new' flag would be 1 for both controls. | |||
472 | The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup(). | 491 | The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup(). |
473 | 492 | ||
474 | 493 | ||
494 | Handling autogain/gain-type Controls with Auto Clusters | ||
495 | ======================================================= | ||
496 | |||
497 | A common type of control cluster is one that handles 'auto-foo/foo'-type | ||
498 | controls. Typical examples are autogain/gain, autoexposure/exposure, | ||
499 | autowhitebalance/red balance/blue balance. In all cases you have one controls | ||
500 | that determines whether another control is handled automatically by the hardware, | ||
501 | or whether it is under manual control from the user. | ||
502 | |||
503 | If the cluster is in automatic mode, then the manual controls should be | ||
504 | marked inactive. When the volatile controls are read the g_volatile_ctrl | ||
505 | operation should return the value that the hardware's automatic mode set up | ||
506 | automatically. | ||
507 | |||
508 | If the cluster is put in manual mode, then the manual controls should become | ||
509 | active again and the is_volatile flag should be ignored (so g_volatile_ctrl is | ||
510 | no longer called while in manual mode). | ||
511 | |||
512 | Finally the V4L2_CTRL_FLAG_UPDATE should be set for the auto control since | ||
513 | changing that control affects the control flags of the manual controls. | ||
514 | |||
515 | In order to simplify this a special variation of v4l2_ctrl_cluster was | ||
516 | introduced: | ||
517 | |||
518 | void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls, | ||
519 | u8 manual_val, bool set_volatile); | ||
520 | |||
521 | The first two arguments are identical to v4l2_ctrl_cluster. The third argument | ||
522 | tells the framework which value switches the cluster into manual mode. The | ||
523 | last argument will optionally set the is_volatile flag for the non-auto controls. | ||
524 | |||
525 | The first control of the cluster is assumed to be the 'auto' control. | ||
526 | |||
527 | Using this function will ensure that you don't need to handle all the complex | ||
528 | flag and volatile handling. | ||
529 | |||
530 | |||
475 | VIDIOC_LOG_STATUS Support | 531 | VIDIOC_LOG_STATUS Support |
476 | ========================= | 532 | ========================= |
477 | 533 | ||