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