diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-05-05 09:16:49 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-17 10:57:23 -0400 |
commit | 48e393a263d3a20b27f4db9a169f4f1874777e6b (patch) | |
tree | 434a4d89d6d5ca98f24bbdbf5b97ffb2bf10444d /Documentation/DocBook | |
parent | 10fa813de336673c02d62a7b90528b50cdb6f3e7 (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.xml | 74 |
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 |
14 | several IDs for specific purposes. Drivers can also implement their | 14 | several IDs for specific purposes. Drivers can also implement their |
15 | own custom controls using <constant>V4L2_CID_PRIVATE_BASE</constant> | 15 | own custom controls using <constant>V4L2_CID_PRIVATE_BASE</constant> |
16 | <footnote><para>The use of <constant>V4L2_CID_PRIVATE_BASE</constant> | ||
17 | is problematic because different drivers may use the same | ||
18 | <constant>V4L2_CID_PRIVATE_BASE</constant> ID for different controls. | ||
19 | This makes it hard to programatically set such controls since the meaning | ||
20 | of the control with that ID is driver dependent. In order to resolve this | ||
21 | drivers use unique IDs and the <constant>V4L2_CID_PRIVATE_BASE</constant> | ||
22 | IDs are mapped to those unique IDs by the kernel. Consider these | ||
23 | <constant>V4L2_CID_PRIVATE_BASE</constant> IDs as aliases to the real | ||
24 | IDs.</para> | ||
25 | <para>Many applications today still use the <constant>V4L2_CID_PRIVATE_BASE</constant> | ||
26 | IDs instead of using &VIDIOC-QUERYCTRL; with the <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant> | ||
27 | flag to enumerate all IDs, so support for <constant>V4L2_CID_PRIVATE_BASE</constant> | ||
28 | is still around.</para></footnote> | ||
16 | and higher values. The pre-defined control IDs have the prefix | 29 | and 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 |
18 | linkend="control-id" />. The ID is used when querying the attributes of | 31 | linkend="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 | |||
31 | or output. Different in the sense of other bounds, another default and | 44 | or output. Different in the sense of other bounds, another default and |
32 | current value, step size or other menu items. A control with a certain | 45 | current 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 |
34 | type.<footnote> | 47 | type.</para> |
35 | <para>It will be more convenient for applications if drivers | 48 | |
36 | make use of the <constant>V4L2_CTRL_FLAG_DISABLED</constant> flag, but | 49 | <para>If a control is not applicable to the current configuration |
37 | that was never required.</para> | 50 | of the device (for example, it doesn't apply to the current video input) |
38 | </footnote> Control values are stored globally, they do not | 51 | drivers set the <constant>V4L2_CTRL_FLAG_INACTIVE</constant> flag.</para> |
52 | |||
53 | <para>Control values are stored globally, they do not | ||
39 | change when switching except to stay within the reported bounds. They | 54 | change when switching except to stay within the reported bounds. They |
40 | also do not change ⪚ when the device is opened or closed, when the | 55 | also do not change ⪚ when the device is opened or closed, when the |
41 | tuner radio frequency is changed or generally never without | 56 | tuner radio frequency is changed or generally never without |
42 | application request. Since V4L2 specifies no event mechanism, panel | 57 | application request.</para> |
43 | applications intended to cooperate with other panel applications (be | 58 | |
44 | they built into a larger application, as a TV viewer) may need to | 59 | <para>V4L2 specifies an event mechanism to notify applications |
45 | regularly poll control values to update their user | 60 | when controls change value (see &VIDIOC-SUBSCRIBE-EVENT;, event |
46 | interface.<footnote> | 61 | <constant>V4L2_EVENT_CTRL</constant>), panel applications might want to make |
47 | <para>Applications could call an ioctl to request events. | 62 | use of that in order to always reflect the correct control value.</para> |
48 | After another process called &VIDIOC-S-CTRL; or another ioctl changing | ||
49 | shared properties the &func-select; function would indicate | ||
50 | readability until any ioctl (querying the properties) is | ||
51 | called.</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>, | |||
434 | controls, <constant>VIDIOC_QUERYMENU</constant> when it has one or | 444 | controls, <constant>VIDIOC_QUERYMENU</constant> when it has one or |
435 | more menu type controls.</para> | 445 | more 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> | ||
516 | memset(&queryctrl, 0, sizeof(queryctrl)); | ||
517 | |||
518 | queryctrl.id = V4L2_CTRL_CLASS_USER | V4L2_CTRL_FLAG_NEXT_CTRL; | ||
519 | while (0 == ioctl(fd, &VIDIOC-QUERYCTRL;, &queryctrl)) { | ||
520 | if (V4L2_CTRL_ID2CLASS(queryctrl.id) != V4L2_CTRL_CLASS_USER) | ||
521 | break; | ||
522 | if (queryctrl.flags & 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 | } | ||
532 | if (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 |
700 | combination with <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant>. In | 736 | combination with <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant>. In |
701 | that case the old method of enumerating control should be used (see | 737 | that case the old method of enumerating control should be used (see |
702 | 1.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 |
703 | all controls, including driver-private controls.</para> | 739 | all controls, including driver-private controls.</para> |
704 | </section> | 740 | </section> |
705 | 741 | ||