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