Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[sfrench/cifs-2.6.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:: After switching input or output the list of enumerated image
44    formats may be different.
45
46
47 .. _v4l2-fmtdesc:
48
49 .. flat-table:: struct v4l2_fmtdesc
50     :header-rows:  0
51     :stub-columns: 0
52     :widths:       1 1 2
53
54
55     -  .. row 1
56
57        -  __u32
58
59        -  ``index``
60
61        -  Number of the format in the enumeration, set by the application.
62           This is in no way related to the ``pixelformat`` field.
63
64     -  .. row 2
65
66        -  __u32
67
68        -  ``type``
69
70        -  Type of the data stream, set by the application. Only these types
71           are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,
72           ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
73           ``V4L2_BUF_TYPE_VIDEO_OUTPUT``,
74           ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
75           ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :ref:`v4l2-buf-type`.
76
77     -  .. row 3
78
79        -  __u32
80
81        -  ``flags``
82
83        -  See :ref:`fmtdesc-flags`
84
85     -  .. row 4
86
87        -  __u8
88
89        -  ``description``\ [32]
90
91        -  Description of the format, a NUL-terminated ASCII string. This
92           information is intended for the user, for example: "YUV 4:2:2".
93
94     -  .. row 5
95
96        -  __u32
97
98        -  ``pixelformat``
99
100        -  The image format identifier. This is a four character code as
101           computed by the v4l2_fourcc() macro:
102
103     -  .. row 6
104
105        -  :cspan:`2`
106
107
108           .. _v4l2-fourcc:
109           .. code-block:: c
110
111               #define v4l2_fourcc(a,b,c,d) (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
112
113           Several image formats are already defined by this specification in
114           :ref:`pixfmt`.
115
116           .. attention:: These codes are not the same as those used
117              in the Windows world.
118
119     -  .. row 7
120
121        -  __u32
122
123        -  ``reserved``\ [4]
124
125        -  Reserved for future extensions. Drivers must set the array to
126           zero.
127
128
129
130 .. _fmtdesc-flags:
131
132 .. flat-table:: Image Format Description Flags
133     :header-rows:  0
134     :stub-columns: 0
135     :widths:       3 1 4
136
137
138     -  .. row 1
139
140        -  ``V4L2_FMT_FLAG_COMPRESSED``
141
142        -  0x0001
143
144        -  This is a compressed format.
145
146     -  .. row 2
147
148        -  ``V4L2_FMT_FLAG_EMULATED``
149
150        -  0x0002
151
152        -  This format is not native to the device but emulated through
153           software (usually libv4l2), where possible try to use a native
154           format instead for better performance.
155
156
157 Return Value
158 ============
159
160 On success 0 is returned, on error -1 and the ``errno`` variable is set
161 appropriately. The generic error codes are described at the
162 :ref:`Generic Error Codes <gen-errors>` chapter.
163
164 EINVAL
165     The struct :ref:`v4l2_fmtdesc <v4l2-fmtdesc>` ``type`` is not
166     supported or the ``index`` is out of bounds.