diff options
Diffstat (limited to 'Documentation/video4linux/v4l2-controls.txt')
-rw-r--r-- | Documentation/video4linux/v4l2-controls.txt | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt index 881e7f44491..9346fc8cbf2 100644 --- a/Documentation/video4linux/v4l2-controls.txt +++ b/Documentation/video4linux/v4l2-controls.txt | |||
@@ -277,16 +277,13 @@ implement g_volatile_ctrl like this: | |||
277 | { | 277 | { |
278 | switch (ctrl->id) { | 278 | switch (ctrl->id) { |
279 | case V4L2_CID_BRIGHTNESS: | 279 | case V4L2_CID_BRIGHTNESS: |
280 | ctrl->cur.val = read_reg(0x123); | 280 | ctrl->val = read_reg(0x123); |
281 | break; | 281 | break; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | The 'new value' union is not used in g_volatile_ctrl. In general controls | 285 | Note that you use the 'new value' union as well in g_volatile_ctrl. In general |
286 | that need to implement g_volatile_ctrl are read-only controls. | 286 | controls that need to implement g_volatile_ctrl are read-only controls. |
287 | |||
288 | Note that if one or more controls in a control cluster are marked as volatile, | ||
289 | then all the controls in the cluster are seen as volatile. | ||
290 | 287 | ||
291 | To mark a control as volatile you have to set the is_volatile flag: | 288 | To mark a control as volatile you have to set the is_volatile flag: |
292 | 289 | ||
@@ -453,6 +450,25 @@ In the example above the following are equivalent for the VOLUME case: | |||
453 | 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] |
454 | ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE] | 451 | ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE] |
455 | 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 | |||
456 | 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 |
457 | 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 |
458 | 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 |
@@ -475,6 +491,43 @@ controls, then the 'is_new' flag would be 1 for both controls. | |||
475 | 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(). |
476 | 492 | ||
477 | 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 | |||
478 | VIDIOC_LOG_STATUS Support | 531 | VIDIOC_LOG_STATUS Support |
479 | ========================= | 532 | ========================= |
480 | 533 | ||
@@ -636,9 +689,7 @@ button controls are write-only controls. | |||
636 | -EINVAL as the spec says. | 689 | -EINVAL as the spec says. |
637 | 690 | ||
638 | 5) The spec does not mention what should happen when you try to set/get a | 691 | 5) The spec does not mention what should happen when you try to set/get a |
639 | control class controls. ivtv currently returns -EINVAL (indicating that the | 692 | control class controls. The framework will return -EACCES. |
640 | control ID does not exist) while the framework will return -EACCES, which | ||
641 | makes more sense. | ||
642 | 693 | ||
643 | 694 | ||
644 | Proposals for Extensions | 695 | Proposals for Extensions |