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