Merge tag 'mailbox-v4.21' of git://git.linaro.org/landing-teams/working/fujitsu/integ...
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / vidioc-enum-frameintervals.rst
1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 .. _VIDIOC_ENUM_FRAMEINTERVALS:
11
12 ********************************
13 ioctl VIDIOC_ENUM_FRAMEINTERVALS
14 ********************************
15
16 Name
17 ====
18
19 VIDIOC_ENUM_FRAMEINTERVALS - Enumerate frame intervals
20
21
22 Synopsis
23 ========
24
25 .. c:function:: int ioctl( int fd, VIDIOC_ENUM_FRAMEINTERVALS, struct v4l2_frmivalenum *argp )
26     :name: VIDIOC_ENUM_FRAMEINTERVALS
27
28
29 Arguments
30 =========
31
32 ``fd``
33     File descriptor returned by :ref:`open() <func-open>`.
34
35 ``argp``
36     Pointer to struct :c:type:`v4l2_frmivalenum`
37     that contains a pixel format and size and receives a frame interval.
38
39
40 Description
41 ===========
42
43 This ioctl allows applications to enumerate all frame intervals that the
44 device supports for the given pixel format and frame size.
45
46 The supported pixel formats and frame sizes can be obtained by using the
47 :ref:`VIDIOC_ENUM_FMT` and
48 :ref:`VIDIOC_ENUM_FRAMESIZES` functions.
49
50 The return value and the content of the ``v4l2_frmivalenum.type`` field
51 depend on the type of frame intervals the device supports. Here are the
52 semantics of the function for the different cases:
53
54 -  **Discrete:** The function returns success if the given index value
55    (zero-based) is valid. The application should increase the index by
56    one for each call until ``EINVAL`` is returned. The
57    `v4l2_frmivalenum.type` field is set to
58    `V4L2_FRMIVAL_TYPE_DISCRETE` by the driver. Of the union only
59    the `discrete` member is valid.
60
61 -  **Step-wise:** The function returns success if the given index value
62    is zero and ``EINVAL`` for any other index value. The
63    ``v4l2_frmivalenum.type`` field is set to
64    ``V4L2_FRMIVAL_TYPE_STEPWISE`` by the driver. Of the union only the
65    ``stepwise`` member is valid.
66
67 -  **Continuous:** This is a special case of the step-wise type above.
68    The function returns success if the given index value is zero and
69    ``EINVAL`` for any other index value. The ``v4l2_frmivalenum.type``
70    field is set to ``V4L2_FRMIVAL_TYPE_CONTINUOUS`` by the driver. Of
71    the union only the ``stepwise`` member is valid and the ``step``
72    value is set to 1.
73
74 When the application calls the function with index zero, it must check
75 the ``type`` field to determine the type of frame interval enumeration
76 the device supports. Only for the ``V4L2_FRMIVAL_TYPE_DISCRETE`` type
77 does it make sense to increase the index value to receive more frame
78 intervals.
79
80 .. note::
81
82    The order in which the frame intervals are returned has no
83    special meaning. In particular does it not say anything about potential
84    default frame intervals.
85
86 Applications can assume that the enumeration data does not change
87 without any interaction from the application itself. This means that the
88 enumeration data is consistent if the application does not perform any
89 other ioctl calls while it runs the frame interval enumeration.
90
91 .. note::
92
93    **Frame intervals and frame rates:** The V4L2 API uses frame
94    intervals instead of frame rates. Given the frame interval the frame
95    rate can be computed as follows:
96
97    ::
98
99        frame_rate = 1 / frame_interval
100
101
102 Structs
103 =======
104
105 In the structs below, *IN* denotes a value that has to be filled in by
106 the application, *OUT* denotes values that the driver fills in. The
107 application should zero out all members except for the *IN* fields.
108
109
110 .. c:type:: v4l2_frmival_stepwise
111
112 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
113
114 .. flat-table:: struct v4l2_frmival_stepwise
115     :header-rows:  0
116     :stub-columns: 0
117     :widths:       1 1 2
118
119     * - struct :c:type:`v4l2_fract`
120       - ``min``
121       - Minimum frame interval [s].
122     * - struct :c:type:`v4l2_fract`
123       - ``max``
124       - Maximum frame interval [s].
125     * - struct :c:type:`v4l2_fract`
126       - ``step``
127       - Frame interval step size [s].
128
129
130
131 .. c:type:: v4l2_frmivalenum
132
133 .. tabularcolumns:: |p{1.8cm}|p{4.4cm}|p{2.4cm}|p{8.9cm}|
134
135 .. flat-table:: struct v4l2_frmivalenum
136     :header-rows:  0
137     :stub-columns: 0
138
139     * - __u32
140       - ``index``
141       -
142       - IN: Index of the given frame interval in the enumeration.
143     * - __u32
144       - ``pixel_format``
145       -
146       - IN: Pixel format for which the frame intervals are enumerated.
147     * - __u32
148       - ``width``
149       -
150       - IN: Frame width for which the frame intervals are enumerated.
151     * - __u32
152       - ``height``
153       -
154       - IN: Frame height for which the frame intervals are enumerated.
155     * - __u32
156       - ``type``
157       -
158       - OUT: Frame interval type the device supports.
159     * - union
160       -
161       -
162       - OUT: Frame interval with the given index.
163     * -
164       - struct :c:type:`v4l2_fract`
165       - ``discrete``
166       - Frame interval [s].
167     * -
168       - struct :c:type:`v4l2_frmival_stepwise`
169       - ``stepwise``
170       -
171     * - __u32
172       - ``reserved[2]``
173       -
174       - Reserved space for future use. Must be zeroed by drivers and
175         applications.
176
177
178
179 Enums
180 =====
181
182
183 .. c:type:: v4l2_frmivaltypes
184
185 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
186
187 .. flat-table:: enum v4l2_frmivaltypes
188     :header-rows:  0
189     :stub-columns: 0
190     :widths:       3 1 4
191
192     * - ``V4L2_FRMIVAL_TYPE_DISCRETE``
193       - 1
194       - Discrete frame interval.
195     * - ``V4L2_FRMIVAL_TYPE_CONTINUOUS``
196       - 2
197       - Continuous frame interval.
198     * - ``V4L2_FRMIVAL_TYPE_STEPWISE``
199       - 3
200       - Step-wise defined frame interval.
201
202
203 Return Value
204 ============
205
206 On success 0 is returned, on error -1 and the ``errno`` variable is set
207 appropriately. The generic error codes are described at the
208 :ref:`Generic Error Codes <gen-errors>` chapter.