1*3affaa5aSBrian Starkey.. SPDX-License-Identifier: GPL-2.0+ 2*3affaa5aSBrian Starkey 3*3affaa5aSBrian Starkey=================================== 4*3affaa5aSBrian Starkey Arm Framebuffer Compression (AFBC) 5*3affaa5aSBrian Starkey=================================== 6*3affaa5aSBrian Starkey 7*3affaa5aSBrian StarkeyAFBC is a proprietary lossless image compression protocol and format. 8*3affaa5aSBrian StarkeyIt provides fine-grained random access and minimizes the amount of 9*3affaa5aSBrian Starkeydata transferred between IP blocks. 10*3affaa5aSBrian Starkey 11*3affaa5aSBrian StarkeyAFBC can be enabled on drivers which support it via use of the AFBC 12*3affaa5aSBrian Starkeyformat modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*). 13*3affaa5aSBrian Starkey 14*3affaa5aSBrian StarkeyAll users of the AFBC modifiers must follow the usage guidelines laid 15*3affaa5aSBrian Starkeyout in this document, to ensure compatibility across different AFBC 16*3affaa5aSBrian Starkeyproducers and consumers. 17*3affaa5aSBrian Starkey 18*3affaa5aSBrian StarkeyComponents and Ordering 19*3affaa5aSBrian Starkey======================= 20*3affaa5aSBrian Starkey 21*3affaa5aSBrian StarkeyAFBC streams can contain several components - where a component 22*3affaa5aSBrian Starkeycorresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr). 23*3affaa5aSBrian StarkeyThe assignment of input/output color channels must be consistent 24*3affaa5aSBrian Starkeybetween the encoder and the decoder for correct operation, otherwise 25*3affaa5aSBrian Starkeythe consumer will interpret the decoded data incorrectly. 26*3affaa5aSBrian Starkey 27*3affaa5aSBrian StarkeyFurthermore, when the lossless colorspace transform is used 28*3affaa5aSBrian Starkey(AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers for 29*3affaa5aSBrian Starkeymaximum compression efficiency), the component order must be: 30*3affaa5aSBrian Starkey 31*3affaa5aSBrian Starkey * Component 0: R 32*3affaa5aSBrian Starkey * Component 1: G 33*3affaa5aSBrian Starkey * Component 2: B 34*3affaa5aSBrian Starkey 35*3affaa5aSBrian StarkeyThe component ordering is communicated via the fourcc code in the 36*3affaa5aSBrian Starkeyfourcc:modifier pair. In general, component '0' is considered to 37*3affaa5aSBrian Starkeyreside in the least-significant bits of the corresponding linear 38*3affaa5aSBrian Starkeyformat. For example, COMP(bits): 39*3affaa5aSBrian Starkey 40*3affaa5aSBrian Starkey * DRM_FORMAT_ABGR8888 41*3affaa5aSBrian Starkey 42*3affaa5aSBrian Starkey * Component 0: R(8) 43*3affaa5aSBrian Starkey * Component 1: G(8) 44*3affaa5aSBrian Starkey * Component 2: B(8) 45*3affaa5aSBrian Starkey * Component 3: A(8) 46*3affaa5aSBrian Starkey 47*3affaa5aSBrian Starkey * DRM_FORMAT_BGR888 48*3affaa5aSBrian Starkey 49*3affaa5aSBrian Starkey * Component 0: R(8) 50*3affaa5aSBrian Starkey * Component 1: G(8) 51*3affaa5aSBrian Starkey * Component 2: B(8) 52*3affaa5aSBrian Starkey 53*3affaa5aSBrian Starkey * DRM_FORMAT_YUYV 54*3affaa5aSBrian Starkey 55*3affaa5aSBrian Starkey * Component 0: Y(8) 56*3affaa5aSBrian Starkey * Component 1: Cb(8, 2x1 subsampled) 57*3affaa5aSBrian Starkey * Component 2: Cr(8, 2x1 subsampled) 58*3affaa5aSBrian Starkey 59*3affaa5aSBrian StarkeyIn AFBC, 'X' components are not treated any differently from any other 60*3affaa5aSBrian Starkeycomponent. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR8888 61*3affaa5aSBrian Starkeyencodes with 4 components, like so: 62*3affaa5aSBrian Starkey 63*3affaa5aSBrian Starkey * DRM_FORMAT_XBGR8888 64*3affaa5aSBrian Starkey 65*3affaa5aSBrian Starkey * Component 0: R(8) 66*3affaa5aSBrian Starkey * Component 1: G(8) 67*3affaa5aSBrian Starkey * Component 2: B(8) 68*3affaa5aSBrian Starkey * Component 3: X(8) 69*3affaa5aSBrian Starkey 70*3affaa5aSBrian StarkeyPlease note, however, that the inclusion of a "wasted" 'X' channel is 71*3affaa5aSBrian Starkeybad for compression efficiency, and so it's recommended to avoid 72*3affaa5aSBrian Starkeyformats containing 'X' bits. If a fourth component is 73*3affaa5aSBrian Starkeyrequired/expected by the encoder/decoder, then it is recommended to 74*3affaa5aSBrian Starkeyinstead use an equivalent format with alpha, setting all alpha bits to 75*3affaa5aSBrian Starkey'1'. If there is no requirement for a fourth component, then a format 76*3affaa5aSBrian Starkeywhich doesn't include alpha can be used, e.g. DRM_FORMAT_BGR888. 77*3affaa5aSBrian Starkey 78*3affaa5aSBrian StarkeyNumber of Planes 79*3affaa5aSBrian Starkey================ 80*3affaa5aSBrian Starkey 81*3affaa5aSBrian StarkeyFormats which are typically multi-planar in linear layouts (e.g. YUV 82*3affaa5aSBrian Starkey420), can be encoded into one, or multiple, AFBC planes. As with 83*3affaa5aSBrian Starkeycomponent order, the encoder and decoder must agree about the number 84*3affaa5aSBrian Starkeyof planes in order to correctly decode the buffer. The fourcc code is 85*3affaa5aSBrian Starkeyused to determine the number of encoded planes in an AFBC buffer, 86*3affaa5aSBrian Starkeymatching the number of planes for the linear (unmodified) format. 87*3affaa5aSBrian StarkeyWithin each plane, the component ordering also follows the fourcc 88*3affaa5aSBrian Starkeycode: 89*3affaa5aSBrian Starkey 90*3affaa5aSBrian StarkeyFor example: 91*3affaa5aSBrian Starkey 92*3affaa5aSBrian Starkey * DRM_FORMAT_YUYV: nplanes = 1 93*3affaa5aSBrian Starkey 94*3affaa5aSBrian Starkey * Plane 0: 95*3affaa5aSBrian Starkey 96*3affaa5aSBrian Starkey * Component 0: Y(8) 97*3affaa5aSBrian Starkey * Component 1: Cb(8, 2x1 subsampled) 98*3affaa5aSBrian Starkey * Component 2: Cr(8, 2x1 subsampled) 99*3affaa5aSBrian Starkey 100*3affaa5aSBrian Starkey * DRM_FORMAT_NV12: nplanes = 2 101*3affaa5aSBrian Starkey 102*3affaa5aSBrian Starkey * Plane 0: 103*3affaa5aSBrian Starkey 104*3affaa5aSBrian Starkey * Component 0: Y(8) 105*3affaa5aSBrian Starkey 106*3affaa5aSBrian Starkey * Plane 1: 107*3affaa5aSBrian Starkey 108*3affaa5aSBrian Starkey * Component 0: Cb(8, 2x1 subsampled) 109*3affaa5aSBrian Starkey * Component 1: Cr(8, 2x1 subsampled) 110*3affaa5aSBrian Starkey 111*3affaa5aSBrian StarkeyCross-device interoperability 112*3affaa5aSBrian Starkey============================= 113*3affaa5aSBrian Starkey 114*3affaa5aSBrian StarkeyFor maximum compatibility across devices, the table below defines 115*3affaa5aSBrian Starkeycanonical formats for use between AFBC-enabled devices. Formats which 116*3affaa5aSBrian Starkeyare listed here must be used exactly as specified when using the AFBC 117*3affaa5aSBrian Starkeymodifiers. Formats which are not listed should be avoided. 118*3affaa5aSBrian Starkey 119*3affaa5aSBrian Starkey.. flat-table:: AFBC formats 120*3affaa5aSBrian Starkey 121*3affaa5aSBrian Starkey * - Fourcc code 122*3affaa5aSBrian Starkey - Description 123*3affaa5aSBrian Starkey - Planes/Components 124*3affaa5aSBrian Starkey 125*3affaa5aSBrian Starkey * - DRM_FORMAT_ABGR2101010 126*3affaa5aSBrian Starkey - 10-bit per component RGB, with 2-bit alpha 127*3affaa5aSBrian Starkey - Plane 0: 4 components 128*3affaa5aSBrian Starkey * Component 0: R(10) 129*3affaa5aSBrian Starkey * Component 1: G(10) 130*3affaa5aSBrian Starkey * Component 2: B(10) 131*3affaa5aSBrian Starkey * Component 3: A(2) 132*3affaa5aSBrian Starkey 133*3affaa5aSBrian Starkey * - DRM_FORMAT_ABGR8888 134*3affaa5aSBrian Starkey - 8-bit per component RGB, with 8-bit alpha 135*3affaa5aSBrian Starkey - Plane 0: 4 components 136*3affaa5aSBrian Starkey * Component 0: R(8) 137*3affaa5aSBrian Starkey * Component 1: G(8) 138*3affaa5aSBrian Starkey * Component 2: B(8) 139*3affaa5aSBrian Starkey * Component 3: A(8) 140*3affaa5aSBrian Starkey 141*3affaa5aSBrian Starkey * - DRM_FORMAT_BGR888 142*3affaa5aSBrian Starkey - 8-bit per component RGB 143*3affaa5aSBrian Starkey - Plane 0: 3 components 144*3affaa5aSBrian Starkey * Component 0: R(8) 145*3affaa5aSBrian Starkey * Component 1: G(8) 146*3affaa5aSBrian Starkey * Component 2: B(8) 147*3affaa5aSBrian Starkey 148*3affaa5aSBrian Starkey * - DRM_FORMAT_BGR565 149*3affaa5aSBrian Starkey - 5/6-bit per component RGB 150*3affaa5aSBrian Starkey - Plane 0: 3 components 151*3affaa5aSBrian Starkey * Component 0: R(5) 152*3affaa5aSBrian Starkey * Component 1: G(6) 153*3affaa5aSBrian Starkey * Component 2: B(5) 154*3affaa5aSBrian Starkey 155*3affaa5aSBrian Starkey * - DRM_FORMAT_ABGR1555 156*3affaa5aSBrian Starkey - 5-bit per component RGB, with 1-bit alpha 157*3affaa5aSBrian Starkey - Plane 0: 4 components 158*3affaa5aSBrian Starkey * Component 0: R(5) 159*3affaa5aSBrian Starkey * Component 1: G(5) 160*3affaa5aSBrian Starkey * Component 2: B(5) 161*3affaa5aSBrian Starkey * Component 3: A(1) 162*3affaa5aSBrian Starkey 163*3affaa5aSBrian Starkey * - DRM_FORMAT_VUY888 164*3affaa5aSBrian Starkey - 8-bit per component YCbCr 444, single plane 165*3affaa5aSBrian Starkey - Plane 0: 3 components 166*3affaa5aSBrian Starkey * Component 0: Y(8) 167*3affaa5aSBrian Starkey * Component 1: Cb(8) 168*3affaa5aSBrian Starkey * Component 2: Cr(8) 169*3affaa5aSBrian Starkey 170*3affaa5aSBrian Starkey * - DRM_FORMAT_VUY101010 171*3affaa5aSBrian Starkey - 10-bit per component YCbCr 444, single plane 172*3affaa5aSBrian Starkey - Plane 0: 3 components 173*3affaa5aSBrian Starkey * Component 0: Y(10) 174*3affaa5aSBrian Starkey * Component 1: Cb(10) 175*3affaa5aSBrian Starkey * Component 2: Cr(10) 176*3affaa5aSBrian Starkey 177*3affaa5aSBrian Starkey * - DRM_FORMAT_YUYV 178*3affaa5aSBrian Starkey - 8-bit per component YCbCr 422, single plane 179*3affaa5aSBrian Starkey - Plane 0: 3 components 180*3affaa5aSBrian Starkey * Component 0: Y(8) 181*3affaa5aSBrian Starkey * Component 1: Cb(8, 2x1 subsampled) 182*3affaa5aSBrian Starkey * Component 2: Cr(8, 2x1 subsampled) 183*3affaa5aSBrian Starkey 184*3affaa5aSBrian Starkey * - DRM_FORMAT_NV16 185*3affaa5aSBrian Starkey - 8-bit per component YCbCr 422, two plane 186*3affaa5aSBrian Starkey - Plane 0: 1 component 187*3affaa5aSBrian Starkey * Component 0: Y(8) 188*3affaa5aSBrian Starkey Plane 1: 2 components 189*3affaa5aSBrian Starkey * Component 0: Cb(8, 2x1 subsampled) 190*3affaa5aSBrian Starkey * Component 1: Cr(8, 2x1 subsampled) 191*3affaa5aSBrian Starkey 192*3affaa5aSBrian Starkey * - DRM_FORMAT_Y210 193*3affaa5aSBrian Starkey - 10-bit per component YCbCr 422, single plane 194*3affaa5aSBrian Starkey - Plane 0: 3 components 195*3affaa5aSBrian Starkey * Component 0: Y(10) 196*3affaa5aSBrian Starkey * Component 1: Cb(10, 2x1 subsampled) 197*3affaa5aSBrian Starkey * Component 2: Cr(10, 2x1 subsampled) 198*3affaa5aSBrian Starkey 199*3affaa5aSBrian Starkey * - DRM_FORMAT_P210 200*3affaa5aSBrian Starkey - 10-bit per component YCbCr 422, two plane 201*3affaa5aSBrian Starkey - Plane 0: 1 component 202*3affaa5aSBrian Starkey * Component 0: Y(10) 203*3affaa5aSBrian Starkey Plane 1: 2 components 204*3affaa5aSBrian Starkey * Component 0: Cb(10, 2x1 subsampled) 205*3affaa5aSBrian Starkey * Component 1: Cr(10, 2x1 subsampled) 206*3affaa5aSBrian Starkey 207*3affaa5aSBrian Starkey * - DRM_FORMAT_YUV420_8BIT 208*3affaa5aSBrian Starkey - 8-bit per component YCbCr 420, single plane 209*3affaa5aSBrian Starkey - Plane 0: 3 components 210*3affaa5aSBrian Starkey * Component 0: Y(8) 211*3affaa5aSBrian Starkey * Component 1: Cb(8, 2x2 subsampled) 212*3affaa5aSBrian Starkey * Component 2: Cr(8, 2x2 subsampled) 213*3affaa5aSBrian Starkey 214*3affaa5aSBrian Starkey * - DRM_FORMAT_YUV420_10BIT 215*3affaa5aSBrian Starkey - 10-bit per component YCbCr 420, single plane 216*3affaa5aSBrian Starkey - Plane 0: 3 components 217*3affaa5aSBrian Starkey * Component 0: Y(10) 218*3affaa5aSBrian Starkey * Component 1: Cb(10, 2x2 subsampled) 219*3affaa5aSBrian Starkey * Component 2: Cr(10, 2x2 subsampled) 220*3affaa5aSBrian Starkey 221*3affaa5aSBrian Starkey * - DRM_FORMAT_NV12 222*3affaa5aSBrian Starkey - 8-bit per component YCbCr 420, two plane 223*3affaa5aSBrian Starkey - Plane 0: 1 component 224*3affaa5aSBrian Starkey * Component 0: Y(8) 225*3affaa5aSBrian Starkey Plane 1: 2 components 226*3affaa5aSBrian Starkey * Component 0: Cb(8, 2x2 subsampled) 227*3affaa5aSBrian Starkey * Component 1: Cr(8, 2x2 subsampled) 228*3affaa5aSBrian Starkey 229*3affaa5aSBrian Starkey * - DRM_FORMAT_P010 230*3affaa5aSBrian Starkey - 10-bit per component YCbCr 420, two plane 231*3affaa5aSBrian Starkey - Plane 0: 1 component 232*3affaa5aSBrian Starkey * Component 0: Y(10) 233*3affaa5aSBrian Starkey Plane 1: 2 components 234*3affaa5aSBrian Starkey * Component 0: Cb(10, 2x2 subsampled) 235*3affaa5aSBrian Starkey * Component 1: Cr(10, 2x2 subsampled) 236