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