]> git.karo-electronics.de Git - karo-tx-linux.git/blob - Documentation/media/uapi/v4l/pixfmt-002.rst
[media] docs-rst: add tabularcolumns to all tables
[karo-tx-linux.git] / Documentation / media / uapi / v4l / pixfmt-002.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 ******************************
4 Single-planar format structure
5 ******************************
6
7
8 .. _v4l2-pix-format:
9
10 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
11
12 .. flat-table:: struct v4l2_pix_format
13     :header-rows:  0
14     :stub-columns: 0
15     :widths:       1 1 2
16
17
18     -  .. row 1
19
20        -  __u32
21
22        -  ``width``
23
24        -  Image width in pixels.
25
26     -  .. row 2
27
28        -  __u32
29
30        -  ``height``
31
32        -  Image height in pixels. If ``field`` is one of ``V4L2_FIELD_TOP``,
33           ``V4L2_FIELD_BOTTOM`` or ``V4L2_FIELD_ALTERNATE`` then height
34           refers to the number of lines in the field, otherwise it refers to
35           the number of lines in the frame (which is twice the field height
36           for interlaced formats).
37
38     -  .. row 3
39
40        -  :cspan:`2` Applications set these fields to request an image
41           size, drivers return the closest possible values. In case of
42           planar formats the ``width`` and ``height`` applies to the largest
43           plane. To avoid ambiguities drivers must return values rounded up
44           to a multiple of the scale factor of any smaller planes. For
45           example when the image format is YUV 4:2:0, ``width`` and
46           ``height`` must be multiples of two.
47
48     -  .. row 4
49
50        -  __u32
51
52        -  ``pixelformat``
53
54        -  The pixel format or type of compression, set by the application.
55           This is a little endian
56           :ref:`four character code <v4l2-fourcc>`. V4L2 defines standard
57           RGB formats in :ref:`rgb-formats`, YUV formats in
58           :ref:`yuv-formats`, and reserved codes in
59           :ref:`reserved-formats`
60
61     -  .. row 5
62
63        -  enum :ref:`v4l2_field <v4l2-field>`
64
65        -  ``field``
66
67        -  Video images are typically interlaced. Applications can request to
68           capture or output only the top or bottom field, or both fields
69           interlaced or sequentially stored in one buffer or alternating in
70           separate buffers. Drivers return the actual field order selected.
71           For more details on fields see :ref:`field-order`.
72
73     -  .. row 6
74
75        -  __u32
76
77        -  ``bytesperline``
78
79        -  Distance in bytes between the leftmost pixels in two adjacent
80           lines.
81
82     -  .. row 7
83
84        -  :cspan:`2`
85
86           Both applications and drivers can set this field to request
87           padding bytes at the end of each line. Drivers however may ignore
88           the value requested by the application, returning ``width`` times
89           bytes per pixel or a larger value required by the hardware. That
90           implies applications can just set this field to zero to get a
91           reasonable default.
92
93           Video hardware may access padding bytes, therefore they must
94           reside in accessible memory. Consider cases where padding bytes
95           after the last line of an image cross a system page boundary.
96           Input devices may write padding bytes, the value is undefined.
97           Output devices ignore the contents of padding bytes.
98
99           When the image format is planar the ``bytesperline`` value applies
100           to the first plane and is divided by the same factor as the
101           ``width`` field for the other planes. For example the Cb and Cr
102           planes of a YUV 4:2:0 image have half as many padding bytes
103           following each line as the Y plane. To avoid ambiguities drivers
104           must return a ``bytesperline`` value rounded up to a multiple of
105           the scale factor.
106
107           For compressed formats the ``bytesperline`` value makes no sense.
108           Applications and drivers must set this to 0 in that case.
109
110     -  .. row 8
111
112        -  __u32
113
114        -  ``sizeimage``
115
116        -  Size in bytes of the buffer to hold a complete image, set by the
117           driver. Usually this is ``bytesperline`` times ``height``. When
118           the image consists of variable length compressed data this is the
119           maximum number of bytes required to hold an image.
120
121     -  .. row 9
122
123        -  enum :ref:`v4l2_colorspace <v4l2-colorspace>`
124
125        -  ``colorspace``
126
127        -  This information supplements the ``pixelformat`` and must be set
128           by the driver for capture streams and by the application for
129           output streams, see :ref:`colorspaces`.
130
131     -  .. row 10
132
133        -  __u32
134
135        -  ``priv``
136
137        -  This field indicates whether the remaining fields of the
138           :ref:`struct v4l2_pix_format <v4l2-pix-format>` structure, also called the
139           extended fields, are valid. When set to
140           ``V4L2_PIX_FMT_PRIV_MAGIC``, it indicates that the extended fields
141           have been correctly initialized. When set to any other value it
142           indicates that the extended fields contain undefined values.
143
144           Applications that wish to use the pixel format extended fields
145           must first ensure that the feature is supported by querying the
146           device for the :ref:`V4L2_CAP_EXT_PIX_FORMAT <querycap>`
147           capability. If the capability isn't set the pixel format extended
148           fields are not supported and using the extended fields will lead
149           to undefined results.
150
151           To use the extended fields, applications must set the ``priv``
152           field to ``V4L2_PIX_FMT_PRIV_MAGIC``, initialize all the extended
153           fields and zero the unused bytes of the
154           :ref:`struct v4l2_format <v4l2-format>` ``raw_data`` field.
155
156           When the ``priv`` field isn't set to ``V4L2_PIX_FMT_PRIV_MAGIC``
157           drivers must act as if all the extended fields were set to zero.
158           On return drivers must set the ``priv`` field to
159           ``V4L2_PIX_FMT_PRIV_MAGIC`` and all the extended fields to
160           applicable values.
161
162     -  .. row 11
163
164        -  __u32
165
166        -  ``flags``
167
168        -  Flags set by the application or driver, see :ref:`format-flags`.
169
170     -  .. row 12
171
172        -  enum :ref:`v4l2_ycbcr_encoding <v4l2-ycbcr-encoding>`
173
174        -  ``ycbcr_enc``
175
176        -  This information supplements the ``colorspace`` and must be set by
177           the driver for capture streams and by the application for output
178           streams, see :ref:`colorspaces`.
179
180     -  .. row 13
181
182        -  enum :ref:`v4l2_quantization <v4l2-quantization>`
183
184        -  ``quantization``
185
186        -  This information supplements the ``colorspace`` and must be set by
187           the driver for capture streams and by the application for output
188           streams, see :ref:`colorspaces`.
189
190     -  .. row 14
191
192        -  enum :ref:`v4l2_xfer_func <v4l2-xfer-func>`
193
194        -  ``xfer_func``
195
196        -  This information supplements the ``colorspace`` and must be set by
197           the driver for capture streams and by the application for output
198           streams, see :ref:`colorspaces`.