236 lines · plain
1.. SPDX-License-Identifier: GPL-2.0+2 3===================================4 Arm Framebuffer Compression (AFBC)5===================================6 7AFBC is a proprietary lossless image compression protocol and format.8It provides fine-grained random access and minimizes the amount of9data transferred between IP blocks.10 11AFBC can be enabled on drivers which support it via use of the AFBC12format modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*).13 14All users of the AFBC modifiers must follow the usage guidelines laid15out in this document, to ensure compatibility across different AFBC16producers and consumers.17 18Components and Ordering19=======================20 21AFBC streams can contain several components - where a component22corresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr).23The assignment of input/output color channels must be consistent24between the encoder and the decoder for correct operation, otherwise25the consumer will interpret the decoded data incorrectly.26 27Furthermore, when the lossless colorspace transform is used28(AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers for29maximum compression efficiency), the component order must be:30 31 * Component 0: R32 * Component 1: G33 * Component 2: B34 35The component ordering is communicated via the fourcc code in the36fourcc:modifier pair. In general, component '0' is considered to37reside in the least-significant bits of the corresponding linear38format. For example, COMP(bits):39 40 * DRM_FORMAT_ABGR888841 42 * Component 0: R(8)43 * Component 1: G(8)44 * Component 2: B(8)45 * Component 3: A(8)46 47 * DRM_FORMAT_BGR88848 49 * Component 0: R(8)50 * Component 1: G(8)51 * Component 2: B(8)52 53 * DRM_FORMAT_YUYV54 55 * Component 0: Y(8)56 * Component 1: Cb(8, 2x1 subsampled)57 * Component 2: Cr(8, 2x1 subsampled)58 59In AFBC, 'X' components are not treated any differently from any other60component. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR888861encodes with 4 components, like so:62 63 * DRM_FORMAT_XBGR888864 65 * Component 0: R(8)66 * Component 1: G(8)67 * Component 2: B(8)68 * Component 3: X(8)69 70Please note, however, that the inclusion of a "wasted" 'X' channel is71bad for compression efficiency, and so it's recommended to avoid72formats containing 'X' bits. If a fourth component is73required/expected by the encoder/decoder, then it is recommended to74instead use an equivalent format with alpha, setting all alpha bits to75'1'. If there is no requirement for a fourth component, then a format76which doesn't include alpha can be used, e.g. DRM_FORMAT_BGR888.77 78Number of Planes79================80 81Formats which are typically multi-planar in linear layouts (e.g. YUV82420), can be encoded into one, or multiple, AFBC planes. As with83component order, the encoder and decoder must agree about the number84of planes in order to correctly decode the buffer. The fourcc code is85used to determine the number of encoded planes in an AFBC buffer,86matching the number of planes for the linear (unmodified) format.87Within each plane, the component ordering also follows the fourcc88code:89 90For example:91 92 * DRM_FORMAT_YUYV: nplanes = 193 94 * Plane 0:95 96 * Component 0: Y(8)97 * Component 1: Cb(8, 2x1 subsampled)98 * Component 2: Cr(8, 2x1 subsampled)99 100 * DRM_FORMAT_NV12: nplanes = 2101 102 * Plane 0:103 104 * Component 0: Y(8)105 106 * Plane 1:107 108 * Component 0: Cb(8, 2x1 subsampled)109 * Component 1: Cr(8, 2x1 subsampled)110 111Cross-device interoperability112=============================113 114For maximum compatibility across devices, the table below defines115canonical formats for use between AFBC-enabled devices. Formats which116are listed here must be used exactly as specified when using the AFBC117modifiers. Formats which are not listed should be avoided.118 119.. flat-table:: AFBC formats120 121 * - Fourcc code122 - Description123 - Planes/Components124 125 * - DRM_FORMAT_ABGR2101010126 - 10-bit per component RGB, with 2-bit alpha127 - Plane 0: 4 components128 * Component 0: R(10)129 * Component 1: G(10)130 * Component 2: B(10)131 * Component 3: A(2)132 133 * - DRM_FORMAT_ABGR8888134 - 8-bit per component RGB, with 8-bit alpha135 - Plane 0: 4 components136 * Component 0: R(8)137 * Component 1: G(8)138 * Component 2: B(8)139 * Component 3: A(8)140 141 * - DRM_FORMAT_BGR888142 - 8-bit per component RGB143 - Plane 0: 3 components144 * Component 0: R(8)145 * Component 1: G(8)146 * Component 2: B(8)147 148 * - DRM_FORMAT_BGR565149 - 5/6-bit per component RGB150 - Plane 0: 3 components151 * Component 0: R(5)152 * Component 1: G(6)153 * Component 2: B(5)154 155 * - DRM_FORMAT_ABGR1555156 - 5-bit per component RGB, with 1-bit alpha157 - Plane 0: 4 components158 * Component 0: R(5)159 * Component 1: G(5)160 * Component 2: B(5)161 * Component 3: A(1)162 163 * - DRM_FORMAT_VUY888164 - 8-bit per component YCbCr 444, single plane165 - Plane 0: 3 components166 * Component 0: Y(8)167 * Component 1: Cb(8)168 * Component 2: Cr(8)169 170 * - DRM_FORMAT_VUY101010171 - 10-bit per component YCbCr 444, single plane172 - Plane 0: 3 components173 * Component 0: Y(10)174 * Component 1: Cb(10)175 * Component 2: Cr(10)176 177 * - DRM_FORMAT_YUYV178 - 8-bit per component YCbCr 422, single plane179 - Plane 0: 3 components180 * Component 0: Y(8)181 * Component 1: Cb(8, 2x1 subsampled)182 * Component 2: Cr(8, 2x1 subsampled)183 184 * - DRM_FORMAT_NV16185 - 8-bit per component YCbCr 422, two plane186 - Plane 0: 1 component187 * Component 0: Y(8)188 Plane 1: 2 components189 * Component 0: Cb(8, 2x1 subsampled)190 * Component 1: Cr(8, 2x1 subsampled)191 192 * - DRM_FORMAT_Y210193 - 10-bit per component YCbCr 422, single plane194 - Plane 0: 3 components195 * Component 0: Y(10)196 * Component 1: Cb(10, 2x1 subsampled)197 * Component 2: Cr(10, 2x1 subsampled)198 199 * - DRM_FORMAT_P210200 - 10-bit per component YCbCr 422, two plane201 - Plane 0: 1 component202 * Component 0: Y(10)203 Plane 1: 2 components204 * Component 0: Cb(10, 2x1 subsampled)205 * Component 1: Cr(10, 2x1 subsampled)206 207 * - DRM_FORMAT_YUV420_8BIT208 - 8-bit per component YCbCr 420, single plane209 - Plane 0: 3 components210 * Component 0: Y(8)211 * Component 1: Cb(8, 2x2 subsampled)212 * Component 2: Cr(8, 2x2 subsampled)213 214 * - DRM_FORMAT_YUV420_10BIT215 - 10-bit per component YCbCr 420, single plane216 - Plane 0: 3 components217 * Component 0: Y(10)218 * Component 1: Cb(10, 2x2 subsampled)219 * Component 2: Cr(10, 2x2 subsampled)220 221 * - DRM_FORMAT_NV12222 - 8-bit per component YCbCr 420, two plane223 - Plane 0: 1 component224 * Component 0: Y(8)225 Plane 1: 2 components226 * Component 0: Cb(8, 2x2 subsampled)227 * Component 1: Cr(8, 2x2 subsampled)228 229 * - DRM_FORMAT_P010230 - 10-bit per component YCbCr 420, two plane231 - Plane 0: 1 component232 * Component 0: Y(10)233 Plane 1: 2 components234 * Component 0: Cb(10, 2x2 subsampled)235 * Component 1: Cr(10, 2x2 subsampled)236