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