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