162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2011 Intel Corporation 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the next 1262306a36Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 1362306a36Sopenharmony_ci * Software. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1662306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1762306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1862306a36Sopenharmony_ci * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 1962306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2062306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2162306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2262306a36Sopenharmony_ci */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#ifndef DRM_FOURCC_H 2562306a36Sopenharmony_ci#define DRM_FOURCC_H 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include "drm.h" 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#if defined(__cplusplus) 3062306a36Sopenharmony_ciextern "C" { 3162306a36Sopenharmony_ci#endif 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/** 3462306a36Sopenharmony_ci * DOC: overview 3562306a36Sopenharmony_ci * 3662306a36Sopenharmony_ci * In the DRM subsystem, framebuffer pixel formats are described using the 3762306a36Sopenharmony_ci * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the 3862306a36Sopenharmony_ci * fourcc code, a Format Modifier may optionally be provided, in order to 3962306a36Sopenharmony_ci * further describe the buffer's format - for example tiling or compression. 4062306a36Sopenharmony_ci * 4162306a36Sopenharmony_ci * Format Modifiers 4262306a36Sopenharmony_ci * ---------------- 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * Format modifiers are used in conjunction with a fourcc code, forming a 4562306a36Sopenharmony_ci * unique fourcc:modifier pair. This format:modifier pair must fully define the 4662306a36Sopenharmony_ci * format and data layout of the buffer, and should be the only way to describe 4762306a36Sopenharmony_ci * that particular buffer. 4862306a36Sopenharmony_ci * 4962306a36Sopenharmony_ci * Having multiple fourcc:modifier pairs which describe the same layout should 5062306a36Sopenharmony_ci * be avoided, as such aliases run the risk of different drivers exposing 5162306a36Sopenharmony_ci * different names for the same data format, forcing userspace to understand 5262306a36Sopenharmony_ci * that they are aliases. 5362306a36Sopenharmony_ci * 5462306a36Sopenharmony_ci * Format modifiers may change any property of the buffer, including the number 5562306a36Sopenharmony_ci * of planes and/or the required allocation size. Format modifiers are 5662306a36Sopenharmony_ci * vendor-namespaced, and as such the relationship between a fourcc code and a 5762306a36Sopenharmony_ci * modifier is specific to the modifer being used. For example, some modifiers 5862306a36Sopenharmony_ci * may preserve meaning - such as number of planes - from the fourcc code, 5962306a36Sopenharmony_ci * whereas others may not. 6062306a36Sopenharmony_ci * 6162306a36Sopenharmony_ci * Modifiers must uniquely encode buffer layout. In other words, a buffer must 6262306a36Sopenharmony_ci * match only a single modifier. A modifier must not be a subset of layouts of 6362306a36Sopenharmony_ci * another modifier. For instance, it's incorrect to encode pitch alignment in 6462306a36Sopenharmony_ci * a modifier: a buffer may match a 64-pixel aligned modifier and a 32-pixel 6562306a36Sopenharmony_ci * aligned modifier. That said, modifiers can have implicit minimal 6662306a36Sopenharmony_ci * requirements. 6762306a36Sopenharmony_ci * 6862306a36Sopenharmony_ci * For modifiers where the combination of fourcc code and modifier can alias, 6962306a36Sopenharmony_ci * a canonical pair needs to be defined and used by all drivers. Preferred 7062306a36Sopenharmony_ci * combinations are also encouraged where all combinations might lead to 7162306a36Sopenharmony_ci * confusion and unnecessarily reduced interoperability. An example for the 7262306a36Sopenharmony_ci * latter is AFBC, where the ABGR layouts are preferred over ARGB layouts. 7362306a36Sopenharmony_ci * 7462306a36Sopenharmony_ci * There are two kinds of modifier users: 7562306a36Sopenharmony_ci * 7662306a36Sopenharmony_ci * - Kernel and user-space drivers: for drivers it's important that modifiers 7762306a36Sopenharmony_ci * don't alias, otherwise two drivers might support the same format but use 7862306a36Sopenharmony_ci * different aliases, preventing them from sharing buffers in an efficient 7962306a36Sopenharmony_ci * format. 8062306a36Sopenharmony_ci * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users 8162306a36Sopenharmony_ci * see modifiers as opaque tokens they can check for equality and intersect. 8262306a36Sopenharmony_ci * These users musn't need to know to reason about the modifier value 8362306a36Sopenharmony_ci * (i.e. they are not expected to extract information out of the modifier). 8462306a36Sopenharmony_ci * 8562306a36Sopenharmony_ci * Vendors should document their modifier usage in as much detail as 8662306a36Sopenharmony_ci * possible, to ensure maximum compatibility across devices, drivers and 8762306a36Sopenharmony_ci * applications. 8862306a36Sopenharmony_ci * 8962306a36Sopenharmony_ci * The authoritative list of format modifier codes is found in 9062306a36Sopenharmony_ci * `include/uapi/drm/drm_fourcc.h` 9162306a36Sopenharmony_ci * 9262306a36Sopenharmony_ci * Open Source User Waiver 9362306a36Sopenharmony_ci * ----------------------- 9462306a36Sopenharmony_ci * 9562306a36Sopenharmony_ci * Because this is the authoritative source for pixel formats and modifiers 9662306a36Sopenharmony_ci * referenced by GL, Vulkan extensions and other standards and hence used both 9762306a36Sopenharmony_ci * by open source and closed source driver stacks, the usual requirement for an 9862306a36Sopenharmony_ci * upstream in-kernel or open source userspace user does not apply. 9962306a36Sopenharmony_ci * 10062306a36Sopenharmony_ci * To ensure, as much as feasible, compatibility across stacks and avoid 10162306a36Sopenharmony_ci * confusion with incompatible enumerations stakeholders for all relevant driver 10262306a36Sopenharmony_ci * stacks should approve additions. 10362306a36Sopenharmony_ci */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 10662306a36Sopenharmony_ci ((__u32)(c) << 16) | ((__u32)(d) << 24)) 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci#define DRM_FORMAT_BIG_ENDIAN (1U<<31) /* format is big endian instead of little endian */ 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* Reserve 0 for the invalid format specifier */ 11162306a36Sopenharmony_ci#define DRM_FORMAT_INVALID 0 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* color index */ 11462306a36Sopenharmony_ci#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ 11562306a36Sopenharmony_ci#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ 11662306a36Sopenharmony_ci#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */ 11762306a36Sopenharmony_ci#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci/* 1 bpp Darkness (inverse relationship between channel value and brightness) */ 12062306a36Sopenharmony_ci#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */ 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/* 2 bpp Darkness (inverse relationship between channel value and brightness) */ 12362306a36Sopenharmony_ci#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */ 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* 4 bpp Darkness (inverse relationship between channel value and brightness) */ 12662306a36Sopenharmony_ci#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */ 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci/* 8 bpp Darkness (inverse relationship between channel value and brightness) */ 12962306a36Sopenharmony_ci#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */ 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci/* 1 bpp Red (direct relationship between channel value and brightness) */ 13262306a36Sopenharmony_ci#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */ 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* 2 bpp Red (direct relationship between channel value and brightness) */ 13562306a36Sopenharmony_ci#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */ 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* 4 bpp Red (direct relationship between channel value and brightness) */ 13862306a36Sopenharmony_ci#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */ 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* 8 bpp Red (direct relationship between channel value and brightness) */ 14162306a36Sopenharmony_ci#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci/* 10 bpp Red (direct relationship between channel value and brightness) */ 14462306a36Sopenharmony_ci#define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */ 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci/* 12 bpp Red (direct relationship between channel value and brightness) */ 14762306a36Sopenharmony_ci#define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */ 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci/* 16 bpp Red (direct relationship between channel value and brightness) */ 15062306a36Sopenharmony_ci#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* 16 bpp RG */ 15362306a36Sopenharmony_ci#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 15462306a36Sopenharmony_ci#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/* 32 bpp RG */ 15762306a36Sopenharmony_ci#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ 15862306a36Sopenharmony_ci#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* 8 bpp RGB */ 16162306a36Sopenharmony_ci#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 16262306a36Sopenharmony_ci#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci/* 16 bpp RGB */ 16562306a36Sopenharmony_ci#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 16662306a36Sopenharmony_ci#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 16762306a36Sopenharmony_ci#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 16862306a36Sopenharmony_ci#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 17162306a36Sopenharmony_ci#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 17262306a36Sopenharmony_ci#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 17362306a36Sopenharmony_ci#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 17662306a36Sopenharmony_ci#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 17762306a36Sopenharmony_ci#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 17862306a36Sopenharmony_ci#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 18162306a36Sopenharmony_ci#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 18262306a36Sopenharmony_ci#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 18362306a36Sopenharmony_ci#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 18662306a36Sopenharmony_ci#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* 24 bpp RGB */ 18962306a36Sopenharmony_ci#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 19062306a36Sopenharmony_ci#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci/* 32 bpp RGB */ 19362306a36Sopenharmony_ci#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 19462306a36Sopenharmony_ci#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 19562306a36Sopenharmony_ci#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 19662306a36Sopenharmony_ci#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 19962306a36Sopenharmony_ci#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 20062306a36Sopenharmony_ci#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 20162306a36Sopenharmony_ci#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 20462306a36Sopenharmony_ci#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 20562306a36Sopenharmony_ci#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 20662306a36Sopenharmony_ci#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 20962306a36Sopenharmony_ci#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 21062306a36Sopenharmony_ci#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 21162306a36Sopenharmony_ci#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* 64 bpp RGB */ 21462306a36Sopenharmony_ci#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 21562306a36Sopenharmony_ci#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 21862306a36Sopenharmony_ci#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* 22162306a36Sopenharmony_ci * Floating point 64bpp RGB 22262306a36Sopenharmony_ci * IEEE 754-2008 binary16 half-precision float 22362306a36Sopenharmony_ci * [15:0] sign:exponent:mantissa 1:5:10 22462306a36Sopenharmony_ci */ 22562306a36Sopenharmony_ci#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 22662306a36Sopenharmony_ci#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 22962306a36Sopenharmony_ci#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci/* 23262306a36Sopenharmony_ci * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits 23362306a36Sopenharmony_ci * of unused padding per component: 23462306a36Sopenharmony_ci */ 23562306a36Sopenharmony_ci#define DRM_FORMAT_AXBXGXRX106106106106 fourcc_code('A', 'B', '1', '0') /* [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian */ 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci/* packed YCbCr */ 23862306a36Sopenharmony_ci#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 23962306a36Sopenharmony_ci#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 24062306a36Sopenharmony_ci#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 24162306a36Sopenharmony_ci#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 24462306a36Sopenharmony_ci#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */ 24562306a36Sopenharmony_ci#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ 24662306a36Sopenharmony_ci#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */ 24762306a36Sopenharmony_ci#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */ 24862306a36Sopenharmony_ci#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */ 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci/* 25162306a36Sopenharmony_ci * packed Y2xx indicate for each component, xx valid data occupy msb 25262306a36Sopenharmony_ci * 16-xx padding occupy lsb 25362306a36Sopenharmony_ci */ 25462306a36Sopenharmony_ci#define DRM_FORMAT_Y210 fourcc_code('Y', '2', '1', '0') /* [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels */ 25562306a36Sopenharmony_ci#define DRM_FORMAT_Y212 fourcc_code('Y', '2', '1', '2') /* [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels */ 25662306a36Sopenharmony_ci#define DRM_FORMAT_Y216 fourcc_code('Y', '2', '1', '6') /* [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels */ 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci/* 25962306a36Sopenharmony_ci * packed Y4xx indicate for each component, xx valid data occupy msb 26062306a36Sopenharmony_ci * 16-xx padding occupy lsb except Y410 26162306a36Sopenharmony_ci */ 26262306a36Sopenharmony_ci#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') /* [31:0] A:Cr:Y:Cb 2:10:10:10 little endian */ 26362306a36Sopenharmony_ci#define DRM_FORMAT_Y412 fourcc_code('Y', '4', '1', '2') /* [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian */ 26462306a36Sopenharmony_ci#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6') /* [63:0] A:Cr:Y:Cb 16:16:16:16 little endian */ 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci#define DRM_FORMAT_XVYU2101010 fourcc_code('X', 'V', '3', '0') /* [31:0] X:Cr:Y:Cb 2:10:10:10 little endian */ 26762306a36Sopenharmony_ci#define DRM_FORMAT_XVYU12_16161616 fourcc_code('X', 'V', '3', '6') /* [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian */ 26862306a36Sopenharmony_ci#define DRM_FORMAT_XVYU16161616 fourcc_code('X', 'V', '4', '8') /* [63:0] X:Cr:Y:Cb 16:16:16:16 little endian */ 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci/* 27162306a36Sopenharmony_ci * packed YCbCr420 2x2 tiled formats 27262306a36Sopenharmony_ci * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile 27362306a36Sopenharmony_ci */ 27462306a36Sopenharmony_ci/* [63:0] A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */ 27562306a36Sopenharmony_ci#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0') 27662306a36Sopenharmony_ci/* [63:0] X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */ 27762306a36Sopenharmony_ci#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0') 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci/* [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 28062306a36Sopenharmony_ci#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 28162306a36Sopenharmony_ci/* [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 28262306a36Sopenharmony_ci#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2') 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci/* 28562306a36Sopenharmony_ci * 1-plane YUV 4:2:0 28662306a36Sopenharmony_ci * In these formats, the component ordering is specified (Y, followed by U 28762306a36Sopenharmony_ci * then V), but the exact Linear layout is undefined. 28862306a36Sopenharmony_ci * These formats can only be used with a non-Linear modifier. 28962306a36Sopenharmony_ci */ 29062306a36Sopenharmony_ci#define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8') 29162306a36Sopenharmony_ci#define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci/* 29462306a36Sopenharmony_ci * 2 plane RGB + A 29562306a36Sopenharmony_ci * index 0 = RGB plane, same format as the corresponding non _A8 format has 29662306a36Sopenharmony_ci * index 1 = A plane, [7:0] A 29762306a36Sopenharmony_ci */ 29862306a36Sopenharmony_ci#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') 29962306a36Sopenharmony_ci#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') 30062306a36Sopenharmony_ci#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') 30162306a36Sopenharmony_ci#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') 30262306a36Sopenharmony_ci#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') 30362306a36Sopenharmony_ci#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') 30462306a36Sopenharmony_ci#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') 30562306a36Sopenharmony_ci#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_ci/* 30862306a36Sopenharmony_ci * 2 plane YCbCr 30962306a36Sopenharmony_ci * index 0 = Y plane, [7:0] Y 31062306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 31162306a36Sopenharmony_ci * or 31262306a36Sopenharmony_ci * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 31362306a36Sopenharmony_ci */ 31462306a36Sopenharmony_ci#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 31562306a36Sopenharmony_ci#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 31662306a36Sopenharmony_ci#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 31762306a36Sopenharmony_ci#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 31862306a36Sopenharmony_ci#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 31962306a36Sopenharmony_ci#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 32062306a36Sopenharmony_ci/* 32162306a36Sopenharmony_ci * 2 plane YCbCr 32262306a36Sopenharmony_ci * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian 32362306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian 32462306a36Sopenharmony_ci */ 32562306a36Sopenharmony_ci#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* 32862306a36Sopenharmony_ci * 2 plane YCbCr MSB aligned 32962306a36Sopenharmony_ci * index 0 = Y plane, [15:0] Y:x [10:6] little endian 33062306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 33162306a36Sopenharmony_ci */ 33262306a36Sopenharmony_ci#define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */ 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci/* 33562306a36Sopenharmony_ci * 2 plane YCbCr MSB aligned 33662306a36Sopenharmony_ci * index 0 = Y plane, [15:0] Y:x [10:6] little endian 33762306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 33862306a36Sopenharmony_ci */ 33962306a36Sopenharmony_ci#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */ 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* 34262306a36Sopenharmony_ci * 2 plane YCbCr MSB aligned 34362306a36Sopenharmony_ci * index 0 = Y plane, [15:0] Y:x [12:4] little endian 34462306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian 34562306a36Sopenharmony_ci */ 34662306a36Sopenharmony_ci#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */ 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ci/* 34962306a36Sopenharmony_ci * 2 plane YCbCr MSB aligned 35062306a36Sopenharmony_ci * index 0 = Y plane, [15:0] Y little endian 35162306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_ci#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci/* 2 plane YCbCr420. 35662306a36Sopenharmony_ci * 3 10 bit components and 2 padding bits packed into 4 bytes. 35762306a36Sopenharmony_ci * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian 35862306a36Sopenharmony_ci * index 1 = Cr:Cb plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 [2:10:10:10:2:10:10:10] little endian 35962306a36Sopenharmony_ci */ 36062306a36Sopenharmony_ci#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel packed */ 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci/* 3 plane non-subsampled (444) YCbCr 36362306a36Sopenharmony_ci * 16 bits per component, but only 10 bits are used and 6 bits are padded 36462306a36Sopenharmony_ci * index 0: Y plane, [15:0] Y:x [10:6] little endian 36562306a36Sopenharmony_ci * index 1: Cb plane, [15:0] Cb:x [10:6] little endian 36662306a36Sopenharmony_ci * index 2: Cr plane, [15:0] Cr:x [10:6] little endian 36762306a36Sopenharmony_ci */ 36862306a36Sopenharmony_ci#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci/* 3 plane non-subsampled (444) YCrCb 37162306a36Sopenharmony_ci * 16 bits per component, but only 10 bits are used and 6 bits are padded 37262306a36Sopenharmony_ci * index 0: Y plane, [15:0] Y:x [10:6] little endian 37362306a36Sopenharmony_ci * index 1: Cr plane, [15:0] Cr:x [10:6] little endian 37462306a36Sopenharmony_ci * index 2: Cb plane, [15:0] Cb:x [10:6] little endian 37562306a36Sopenharmony_ci */ 37662306a36Sopenharmony_ci#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci/* 37962306a36Sopenharmony_ci * 3 plane YCbCr 38062306a36Sopenharmony_ci * index 0: Y plane, [7:0] Y 38162306a36Sopenharmony_ci * index 1: Cb plane, [7:0] Cb 38262306a36Sopenharmony_ci * index 2: Cr plane, [7:0] Cr 38362306a36Sopenharmony_ci * or 38462306a36Sopenharmony_ci * index 1: Cr plane, [7:0] Cr 38562306a36Sopenharmony_ci * index 2: Cb plane, [7:0] Cb 38662306a36Sopenharmony_ci */ 38762306a36Sopenharmony_ci#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 38862306a36Sopenharmony_ci#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 38962306a36Sopenharmony_ci#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 39062306a36Sopenharmony_ci#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 39162306a36Sopenharmony_ci#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 39262306a36Sopenharmony_ci#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 39362306a36Sopenharmony_ci#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 39462306a36Sopenharmony_ci#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 39562306a36Sopenharmony_ci#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 39662306a36Sopenharmony_ci#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci/* 40062306a36Sopenharmony_ci * Format Modifiers: 40162306a36Sopenharmony_ci * 40262306a36Sopenharmony_ci * Format modifiers describe, typically, a re-ordering or modification 40362306a36Sopenharmony_ci * of the data in a plane of an FB. This can be used to express tiled/ 40462306a36Sopenharmony_ci * swizzled formats, or compression, or a combination of the two. 40562306a36Sopenharmony_ci * 40662306a36Sopenharmony_ci * The upper 8 bits of the format modifier are a vendor-id as assigned 40762306a36Sopenharmony_ci * below. The lower 56 bits are assigned as vendor sees fit. 40862306a36Sopenharmony_ci */ 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci/* Vendor Ids: */ 41162306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_NONE 0 41262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 41362306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 41462306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03 41562306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 41662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 41762306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 41862306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 41962306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 42062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 42162306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci/* add more to the end as needed */ 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci#define fourcc_mod_get_vendor(modifier) \ 42862306a36Sopenharmony_ci (((modifier) >> 56) & 0xff) 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci#define fourcc_mod_is_vendor(modifier, vendor) \ 43162306a36Sopenharmony_ci (fourcc_mod_get_vendor(modifier) == DRM_FORMAT_MOD_VENDOR_## vendor) 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_ci#define fourcc_mod_code(vendor, val) \ 43462306a36Sopenharmony_ci ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci/* 43762306a36Sopenharmony_ci * Format Modifier tokens: 43862306a36Sopenharmony_ci * 43962306a36Sopenharmony_ci * When adding a new token please document the layout with a code comment, 44062306a36Sopenharmony_ci * similar to the fourcc codes above. drm_fourcc.h is considered the 44162306a36Sopenharmony_ci * authoritative source for all of these. 44262306a36Sopenharmony_ci * 44362306a36Sopenharmony_ci * Generic modifier names: 44462306a36Sopenharmony_ci * 44562306a36Sopenharmony_ci * DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral names 44662306a36Sopenharmony_ci * for layouts which are common across multiple vendors. To preserve 44762306a36Sopenharmony_ci * compatibility, in cases where a vendor-specific definition already exists and 44862306a36Sopenharmony_ci * a generic name for it is desired, the common name is a purely symbolic alias 44962306a36Sopenharmony_ci * and must use the same numerical value as the original definition. 45062306a36Sopenharmony_ci * 45162306a36Sopenharmony_ci * Note that generic names should only be used for modifiers which describe 45262306a36Sopenharmony_ci * generic layouts (such as pixel re-ordering), which may have 45362306a36Sopenharmony_ci * independently-developed support across multiple vendors. 45462306a36Sopenharmony_ci * 45562306a36Sopenharmony_ci * In future cases where a generic layout is identified before merging with a 45662306a36Sopenharmony_ci * vendor-specific modifier, a new 'GENERIC' vendor or modifier using vendor 45762306a36Sopenharmony_ci * 'NONE' could be considered. This should only be for obvious, exceptional 45862306a36Sopenharmony_ci * cases to avoid polluting the 'GENERIC' namespace with modifiers which only 45962306a36Sopenharmony_ci * apply to a single vendor. 46062306a36Sopenharmony_ci * 46162306a36Sopenharmony_ci * Generic names should not be used for cases where multiple hardware vendors 46262306a36Sopenharmony_ci * have implementations of the same standardised compression scheme (such as 46362306a36Sopenharmony_ci * AFBC). In those cases, all implementations should use the same format 46462306a36Sopenharmony_ci * modifier(s), reflecting the vendor of the standard. 46562306a36Sopenharmony_ci */ 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci/* 47062306a36Sopenharmony_ci * Invalid Modifier 47162306a36Sopenharmony_ci * 47262306a36Sopenharmony_ci * This modifier can be used as a sentinel to terminate the format modifiers 47362306a36Sopenharmony_ci * list, or to initialize a variable with an invalid modifier. It might also be 47462306a36Sopenharmony_ci * used to report an error back to userspace for certain APIs. 47562306a36Sopenharmony_ci */ 47662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci/* 47962306a36Sopenharmony_ci * Linear Layout 48062306a36Sopenharmony_ci * 48162306a36Sopenharmony_ci * Just plain linear layout. Note that this is different from no specifying any 48262306a36Sopenharmony_ci * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), 48362306a36Sopenharmony_ci * which tells the driver to also take driver-internal information into account 48462306a36Sopenharmony_ci * and so might actually result in a tiled framebuffer. 48562306a36Sopenharmony_ci */ 48662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_ci/* 48962306a36Sopenharmony_ci * Deprecated: use DRM_FORMAT_MOD_LINEAR instead 49062306a36Sopenharmony_ci * 49162306a36Sopenharmony_ci * The "none" format modifier doesn't actually mean that the modifier is 49262306a36Sopenharmony_ci * implicit, instead it means that the layout is linear. Whether modifiers are 49362306a36Sopenharmony_ci * used is out-of-band information carried in an API-specific way (e.g. in a 49462306a36Sopenharmony_ci * flag for drm_mode_fb_cmd2). 49562306a36Sopenharmony_ci */ 49662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NONE 0 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci/* Intel framebuffer modifiers */ 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci/* 50162306a36Sopenharmony_ci * Intel X-tiling layout 50262306a36Sopenharmony_ci * 50362306a36Sopenharmony_ci * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 50462306a36Sopenharmony_ci * in row-major layout. Within the tile bytes are laid out row-major, with 50562306a36Sopenharmony_ci * a platform-dependent stride. On top of that the memory can apply 50662306a36Sopenharmony_ci * platform-depending swizzling of some higher address bits into bit6. 50762306a36Sopenharmony_ci * 50862306a36Sopenharmony_ci * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 50962306a36Sopenharmony_ci * On earlier platforms the is highly platforms specific and not useful for 51062306a36Sopenharmony_ci * cross-driver sharing. It exists since on a given platform it does uniquely 51162306a36Sopenharmony_ci * identify the layout in a simple way for i915-specific userspace, which 51262306a36Sopenharmony_ci * facilitated conversion of userspace to modifiers. Additionally the exact 51362306a36Sopenharmony_ci * format on some really old platforms is not known. 51462306a36Sopenharmony_ci */ 51562306a36Sopenharmony_ci#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 51662306a36Sopenharmony_ci 51762306a36Sopenharmony_ci/* 51862306a36Sopenharmony_ci * Intel Y-tiling layout 51962306a36Sopenharmony_ci * 52062306a36Sopenharmony_ci * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 52162306a36Sopenharmony_ci * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 52262306a36Sopenharmony_ci * chunks column-major, with a platform-dependent height. On top of that the 52362306a36Sopenharmony_ci * memory can apply platform-depending swizzling of some higher address bits 52462306a36Sopenharmony_ci * into bit6. 52562306a36Sopenharmony_ci * 52662306a36Sopenharmony_ci * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 52762306a36Sopenharmony_ci * On earlier platforms the is highly platforms specific and not useful for 52862306a36Sopenharmony_ci * cross-driver sharing. It exists since on a given platform it does uniquely 52962306a36Sopenharmony_ci * identify the layout in a simple way for i915-specific userspace, which 53062306a36Sopenharmony_ci * facilitated conversion of userspace to modifiers. Additionally the exact 53162306a36Sopenharmony_ci * format on some really old platforms is not known. 53262306a36Sopenharmony_ci */ 53362306a36Sopenharmony_ci#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ci/* 53662306a36Sopenharmony_ci * Intel Yf-tiling layout 53762306a36Sopenharmony_ci * 53862306a36Sopenharmony_ci * This is a tiled layout using 4Kb tiles in row-major layout. 53962306a36Sopenharmony_ci * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 54062306a36Sopenharmony_ci * are arranged in four groups (two wide, two high) with column-major layout. 54162306a36Sopenharmony_ci * Each group therefore consits out of four 256 byte units, which are also laid 54262306a36Sopenharmony_ci * out as 2x2 column-major. 54362306a36Sopenharmony_ci * 256 byte units are made out of four 64 byte blocks of pixels, producing 54462306a36Sopenharmony_ci * either a square block or a 2:1 unit. 54562306a36Sopenharmony_ci * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 54662306a36Sopenharmony_ci * in pixel depends on the pixel depth. 54762306a36Sopenharmony_ci */ 54862306a36Sopenharmony_ci#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ci/* 55162306a36Sopenharmony_ci * Intel color control surface (CCS) for render compression 55262306a36Sopenharmony_ci * 55362306a36Sopenharmony_ci * The framebuffer format must be one of the 8:8:8:8 RGB formats. 55462306a36Sopenharmony_ci * The main surface will be plane index 0 and must be Y/Yf-tiled, 55562306a36Sopenharmony_ci * the CCS will be plane index 1. 55662306a36Sopenharmony_ci * 55762306a36Sopenharmony_ci * Each CCS tile matches a 1024x512 pixel area of the main surface. 55862306a36Sopenharmony_ci * To match certain aspects of the 3D hardware the CCS is 55962306a36Sopenharmony_ci * considered to be made up of normal 128Bx32 Y tiles, Thus 56062306a36Sopenharmony_ci * the CCS pitch must be specified in multiples of 128 bytes. 56162306a36Sopenharmony_ci * 56262306a36Sopenharmony_ci * In reality the CCS tile appears to be a 64Bx64 Y tile, composed 56362306a36Sopenharmony_ci * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. 56462306a36Sopenharmony_ci * But that fact is not relevant unless the memory is accessed 56562306a36Sopenharmony_ci * directly. 56662306a36Sopenharmony_ci */ 56762306a36Sopenharmony_ci#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) 56862306a36Sopenharmony_ci#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_ci/* 57162306a36Sopenharmony_ci * Intel color control surfaces (CCS) for Gen-12 render compression. 57262306a36Sopenharmony_ci * 57362306a36Sopenharmony_ci * The main surface is Y-tiled and at plane index 0, the CCS is linear and 57462306a36Sopenharmony_ci * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 57562306a36Sopenharmony_ci * main surface. In other words, 4 bits in CCS map to a main surface cache 57662306a36Sopenharmony_ci * line pair. The main surface pitch is required to be a multiple of four 57762306a36Sopenharmony_ci * Y-tile widths. 57862306a36Sopenharmony_ci */ 57962306a36Sopenharmony_ci#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6) 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_ci/* 58262306a36Sopenharmony_ci * Intel color control surfaces (CCS) for Gen-12 media compression 58362306a36Sopenharmony_ci * 58462306a36Sopenharmony_ci * The main surface is Y-tiled and at plane index 0, the CCS is linear and 58562306a36Sopenharmony_ci * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 58662306a36Sopenharmony_ci * main surface. In other words, 4 bits in CCS map to a main surface cache 58762306a36Sopenharmony_ci * line pair. The main surface pitch is required to be a multiple of four 58862306a36Sopenharmony_ci * Y-tile widths. For semi-planar formats like NV12, CCS planes follow the 58962306a36Sopenharmony_ci * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 59062306a36Sopenharmony_ci * planes 2 and 3 for the respective CCS. 59162306a36Sopenharmony_ci */ 59262306a36Sopenharmony_ci#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7) 59362306a36Sopenharmony_ci 59462306a36Sopenharmony_ci/* 59562306a36Sopenharmony_ci * Intel Color Control Surface with Clear Color (CCS) for Gen-12 render 59662306a36Sopenharmony_ci * compression. 59762306a36Sopenharmony_ci * 59862306a36Sopenharmony_ci * The main surface is Y-tiled and is at plane index 0 whereas CCS is linear 59962306a36Sopenharmony_ci * and at index 1. The clear color is stored at index 2, and the pitch should 60062306a36Sopenharmony_ci * be 64 bytes aligned. The clear color structure is 256 bits. The first 128 bits 60162306a36Sopenharmony_ci * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 60262306a36Sopenharmony_ci * by 32 bits. The raw clear color is consumed by the 3d engine and generates 60362306a36Sopenharmony_ci * the converted clear color of size 64 bits. The first 32 bits store the Lower 60462306a36Sopenharmony_ci * Converted Clear Color value and the next 32 bits store the Higher Converted 60562306a36Sopenharmony_ci * Clear Color value when applicable. The Converted Clear Color values are 60662306a36Sopenharmony_ci * consumed by the DE. The last 64 bits are used to store Color Discard Enable 60762306a36Sopenharmony_ci * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 60862306a36Sopenharmony_ci * corresponds to an area of 4x1 tiles in the main surface. The main surface 60962306a36Sopenharmony_ci * pitch is required to be a multiple of 4 tile widths. 61062306a36Sopenharmony_ci */ 61162306a36Sopenharmony_ci#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8) 61262306a36Sopenharmony_ci 61362306a36Sopenharmony_ci/* 61462306a36Sopenharmony_ci * Intel Tile 4 layout 61562306a36Sopenharmony_ci * 61662306a36Sopenharmony_ci * This is a tiled layout using 4KB tiles in a row-major layout. It has the same 61762306a36Sopenharmony_ci * shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4). It 61862306a36Sopenharmony_ci * only differs from Tile Y at the 256B granularity in between. At this 61962306a36Sopenharmony_ci * granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a shape 62062306a36Sopenharmony_ci * of 64B x 8 rows. 62162306a36Sopenharmony_ci */ 62262306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9) 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ci/* 62562306a36Sopenharmony_ci * Intel color control surfaces (CCS) for DG2 render compression. 62662306a36Sopenharmony_ci * 62762306a36Sopenharmony_ci * The main surface is Tile 4 and at plane index 0. The CCS data is stored 62862306a36Sopenharmony_ci * outside of the GEM object in a reserved memory area dedicated for the 62962306a36Sopenharmony_ci * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The 63062306a36Sopenharmony_ci * main surface pitch is required to be a multiple of four Tile 4 widths. 63162306a36Sopenharmony_ci */ 63262306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS fourcc_mod_code(INTEL, 10) 63362306a36Sopenharmony_ci 63462306a36Sopenharmony_ci/* 63562306a36Sopenharmony_ci * Intel color control surfaces (CCS) for DG2 media compression. 63662306a36Sopenharmony_ci * 63762306a36Sopenharmony_ci * The main surface is Tile 4 and at plane index 0. For semi-planar formats 63862306a36Sopenharmony_ci * like NV12, the Y and UV planes are Tile 4 and are located at plane indices 63962306a36Sopenharmony_ci * 0 and 1, respectively. The CCS for all planes are stored outside of the 64062306a36Sopenharmony_ci * GEM object in a reserved memory area dedicated for the storage of the 64162306a36Sopenharmony_ci * CCS data for all RC/RC_CC/MC compressible GEM objects. The main surface 64262306a36Sopenharmony_ci * pitch is required to be a multiple of four Tile 4 widths. 64362306a36Sopenharmony_ci */ 64462306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_DG2_MC_CCS fourcc_mod_code(INTEL, 11) 64562306a36Sopenharmony_ci 64662306a36Sopenharmony_ci/* 64762306a36Sopenharmony_ci * Intel Color Control Surface with Clear Color (CCS) for DG2 render compression. 64862306a36Sopenharmony_ci * 64962306a36Sopenharmony_ci * The main surface is Tile 4 and at plane index 0. The CCS data is stored 65062306a36Sopenharmony_ci * outside of the GEM object in a reserved memory area dedicated for the 65162306a36Sopenharmony_ci * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The 65262306a36Sopenharmony_ci * main surface pitch is required to be a multiple of four Tile 4 widths. The 65362306a36Sopenharmony_ci * clear color is stored at plane index 1 and the pitch should be 64 bytes 65462306a36Sopenharmony_ci * aligned. The format of the 256 bits of clear color data matches the one used 65562306a36Sopenharmony_ci * for the I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC modifier, see its description 65662306a36Sopenharmony_ci * for details. 65762306a36Sopenharmony_ci */ 65862306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12) 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ci/* 66162306a36Sopenharmony_ci * Intel Color Control Surfaces (CCS) for display ver. 14 render compression. 66262306a36Sopenharmony_ci * 66362306a36Sopenharmony_ci * The main surface is tile4 and at plane index 0, the CCS is linear and 66462306a36Sopenharmony_ci * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 66562306a36Sopenharmony_ci * main surface. In other words, 4 bits in CCS map to a main surface cache 66662306a36Sopenharmony_ci * line pair. The main surface pitch is required to be a multiple of four 66762306a36Sopenharmony_ci * tile4 widths. 66862306a36Sopenharmony_ci */ 66962306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS fourcc_mod_code(INTEL, 13) 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_ci/* 67262306a36Sopenharmony_ci * Intel Color Control Surfaces (CCS) for display ver. 14 media compression 67362306a36Sopenharmony_ci * 67462306a36Sopenharmony_ci * The main surface is tile4 and at plane index 0, the CCS is linear and 67562306a36Sopenharmony_ci * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 67662306a36Sopenharmony_ci * main surface. In other words, 4 bits in CCS map to a main surface cache 67762306a36Sopenharmony_ci * line pair. The main surface pitch is required to be a multiple of four 67862306a36Sopenharmony_ci * tile4 widths. For semi-planar formats like NV12, CCS planes follow the 67962306a36Sopenharmony_ci * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 68062306a36Sopenharmony_ci * planes 2 and 3 for the respective CCS. 68162306a36Sopenharmony_ci */ 68262306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_MTL_MC_CCS fourcc_mod_code(INTEL, 14) 68362306a36Sopenharmony_ci 68462306a36Sopenharmony_ci/* 68562306a36Sopenharmony_ci * Intel Color Control Surface with Clear Color (CCS) for display ver. 14 render 68662306a36Sopenharmony_ci * compression. 68762306a36Sopenharmony_ci * 68862306a36Sopenharmony_ci * The main surface is tile4 and is at plane index 0 whereas CCS is linear 68962306a36Sopenharmony_ci * and at index 1. The clear color is stored at index 2, and the pitch should 69062306a36Sopenharmony_ci * be ignored. The clear color structure is 256 bits. The first 128 bits 69162306a36Sopenharmony_ci * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 69262306a36Sopenharmony_ci * by 32 bits. The raw clear color is consumed by the 3d engine and generates 69362306a36Sopenharmony_ci * the converted clear color of size 64 bits. The first 32 bits store the Lower 69462306a36Sopenharmony_ci * Converted Clear Color value and the next 32 bits store the Higher Converted 69562306a36Sopenharmony_ci * Clear Color value when applicable. The Converted Clear Color values are 69662306a36Sopenharmony_ci * consumed by the DE. The last 64 bits are used to store Color Discard Enable 69762306a36Sopenharmony_ci * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 69862306a36Sopenharmony_ci * corresponds to an area of 4x1 tiles in the main surface. The main surface 69962306a36Sopenharmony_ci * pitch is required to be a multiple of 4 tile widths. 70062306a36Sopenharmony_ci */ 70162306a36Sopenharmony_ci#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC fourcc_mod_code(INTEL, 15) 70262306a36Sopenharmony_ci 70362306a36Sopenharmony_ci/* 70462306a36Sopenharmony_ci * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 70562306a36Sopenharmony_ci * 70662306a36Sopenharmony_ci * Macroblocks are laid in a Z-shape, and each pixel data is following the 70762306a36Sopenharmony_ci * standard NV12 style. 70862306a36Sopenharmony_ci * As for NV12, an image is the result of two frame buffers: one for Y, 70962306a36Sopenharmony_ci * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 71062306a36Sopenharmony_ci * Alignment requirements are (for each buffer): 71162306a36Sopenharmony_ci * - multiple of 128 pixels for the width 71262306a36Sopenharmony_ci * - multiple of 32 pixels for the height 71362306a36Sopenharmony_ci * 71462306a36Sopenharmony_ci * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 71562306a36Sopenharmony_ci */ 71662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 71762306a36Sopenharmony_ci 71862306a36Sopenharmony_ci/* 71962306a36Sopenharmony_ci * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks 72062306a36Sopenharmony_ci * 72162306a36Sopenharmony_ci * This is a simple tiled layout using tiles of 16x16 pixels in a row-major 72262306a36Sopenharmony_ci * layout. For YCbCr formats Cb/Cr components are taken in such a way that 72362306a36Sopenharmony_ci * they correspond to their 16x16 luma block. 72462306a36Sopenharmony_ci */ 72562306a36Sopenharmony_ci#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_ci/* 72862306a36Sopenharmony_ci * Qualcomm Compressed Format 72962306a36Sopenharmony_ci * 73062306a36Sopenharmony_ci * Refers to a compressed variant of the base format that is compressed. 73162306a36Sopenharmony_ci * Implementation may be platform and base-format specific. 73262306a36Sopenharmony_ci * 73362306a36Sopenharmony_ci * Each macrotile consists of m x n (mostly 4 x 4) tiles. 73462306a36Sopenharmony_ci * Pixel data pitch/stride is aligned with macrotile width. 73562306a36Sopenharmony_ci * Pixel data height is aligned with macrotile height. 73662306a36Sopenharmony_ci * Entire pixel data buffer is aligned with 4k(bytes). 73762306a36Sopenharmony_ci */ 73862306a36Sopenharmony_ci#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci/* 74162306a36Sopenharmony_ci * Qualcomm Tiled Format 74262306a36Sopenharmony_ci * 74362306a36Sopenharmony_ci * Similar to DRM_FORMAT_MOD_QCOM_COMPRESSED but not compressed. 74462306a36Sopenharmony_ci * Implementation may be platform and base-format specific. 74562306a36Sopenharmony_ci * 74662306a36Sopenharmony_ci * Each macrotile consists of m x n (mostly 4 x 4) tiles. 74762306a36Sopenharmony_ci * Pixel data pitch/stride is aligned with macrotile width. 74862306a36Sopenharmony_ci * Pixel data height is aligned with macrotile height. 74962306a36Sopenharmony_ci * Entire pixel data buffer is aligned with 4k(bytes). 75062306a36Sopenharmony_ci */ 75162306a36Sopenharmony_ci#define DRM_FORMAT_MOD_QCOM_TILED3 fourcc_mod_code(QCOM, 3) 75262306a36Sopenharmony_ci 75362306a36Sopenharmony_ci/* 75462306a36Sopenharmony_ci * Qualcomm Alternate Tiled Format 75562306a36Sopenharmony_ci * 75662306a36Sopenharmony_ci * Alternate tiled format typically only used within GMEM. 75762306a36Sopenharmony_ci * Implementation may be platform and base-format specific. 75862306a36Sopenharmony_ci */ 75962306a36Sopenharmony_ci#define DRM_FORMAT_MOD_QCOM_TILED2 fourcc_mod_code(QCOM, 2) 76062306a36Sopenharmony_ci 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci/* Vivante framebuffer modifiers */ 76362306a36Sopenharmony_ci 76462306a36Sopenharmony_ci/* 76562306a36Sopenharmony_ci * Vivante 4x4 tiling layout 76662306a36Sopenharmony_ci * 76762306a36Sopenharmony_ci * This is a simple tiled layout using tiles of 4x4 pixels in a row-major 76862306a36Sopenharmony_ci * layout. 76962306a36Sopenharmony_ci */ 77062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) 77162306a36Sopenharmony_ci 77262306a36Sopenharmony_ci/* 77362306a36Sopenharmony_ci * Vivante 64x64 super-tiling layout 77462306a36Sopenharmony_ci * 77562306a36Sopenharmony_ci * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile 77662306a36Sopenharmony_ci * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- 77762306a36Sopenharmony_ci * major layout. 77862306a36Sopenharmony_ci * 77962306a36Sopenharmony_ci * For more information: see 78062306a36Sopenharmony_ci * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling 78162306a36Sopenharmony_ci */ 78262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) 78362306a36Sopenharmony_ci 78462306a36Sopenharmony_ci/* 78562306a36Sopenharmony_ci * Vivante 4x4 tiling layout for dual-pipe 78662306a36Sopenharmony_ci * 78762306a36Sopenharmony_ci * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a 78862306a36Sopenharmony_ci * different base address. Offsets from the base addresses are therefore halved 78962306a36Sopenharmony_ci * compared to the non-split tiled layout. 79062306a36Sopenharmony_ci */ 79162306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) 79262306a36Sopenharmony_ci 79362306a36Sopenharmony_ci/* 79462306a36Sopenharmony_ci * Vivante 64x64 super-tiling layout for dual-pipe 79562306a36Sopenharmony_ci * 79662306a36Sopenharmony_ci * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile 79762306a36Sopenharmony_ci * starts at a different base address. Offsets from the base addresses are 79862306a36Sopenharmony_ci * therefore halved compared to the non-split super-tiled layout. 79962306a36Sopenharmony_ci */ 80062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci/* 80362306a36Sopenharmony_ci * Vivante TS (tile-status) buffer modifiers. They can be combined with all of 80462306a36Sopenharmony_ci * the color buffer tiling modifiers defined above. When TS is present it's a 80562306a36Sopenharmony_ci * separate buffer containing the clear/compression status of each tile. The 80662306a36Sopenharmony_ci * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer 80762306a36Sopenharmony_ci * tile size in bytes covered by one entry in the status buffer and s is the 80862306a36Sopenharmony_ci * number of status bits per entry. 80962306a36Sopenharmony_ci * We reserve the top 8 bits of the Vivante modifier space for tile status 81062306a36Sopenharmony_ci * clear/compression modifiers, as future cores might add some more TS layout 81162306a36Sopenharmony_ci * variations. 81262306a36Sopenharmony_ci */ 81362306a36Sopenharmony_ci#define VIVANTE_MOD_TS_64_4 (1ULL << 48) 81462306a36Sopenharmony_ci#define VIVANTE_MOD_TS_64_2 (2ULL << 48) 81562306a36Sopenharmony_ci#define VIVANTE_MOD_TS_128_4 (3ULL << 48) 81662306a36Sopenharmony_ci#define VIVANTE_MOD_TS_256_4 (4ULL << 48) 81762306a36Sopenharmony_ci#define VIVANTE_MOD_TS_MASK (0xfULL << 48) 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci/* 82062306a36Sopenharmony_ci * Vivante compression modifiers. Those depend on a TS modifier being present 82162306a36Sopenharmony_ci * as the TS bits get reinterpreted as compression tags instead of simple 82262306a36Sopenharmony_ci * clear markers when compression is enabled. 82362306a36Sopenharmony_ci */ 82462306a36Sopenharmony_ci#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52) 82562306a36Sopenharmony_ci#define VIVANTE_MOD_COMP_MASK (0xfULL << 52) 82662306a36Sopenharmony_ci 82762306a36Sopenharmony_ci/* Masking out the extension bits will yield the base modifier. */ 82862306a36Sopenharmony_ci#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \ 82962306a36Sopenharmony_ci VIVANTE_MOD_COMP_MASK) 83062306a36Sopenharmony_ci 83162306a36Sopenharmony_ci/* NVIDIA frame buffer modifiers */ 83262306a36Sopenharmony_ci 83362306a36Sopenharmony_ci/* 83462306a36Sopenharmony_ci * Tegra Tiled Layout, used by Tegra 2, 3 and 4. 83562306a36Sopenharmony_ci * 83662306a36Sopenharmony_ci * Pixels are arranged in simple tiles of 16 x 16 bytes. 83762306a36Sopenharmony_ci */ 83862306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1) 83962306a36Sopenharmony_ci 84062306a36Sopenharmony_ci/* 84162306a36Sopenharmony_ci * Generalized Block Linear layout, used by desktop GPUs starting with NV50/G80, 84262306a36Sopenharmony_ci * and Tegra GPUs starting with Tegra K1. 84362306a36Sopenharmony_ci * 84462306a36Sopenharmony_ci * Pixels are arranged in Groups of Bytes (GOBs). GOB size and layout varies 84562306a36Sopenharmony_ci * based on the architecture generation. GOBs themselves are then arranged in 84662306a36Sopenharmony_ci * 3D blocks, with the block dimensions (in terms of GOBs) always being a power 84762306a36Sopenharmony_ci * of two, and hence expressible as their log2 equivalent (E.g., "2" represents 84862306a36Sopenharmony_ci * a block depth or height of "4"). 84962306a36Sopenharmony_ci * 85062306a36Sopenharmony_ci * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 85162306a36Sopenharmony_ci * in full detail. 85262306a36Sopenharmony_ci * 85362306a36Sopenharmony_ci * Macro 85462306a36Sopenharmony_ci * Bits Param Description 85562306a36Sopenharmony_ci * ---- ----- ----------------------------------------------------------------- 85662306a36Sopenharmony_ci * 85762306a36Sopenharmony_ci * 3:0 h log2(height) of each block, in GOBs. Placed here for 85862306a36Sopenharmony_ci * compatibility with the existing 85962306a36Sopenharmony_ci * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 86062306a36Sopenharmony_ci * 86162306a36Sopenharmony_ci * 4:4 - Must be 1, to indicate block-linear layout. Necessary for 86262306a36Sopenharmony_ci * compatibility with the existing 86362306a36Sopenharmony_ci * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 86462306a36Sopenharmony_ci * 86562306a36Sopenharmony_ci * 8:5 - Reserved (To support 3D-surfaces with variable log2(depth) block 86662306a36Sopenharmony_ci * size). Must be zero. 86762306a36Sopenharmony_ci * 86862306a36Sopenharmony_ci * Note there is no log2(width) parameter. Some portions of the 86962306a36Sopenharmony_ci * hardware support a block width of two gobs, but it is impractical 87062306a36Sopenharmony_ci * to use due to lack of support elsewhere, and has no known 87162306a36Sopenharmony_ci * benefits. 87262306a36Sopenharmony_ci * 87362306a36Sopenharmony_ci * 11:9 - Reserved (To support 2D-array textures with variable array stride 87462306a36Sopenharmony_ci * in blocks, specified via log2(tile width in blocks)). Must be 87562306a36Sopenharmony_ci * zero. 87662306a36Sopenharmony_ci * 87762306a36Sopenharmony_ci * 19:12 k Page Kind. This value directly maps to a field in the page 87862306a36Sopenharmony_ci * tables of all GPUs >= NV50. It affects the exact layout of bits 87962306a36Sopenharmony_ci * in memory and can be derived from the tuple 88062306a36Sopenharmony_ci * 88162306a36Sopenharmony_ci * (format, GPU model, compression type, samples per pixel) 88262306a36Sopenharmony_ci * 88362306a36Sopenharmony_ci * Where compression type is defined below. If GPU model were 88462306a36Sopenharmony_ci * implied by the format modifier, format, or memory buffer, page 88562306a36Sopenharmony_ci * kind would not need to be included in the modifier itself, but 88662306a36Sopenharmony_ci * since the modifier should define the layout of the associated 88762306a36Sopenharmony_ci * memory buffer independent from any device or other context, it 88862306a36Sopenharmony_ci * must be included here. 88962306a36Sopenharmony_ci * 89062306a36Sopenharmony_ci * 21:20 g GOB Height and Page Kind Generation. The height of a GOB changed 89162306a36Sopenharmony_ci * starting with Fermi GPUs. Additionally, the mapping between page 89262306a36Sopenharmony_ci * kind and bit layout has changed at various points. 89362306a36Sopenharmony_ci * 89462306a36Sopenharmony_ci * 0 = Gob Height 8, Fermi - Volta, Tegra K1+ Page Kind mapping 89562306a36Sopenharmony_ci * 1 = Gob Height 4, G80 - GT2XX Page Kind mapping 89662306a36Sopenharmony_ci * 2 = Gob Height 8, Turing+ Page Kind mapping 89762306a36Sopenharmony_ci * 3 = Reserved for future use. 89862306a36Sopenharmony_ci * 89962306a36Sopenharmony_ci * 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further 90062306a36Sopenharmony_ci * bit remapping step that occurs at an even lower level than the 90162306a36Sopenharmony_ci * page kind and block linear swizzles. This causes the layout of 90262306a36Sopenharmony_ci * surfaces mapped in those SOC's GPUs to be incompatible with the 90362306a36Sopenharmony_ci * equivalent mapping on other GPUs in the same system. 90462306a36Sopenharmony_ci * 90562306a36Sopenharmony_ci * 0 = Tegra K1 - Tegra Parker/TX2 Layout. 90662306a36Sopenharmony_ci * 1 = Desktop GPU and Tegra Xavier+ Layout 90762306a36Sopenharmony_ci * 90862306a36Sopenharmony_ci * 25:23 c Lossless Framebuffer Compression type. 90962306a36Sopenharmony_ci * 91062306a36Sopenharmony_ci * 0 = none 91162306a36Sopenharmony_ci * 1 = ROP/3D, layout 1, exact compression format implied by Page 91262306a36Sopenharmony_ci * Kind field 91362306a36Sopenharmony_ci * 2 = ROP/3D, layout 2, exact compression format implied by Page 91462306a36Sopenharmony_ci * Kind field 91562306a36Sopenharmony_ci * 3 = CDE horizontal 91662306a36Sopenharmony_ci * 4 = CDE vertical 91762306a36Sopenharmony_ci * 5 = Reserved for future use 91862306a36Sopenharmony_ci * 6 = Reserved for future use 91962306a36Sopenharmony_ci * 7 = Reserved for future use 92062306a36Sopenharmony_ci * 92162306a36Sopenharmony_ci * 55:25 - Reserved for future use. Must be zero. 92262306a36Sopenharmony_ci */ 92362306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(c, s, g, k, h) \ 92462306a36Sopenharmony_ci fourcc_mod_code(NVIDIA, (0x10 | \ 92562306a36Sopenharmony_ci ((h) & 0xf) | \ 92662306a36Sopenharmony_ci (((k) & 0xff) << 12) | \ 92762306a36Sopenharmony_ci (((g) & 0x3) << 20) | \ 92862306a36Sopenharmony_ci (((s) & 0x1) << 22) | \ 92962306a36Sopenharmony_ci (((c) & 0x7) << 23))) 93062306a36Sopenharmony_ci 93162306a36Sopenharmony_ci/* To grandfather in prior block linear format modifiers to the above layout, 93262306a36Sopenharmony_ci * the page kind "0", which corresponds to "pitch/linear" and hence is unusable 93362306a36Sopenharmony_ci * with block-linear layouts, is remapped within drivers to the value 0xfe, 93462306a36Sopenharmony_ci * which corresponds to the "generic" kind used for simple single-sample 93562306a36Sopenharmony_ci * uncompressed color formats on Fermi - Volta GPUs. 93662306a36Sopenharmony_ci */ 93762306a36Sopenharmony_cistatic inline __u64 93862306a36Sopenharmony_cidrm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) 93962306a36Sopenharmony_ci{ 94062306a36Sopenharmony_ci if (!(modifier & 0x10) || (modifier & (0xff << 12))) 94162306a36Sopenharmony_ci return modifier; 94262306a36Sopenharmony_ci else 94362306a36Sopenharmony_ci return modifier | (0xfe << 12); 94462306a36Sopenharmony_ci} 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci/* 94762306a36Sopenharmony_ci * 16Bx2 Block Linear layout, used by Tegra K1 and later 94862306a36Sopenharmony_ci * 94962306a36Sopenharmony_ci * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked 95062306a36Sopenharmony_ci * vertically by a power of 2 (1 to 32 GOBs) to form a block. 95162306a36Sopenharmony_ci * 95262306a36Sopenharmony_ci * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. 95362306a36Sopenharmony_ci * 95462306a36Sopenharmony_ci * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. 95562306a36Sopenharmony_ci * Valid values are: 95662306a36Sopenharmony_ci * 95762306a36Sopenharmony_ci * 0 == ONE_GOB 95862306a36Sopenharmony_ci * 1 == TWO_GOBS 95962306a36Sopenharmony_ci * 2 == FOUR_GOBS 96062306a36Sopenharmony_ci * 3 == EIGHT_GOBS 96162306a36Sopenharmony_ci * 4 == SIXTEEN_GOBS 96262306a36Sopenharmony_ci * 5 == THIRTYTWO_GOBS 96362306a36Sopenharmony_ci * 96462306a36Sopenharmony_ci * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 96562306a36Sopenharmony_ci * in full detail. 96662306a36Sopenharmony_ci */ 96762306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \ 96862306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0, (v)) 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \ 97162306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0) 97262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \ 97362306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1) 97462306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \ 97562306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2) 97662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \ 97762306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3) 97862306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \ 97962306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4) 98062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \ 98162306a36Sopenharmony_ci DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5) 98262306a36Sopenharmony_ci 98362306a36Sopenharmony_ci/* 98462306a36Sopenharmony_ci * Some Broadcom modifiers take parameters, for example the number of 98562306a36Sopenharmony_ci * vertical lines in the image. Reserve the lower 32 bits for modifier 98662306a36Sopenharmony_ci * type, and the next 24 bits for parameters. Top 8 bits are the 98762306a36Sopenharmony_ci * vendor code. 98862306a36Sopenharmony_ci */ 98962306a36Sopenharmony_ci#define __fourcc_mod_broadcom_param_shift 8 99062306a36Sopenharmony_ci#define __fourcc_mod_broadcom_param_bits 48 99162306a36Sopenharmony_ci#define fourcc_mod_broadcom_code(val, params) \ 99262306a36Sopenharmony_ci fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) 99362306a36Sopenharmony_ci#define fourcc_mod_broadcom_param(m) \ 99462306a36Sopenharmony_ci ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ 99562306a36Sopenharmony_ci ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) 99662306a36Sopenharmony_ci#define fourcc_mod_broadcom_mod(m) \ 99762306a36Sopenharmony_ci ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ 99862306a36Sopenharmony_ci __fourcc_mod_broadcom_param_shift)) 99962306a36Sopenharmony_ci 100062306a36Sopenharmony_ci/* 100162306a36Sopenharmony_ci * Broadcom VC4 "T" format 100262306a36Sopenharmony_ci * 100362306a36Sopenharmony_ci * This is the primary layout that the V3D GPU can texture from (it 100462306a36Sopenharmony_ci * can't do linear). The T format has: 100562306a36Sopenharmony_ci * 100662306a36Sopenharmony_ci * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 100762306a36Sopenharmony_ci * pixels at 32 bit depth. 100862306a36Sopenharmony_ci * 100962306a36Sopenharmony_ci * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually 101062306a36Sopenharmony_ci * 16x16 pixels). 101162306a36Sopenharmony_ci * 101262306a36Sopenharmony_ci * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On 101362306a36Sopenharmony_ci * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows 101462306a36Sopenharmony_ci * they're (TR, BR, BL, TL), where bottom left is start of memory. 101562306a36Sopenharmony_ci * 101662306a36Sopenharmony_ci * - an image made of 4k tiles in rows either left-to-right (even rows of 4k 101762306a36Sopenharmony_ci * tiles) or right-to-left (odd rows of 4k tiles). 101862306a36Sopenharmony_ci */ 101962306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) 102062306a36Sopenharmony_ci 102162306a36Sopenharmony_ci/* 102262306a36Sopenharmony_ci * Broadcom SAND format 102362306a36Sopenharmony_ci * 102462306a36Sopenharmony_ci * This is the native format that the H.264 codec block uses. For VC4 102562306a36Sopenharmony_ci * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. 102662306a36Sopenharmony_ci * 102762306a36Sopenharmony_ci * The image can be considered to be split into columns, and the 102862306a36Sopenharmony_ci * columns are placed consecutively into memory. The width of those 102962306a36Sopenharmony_ci * columns can be either 32, 64, 128, or 256 pixels, but in practice 103062306a36Sopenharmony_ci * only 128 pixel columns are used. 103162306a36Sopenharmony_ci * 103262306a36Sopenharmony_ci * The pitch between the start of each column is set to optimally 103362306a36Sopenharmony_ci * switch between SDRAM banks. This is passed as the number of lines 103462306a36Sopenharmony_ci * of column width in the modifier (we can't use the stride value due 103562306a36Sopenharmony_ci * to various core checks that look at it , so you should set the 103662306a36Sopenharmony_ci * stride to width*cpp). 103762306a36Sopenharmony_ci * 103862306a36Sopenharmony_ci * Note that the column height for this format modifier is the same 103962306a36Sopenharmony_ci * for all of the planes, assuming that each column contains both Y 104062306a36Sopenharmony_ci * and UV. Some SAND-using hardware stores UV in a separate tiled 104162306a36Sopenharmony_ci * image from Y to reduce the column height, which is not supported 104262306a36Sopenharmony_ci * with these modifiers. 104362306a36Sopenharmony_ci * 104462306a36Sopenharmony_ci * The DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT modifier is also 104562306a36Sopenharmony_ci * supported for DRM_FORMAT_P030 where the columns remain as 128 bytes 104662306a36Sopenharmony_ci * wide, but as this is a 10 bpp format that translates to 96 pixels. 104762306a36Sopenharmony_ci */ 104862306a36Sopenharmony_ci 104962306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ 105062306a36Sopenharmony_ci fourcc_mod_broadcom_code(2, v) 105162306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ 105262306a36Sopenharmony_ci fourcc_mod_broadcom_code(3, v) 105362306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ 105462306a36Sopenharmony_ci fourcc_mod_broadcom_code(4, v) 105562306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ 105662306a36Sopenharmony_ci fourcc_mod_broadcom_code(5, v) 105762306a36Sopenharmony_ci 105862306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ 105962306a36Sopenharmony_ci DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) 106062306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ 106162306a36Sopenharmony_ci DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) 106262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ 106362306a36Sopenharmony_ci DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) 106462306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ 106562306a36Sopenharmony_ci DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) 106662306a36Sopenharmony_ci 106762306a36Sopenharmony_ci/* Broadcom UIF format 106862306a36Sopenharmony_ci * 106962306a36Sopenharmony_ci * This is the common format for the current Broadcom multimedia 107062306a36Sopenharmony_ci * blocks, including V3D 3.x and newer, newer video codecs, and 107162306a36Sopenharmony_ci * displays. 107262306a36Sopenharmony_ci * 107362306a36Sopenharmony_ci * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), 107462306a36Sopenharmony_ci * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are 107562306a36Sopenharmony_ci * stored in columns, with padding between the columns to ensure that 107662306a36Sopenharmony_ci * moving from one column to the next doesn't hit the same SDRAM page 107762306a36Sopenharmony_ci * bank. 107862306a36Sopenharmony_ci * 107962306a36Sopenharmony_ci * To calculate the padding, it is assumed that each hardware block 108062306a36Sopenharmony_ci * and the software driving it knows the platform's SDRAM page size, 108162306a36Sopenharmony_ci * number of banks, and XOR address, and that it's identical between 108262306a36Sopenharmony_ci * all blocks using the format. This tiling modifier will use XOR as 108362306a36Sopenharmony_ci * necessary to reduce the padding. If a hardware block can't do XOR, 108462306a36Sopenharmony_ci * the assumption is that a no-XOR tiling modifier will be created. 108562306a36Sopenharmony_ci */ 108662306a36Sopenharmony_ci#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) 108762306a36Sopenharmony_ci 108862306a36Sopenharmony_ci/* 108962306a36Sopenharmony_ci * Arm Framebuffer Compression (AFBC) modifiers 109062306a36Sopenharmony_ci * 109162306a36Sopenharmony_ci * AFBC is a proprietary lossless image compression protocol and format. 109262306a36Sopenharmony_ci * It provides fine-grained random access and minimizes the amount of data 109362306a36Sopenharmony_ci * transferred between IP blocks. 109462306a36Sopenharmony_ci * 109562306a36Sopenharmony_ci * AFBC has several features which may be supported and/or used, which are 109662306a36Sopenharmony_ci * represented using bits in the modifier. Not all combinations are valid, 109762306a36Sopenharmony_ci * and different devices or use-cases may support different combinations. 109862306a36Sopenharmony_ci * 109962306a36Sopenharmony_ci * Further information on the use of AFBC modifiers can be found in 110062306a36Sopenharmony_ci * Documentation/gpu/afbc.rst 110162306a36Sopenharmony_ci */ 110262306a36Sopenharmony_ci 110362306a36Sopenharmony_ci/* 110462306a36Sopenharmony_ci * The top 4 bits (out of the 56 bits alloted for specifying vendor specific 110562306a36Sopenharmony_ci * modifiers) denote the category for modifiers. Currently we have three 110662306a36Sopenharmony_ci * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of 110762306a36Sopenharmony_ci * sixteen different categories. 110862306a36Sopenharmony_ci */ 110962306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_CODE(__type, __val) \ 111062306a36Sopenharmony_ci fourcc_mod_code(ARM, ((__u64)(__type) << 52) | ((__val) & 0x000fffffffffffffULL)) 111162306a36Sopenharmony_ci 111262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_TYPE_AFBC 0x00 111362306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_TYPE_MISC 0x01 111462306a36Sopenharmony_ci 111562306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) \ 111662306a36Sopenharmony_ci DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFBC, __afbc_mode) 111762306a36Sopenharmony_ci 111862306a36Sopenharmony_ci/* 111962306a36Sopenharmony_ci * AFBC superblock size 112062306a36Sopenharmony_ci * 112162306a36Sopenharmony_ci * Indicates the superblock size(s) used for the AFBC buffer. The buffer 112262306a36Sopenharmony_ci * size (in pixels) must be aligned to a multiple of the superblock size. 112362306a36Sopenharmony_ci * Four lowest significant bits(LSBs) are reserved for block size. 112462306a36Sopenharmony_ci * 112562306a36Sopenharmony_ci * Where one superblock size is specified, it applies to all planes of the 112662306a36Sopenharmony_ci * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified, 112762306a36Sopenharmony_ci * the first applies to the Luma plane and the second applies to the Chroma 112862306a36Sopenharmony_ci * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma). 112962306a36Sopenharmony_ci * Multiple superblock sizes are only valid for multi-plane YCbCr formats. 113062306a36Sopenharmony_ci */ 113162306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf 113262306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) 113362306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) 113462306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 (3ULL) 113562306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL) 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci/* 113862306a36Sopenharmony_ci * AFBC lossless colorspace transform 113962306a36Sopenharmony_ci * 114062306a36Sopenharmony_ci * Indicates that the buffer makes use of the AFBC lossless colorspace 114162306a36Sopenharmony_ci * transform. 114262306a36Sopenharmony_ci */ 114362306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_YTR (1ULL << 4) 114462306a36Sopenharmony_ci 114562306a36Sopenharmony_ci/* 114662306a36Sopenharmony_ci * AFBC block-split 114762306a36Sopenharmony_ci * 114862306a36Sopenharmony_ci * Indicates that the payload of each superblock is split. The second 114962306a36Sopenharmony_ci * half of the payload is positioned at a predefined offset from the start 115062306a36Sopenharmony_ci * of the superblock payload. 115162306a36Sopenharmony_ci */ 115262306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_ci/* 115562306a36Sopenharmony_ci * AFBC sparse layout 115662306a36Sopenharmony_ci * 115762306a36Sopenharmony_ci * This flag indicates that the payload of each superblock must be stored at a 115862306a36Sopenharmony_ci * predefined position relative to the other superblocks in the same AFBC 115962306a36Sopenharmony_ci * buffer. This order is the same order used by the header buffer. In this mode 116062306a36Sopenharmony_ci * each superblock is given the same amount of space as an uncompressed 116162306a36Sopenharmony_ci * superblock of the particular format would require, rounding up to the next 116262306a36Sopenharmony_ci * multiple of 128 bytes in size. 116362306a36Sopenharmony_ci */ 116462306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) 116562306a36Sopenharmony_ci 116662306a36Sopenharmony_ci/* 116762306a36Sopenharmony_ci * AFBC copy-block restrict 116862306a36Sopenharmony_ci * 116962306a36Sopenharmony_ci * Buffers with this flag must obey the copy-block restriction. The restriction 117062306a36Sopenharmony_ci * is such that there are no copy-blocks referring across the border of 8x8 117162306a36Sopenharmony_ci * blocks. For the subsampled data the 8x8 limitation is also subsampled. 117262306a36Sopenharmony_ci */ 117362306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_CBR (1ULL << 7) 117462306a36Sopenharmony_ci 117562306a36Sopenharmony_ci/* 117662306a36Sopenharmony_ci * AFBC tiled layout 117762306a36Sopenharmony_ci * 117862306a36Sopenharmony_ci * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all 117962306a36Sopenharmony_ci * superblocks inside a tile are stored together in memory. 8x8 tiles are used 118062306a36Sopenharmony_ci * for pixel formats up to and including 32 bpp while 4x4 tiles are used for 118162306a36Sopenharmony_ci * larger bpp formats. The order between the tiles is scan line. 118262306a36Sopenharmony_ci * When the tiled layout is used, the buffer size (in pixels) must be aligned 118362306a36Sopenharmony_ci * to the tile size. 118462306a36Sopenharmony_ci */ 118562306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_TILED (1ULL << 8) 118662306a36Sopenharmony_ci 118762306a36Sopenharmony_ci/* 118862306a36Sopenharmony_ci * AFBC solid color blocks 118962306a36Sopenharmony_ci * 119062306a36Sopenharmony_ci * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth 119162306a36Sopenharmony_ci * can be reduced if a whole superblock is a single color. 119262306a36Sopenharmony_ci */ 119362306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_SC (1ULL << 9) 119462306a36Sopenharmony_ci 119562306a36Sopenharmony_ci/* 119662306a36Sopenharmony_ci * AFBC double-buffer 119762306a36Sopenharmony_ci * 119862306a36Sopenharmony_ci * Indicates that the buffer is allocated in a layout safe for front-buffer 119962306a36Sopenharmony_ci * rendering. 120062306a36Sopenharmony_ci */ 120162306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_DB (1ULL << 10) 120262306a36Sopenharmony_ci 120362306a36Sopenharmony_ci/* 120462306a36Sopenharmony_ci * AFBC buffer content hints 120562306a36Sopenharmony_ci * 120662306a36Sopenharmony_ci * Indicates that the buffer includes per-superblock content hints. 120762306a36Sopenharmony_ci */ 120862306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_BCH (1ULL << 11) 120962306a36Sopenharmony_ci 121062306a36Sopenharmony_ci/* AFBC uncompressed storage mode 121162306a36Sopenharmony_ci * 121262306a36Sopenharmony_ci * Indicates that the buffer is using AFBC uncompressed storage mode. 121362306a36Sopenharmony_ci * In this mode all superblock payloads in the buffer use the uncompressed 121462306a36Sopenharmony_ci * storage mode, which is usually only used for data which cannot be compressed. 121562306a36Sopenharmony_ci * The buffer layout is the same as for AFBC buffers without USM set, this only 121662306a36Sopenharmony_ci * affects the storage mode of the individual superblocks. Note that even a 121762306a36Sopenharmony_ci * buffer without USM set may use uncompressed storage mode for some or all 121862306a36Sopenharmony_ci * superblocks, USM just guarantees it for all. 121962306a36Sopenharmony_ci */ 122062306a36Sopenharmony_ci#define AFBC_FORMAT_MOD_USM (1ULL << 12) 122162306a36Sopenharmony_ci 122262306a36Sopenharmony_ci/* 122362306a36Sopenharmony_ci * Arm Fixed-Rate Compression (AFRC) modifiers 122462306a36Sopenharmony_ci * 122562306a36Sopenharmony_ci * AFRC is a proprietary fixed rate image compression protocol and format, 122662306a36Sopenharmony_ci * designed to provide guaranteed bandwidth and memory footprint 122762306a36Sopenharmony_ci * reductions in graphics and media use-cases. 122862306a36Sopenharmony_ci * 122962306a36Sopenharmony_ci * AFRC buffers consist of one or more planes, with the same components 123062306a36Sopenharmony_ci * and meaning as an uncompressed buffer using the same pixel format. 123162306a36Sopenharmony_ci * 123262306a36Sopenharmony_ci * Within each plane, the pixel/luma/chroma values are grouped into 123362306a36Sopenharmony_ci * "coding unit" blocks which are individually compressed to a 123462306a36Sopenharmony_ci * fixed size (in bytes). All coding units within a given plane of a buffer 123562306a36Sopenharmony_ci * store the same number of values, and have the same compressed size. 123662306a36Sopenharmony_ci * 123762306a36Sopenharmony_ci * The coding unit size is configurable, allowing different rates of compression. 123862306a36Sopenharmony_ci * 123962306a36Sopenharmony_ci * The start of each AFRC buffer plane must be aligned to an alignment granule which 124062306a36Sopenharmony_ci * depends on the coding unit size. 124162306a36Sopenharmony_ci * 124262306a36Sopenharmony_ci * Coding Unit Size Plane Alignment 124362306a36Sopenharmony_ci * ---------------- --------------- 124462306a36Sopenharmony_ci * 16 bytes 1024 bytes 124562306a36Sopenharmony_ci * 24 bytes 512 bytes 124662306a36Sopenharmony_ci * 32 bytes 2048 bytes 124762306a36Sopenharmony_ci * 124862306a36Sopenharmony_ci * Coding units are grouped into paging tiles. AFRC buffer dimensions must be aligned 124962306a36Sopenharmony_ci * to a multiple of the paging tile dimensions. 125062306a36Sopenharmony_ci * The dimensions of each paging tile depend on whether the buffer is optimised for 125162306a36Sopenharmony_ci * scanline (SCAN layout) or rotated (ROT layout) access. 125262306a36Sopenharmony_ci * 125362306a36Sopenharmony_ci * Layout Paging Tile Width Paging Tile Height 125462306a36Sopenharmony_ci * ------ ----------------- ------------------ 125562306a36Sopenharmony_ci * SCAN 16 coding units 4 coding units 125662306a36Sopenharmony_ci * ROT 8 coding units 8 coding units 125762306a36Sopenharmony_ci * 125862306a36Sopenharmony_ci * The dimensions of each coding unit depend on the number of components 125962306a36Sopenharmony_ci * in the compressed plane and whether the buffer is optimised for 126062306a36Sopenharmony_ci * scanline (SCAN layout) or rotated (ROT layout) access. 126162306a36Sopenharmony_ci * 126262306a36Sopenharmony_ci * Number of Components in Plane Layout Coding Unit Width Coding Unit Height 126362306a36Sopenharmony_ci * ----------------------------- --------- ----------------- ------------------ 126462306a36Sopenharmony_ci * 1 SCAN 16 samples 4 samples 126562306a36Sopenharmony_ci * Example: 16x4 luma samples in a 'Y' plane 126662306a36Sopenharmony_ci * 16x4 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 126762306a36Sopenharmony_ci * ----------------------------- --------- ----------------- ------------------ 126862306a36Sopenharmony_ci * 1 ROT 8 samples 8 samples 126962306a36Sopenharmony_ci * Example: 8x8 luma samples in a 'Y' plane 127062306a36Sopenharmony_ci * 8x8 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 127162306a36Sopenharmony_ci * ----------------------------- --------- ----------------- ------------------ 127262306a36Sopenharmony_ci * 2 DONT CARE 8 samples 4 samples 127362306a36Sopenharmony_ci * Example: 8x4 chroma pairs in the 'UV' plane of a semi-planar YUV buffer 127462306a36Sopenharmony_ci * ----------------------------- --------- ----------------- ------------------ 127562306a36Sopenharmony_ci * 3 DONT CARE 4 samples 4 samples 127662306a36Sopenharmony_ci * Example: 4x4 pixels in an RGB buffer without alpha 127762306a36Sopenharmony_ci * ----------------------------- --------- ----------------- ------------------ 127862306a36Sopenharmony_ci * 4 DONT CARE 4 samples 4 samples 127962306a36Sopenharmony_ci * Example: 4x4 pixels in an RGB buffer with alpha 128062306a36Sopenharmony_ci */ 128162306a36Sopenharmony_ci 128262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_TYPE_AFRC 0x02 128362306a36Sopenharmony_ci 128462306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_AFRC(__afrc_mode) \ 128562306a36Sopenharmony_ci DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFRC, __afrc_mode) 128662306a36Sopenharmony_ci 128762306a36Sopenharmony_ci/* 128862306a36Sopenharmony_ci * AFRC coding unit size modifier. 128962306a36Sopenharmony_ci * 129062306a36Sopenharmony_ci * Indicates the number of bytes used to store each compressed coding unit for 129162306a36Sopenharmony_ci * one or more planes in an AFRC encoded buffer. The coding unit size for chrominance 129262306a36Sopenharmony_ci * is the same for both Cb and Cr, which may be stored in separate planes. 129362306a36Sopenharmony_ci * 129462306a36Sopenharmony_ci * AFRC_FORMAT_MOD_CU_SIZE_P0 indicates the number of bytes used to store 129562306a36Sopenharmony_ci * each compressed coding unit in the first plane of the buffer. For RGBA buffers 129662306a36Sopenharmony_ci * this is the only plane, while for semi-planar and fully-planar YUV buffers, 129762306a36Sopenharmony_ci * this corresponds to the luma plane. 129862306a36Sopenharmony_ci * 129962306a36Sopenharmony_ci * AFRC_FORMAT_MOD_CU_SIZE_P12 indicates the number of bytes used to store 130062306a36Sopenharmony_ci * each compressed coding unit in the second and third planes in the buffer. 130162306a36Sopenharmony_ci * For semi-planar and fully-planar YUV buffers, this corresponds to the chroma plane(s). 130262306a36Sopenharmony_ci * 130362306a36Sopenharmony_ci * For single-plane buffers, AFRC_FORMAT_MOD_CU_SIZE_P0 must be specified 130462306a36Sopenharmony_ci * and AFRC_FORMAT_MOD_CU_SIZE_P12 must be zero. 130562306a36Sopenharmony_ci * For semi-planar and fully-planar buffers, both AFRC_FORMAT_MOD_CU_SIZE_P0 and 130662306a36Sopenharmony_ci * AFRC_FORMAT_MOD_CU_SIZE_P12 must be specified. 130762306a36Sopenharmony_ci */ 130862306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_MASK 0xf 130962306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_16 (1ULL) 131062306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_24 (2ULL) 131162306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_32 (3ULL) 131262306a36Sopenharmony_ci 131362306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_P0(__afrc_cu_size) (__afrc_cu_size) 131462306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_CU_SIZE_P12(__afrc_cu_size) ((__afrc_cu_size) << 4) 131562306a36Sopenharmony_ci 131662306a36Sopenharmony_ci/* 131762306a36Sopenharmony_ci * AFRC scanline memory layout. 131862306a36Sopenharmony_ci * 131962306a36Sopenharmony_ci * Indicates if the buffer uses the scanline-optimised layout 132062306a36Sopenharmony_ci * for an AFRC encoded buffer, otherwise, it uses the rotation-optimised layout. 132162306a36Sopenharmony_ci * The memory layout is the same for all planes. 132262306a36Sopenharmony_ci */ 132362306a36Sopenharmony_ci#define AFRC_FORMAT_MOD_LAYOUT_SCAN (1ULL << 8) 132462306a36Sopenharmony_ci 132562306a36Sopenharmony_ci/* 132662306a36Sopenharmony_ci * Arm 16x16 Block U-Interleaved modifier 132762306a36Sopenharmony_ci * 132862306a36Sopenharmony_ci * This is used by Arm Mali Utgard and Midgard GPUs. It divides the image 132962306a36Sopenharmony_ci * into 16x16 pixel blocks. Blocks are stored linearly in order, but pixels 133062306a36Sopenharmony_ci * in the block are reordered. 133162306a36Sopenharmony_ci */ 133262306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ 133362306a36Sopenharmony_ci DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) 133462306a36Sopenharmony_ci 133562306a36Sopenharmony_ci/* 133662306a36Sopenharmony_ci * Allwinner tiled modifier 133762306a36Sopenharmony_ci * 133862306a36Sopenharmony_ci * This tiling mode is implemented by the VPU found on all Allwinner platforms, 133962306a36Sopenharmony_ci * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 134062306a36Sopenharmony_ci * planes. 134162306a36Sopenharmony_ci * 134262306a36Sopenharmony_ci * With this tiling, the luminance samples are disposed in tiles representing 134362306a36Sopenharmony_ci * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. 134462306a36Sopenharmony_ci * The pixel order in each tile is linear and the tiles are disposed linearly, 134562306a36Sopenharmony_ci * both in row-major order. 134662306a36Sopenharmony_ci */ 134762306a36Sopenharmony_ci#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) 134862306a36Sopenharmony_ci 134962306a36Sopenharmony_ci/* 135062306a36Sopenharmony_ci * Amlogic Video Framebuffer Compression modifiers 135162306a36Sopenharmony_ci * 135262306a36Sopenharmony_ci * Amlogic uses a proprietary lossless image compression protocol and format 135362306a36Sopenharmony_ci * for their hardware video codec accelerators, either video decoders or 135462306a36Sopenharmony_ci * video input encoders. 135562306a36Sopenharmony_ci * 135662306a36Sopenharmony_ci * It considerably reduces memory bandwidth while writing and reading 135762306a36Sopenharmony_ci * frames in memory. 135862306a36Sopenharmony_ci * 135962306a36Sopenharmony_ci * The underlying storage is considered to be 3 components, 8bit or 10-bit 136062306a36Sopenharmony_ci * per component YCbCr 420, single plane : 136162306a36Sopenharmony_ci * - DRM_FORMAT_YUV420_8BIT 136262306a36Sopenharmony_ci * - DRM_FORMAT_YUV420_10BIT 136362306a36Sopenharmony_ci * 136462306a36Sopenharmony_ci * The first 8 bits of the mode defines the layout, then the following 8 bits 136562306a36Sopenharmony_ci * defines the options changing the layout. 136662306a36Sopenharmony_ci * 136762306a36Sopenharmony_ci * Not all combinations are valid, and different SoCs may support different 136862306a36Sopenharmony_ci * combinations of layout and options. 136962306a36Sopenharmony_ci */ 137062306a36Sopenharmony_ci#define __fourcc_mod_amlogic_layout_mask 0xff 137162306a36Sopenharmony_ci#define __fourcc_mod_amlogic_options_shift 8 137262306a36Sopenharmony_ci#define __fourcc_mod_amlogic_options_mask 0xff 137362306a36Sopenharmony_ci 137462306a36Sopenharmony_ci#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \ 137562306a36Sopenharmony_ci fourcc_mod_code(AMLOGIC, \ 137662306a36Sopenharmony_ci ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ 137762306a36Sopenharmony_ci (((__options) & __fourcc_mod_amlogic_options_mask) \ 137862306a36Sopenharmony_ci << __fourcc_mod_amlogic_options_shift)) 137962306a36Sopenharmony_ci 138062306a36Sopenharmony_ci/* Amlogic FBC Layouts */ 138162306a36Sopenharmony_ci 138262306a36Sopenharmony_ci/* 138362306a36Sopenharmony_ci * Amlogic FBC Basic Layout 138462306a36Sopenharmony_ci * 138562306a36Sopenharmony_ci * The basic layout is composed of: 138662306a36Sopenharmony_ci * - a body content organized in 64x32 superblocks with 4096 bytes per 138762306a36Sopenharmony_ci * superblock in default mode. 138862306a36Sopenharmony_ci * - a 32 bytes per 128x64 header block 138962306a36Sopenharmony_ci * 139062306a36Sopenharmony_ci * This layout is transferrable between Amlogic SoCs supporting this modifier. 139162306a36Sopenharmony_ci */ 139262306a36Sopenharmony_ci#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) 139362306a36Sopenharmony_ci 139462306a36Sopenharmony_ci/* 139562306a36Sopenharmony_ci * Amlogic FBC Scatter Memory layout 139662306a36Sopenharmony_ci * 139762306a36Sopenharmony_ci * Indicates the header contains IOMMU references to the compressed 139862306a36Sopenharmony_ci * frames content to optimize memory access and layout. 139962306a36Sopenharmony_ci * 140062306a36Sopenharmony_ci * In this mode, only the header memory address is needed, thus the 140162306a36Sopenharmony_ci * content memory organization is tied to the current producer 140262306a36Sopenharmony_ci * execution and cannot be saved/dumped neither transferrable between 140362306a36Sopenharmony_ci * Amlogic SoCs supporting this modifier. 140462306a36Sopenharmony_ci * 140562306a36Sopenharmony_ci * Due to the nature of the layout, these buffers are not expected to 140662306a36Sopenharmony_ci * be accessible by the user-space clients, but only accessible by the 140762306a36Sopenharmony_ci * hardware producers and consumers. 140862306a36Sopenharmony_ci * 140962306a36Sopenharmony_ci * The user-space clients should expect a failure while trying to mmap 141062306a36Sopenharmony_ci * the DMA-BUF handle returned by the producer. 141162306a36Sopenharmony_ci */ 141262306a36Sopenharmony_ci#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) 141362306a36Sopenharmony_ci 141462306a36Sopenharmony_ci/* Amlogic FBC Layout Options Bit Mask */ 141562306a36Sopenharmony_ci 141662306a36Sopenharmony_ci/* 141762306a36Sopenharmony_ci * Amlogic FBC Memory Saving mode 141862306a36Sopenharmony_ci * 141962306a36Sopenharmony_ci * Indicates the storage is packed when pixel size is multiple of word 142062306a36Sopenharmony_ci * boudaries, i.e. 8bit should be stored in this mode to save allocation 142162306a36Sopenharmony_ci * memory. 142262306a36Sopenharmony_ci * 142362306a36Sopenharmony_ci * This mode reduces body layout to 3072 bytes per 64x32 superblock with 142462306a36Sopenharmony_ci * the basic layout and 3200 bytes per 64x32 superblock combined with 142562306a36Sopenharmony_ci * the scatter layout. 142662306a36Sopenharmony_ci */ 142762306a36Sopenharmony_ci#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) 142862306a36Sopenharmony_ci 142962306a36Sopenharmony_ci/* 143062306a36Sopenharmony_ci * AMD modifiers 143162306a36Sopenharmony_ci * 143262306a36Sopenharmony_ci * Memory layout: 143362306a36Sopenharmony_ci * 143462306a36Sopenharmony_ci * without DCC: 143562306a36Sopenharmony_ci * - main surface 143662306a36Sopenharmony_ci * 143762306a36Sopenharmony_ci * with DCC & without DCC_RETILE: 143862306a36Sopenharmony_ci * - main surface in plane 0 143962306a36Sopenharmony_ci * - DCC surface in plane 1 (RB-aligned, pipe-aligned if DCC_PIPE_ALIGN is set) 144062306a36Sopenharmony_ci * 144162306a36Sopenharmony_ci * with DCC & DCC_RETILE: 144262306a36Sopenharmony_ci * - main surface in plane 0 144362306a36Sopenharmony_ci * - displayable DCC surface in plane 1 (not RB-aligned & not pipe-aligned) 144462306a36Sopenharmony_ci * - pipe-aligned DCC surface in plane 2 (RB-aligned & pipe-aligned) 144562306a36Sopenharmony_ci * 144662306a36Sopenharmony_ci * For multi-plane formats the above surfaces get merged into one plane for 144762306a36Sopenharmony_ci * each format plane, based on the required alignment only. 144862306a36Sopenharmony_ci * 144962306a36Sopenharmony_ci * Bits Parameter Notes 145062306a36Sopenharmony_ci * ----- ------------------------ --------------------------------------------- 145162306a36Sopenharmony_ci * 145262306a36Sopenharmony_ci * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* 145362306a36Sopenharmony_ci * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* 145462306a36Sopenharmony_ci * 13 DCC 145562306a36Sopenharmony_ci * 14 DCC_RETILE 145662306a36Sopenharmony_ci * 15 DCC_PIPE_ALIGN 145762306a36Sopenharmony_ci * 16 DCC_INDEPENDENT_64B 145862306a36Sopenharmony_ci * 17 DCC_INDEPENDENT_128B 145962306a36Sopenharmony_ci * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* 146062306a36Sopenharmony_ci * 20 DCC_CONSTANT_ENCODE 146162306a36Sopenharmony_ci * 23:21 PIPE_XOR_BITS Only for some chips 146262306a36Sopenharmony_ci * 26:24 BANK_XOR_BITS Only for some chips 146362306a36Sopenharmony_ci * 29:27 PACKERS Only for some chips 146462306a36Sopenharmony_ci * 32:30 RB Only for some chips 146562306a36Sopenharmony_ci * 35:33 PIPE Only for some chips 146662306a36Sopenharmony_ci * 55:36 - Reserved for future use, must be zero 146762306a36Sopenharmony_ci */ 146862306a36Sopenharmony_ci#define AMD_FMT_MOD fourcc_mod_code(AMD, 0) 146962306a36Sopenharmony_ci 147062306a36Sopenharmony_ci#define IS_AMD_FMT_MOD(val) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD) 147162306a36Sopenharmony_ci 147262306a36Sopenharmony_ci/* Reserve 0 for GFX8 and older */ 147362306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VER_GFX9 1 147462306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VER_GFX10 2 147562306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3 147662306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VER_GFX11 4 147762306a36Sopenharmony_ci 147862306a36Sopenharmony_ci/* 147962306a36Sopenharmony_ci * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical 148062306a36Sopenharmony_ci * version. 148162306a36Sopenharmony_ci */ 148262306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX9_64K_S 9 148362306a36Sopenharmony_ci 148462306a36Sopenharmony_ci/* 148562306a36Sopenharmony_ci * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has 148662306a36Sopenharmony_ci * GFX9 as canonical version. 148762306a36Sopenharmony_ci */ 148862306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX9_64K_D 10 148962306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25 149062306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26 149162306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27 149262306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31 149362306a36Sopenharmony_ci 149462306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_BLOCK_64B 0 149562306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_BLOCK_128B 1 149662306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_BLOCK_256B 2 149762306a36Sopenharmony_ci 149862306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VERSION_SHIFT 0 149962306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_VERSION_MASK 0xFF 150062306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_SHIFT 8 150162306a36Sopenharmony_ci#define AMD_FMT_MOD_TILE_MASK 0x1F 150262306a36Sopenharmony_ci 150362306a36Sopenharmony_ci/* Whether DCC compression is enabled. */ 150462306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_SHIFT 13 150562306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_MASK 0x1 150662306a36Sopenharmony_ci 150762306a36Sopenharmony_ci/* 150862306a36Sopenharmony_ci * Whether to include two DCC surfaces, one which is rb & pipe aligned, and 150962306a36Sopenharmony_ci * one which is not-aligned. 151062306a36Sopenharmony_ci */ 151162306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_RETILE_SHIFT 14 151262306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_RETILE_MASK 0x1 151362306a36Sopenharmony_ci 151462306a36Sopenharmony_ci/* Only set if DCC_RETILE = false */ 151562306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_PIPE_ALIGN_SHIFT 15 151662306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_PIPE_ALIGN_MASK 0x1 151762306a36Sopenharmony_ci 151862306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_SHIFT 16 151962306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_MASK 0x1 152062306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_SHIFT 17 152162306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_MASK 0x1 152262306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_SHIFT 18 152362306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 152462306a36Sopenharmony_ci 152562306a36Sopenharmony_ci/* 152662306a36Sopenharmony_ci * DCC supports embedding some clear colors directly in the DCC surface. 152762306a36Sopenharmony_ci * However, on older GPUs the rendering HW ignores the embedded clear color 152862306a36Sopenharmony_ci * and prefers the driver provided color. This necessitates doing a fastclear 152962306a36Sopenharmony_ci * eliminate operation before a process transfers control. 153062306a36Sopenharmony_ci * 153162306a36Sopenharmony_ci * If this bit is set that means the fastclear eliminate is not needed for these 153262306a36Sopenharmony_ci * embeddable colors. 153362306a36Sopenharmony_ci */ 153462306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_SHIFT 20 153562306a36Sopenharmony_ci#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_MASK 0x1 153662306a36Sopenharmony_ci 153762306a36Sopenharmony_ci/* 153862306a36Sopenharmony_ci * The below fields are for accounting for per GPU differences. These are only 153962306a36Sopenharmony_ci * relevant for GFX9 and later and if the tile field is *_X/_T. 154062306a36Sopenharmony_ci * 154162306a36Sopenharmony_ci * PIPE_XOR_BITS = always needed 154262306a36Sopenharmony_ci * BANK_XOR_BITS = only for TILE_VER_GFX9 154362306a36Sopenharmony_ci * PACKERS = only for TILE_VER_GFX10_RBPLUS 154462306a36Sopenharmony_ci * RB = only for TILE_VER_GFX9 & DCC 154562306a36Sopenharmony_ci * PIPE = only for TILE_VER_GFX9 & DCC & (DCC_RETILE | DCC_PIPE_ALIGN) 154662306a36Sopenharmony_ci */ 154762306a36Sopenharmony_ci#define AMD_FMT_MOD_PIPE_XOR_BITS_SHIFT 21 154862306a36Sopenharmony_ci#define AMD_FMT_MOD_PIPE_XOR_BITS_MASK 0x7 154962306a36Sopenharmony_ci#define AMD_FMT_MOD_BANK_XOR_BITS_SHIFT 24 155062306a36Sopenharmony_ci#define AMD_FMT_MOD_BANK_XOR_BITS_MASK 0x7 155162306a36Sopenharmony_ci#define AMD_FMT_MOD_PACKERS_SHIFT 27 155262306a36Sopenharmony_ci#define AMD_FMT_MOD_PACKERS_MASK 0x7 155362306a36Sopenharmony_ci#define AMD_FMT_MOD_RB_SHIFT 30 155462306a36Sopenharmony_ci#define AMD_FMT_MOD_RB_MASK 0x7 155562306a36Sopenharmony_ci#define AMD_FMT_MOD_PIPE_SHIFT 33 155662306a36Sopenharmony_ci#define AMD_FMT_MOD_PIPE_MASK 0x7 155762306a36Sopenharmony_ci 155862306a36Sopenharmony_ci#define AMD_FMT_MOD_SET(field, value) \ 155962306a36Sopenharmony_ci ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT) 156062306a36Sopenharmony_ci#define AMD_FMT_MOD_GET(field, value) \ 156162306a36Sopenharmony_ci (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK) 156262306a36Sopenharmony_ci#define AMD_FMT_MOD_CLEAR(field) \ 156362306a36Sopenharmony_ci (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) 156462306a36Sopenharmony_ci 156562306a36Sopenharmony_ci#if defined(__cplusplus) 156662306a36Sopenharmony_ci} 156762306a36Sopenharmony_ci#endif 156862306a36Sopenharmony_ci 156962306a36Sopenharmony_ci#endif /* DRM_FOURCC_H */ 1570