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