1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2.. c:namespace:: V4L
3
4.. _VIDIOC_ENUM_FRAMESIZES:
5
6****************************
7ioctl VIDIOC_ENUM_FRAMESIZES
8****************************
9
10Name
11====
12
13VIDIOC_ENUM_FRAMESIZES - Enumerate frame sizes
14
15Synopsis
16========
17
18.. c:macro:: VIDIOC_ENUM_FRAMESIZES
19
20``int ioctl(int fd, VIDIOC_ENUM_FRAMESIZES, struct v4l2_frmsizeenum *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_frmsizeenum`
30    that contains an index and pixel format and receives a frame width
31    and height.
32
33Description
34===========
35
36This ioctl allows applications to enumerate all frame sizes (i. e. width
37and height in pixels) that the device supports for the given pixel
38format.
39
40The supported pixel formats can be obtained by using the
41:ref:`VIDIOC_ENUM_FMT` function.
42
43The return value and the content of the ``v4l2_frmsizeenum.type`` field
44depend on the type of frame sizes the device supports. Here are the
45semantics of the function for the different cases:
46
47-  **Discrete:** The function returns success if the given index value
48   (zero-based) is valid. The application should increase the index by
49   one for each call until ``EINVAL`` is returned. The
50   ``v4l2_frmsizeenum.type`` field is set to
51   ``V4L2_FRMSIZE_TYPE_DISCRETE`` by the driver. Of the union only the
52   ``discrete`` member is valid.
53
54-  **Step-wise:** The function returns success if the given index value
55   is zero and ``EINVAL`` for any other index value. The
56   ``v4l2_frmsizeenum.type`` field is set to
57   ``V4L2_FRMSIZE_TYPE_STEPWISE`` by the driver. Of the union only the
58   ``stepwise`` member is valid.
59
60-  **Continuous:** This is a special case of the step-wise type above.
61   The function returns success if the given index value is zero and
62   ``EINVAL`` for any other index value. The ``v4l2_frmsizeenum.type``
63   field is set to ``V4L2_FRMSIZE_TYPE_CONTINUOUS`` by the driver. Of
64   the union only the ``stepwise`` member is valid and the
65   ``step_width`` and ``step_height`` values are set to 1.
66
67When the application calls the function with index zero, it must check
68the ``type`` field to determine the type of frame size enumeration the
69device supports. Only for the ``V4L2_FRMSIZE_TYPE_DISCRETE`` type does
70it make sense to increase the index value to receive more frame sizes.
71
72.. note::
73
74   The order in which the frame sizes are returned has no special
75   meaning. In particular does it not say anything about potential default
76   format sizes.
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 size enumeration.
82
83Structs
84=======
85
86In the structs below, *IN* denotes a value that has to be filled in by
87the application, *OUT* denotes values that the driver fills in. The
88application should zero out all members except for the *IN* fields.
89
90.. c:type:: v4l2_frmsize_discrete
91
92.. flat-table:: struct v4l2_frmsize_discrete
93    :header-rows:  0
94    :stub-columns: 0
95    :widths:       1 1 2
96
97    * - __u32
98      - ``width``
99      - Width of the frame [pixel].
100    * - __u32
101      - ``height``
102      - Height of the frame [pixel].
103
104
105.. c:type:: v4l2_frmsize_stepwise
106
107.. flat-table:: struct v4l2_frmsize_stepwise
108    :header-rows:  0
109    :stub-columns: 0
110    :widths:       1 1 2
111
112    * - __u32
113      - ``min_width``
114      - Minimum frame width [pixel].
115    * - __u32
116      - ``max_width``
117      - Maximum frame width [pixel].
118    * - __u32
119      - ``step_width``
120      - Frame width step size [pixel].
121    * - __u32
122      - ``min_height``
123      - Minimum frame height [pixel].
124    * - __u32
125      - ``max_height``
126      - Maximum frame height [pixel].
127    * - __u32
128      - ``step_height``
129      - Frame height step size [pixel].
130
131
132.. c:type:: v4l2_frmsizeenum
133
134.. tabularcolumns:: |p{6.4cm}|p{2.8cm}|p{8.1cm}|
135
136.. flat-table:: struct v4l2_frmsizeenum
137    :header-rows:  0
138    :stub-columns: 0
139
140    * - __u32
141      - ``index``
142      - IN: Index of the given frame size in the enumeration.
143    * - __u32
144      - ``pixel_format``
145      - IN: Pixel format for which the frame sizes are enumerated.
146    * - __u32
147      - ``type``
148      - OUT: Frame size type the device supports.
149    * - union {
150      - (anonymous)
151      - OUT: Frame size with the given index.
152    * - struct :c:type:`v4l2_frmsize_discrete`
153      - ``discrete``
154      -
155    * - struct :c:type:`v4l2_frmsize_stepwise`
156      - ``stepwise``
157      -
158    * - }
159      -
160      -
161    * - __u32
162      - ``reserved[2]``
163      - Reserved space for future use. Must be zeroed by drivers and
164	applications.
165
166
167Enums
168=====
169
170.. c:type:: v4l2_frmsizetypes
171
172.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
173
174.. flat-table:: enum v4l2_frmsizetypes
175    :header-rows:  0
176    :stub-columns: 0
177    :widths:       3 1 4
178
179    * - ``V4L2_FRMSIZE_TYPE_DISCRETE``
180      - 1
181      - Discrete frame size.
182    * - ``V4L2_FRMSIZE_TYPE_CONTINUOUS``
183      - 2
184      - Continuous frame size.
185    * - ``V4L2_FRMSIZE_TYPE_STEPWISE``
186      - 3
187      - Step-wise defined frame size.
188
189Return Value
190============
191
192On success 0 is returned, on error -1 and the ``errno`` variable is set
193appropriately. The generic error codes are described at the
194:ref:`Generic Error Codes <gen-errors>` chapter.
195