aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-05-05 09:16:49 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-17 10:57:23 -0400
commit48e393a263d3a20b27f4db9a169f4f1874777e6b (patch)
tree434a4d89d6d5ca98f24bbdbf5b97ffb2bf10444d /Documentation/DocBook
parent10fa813de336673c02d62a7b90528b50cdb6f3e7 (diff)
[media] DocBook media: improve control section
Improve the control section: - Clarify the handling of private controls - Explain the V4L2_CTRL_FLAG_INACTIVE flag - Remove obsolete text regarding missing control event (we have them today) and the incorrect V4L2_CTRL_FLAG_DISABLED reference. - Add a code example on how to enumerate over user controls. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r--Documentation/DocBook/media/v4l/controls.xml74
1 files changed, 55 insertions, 19 deletions
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 00cf0a719a35..73bae134a3a1 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -13,6 +13,19 @@ correctly with any device.</para>
13 <para>All controls are accessed using an ID value. V4L2 defines 13 <para>All controls are accessed using an ID value. V4L2 defines
14several IDs for specific purposes. Drivers can also implement their 14several IDs for specific purposes. Drivers can also implement their
15own custom controls using <constant>V4L2_CID_PRIVATE_BASE</constant> 15own custom controls using <constant>V4L2_CID_PRIVATE_BASE</constant>
16<footnote><para>The use of <constant>V4L2_CID_PRIVATE_BASE</constant>
17is problematic because different drivers may use the same
18<constant>V4L2_CID_PRIVATE_BASE</constant> ID for different controls.
19This makes it hard to programatically set such controls since the meaning
20of the control with that ID is driver dependent. In order to resolve this
21drivers use unique IDs and the <constant>V4L2_CID_PRIVATE_BASE</constant>
22IDs are mapped to those unique IDs by the kernel. Consider these
23<constant>V4L2_CID_PRIVATE_BASE</constant> IDs as aliases to the real
24IDs.</para>
25<para>Many applications today still use the <constant>V4L2_CID_PRIVATE_BASE</constant>
26IDs instead of using &VIDIOC-QUERYCTRL; with the <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant>
27flag to enumerate all IDs, so support for <constant>V4L2_CID_PRIVATE_BASE</constant>
28is still around.</para></footnote>
16and higher values. The pre-defined control IDs have the prefix 29and higher values. The pre-defined control IDs have the prefix
17<constant>V4L2_CID_</constant>, and are listed in <xref 30<constant>V4L2_CID_</constant>, and are listed in <xref
18linkend="control-id" />. The ID is used when querying the attributes of 31linkend="control-id" />. The ID is used when querying the attributes of
@@ -31,25 +44,22 @@ the current video input or output, tuner or modulator, or audio input
31or output. Different in the sense of other bounds, another default and 44or output. Different in the sense of other bounds, another default and
32current value, step size or other menu items. A control with a certain 45current value, step size or other menu items. A control with a certain
33<emphasis>custom</emphasis> ID can also change name and 46<emphasis>custom</emphasis> ID can also change name and
34type.<footnote> 47type.</para>
35 <para>It will be more convenient for applications if drivers 48
36make use of the <constant>V4L2_CTRL_FLAG_DISABLED</constant> flag, but 49 <para>If a control is not applicable to the current configuration
37that was never required.</para> 50of the device (for example, it doesn't apply to the current video input)
38 </footnote> Control values are stored globally, they do not 51drivers set the <constant>V4L2_CTRL_FLAG_INACTIVE</constant> flag.</para>
52
53 <para>Control values are stored globally, they do not
39change when switching except to stay within the reported bounds. They 54change when switching except to stay within the reported bounds. They
40also do not change &eg; when the device is opened or closed, when the 55also do not change &eg; when the device is opened or closed, when the
41tuner radio frequency is changed or generally never without 56tuner radio frequency is changed or generally never without
42application request. Since V4L2 specifies no event mechanism, panel 57application request.</para>
43applications intended to cooperate with other panel applications (be 58
44they built into a larger application, as a TV viewer) may need to 59 <para>V4L2 specifies an event mechanism to notify applications
45regularly poll control values to update their user 60when controls change value (see &VIDIOC-SUBSCRIBE-EVENT;, event
46interface.<footnote> 61<constant>V4L2_EVENT_CTRL</constant>), panel applications might want to make
47 <para>Applications could call an ioctl to request events. 62use of that in order to always reflect the correct control value.</para>
48After another process called &VIDIOC-S-CTRL; or another ioctl changing
49shared properties the &func-select; function would indicate
50readability until any ioctl (querying the properties) is
51called.</para>
52 </footnote></para>
53 63
54 <para> 64 <para>
55 All controls use machine endianness. 65 All controls use machine endianness.
@@ -434,8 +444,8 @@ Drivers must implement <constant>VIDIOC_QUERYCTRL</constant>,
434controls, <constant>VIDIOC_QUERYMENU</constant> when it has one or 444controls, <constant>VIDIOC_QUERYMENU</constant> when it has one or
435more menu type controls.</para> 445more menu type controls.</para>
436 446
437 <example> 447 <example id="enum_all_controls">
438 <title>Enumerating all controls</title> 448 <title>Enumerating all user controls</title>
439 449
440 <programlisting> 450 <programlisting>
441&v4l2-queryctrl; queryctrl; 451&v4l2-queryctrl; queryctrl;
@@ -501,6 +511,32 @@ for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;
501 </example> 511 </example>
502 512
503 <example> 513 <example>
514 <title>Enumerating all user controls (alternative)</title>
515 <programlisting>
516memset(&amp;queryctrl, 0, sizeof(queryctrl));
517
518queryctrl.id = V4L2_CTRL_CLASS_USER | V4L2_CTRL_FLAG_NEXT_CTRL;
519while (0 == ioctl(fd, &VIDIOC-QUERYCTRL;, &amp;queryctrl)) {
520 if (V4L2_CTRL_ID2CLASS(queryctrl.id) != V4L2_CTRL_CLASS_USER)
521 break;
522 if (queryctrl.flags &amp; V4L2_CTRL_FLAG_DISABLED)
523 continue;
524
525 printf("Control %s\n", queryctrl.name);
526
527 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
528 enumerate_menu();
529
530 queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
531}
532if (errno != EINVAL) {
533 perror("VIDIOC_QUERYCTRL");
534 exit(EXIT_FAILURE);
535}
536</programlisting>
537 </example>
538
539 <example>
504 <title>Changing controls</title> 540 <title>Changing controls</title>
505 541
506 <programlisting> 542 <programlisting>
@@ -699,7 +735,7 @@ ID based on a control ID.</para>
699<constant>VIDIOC_QUERYCTRL</constant> will fail when used in 735<constant>VIDIOC_QUERYCTRL</constant> will fail when used in
700combination with <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant>. In 736combination with <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant>. In
701that case the old method of enumerating control should be used (see 737that case the old method of enumerating control should be used (see
7021.8). But if it is supported, then it is guaranteed to enumerate over 738<xref linkend="enum_all_controls" />). But if it is supported, then it is guaranteed to enumerate over
703all controls, including driver-private controls.</para> 739all controls, including driver-private controls.</para>
704 </section> 740 </section>
705 741