0001 .. SPDX-License-Identifier: GPL-2.0+
0002
0003 ===================================
0004 Arm Framebuffer Compression (AFBC)
0005 ===================================
0006
0007 AFBC is a proprietary lossless image compression protocol and format.
0008 It provides fine-grained random access and minimizes the amount of
0009 data transferred between IP blocks.
0010
0011 AFBC can be enabled on drivers which support it via use of the AFBC
0012 format modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*).
0013
0014 All users of the AFBC modifiers must follow the usage guidelines laid
0015 out in this document, to ensure compatibility across different AFBC
0016 producers and consumers.
0017
0018 Components and Ordering
0019 =======================
0020
0021 AFBC streams can contain several components - where a component
0022 corresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr).
0023 The assignment of input/output color channels must be consistent
0024 between the encoder and the decoder for correct operation, otherwise
0025 the consumer will interpret the decoded data incorrectly.
0026
0027 Furthermore, when the lossless colorspace transform is used
0028 (AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers for
0029 maximum compression efficiency), the component order must be:
0030
0031 * Component 0: R
0032 * Component 1: G
0033 * Component 2: B
0034
0035 The component ordering is communicated via the fourcc code in the
0036 fourcc:modifier pair. In general, component '0' is considered to
0037 reside in the least-significant bits of the corresponding linear
0038 format. For example, COMP(bits):
0039
0040 * DRM_FORMAT_ABGR8888
0041
0042 * Component 0: R(8)
0043 * Component 1: G(8)
0044 * Component 2: B(8)
0045 * Component 3: A(8)
0046
0047 * DRM_FORMAT_BGR888
0048
0049 * Component 0: R(8)
0050 * Component 1: G(8)
0051 * Component 2: B(8)
0052
0053 * DRM_FORMAT_YUYV
0054
0055 * Component 0: Y(8)
0056 * Component 1: Cb(8, 2x1 subsampled)
0057 * Component 2: Cr(8, 2x1 subsampled)
0058
0059 In AFBC, 'X' components are not treated any differently from any other
0060 component. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR8888
0061 encodes with 4 components, like so:
0062
0063 * DRM_FORMAT_XBGR8888
0064
0065 * Component 0: R(8)
0066 * Component 1: G(8)
0067 * Component 2: B(8)
0068 * Component 3: X(8)
0069
0070 Please note, however, that the inclusion of a "wasted" 'X' channel is
0071 bad for compression efficiency, and so it's recommended to avoid
0072 formats containing 'X' bits. If a fourth component is
0073 required/expected by the encoder/decoder, then it is recommended to
0074 instead use an equivalent format with alpha, setting all alpha bits to
0075 '1'. If there is no requirement for a fourth component, then a format
0076 which doesn't include alpha can be used, e.g. DRM_FORMAT_BGR888.
0077
0078 Number of Planes
0079 ================
0080
0081 Formats which are typically multi-planar in linear layouts (e.g. YUV
0082 420), can be encoded into one, or multiple, AFBC planes. As with
0083 component order, the encoder and decoder must agree about the number
0084 of planes in order to correctly decode the buffer. The fourcc code is
0085 used to determine the number of encoded planes in an AFBC buffer,
0086 matching the number of planes for the linear (unmodified) format.
0087 Within each plane, the component ordering also follows the fourcc
0088 code:
0089
0090 For example:
0091
0092 * DRM_FORMAT_YUYV: nplanes = 1
0093
0094 * Plane 0:
0095
0096 * Component 0: Y(8)
0097 * Component 1: Cb(8, 2x1 subsampled)
0098 * Component 2: Cr(8, 2x1 subsampled)
0099
0100 * DRM_FORMAT_NV12: nplanes = 2
0101
0102 * Plane 0:
0103
0104 * Component 0: Y(8)
0105
0106 * Plane 1:
0107
0108 * Component 0: Cb(8, 2x1 subsampled)
0109 * Component 1: Cr(8, 2x1 subsampled)
0110
0111 Cross-device interoperability
0112 =============================
0113
0114 For maximum compatibility across devices, the table below defines
0115 canonical formats for use between AFBC-enabled devices. Formats which
0116 are listed here must be used exactly as specified when using the AFBC
0117 modifiers. Formats which are not listed should be avoided.
0118
0119 .. flat-table:: AFBC formats
0120
0121 * - Fourcc code
0122 - Description
0123 - Planes/Components
0124
0125 * - DRM_FORMAT_ABGR2101010
0126 - 10-bit per component RGB, with 2-bit alpha
0127 - Plane 0: 4 components
0128 * Component 0: R(10)
0129 * Component 1: G(10)
0130 * Component 2: B(10)
0131 * Component 3: A(2)
0132
0133 * - DRM_FORMAT_ABGR8888
0134 - 8-bit per component RGB, with 8-bit alpha
0135 - Plane 0: 4 components
0136 * Component 0: R(8)
0137 * Component 1: G(8)
0138 * Component 2: B(8)
0139 * Component 3: A(8)
0140
0141 * - DRM_FORMAT_BGR888
0142 - 8-bit per component RGB
0143 - Plane 0: 3 components
0144 * Component 0: R(8)
0145 * Component 1: G(8)
0146 * Component 2: B(8)
0147
0148 * - DRM_FORMAT_BGR565
0149 - 5/6-bit per component RGB
0150 - Plane 0: 3 components
0151 * Component 0: R(5)
0152 * Component 1: G(6)
0153 * Component 2: B(5)
0154
0155 * - DRM_FORMAT_ABGR1555
0156 - 5-bit per component RGB, with 1-bit alpha
0157 - Plane 0: 4 components
0158 * Component 0: R(5)
0159 * Component 1: G(5)
0160 * Component 2: B(5)
0161 * Component 3: A(1)
0162
0163 * - DRM_FORMAT_VUY888
0164 - 8-bit per component YCbCr 444, single plane
0165 - Plane 0: 3 components
0166 * Component 0: Y(8)
0167 * Component 1: Cb(8)
0168 * Component 2: Cr(8)
0169
0170 * - DRM_FORMAT_VUY101010
0171 - 10-bit per component YCbCr 444, single plane
0172 - Plane 0: 3 components
0173 * Component 0: Y(10)
0174 * Component 1: Cb(10)
0175 * Component 2: Cr(10)
0176
0177 * - DRM_FORMAT_YUYV
0178 - 8-bit per component YCbCr 422, single plane
0179 - Plane 0: 3 components
0180 * Component 0: Y(8)
0181 * Component 1: Cb(8, 2x1 subsampled)
0182 * Component 2: Cr(8, 2x1 subsampled)
0183
0184 * - DRM_FORMAT_NV16
0185 - 8-bit per component YCbCr 422, two plane
0186 - Plane 0: 1 component
0187 * Component 0: Y(8)
0188 Plane 1: 2 components
0189 * Component 0: Cb(8, 2x1 subsampled)
0190 * Component 1: Cr(8, 2x1 subsampled)
0191
0192 * - DRM_FORMAT_Y210
0193 - 10-bit per component YCbCr 422, single plane
0194 - Plane 0: 3 components
0195 * Component 0: Y(10)
0196 * Component 1: Cb(10, 2x1 subsampled)
0197 * Component 2: Cr(10, 2x1 subsampled)
0198
0199 * - DRM_FORMAT_P210
0200 - 10-bit per component YCbCr 422, two plane
0201 - Plane 0: 1 component
0202 * Component 0: Y(10)
0203 Plane 1: 2 components
0204 * Component 0: Cb(10, 2x1 subsampled)
0205 * Component 1: Cr(10, 2x1 subsampled)
0206
0207 * - DRM_FORMAT_YUV420_8BIT
0208 - 8-bit per component YCbCr 420, single plane
0209 - Plane 0: 3 components
0210 * Component 0: Y(8)
0211 * Component 1: Cb(8, 2x2 subsampled)
0212 * Component 2: Cr(8, 2x2 subsampled)
0213
0214 * - DRM_FORMAT_YUV420_10BIT
0215 - 10-bit per component YCbCr 420, single plane
0216 - Plane 0: 3 components
0217 * Component 0: Y(10)
0218 * Component 1: Cb(10, 2x2 subsampled)
0219 * Component 2: Cr(10, 2x2 subsampled)
0220
0221 * - DRM_FORMAT_NV12
0222 - 8-bit per component YCbCr 420, two plane
0223 - Plane 0: 1 component
0224 * Component 0: Y(8)
0225 Plane 1: 2 components
0226 * Component 0: Cb(8, 2x2 subsampled)
0227 * Component 1: Cr(8, 2x2 subsampled)
0228
0229 * - DRM_FORMAT_P010
0230 - 10-bit per component YCbCr 420, two plane
0231 - Plane 0: 1 component
0232 * Component 0: Y(10)
0233 Plane 1: 2 components
0234 * Component 0: Cb(10, 2x2 subsampled)
0235 * Component 1: Cr(10, 2x2 subsampled)