blob: 90996f69d6ae7885e89084abddb7bd825e3118a2 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -03003.. _VIDIOC_ENUM_FMT:
Markus Heiser5377d912016-06-30 15:18:56 +02004
5*********************
6ioctl VIDIOC_ENUM_FMT
7*********************
8
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -03009Name
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030010====
Markus Heiser5377d912016-06-30 15:18:56 +020011
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030012VIDIOC_ENUM_FMT - Enumerate image formats
Markus Heiser5377d912016-06-30 15:18:56 +020013
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030014
15Synopsis
Markus Heiser5377d912016-06-30 15:18:56 +020016========
17
Mauro Carvalho Chehabb7e67f62016-07-02 09:49:16 -030018.. cpp:function:: int ioctl( int fd, int request, struct v4l2_fmtdesc *argp )
Markus Heiser5377d912016-06-30 15:18:56 +020019
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030020
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030021Arguments
Markus Heiser5377d912016-06-30 15:18:56 +020022=========
23
24``fd``
25 File descriptor returned by :ref:`open() <func-open>`.
26
27``request``
28 VIDIOC_ENUM_FMT
29
30``argp``
31
32
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030033Description
Markus Heiser5377d912016-06-30 15:18:56 +020034===========
35
36To enumerate image formats applications initialize the ``type`` and
37``index`` field of struct :ref:`v4l2_fmtdesc <v4l2-fmtdesc>` and call
Mauro Carvalho Chehab2212ff22016-07-01 14:33:56 -030038the :ref:`VIDIOC_ENUM_FMT` ioctl with a pointer to this structure. Drivers
Mauro Carvalho Chehabcdb4af02016-07-03 11:53:09 -030039fill the rest of the structure or return an ``EINVAL`` error code. All
Markus Heiser5377d912016-06-30 15:18:56 +020040formats are enumerable by beginning at index zero and incrementing by
Mauro Carvalho Chehabcdb4af02016-07-03 11:53:09 -030041one until ``EINVAL`` is returned.
Markus Heiser5377d912016-06-30 15:18:56 +020042
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -030043.. note:: After switching input or output the list of enumerated image
44 formats may be different.
Markus Heiser5377d912016-06-30 15:18:56 +020045
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.
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030062 This is in no way related to the ``pixelformat`` field.
Markus Heiser5377d912016-06-30 15:18:56 +020063
64 - .. row 2
65
66 - __u32
67
68 - ``type``
69
70 - Type of the data stream, set by the application. Only these types
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030071 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`.
Markus Heiser5377d912016-06-30 15:18:56 +020076
77 - .. row 3
78
79 - __u32
80
81 - ``flags``
82
83 - See :ref:`fmtdesc-flags`
84
85 - .. row 4
86
87 - __u8
88
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -030089 - ``description``\ [32]
Markus Heiser5377d912016-06-30 15:18:56 +020090
91 - Description of the format, a NUL-terminated ASCII string. This
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030092 information is intended for the user, for example: "YUV 4:2:2".
Markus Heiser5377d912016-06-30 15:18:56 +020093
94 - .. row 5
95
96 - __u32
97
98 - ``pixelformat``
99
100 - The image format identifier. This is a four character code as
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300101 computed by the v4l2_fourcc() macro:
Markus Heiser5377d912016-06-30 15:18:56 +0200102
103 - .. row 6
104
105 - :cspan:`2`
106
107
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300108 .. _v4l2-fourcc:
109 .. code-block:: c
Markus Heiser5377d912016-06-30 15:18:56 +0200110
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300111 #define v4l2_fourcc(a,b,c,d) (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
Markus Heiser5377d912016-06-30 15:18:56 +0200112
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300113 Several image formats are already defined by this specification in
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -0300114 :ref:`pixfmt`.
115
116 .. attention:: These codes are not the same as those used
117 in the Windows world.
Markus Heiser5377d912016-06-30 15:18:56 +0200118
119 - .. row 7
120
121 - __u32
122
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -0300123 - ``reserved``\ [4]
Markus Heiser5377d912016-06-30 15:18:56 +0200124
125 - Reserved for future extensions. Drivers must set the array to
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300126 zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200127
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
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300153 software (usually libv4l2), where possible try to use a native
154 format instead for better performance.
Markus Heiser5377d912016-06-30 15:18:56 +0200155
156
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -0300157Return Value
Markus Heiser5377d912016-06-30 15:18:56 +0200158============
159
160On success 0 is returned, on error -1 and the ``errno`` variable is set
161appropriately. The generic error codes are described at the
162:ref:`Generic Error Codes <gen-errors>` chapter.
163
164EINVAL
165 The struct :ref:`v4l2_fmtdesc <v4l2-fmtdesc>` ``type`` is not
166 supported or the ``index`` is out of bounds.