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 | ||
b7e67f6c | 18 | .. cpp: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 | |
706f8a99 MCC |
43 | .. note:: After switching input or output the list of enumerated image |
44 | formats may be different. | |
5377d91f MH |
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. | |
0579e6e3 | 62 | This is in no way related to the ``pixelformat`` field. |
5377d91f MH |
63 | |
64 | - .. row 2 | |
65 | ||
66 | - __u32 | |
67 | ||
68 | - ``type`` | |
69 | ||
70 | - Type of the data stream, set by the application. Only these types | |
0579e6e3 MCC |
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`. | |
5377d91f MH |
76 | |
77 | - .. row 3 | |
78 | ||
79 | - __u32 | |
80 | ||
81 | - ``flags`` | |
82 | ||
83 | - See :ref:`fmtdesc-flags` | |
84 | ||
85 | - .. row 4 | |
86 | ||
87 | - __u8 | |
88 | ||
8968da9b | 89 | - ``description``\ [32] |
5377d91f MH |
90 | |
91 | - Description of the format, a NUL-terminated ASCII string. This | |
0579e6e3 | 92 | information is intended for the user, for example: "YUV 4:2:2". |
5377d91f MH |
93 | |
94 | - .. row 5 | |
95 | ||
96 | - __u32 | |
97 | ||
98 | - ``pixelformat`` | |
99 | ||
100 | - The image format identifier. This is a four character code as | |
0579e6e3 | 101 | computed by the v4l2_fourcc() macro: |
5377d91f MH |
102 | |
103 | - .. row 6 | |
104 | ||
105 | - :cspan:`2` | |
106 | ||
107 | ||
0579e6e3 MCC |
108 | .. _v4l2-fourcc: |
109 | .. code-block:: c | |
5377d91f | 110 | |
0579e6e3 | 111 | #define v4l2_fourcc(a,b,c,d) (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) |
5377d91f | 112 | |
0579e6e3 | 113 | Several image formats are already defined by this specification in |
706f8a99 MCC |
114 | :ref:`pixfmt`. |
115 | ||
116 | .. attention:: These codes are not the same as those used | |
117 | in the Windows world. | |
5377d91f MH |
118 | |
119 | - .. row 7 | |
120 | ||
121 | - __u32 | |
122 | ||
8968da9b | 123 | - ``reserved``\ [4] |
5377d91f MH |
124 | |
125 | - Reserved for future extensions. Drivers must set the array to | |
0579e6e3 | 126 | zero. |
5377d91f MH |
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 | |
0579e6e3 MCC |
153 | software (usually libv4l2), where possible try to use a native |
154 | format instead for better performance. | |
5377d91f MH |
155 | |
156 | ||
15e7d615 | 157 | Return Value |
5377d91f MH |
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. |