1 .. SPDX-License-Identifier: GPL-2.0+
3 ===================================
4 Arm Framebuffer Compression (AFBC)
5 ===================================
7 AFBC is a proprietary lossless image compression protocol and format.
8 It provides fine-grained random access and minimizes the amount of
9 data transferred between IP blocks.
11 AFBC can be enabled on drivers which support it via use of the AFBC
12 format modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*).
14 All users of the AFBC modifiers must follow the usage guidelines laid
15 out in this document, to ensure compatibility across different AFBC
16 producers and consumers.
18 Components and Ordering
19 =======================
21 AFBC streams can contain several components - where a component
22 corresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr).
23 The assignment of input/output color channels must be consistent
24 between the encoder and the decoder for correct operation, otherwise
25 the consumer will interpret the decoded data incorrectly.
27 Furthermore, when the lossless colorspace transform is used
28 (AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers for
29 maximum compression efficiency), the component order must be:
35 The component ordering is communicated via the fourcc code in the
36 fourcc:modifier pair. In general, component '0' is considered to
37 reside in the least-significant bits of the corresponding linear
38 format. For example, COMP(bits):
56 * Component 1: Cb(8, 2x1 subsampled)
57 * Component 2: Cr(8, 2x1 subsampled)
59 In AFBC, 'X' components are not treated any differently from any other
60 component. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR8888
61 encodes with 4 components, like so:
70 Please note, however, that the inclusion of a "wasted" 'X' channel is
71 bad for compression efficiency, and so it's recommended to avoid
72 formats containing 'X' bits. If a fourth component is
73 required/expected by the encoder/decoder, then it is recommended to
74 instead use an equivalent format with alpha, setting all alpha bits to
75 '1'. If there is no requirement for a fourth component, then a format
76 which doesn't include alpha can be used, e.g. DRM_FORMAT_BGR888.
81 Formats which are typically multi-planar in linear layouts (e.g. YUV
82 420), can be encoded into one, or multiple, AFBC planes. As with
83 component order, the encoder and decoder must agree about the number
84 of planes in order to correctly decode the buffer. The fourcc code is
85 used to determine the number of encoded planes in an AFBC buffer,
86 matching the number of planes for the linear (unmodified) format.
87 Within each plane, the component ordering also follows the fourcc
92 * DRM_FORMAT_YUYV: nplanes = 1
97 * Component 1: Cb(8, 2x1 subsampled)
98 * Component 2: Cr(8, 2x1 subsampled)
100 * DRM_FORMAT_NV12: nplanes = 2
108 * Component 0: Cb(8, 2x1 subsampled)
109 * Component 1: Cr(8, 2x1 subsampled)
111 Cross-device interoperability
112 =============================
114 For maximum compatibility across devices, the table below defines
115 canonical formats for use between AFBC-enabled devices. Formats which
116 are listed here must be used exactly as specified when using the AFBC
117 modifiers. Formats which are not listed should be avoided.
119 .. flat-table:: AFBC formats
125 * - DRM_FORMAT_ABGR2101010
126 - 10-bit per component RGB, with 2-bit alpha
127 - Plane 0: 4 components
133 * - DRM_FORMAT_ABGR8888
134 - 8-bit per component RGB, with 8-bit alpha
135 - Plane 0: 4 components
141 * - DRM_FORMAT_BGR888
142 - 8-bit per component RGB
143 - Plane 0: 3 components
148 * - DRM_FORMAT_BGR565
149 - 5/6-bit per component RGB
150 - Plane 0: 3 components
155 * - DRM_FORMAT_ABGR1555
156 - 5-bit per component RGB, with 1-bit alpha
157 - Plane 0: 4 components
163 * - DRM_FORMAT_VUY888
164 - 8-bit per component YCbCr 444, single plane
165 - Plane 0: 3 components
170 * - DRM_FORMAT_VUY101010
171 - 10-bit per component YCbCr 444, single plane
172 - Plane 0: 3 components
174 * Component 1: Cb(10)
175 * Component 2: Cr(10)
178 - 8-bit per component YCbCr 422, single plane
179 - Plane 0: 3 components
181 * Component 1: Cb(8, 2x1 subsampled)
182 * Component 2: Cr(8, 2x1 subsampled)
185 - 8-bit per component YCbCr 422, two plane
186 - Plane 0: 1 component
188 Plane 1: 2 components
189 * Component 0: Cb(8, 2x1 subsampled)
190 * Component 1: Cr(8, 2x1 subsampled)
193 - 10-bit per component YCbCr 422, single plane
194 - Plane 0: 3 components
196 * Component 1: Cb(10, 2x1 subsampled)
197 * Component 2: Cr(10, 2x1 subsampled)
200 - 10-bit per component YCbCr 422, two plane
201 - Plane 0: 1 component
203 Plane 1: 2 components
204 * Component 0: Cb(10, 2x1 subsampled)
205 * Component 1: Cr(10, 2x1 subsampled)
207 * - DRM_FORMAT_YUV420_8BIT
208 - 8-bit per component YCbCr 420, single plane
209 - Plane 0: 3 components
211 * Component 1: Cb(8, 2x2 subsampled)
212 * Component 2: Cr(8, 2x2 subsampled)
214 * - DRM_FORMAT_YUV420_10BIT
215 - 10-bit per component YCbCr 420, single plane
216 - Plane 0: 3 components
218 * Component 1: Cb(10, 2x2 subsampled)
219 * Component 2: Cr(10, 2x2 subsampled)
222 - 8-bit per component YCbCr 420, two plane
223 - Plane 0: 1 component
225 Plane 1: 2 components
226 * Component 0: Cb(8, 2x2 subsampled)
227 * Component 1: Cr(8, 2x2 subsampled)
230 - 10-bit per component YCbCr 420, two plane
231 - Plane 0: 1 component
233 Plane 1: 2 components
234 * Component 0: Cb(10, 2x2 subsampled)
235 * Component 1: Cr(10, 2x2 subsampled)