2d1444b0d017fae7746e7c1fa2794a21e80ac41e
[cascardo/linux.git] / Documentation / media / uapi / v4l / vidioc-enum-fmt.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _VIDIOC_ENUM_FMT:
4
5 *********************
6 ioctl VIDIOC_ENUM_FMT
7 *********************
8
9 Name
10 ====
11
12 VIDIOC_ENUM_FMT - Enumerate image formats
13
14
15 Synopsis
16 ========
17
18 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_fmtdesc *argp )
19
20
21 Arguments
22 =========
23
24 ``fd``
25     File descriptor returned by :ref:`open() <func-open>`.
26
27 ``request``
28     VIDIOC_ENUM_FMT
29
30 ``argp``
31
32
33 Description
34 ===========
35
36 To enumerate image formats applications initialize the ``type`` and
37 ``index`` field of struct :ref:`v4l2_fmtdesc <v4l2-fmtdesc>` and call
38 the :ref:`VIDIOC_ENUM_FMT` ioctl with a pointer to this structure. Drivers
39 fill the rest of the structure or return an ``EINVAL`` error code. All
40 formats are enumerable by beginning at index zero and incrementing by
41 one until ``EINVAL`` is returned.
42
43 .. note::
44
45    After switching input or output the list of enumerated image
46    formats may be different.
47
48
49 .. _v4l2-fmtdesc:
50
51 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
52
53 .. flat-table:: struct v4l2_fmtdesc
54     :header-rows:  0
55     :stub-columns: 0
56     :widths:       1 1 2
57
58     -  .. row 1
59
60        -  __u32
61
62        -  ``index``
63
64        -  Number of the format in the enumeration, set by the application.
65           This is in no way related to the ``pixelformat`` field.
66
67     -  .. row 2
68
69        -  __u32
70
71        -  ``type``
72
73        -  Type of the data stream, set by the application. Only these types
74           are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,
75           ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
76           ``V4L2_BUF_TYPE_VIDEO_OUTPUT``,
77           ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
78           ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :ref:`v4l2-buf-type`.
79
80     -  .. row 3
81
82        -  __u32
83
84        -  ``flags``
85
86        -  See :ref:`fmtdesc-flags`
87
88     -  .. row 4
89
90        -  __u8
91
92        -  ``description``\ [32]
93
94        -  Description of the format, a NUL-terminated ASCII string. This
95           information is intended for the user, for example: "YUV 4:2:2".
96
97     -  .. row 5
98
99        -  __u32
100
101        -  ``pixelformat``
102
103        -  The image format identifier. This is a four character code as
104           computed by the v4l2_fourcc() macro:
105
106     -  .. row 6
107
108        -  :cspan:`2`
109
110           .. _v4l2-fourcc:
111           ``#define v4l2_fourcc(a,b,c,d)``
112
113           ``(((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))``
114
115           Several image formats are already defined by this specification in
116           :ref:`pixfmt`.
117
118           .. attention::
119
120              These codes are not the same as those used
121              in the Windows world.
122
123     -  .. row 7
124
125        -  __u32
126
127        -  ``reserved``\ [4]
128
129        -  Reserved for future extensions. Drivers must set the array to
130           zero.
131
132
133
134 .. _fmtdesc-flags:
135
136 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
137
138 .. flat-table:: Image Format Description Flags
139     :header-rows:  0
140     :stub-columns: 0
141     :widths:       3 1 4
142
143
144     -  .. row 1
145
146        -  ``V4L2_FMT_FLAG_COMPRESSED``
147
148        -  0x0001
149
150        -  This is a compressed format.
151
152     -  .. row 2
153
154        -  ``V4L2_FMT_FLAG_EMULATED``
155
156        -  0x0002
157
158        -  This format is not native to the device but emulated through
159           software (usually libv4l2), where possible try to use a native
160           format instead for better performance.
161
162
163 Return Value
164 ============
165
166 On success 0 is returned, on error -1 and the ``errno`` variable is set
167 appropriately. The generic error codes are described at the
168 :ref:`Generic Error Codes <gen-errors>` chapter.
169
170 EINVAL
171     The struct :ref:`v4l2_fmtdesc <v4l2-fmtdesc>` ``type`` is not
172     supported or the ``index`` is out of bounds.