aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-17 14:49:56 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-17 15:30:36 -0400
commit9488fed623eff249273b83503abfc8a20409f6b1 (patch)
tree3c71050ce059e20db63662d4b8d25f487d451cf2
parent4c21d4fb1b16eaaa6462e76a0eb6b70235a966ea (diff)
[media] doc-rst: move videobuf documentation to media/kapi
This document describes a kapi framework. Move it to the right place. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--Documentation/media/kapi/v4l2-controls.rst169
-rw-r--r--Documentation/media/kapi/videobuf.rst (renamed from Documentation/video4linux/videobuf)0
2 files changed, 122 insertions, 47 deletions
diff --git a/Documentation/media/kapi/v4l2-controls.rst b/Documentation/media/kapi/v4l2-controls.rst
index 5e759cab4538..8ff9ee806042 100644
--- a/Documentation/media/kapi/v4l2-controls.rst
+++ b/Documentation/media/kapi/v4l2-controls.rst
@@ -1,5 +1,8 @@
1V4L2 Controls
2=============
3
1Introduction 4Introduction
2============ 5------------
3 6
4The V4L2 control API seems simple enough, but quickly becomes very hard to 7The V4L2 control API seems simple enough, but quickly becomes very hard to
5implement correctly in drivers. But much of the code needed to handle controls 8implement correctly in drivers. But much of the code needed to handle controls
@@ -26,7 +29,7 @@ for V4L2 drivers and struct v4l2_subdev for sub-device drivers.
26 29
27 30
28Objects in the framework 31Objects in the framework
29======================== 32------------------------
30 33
31There are two main objects: 34There are two main objects:
32 35
@@ -39,12 +42,14 @@ controls, possibly to controls owned by other handlers.
39 42
40 43
41Basic usage for V4L2 and sub-device drivers 44Basic usage for V4L2 and sub-device drivers
42=========================================== 45-------------------------------------------
43 46
441) Prepare the driver: 471) Prepare the driver:
45 48
461.1) Add the handler to your driver's top-level struct: 491.1) Add the handler to your driver's top-level struct:
47 50
51.. code-block:: none
52
48 struct foo_dev { 53 struct foo_dev {
49 ... 54 ...
50 struct v4l2_ctrl_handler ctrl_handler; 55 struct v4l2_ctrl_handler ctrl_handler;
@@ -55,16 +60,20 @@ Basic usage for V4L2 and sub-device drivers
55 60
561.2) Initialize the handler: 611.2) Initialize the handler:
57 62
63.. code-block:: none
64
58 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls); 65 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
59 66
60 The second argument is a hint telling the function how many controls this 67The second argument is a hint telling the function how many controls this
61 handler is expected to handle. It will allocate a hashtable based on this 68handler is expected to handle. It will allocate a hashtable based on this
62 information. It is a hint only. 69information. It is a hint only.
63 70
641.3) Hook the control handler into the driver: 711.3) Hook the control handler into the driver:
65 72
661.3.1) For V4L2 drivers do this: 731.3.1) For V4L2 drivers do this:
67 74
75.. code-block:: none
76
68 struct foo_dev { 77 struct foo_dev {
69 ... 78 ...
70 struct v4l2_device v4l2_dev; 79 struct v4l2_device v4l2_dev;
@@ -75,15 +84,17 @@ Basic usage for V4L2 and sub-device drivers
75 84
76 foo->v4l2_dev.ctrl_handler = &foo->ctrl_handler; 85 foo->v4l2_dev.ctrl_handler = &foo->ctrl_handler;
77 86
78 Where foo->v4l2_dev is of type struct v4l2_device. 87Where foo->v4l2_dev is of type struct v4l2_device.
79 88
80 Finally, remove all control functions from your v4l2_ioctl_ops (if any): 89Finally, remove all control functions from your v4l2_ioctl_ops (if any):
81 vidioc_queryctrl, vidioc_query_ext_ctrl, vidioc_querymenu, vidioc_g_ctrl, 90vidioc_queryctrl, vidioc_query_ext_ctrl, vidioc_querymenu, vidioc_g_ctrl,
82 vidioc_s_ctrl, vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls. 91vidioc_s_ctrl, vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
83 Those are now no longer needed. 92Those are now no longer needed.
84 93
851.3.2) For sub-device drivers do this: 941.3.2) For sub-device drivers do this:
86 95
96.. code-block:: none
97
87 struct foo_dev { 98 struct foo_dev {
88 ... 99 ...
89 struct v4l2_subdev sd; 100 struct v4l2_subdev sd;
@@ -94,10 +105,12 @@ Basic usage for V4L2 and sub-device drivers
94 105
95 foo->sd.ctrl_handler = &foo->ctrl_handler; 106 foo->sd.ctrl_handler = &foo->ctrl_handler;
96 107
97 Where foo->sd is of type struct v4l2_subdev. 108Where foo->sd is of type struct v4l2_subdev.
98 109
99 And set all core control ops in your struct v4l2_subdev_core_ops to these 110And set all core control ops in your struct v4l2_subdev_core_ops to these
100 helpers: 111helpers:
112
113.. code-block:: none
101 114
102 .queryctrl = v4l2_subdev_queryctrl, 115 .queryctrl = v4l2_subdev_queryctrl,
103 .querymenu = v4l2_subdev_querymenu, 116 .querymenu = v4l2_subdev_querymenu,
@@ -107,12 +120,14 @@ Basic usage for V4L2 and sub-device drivers
107 .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, 120 .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
108 .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, 121 .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
109 122
110 Note: this is a temporary solution only. Once all V4L2 drivers that depend 123Note: this is a temporary solution only. Once all V4L2 drivers that depend
111 on subdev drivers are converted to the control framework these helpers will 124on subdev drivers are converted to the control framework these helpers will
112 no longer be needed. 125no longer be needed.
113 126
1141.4) Clean up the handler at the end: 1271.4) Clean up the handler at the end:
115 128
129.. code-block:: none
130
116 v4l2_ctrl_handler_free(&foo->ctrl_handler); 131 v4l2_ctrl_handler_free(&foo->ctrl_handler);
117 132
118 133
@@ -120,12 +135,16 @@ Basic usage for V4L2 and sub-device drivers
120 135
121You add non-menu controls by calling v4l2_ctrl_new_std: 136You add non-menu controls by calling v4l2_ctrl_new_std:
122 137
138.. code-block:: none
139
123 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, 140 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
124 const struct v4l2_ctrl_ops *ops, 141 const struct v4l2_ctrl_ops *ops,
125 u32 id, s32 min, s32 max, u32 step, s32 def); 142 u32 id, s32 min, s32 max, u32 step, s32 def);
126 143
127Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu: 144Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu:
128 145
146.. code-block:: none
147
129 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, 148 struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
130 const struct v4l2_ctrl_ops *ops, 149 const struct v4l2_ctrl_ops *ops,
131 u32 id, s32 max, s32 skip_mask, s32 def); 150 u32 id, s32 max, s32 skip_mask, s32 def);
@@ -133,6 +152,8 @@ Menu and integer menu controls are added by calling v4l2_ctrl_new_std_menu:
133Menu controls with a driver specific menu are added by calling 152Menu controls with a driver specific menu are added by calling
134v4l2_ctrl_new_std_menu_items: 153v4l2_ctrl_new_std_menu_items:
135 154
155.. code-block:: none
156
136 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items( 157 struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
137 struct v4l2_ctrl_handler *hdl, 158 struct v4l2_ctrl_handler *hdl,
138 const struct v4l2_ctrl_ops *ops, u32 id, s32 max, 159 const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
@@ -141,12 +162,16 @@ v4l2_ctrl_new_std_menu_items:
141Integer menu controls with a driver specific menu can be added by calling 162Integer menu controls with a driver specific menu can be added by calling
142v4l2_ctrl_new_int_menu: 163v4l2_ctrl_new_int_menu:
143 164
165.. code-block:: none
166
144 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, 167 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
145 const struct v4l2_ctrl_ops *ops, 168 const struct v4l2_ctrl_ops *ops,
146 u32 id, s32 max, s32 def, const s64 *qmenu_int); 169 u32 id, s32 max, s32 def, const s64 *qmenu_int);
147 170
148These functions are typically called right after the v4l2_ctrl_handler_init: 171These functions are typically called right after the v4l2_ctrl_handler_init:
149 172
173.. code-block:: none
174
150 static const s64 exp_bias_qmenu[] = { 175 static const s64 exp_bias_qmenu[] = {
151 -2, -1, 0, 1, 2 176 -2, -1, 0, 1, 2
152 }; 177 };
@@ -223,6 +248,8 @@ a bit faster that way.
223 248
2243) Optionally force initial control setup: 2493) Optionally force initial control setup:
225 250
251.. code-block:: none
252
226 v4l2_ctrl_handler_setup(&foo->ctrl_handler); 253 v4l2_ctrl_handler_setup(&foo->ctrl_handler);
227 254
228This will call s_ctrl for all controls unconditionally. Effectively this 255This will call s_ctrl for all controls unconditionally. Effectively this
@@ -232,12 +259,16 @@ the hardware are in sync.
232 259
2334) Finally: implement the v4l2_ctrl_ops 2604) Finally: implement the v4l2_ctrl_ops
234 261
262.. code-block:: none
263
235 static const struct v4l2_ctrl_ops foo_ctrl_ops = { 264 static const struct v4l2_ctrl_ops foo_ctrl_ops = {
236 .s_ctrl = foo_s_ctrl, 265 .s_ctrl = foo_s_ctrl,
237 }; 266 };
238 267
239Usually all you need is s_ctrl: 268Usually all you need is s_ctrl:
240 269
270.. code-block:: none
271
241 static int foo_s_ctrl(struct v4l2_ctrl *ctrl) 272 static int foo_s_ctrl(struct v4l2_ctrl *ctrl)
242 { 273 {
243 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler); 274 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
@@ -262,16 +293,14 @@ to do any validation of control values, or implement QUERYCTRL, QUERY_EXT_CTRL
262and QUERYMENU. And G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically supported. 293and QUERYMENU. And G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically supported.
263 294
264 295
265============================================================================== 296.. note::
266 297
267The remainder of this document deals with more advanced topics and scenarios. 298 The remainder sections deal with more advanced controls topics and scenarios.
268In practice the basic usage as described above is sufficient for most drivers. 299 In practice the basic usage as described above is sufficient for most drivers.
269
270===============================================================================
271 300
272 301
273Inheriting Controls 302Inheriting Controls
274=================== 303-------------------
275 304
276When a sub-device is registered with a V4L2 driver by calling 305When a sub-device is registered with a V4L2 driver by calling
277v4l2_device_register_subdev() and the ctrl_handler fields of both v4l2_subdev 306v4l2_device_register_subdev() and the ctrl_handler fields of both v4l2_subdev
@@ -286,21 +315,25 @@ of v4l2_device.
286 315
287 316
288Accessing Control Values 317Accessing Control Values
289======================== 318------------------------
290 319
291The following union is used inside the control framework to access control 320The following union is used inside the control framework to access control
292values: 321values:
293 322
294union v4l2_ctrl_ptr { 323.. code-block:: none
295 s32 *p_s32; 324
296 s64 *p_s64; 325 union v4l2_ctrl_ptr {
297 char *p_char; 326 s32 *p_s32;
298 void *p; 327 s64 *p_s64;
299}; 328 char *p_char;
329 void *p;
330 };
300 331
301The v4l2_ctrl struct contains these fields that can be used to access both 332The v4l2_ctrl struct contains these fields that can be used to access both
302current and new values: 333current and new values:
303 334
335.. code-block:: none
336
304 s32 val; 337 s32 val;
305 struct { 338 struct {
306 s32 val; 339 s32 val;
@@ -312,6 +345,8 @@ current and new values:
312 345
313If the control has a simple s32 type type, then: 346If the control has a simple s32 type type, then:
314 347
348.. code-block:: none
349
315 &ctrl->val == ctrl->p_new.p_s32 350 &ctrl->val == ctrl->p_new.p_s32
316 &ctrl->cur.val == ctrl->p_cur.p_s32 351 &ctrl->cur.val == ctrl->p_cur.p_s32
317 352
@@ -334,6 +369,8 @@ exception is for controls that return a volatile register such as a signal
334strength read-out that changes continuously. In that case you will need to 369strength read-out that changes continuously. In that case you will need to
335implement g_volatile_ctrl like this: 370implement g_volatile_ctrl like this:
336 371
372.. code-block:: none
373
337 static int foo_g_volatile_ctrl(struct v4l2_ctrl *ctrl) 374 static int foo_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
338 { 375 {
339 switch (ctrl->id) { 376 switch (ctrl->id) {
@@ -350,6 +387,8 @@ changes.
350 387
351To mark a control as volatile you have to set V4L2_CTRL_FLAG_VOLATILE: 388To mark a control as volatile you have to set V4L2_CTRL_FLAG_VOLATILE:
352 389
390.. code-block:: none
391
353 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...); 392 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...);
354 if (ctrl) 393 if (ctrl)
355 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; 394 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
@@ -369,6 +408,8 @@ not to introduce deadlocks.
369Outside of the control ops you have to go through to helper functions to get 408Outside of the control ops you have to go through to helper functions to get
370or set a single control value safely in your driver: 409or set a single control value safely in your driver:
371 410
411.. code-block:: none
412
372 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); 413 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
373 int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); 414 int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
374 415
@@ -378,6 +419,8 @@ will result in a deadlock since these helpers lock the handler as well.
378 419
379You can also take the handler lock yourself: 420You can also take the handler lock yourself:
380 421
422.. code-block:: none
423
381 mutex_lock(&state->ctrl_handler.lock); 424 mutex_lock(&state->ctrl_handler.lock);
382 pr_info("String value is '%s'\n", ctrl1->p_cur.p_char); 425 pr_info("String value is '%s'\n", ctrl1->p_cur.p_char);
383 pr_info("Integer value is '%s'\n", ctrl2->cur.val); 426 pr_info("Integer value is '%s'\n", ctrl2->cur.val);
@@ -385,10 +428,12 @@ You can also take the handler lock yourself:
385 428
386 429
387Menu Controls 430Menu Controls
388============= 431-------------
389 432
390The v4l2_ctrl struct contains this union: 433The v4l2_ctrl struct contains this union:
391 434
435.. code-block:: none
436
392 union { 437 union {
393 u32 step; 438 u32 step;
394 u32 menu_skip_mask; 439 u32 menu_skip_mask;
@@ -411,10 +456,12 @@ control, or by calling v4l2_ctrl_new_std_menu().
411 456
412 457
413Custom Controls 458Custom Controls
414=============== 459---------------
415 460
416Driver specific controls can be created using v4l2_ctrl_new_custom(): 461Driver specific controls can be created using v4l2_ctrl_new_custom():
417 462
463.. code-block:: none
464
418 static const struct v4l2_ctrl_config ctrl_filter = { 465 static const struct v4l2_ctrl_config ctrl_filter = {
419 .ops = &ctrl_custom_ops, 466 .ops = &ctrl_custom_ops,
420 .id = V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER, 467 .id = V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER,
@@ -437,7 +484,7 @@ control and will fill in the name, type and flags fields accordingly.
437 484
438 485
439Active and Grabbed Controls 486Active and Grabbed Controls
440=========================== 487---------------------------
441 488
442If you get more complex relationships between controls, then you may have to 489If you get more complex relationships between controls, then you may have to
443activate and deactivate controls. For example, if the Chroma AGC control is 490activate and deactivate controls. For example, if the Chroma AGC control is
@@ -461,16 +508,18 @@ starts or stops streaming.
461 508
462 509
463Control Clusters 510Control Clusters
464================ 511----------------
465 512
466By default all controls are independent from the others. But in more 513By default all controls are independent from the others. But in more
467complex scenarios you can get dependencies from one control to another. 514complex scenarios you can get dependencies from one control to another.
468In that case you need to 'cluster' them: 515In that case you need to 'cluster' them:
469 516
517.. code-block:: none
518
470 struct foo { 519 struct foo {
471 struct v4l2_ctrl_handler ctrl_handler; 520 struct v4l2_ctrl_handler ctrl_handler;
472#define AUDIO_CL_VOLUME (0) 521 #define AUDIO_CL_VOLUME (0)
473#define AUDIO_CL_MUTE (1) 522 #define AUDIO_CL_MUTE (1)
474 struct v4l2_ctrl *audio_cluster[2]; 523 struct v4l2_ctrl *audio_cluster[2];
475 ... 524 ...
476 }; 525 };
@@ -489,6 +538,8 @@ composite control. Similar to how a 'struct' works in C.
489So when s_ctrl is called with V4L2_CID_AUDIO_VOLUME as argument, you should set 538So when s_ctrl is called with V4L2_CID_AUDIO_VOLUME as argument, you should set
490all two controls belonging to the audio_cluster: 539all two controls belonging to the audio_cluster:
491 540
541.. code-block:: none
542
492 static int foo_s_ctrl(struct v4l2_ctrl *ctrl) 543 static int foo_s_ctrl(struct v4l2_ctrl *ctrl)
493 { 544 {
494 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler); 545 struct foo *state = container_of(ctrl->handler, struct foo, ctrl_handler);
@@ -509,12 +560,16 @@ all two controls belonging to the audio_cluster:
509 560
510In the example above the following are equivalent for the VOLUME case: 561In the example above the following are equivalent for the VOLUME case:
511 562
563.. code-block:: none
564
512 ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME] 565 ctrl == ctrl->cluster[AUDIO_CL_VOLUME] == state->audio_cluster[AUDIO_CL_VOLUME]
513 ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE] 566 ctrl->cluster[AUDIO_CL_MUTE] == state->audio_cluster[AUDIO_CL_MUTE]
514 567
515In practice using cluster arrays like this becomes very tiresome. So instead 568In practice using cluster arrays like this becomes very tiresome. So instead
516the following equivalent method is used: 569the following equivalent method is used:
517 570
571.. code-block:: none
572
518 struct { 573 struct {
519 /* audio cluster */ 574 /* audio cluster */
520 struct v4l2_ctrl *volume; 575 struct v4l2_ctrl *volume;
@@ -525,6 +580,8 @@ The anonymous struct is used to clearly 'cluster' these two control pointers,
525but it serves no other purpose. The effect is the same as creating an 580but it serves no other purpose. The effect is the same as creating an
526array with two control pointers. So you can just do: 581array with two control pointers. So you can just do:
527 582
583.. code-block:: none
584
528 state->volume = v4l2_ctrl_new_std(&state->ctrl_handler, ...); 585 state->volume = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
529 state->mute = v4l2_ctrl_new_std(&state->ctrl_handler, ...); 586 state->mute = v4l2_ctrl_new_std(&state->ctrl_handler, ...);
530 v4l2_ctrl_cluster(2, &state->volume); 587 v4l2_ctrl_cluster(2, &state->volume);
@@ -554,7 +611,7 @@ The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup().
554 611
555 612
556Handling autogain/gain-type Controls with Auto Clusters 613Handling autogain/gain-type Controls with Auto Clusters
557======================================================= 614-------------------------------------------------------
558 615
559A common type of control cluster is one that handles 'auto-foo/foo'-type 616A common type of control cluster is one that handles 'auto-foo/foo'-type
560controls. Typical examples are autogain/gain, autoexposure/exposure, 617controls. Typical examples are autogain/gain, autoexposure/exposure,
@@ -579,8 +636,10 @@ changing that control affects the control flags of the manual controls.
579In order to simplify this a special variation of v4l2_ctrl_cluster was 636In order to simplify this a special variation of v4l2_ctrl_cluster was
580introduced: 637introduced:
581 638
582void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls, 639.. code-block:: none
583 u8 manual_val, bool set_volatile); 640
641 void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
642 u8 manual_val, bool set_volatile);
584 643
585The first two arguments are identical to v4l2_ctrl_cluster. The third argument 644The first two arguments are identical to v4l2_ctrl_cluster. The third argument
586tells the framework which value switches the cluster into manual mode. The 645tells the framework which value switches the cluster into manual mode. The
@@ -597,7 +656,7 @@ flag and volatile handling.
597 656
598 657
599VIDIOC_LOG_STATUS Support 658VIDIOC_LOG_STATUS Support
600========================= 659-------------------------
601 660
602This ioctl allow you to dump the current status of a driver to the kernel log. 661This ioctl allow you to dump the current status of a driver to the kernel log.
603The v4l2_ctrl_handler_log_status(ctrl_handler, prefix) can be used to dump the 662The v4l2_ctrl_handler_log_status(ctrl_handler, prefix) can be used to dump the
@@ -607,7 +666,7 @@ for you.
607 666
608 667
609Different Handlers for Different Video Nodes 668Different Handlers for Different Video Nodes
610============================================ 669--------------------------------------------
611 670
612Usually the V4L2 driver has just one control handler that is global for 671Usually the V4L2 driver has just one control handler that is global for
613all video nodes. But you can also specify different control handlers for 672all video nodes. But you can also specify different control handlers for
@@ -632,6 +691,8 @@ of another handler (e.g. for a video device node), then you should first add
632the controls to the first handler, add the other controls to the second 691the controls to the first handler, add the other controls to the second
633handler and finally add the first handler to the second. For example: 692handler and finally add the first handler to the second. For example:
634 693
694.. code-block:: none
695
635 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_VOLUME, ...); 696 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_VOLUME, ...);
636 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...); 697 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...);
637 v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...); 698 v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...);
@@ -644,6 +705,8 @@ all controls.
644 705
645Or you can add specific controls to a handler: 706Or you can add specific controls to a handler:
646 707
708.. code-block:: none
709
647 volume = v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_AUDIO_VOLUME, ...); 710 volume = v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_AUDIO_VOLUME, ...);
648 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_BRIGHTNESS, ...); 711 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_BRIGHTNESS, ...);
649 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_CONTRAST, ...); 712 v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_CONTRAST, ...);
@@ -651,6 +714,8 @@ Or you can add specific controls to a handler:
651What you should not do is make two identical controls for two handlers. 714What you should not do is make two identical controls for two handlers.
652For example: 715For example:
653 716
717.. code-block:: none
718
654 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...); 719 v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...);
655 v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_AUDIO_MUTE, ...); 720 v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_AUDIO_MUTE, ...);
656 721
@@ -660,7 +725,7 @@ can twiddle.
660 725
661 726
662Finding Controls 727Finding Controls
663================ 728----------------
664 729
665Normally you have created the controls yourself and you can store the struct 730Normally you have created the controls yourself and you can store the struct
666v4l2_ctrl pointer into your own struct. 731v4l2_ctrl pointer into your own struct.
@@ -670,6 +735,8 @@ not own. For example, if you have to find a volume control from a subdev.
670 735
671You can do that by calling v4l2_ctrl_find: 736You can do that by calling v4l2_ctrl_find:
672 737
738.. code-block:: none
739
673 struct v4l2_ctrl *volume; 740 struct v4l2_ctrl *volume;
674 741
675 volume = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_AUDIO_VOLUME); 742 volume = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_AUDIO_VOLUME);
@@ -677,6 +744,8 @@ You can do that by calling v4l2_ctrl_find:
677Since v4l2_ctrl_find will lock the handler you have to be careful where you 744Since v4l2_ctrl_find will lock the handler you have to be careful where you
678use it. For example, this is not a good idea: 745use it. For example, this is not a good idea:
679 746
747.. code-block:: none
748
680 struct v4l2_ctrl_handler ctrl_handler; 749 struct v4l2_ctrl_handler ctrl_handler;
681 750
682 v4l2_ctrl_new_std(&ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...); 751 v4l2_ctrl_new_std(&ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...);
@@ -684,6 +753,8 @@ use it. For example, this is not a good idea:
684 753
685...and in video_ops.s_ctrl: 754...and in video_ops.s_ctrl:
686 755
756.. code-block:: none
757
687 case V4L2_CID_BRIGHTNESS: 758 case V4L2_CID_BRIGHTNESS:
688 contrast = v4l2_find_ctrl(&ctrl_handler, V4L2_CID_CONTRAST); 759 contrast = v4l2_find_ctrl(&ctrl_handler, V4L2_CID_CONTRAST);
689 ... 760 ...
@@ -695,7 +766,7 @@ It is recommended not to use this function from inside the control ops.
695 766
696 767
697Inheriting Controls 768Inheriting Controls
698=================== 769-------------------
699 770
700When one control handler is added to another using v4l2_ctrl_add_handler, then 771When one control handler is added to another using v4l2_ctrl_add_handler, then
701by default all controls from one are merged to the other. But a subdev might 772by default all controls from one are merged to the other. But a subdev might
@@ -704,6 +775,8 @@ not when it is used in consumer-level hardware. In that case you want to keep
704those low-level controls local to the subdev. You can do this by simply 775those low-level controls local to the subdev. You can do this by simply
705setting the 'is_private' flag of the control to 1: 776setting the 'is_private' flag of the control to 1:
706 777
778.. code-block:: none
779
707 static const struct v4l2_ctrl_config ctrl_private = { 780 static const struct v4l2_ctrl_config ctrl_private = {
708 .ops = &ctrl_custom_ops, 781 .ops = &ctrl_custom_ops,
709 .id = V4L2_CID_..., 782 .id = V4L2_CID_...,
@@ -720,7 +793,7 @@ These controls will now be skipped when v4l2_ctrl_add_handler is called.
720 793
721 794
722V4L2_CTRL_TYPE_CTRL_CLASS Controls 795V4L2_CTRL_TYPE_CTRL_CLASS Controls
723================================== 796----------------------------------
724 797
725Controls of this type can be used by GUIs to get the name of the control class. 798Controls of this type can be used by GUIs to get the name of the control class.
726A fully featured GUI can make a dialog with multiple tabs with each tab 799A fully featured GUI can make a dialog with multiple tabs with each tab
@@ -733,14 +806,16 @@ class is added.
733 806
734 807
735Adding Notify Callbacks 808Adding Notify Callbacks
736======================= 809-----------------------
737 810
738Sometimes the platform or bridge driver needs to be notified when a control 811Sometimes the platform or bridge driver needs to be notified when a control
739from a sub-device driver changes. You can set a notify callback by calling 812from a sub-device driver changes. You can set a notify callback by calling
740this function: 813this function:
741 814
742void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, 815.. code-block:: none
743 void (*notify)(struct v4l2_ctrl *ctrl, void *priv), void *priv); 816
817 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl,
818 void (*notify)(struct v4l2_ctrl *ctrl, void *priv), void *priv);
744 819
745Whenever the give control changes value the notify callback will be called 820Whenever the give control changes value the notify callback will be called
746with a pointer to the control and the priv pointer that was passed with 821with a pointer to the control and the priv pointer that was passed with
diff --git a/Documentation/video4linux/videobuf b/Documentation/media/kapi/videobuf.rst
index 3ffe9e960b6f..3ffe9e960b6f 100644
--- a/Documentation/video4linux/videobuf
+++ b/Documentation/media/kapi/videobuf.rst