1e88f27b3Smrg/* 2e88f27b3Smrg * Copyright 2011 Intel Corporation 3e88f27b3Smrg * 4e88f27b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5e88f27b3Smrg * copy of this software and associated documentation files (the "Software"), 6e88f27b3Smrg * to deal in the Software without restriction, including without limitation 7e88f27b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8e88f27b3Smrg * and/or sell copies of the Software, and to permit persons to whom the 9e88f27b3Smrg * Software is furnished to do so, subject to the following conditions: 10e88f27b3Smrg * 11e88f27b3Smrg * The above copyright notice and this permission notice (including the next 12e88f27b3Smrg * paragraph) shall be included in all copies or substantial portions of the 13e88f27b3Smrg * Software. 14e88f27b3Smrg * 15e88f27b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16e88f27b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17e88f27b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18e88f27b3Smrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19e88f27b3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20e88f27b3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21e88f27b3Smrg * OTHER DEALINGS IN THE SOFTWARE. 22e88f27b3Smrg */ 23e88f27b3Smrg 24e88f27b3Smrg#ifndef DRM_FOURCC_H 25e88f27b3Smrg#define DRM_FOURCC_H 26e88f27b3Smrg 273f012e29Smrg#include "drm.h" 28e88f27b3Smrg 29d8807b2fSmrg#if defined(__cplusplus) 30d8807b2fSmrgextern "C" { 31d8807b2fSmrg#endif 32d8807b2fSmrg 337cdc0497Smrg/** 347cdc0497Smrg * DOC: overview 357cdc0497Smrg * 367cdc0497Smrg * In the DRM subsystem, framebuffer pixel formats are described using the 377cdc0497Smrg * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the 387cdc0497Smrg * fourcc code, a Format Modifier may optionally be provided, in order to 397cdc0497Smrg * further describe the buffer's format - for example tiling or compression. 407cdc0497Smrg * 417cdc0497Smrg * Format Modifiers 427cdc0497Smrg * ---------------- 437cdc0497Smrg * 447cdc0497Smrg * Format modifiers are used in conjunction with a fourcc code, forming a 457cdc0497Smrg * unique fourcc:modifier pair. This format:modifier pair must fully define the 467cdc0497Smrg * format and data layout of the buffer, and should be the only way to describe 477cdc0497Smrg * that particular buffer. 487cdc0497Smrg * 497cdc0497Smrg * Having multiple fourcc:modifier pairs which describe the same layout should 507cdc0497Smrg * be avoided, as such aliases run the risk of different drivers exposing 517cdc0497Smrg * different names for the same data format, forcing userspace to understand 527cdc0497Smrg * that they are aliases. 537cdc0497Smrg * 547cdc0497Smrg * Format modifiers may change any property of the buffer, including the number 557cdc0497Smrg * of planes and/or the required allocation size. Format modifiers are 567cdc0497Smrg * vendor-namespaced, and as such the relationship between a fourcc code and a 57bbff01ceSmrg * modifier is specific to the modifier being used. For example, some modifiers 587cdc0497Smrg * may preserve meaning - such as number of planes - from the fourcc code, 597cdc0497Smrg * whereas others may not. 607cdc0497Smrg * 6141687f09Smrg * Modifiers must uniquely encode buffer layout. In other words, a buffer must 6241687f09Smrg * match only a single modifier. A modifier must not be a subset of layouts of 6341687f09Smrg * another modifier. For instance, it's incorrect to encode pitch alignment in 6441687f09Smrg * a modifier: a buffer may match a 64-pixel aligned modifier and a 32-pixel 6541687f09Smrg * aligned modifier. That said, modifiers can have implicit minimal 6641687f09Smrg * requirements. 6741687f09Smrg * 6841687f09Smrg * For modifiers where the combination of fourcc code and modifier can alias, 6941687f09Smrg * a canonical pair needs to be defined and used by all drivers. Preferred 7041687f09Smrg * combinations are also encouraged where all combinations might lead to 7141687f09Smrg * confusion and unnecessarily reduced interoperability. An example for the 7241687f09Smrg * latter is AFBC, where the ABGR layouts are preferred over ARGB layouts. 7341687f09Smrg * 7441687f09Smrg * There are two kinds of modifier users: 7541687f09Smrg * 7641687f09Smrg * - Kernel and user-space drivers: for drivers it's important that modifiers 7741687f09Smrg * don't alias, otherwise two drivers might support the same format but use 7841687f09Smrg * different aliases, preventing them from sharing buffers in an efficient 7941687f09Smrg * format. 8041687f09Smrg * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users 8141687f09Smrg * see modifiers as opaque tokens they can check for equality and intersect. 82bbff01ceSmrg * These users mustn't need to know to reason about the modifier value 8341687f09Smrg * (i.e. they are not expected to extract information out of the modifier). 8441687f09Smrg * 857cdc0497Smrg * Vendors should document their modifier usage in as much detail as 867cdc0497Smrg * possible, to ensure maximum compatibility across devices, drivers and 877cdc0497Smrg * applications. 887cdc0497Smrg * 897cdc0497Smrg * The authoritative list of format modifier codes is found in 907cdc0497Smrg * `include/uapi/drm/drm_fourcc.h` 91bbff01ceSmrg * 92bbff01ceSmrg * Open Source User Waiver 93bbff01ceSmrg * ----------------------- 94bbff01ceSmrg * 95bbff01ceSmrg * Because this is the authoritative source for pixel formats and modifiers 96bbff01ceSmrg * referenced by GL, Vulkan extensions and other standards and hence used both 97bbff01ceSmrg * by open source and closed source driver stacks, the usual requirement for an 98bbff01ceSmrg * upstream in-kernel or open source userspace user does not apply. 99bbff01ceSmrg * 100bbff01ceSmrg * To ensure, as much as feasible, compatibility across stacks and avoid 101bbff01ceSmrg * confusion with incompatible enumerations stakeholders for all relevant driver 102bbff01ceSmrg * stacks should approve additions. 1037cdc0497Smrg */ 1047cdc0497Smrg 1053f012e29Smrg#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 1063f012e29Smrg ((__u32)(c) << 16) | ((__u32)(d) << 24)) 107e88f27b3Smrg 10841687f09Smrg#define DRM_FORMAT_BIG_ENDIAN (1U<<31) /* format is big endian instead of little endian */ 109e88f27b3Smrg 1107cdc0497Smrg/* Reserve 0 for the invalid format specifier */ 1117cdc0497Smrg#define DRM_FORMAT_INVALID 0 1127cdc0497Smrg 113e88f27b3Smrg/* color index */ 114bbff01ceSmrg#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 */ 115bbff01ceSmrg#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ 116bbff01ceSmrg#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */ 117e88f27b3Smrg#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 118e88f27b3Smrg 119bbff01ceSmrg/* 1 bpp Darkness (inverse relationship between channel value and brightness) */ 120bbff01ceSmrg#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 */ 121bbff01ceSmrg 122bbff01ceSmrg/* 2 bpp Darkness (inverse relationship between channel value and brightness) */ 123bbff01ceSmrg#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */ 124bbff01ceSmrg 125bbff01ceSmrg/* 4 bpp Darkness (inverse relationship between channel value and brightness) */ 126bbff01ceSmrg#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */ 127bbff01ceSmrg 128bbff01ceSmrg/* 8 bpp Darkness (inverse relationship between channel value and brightness) */ 129bbff01ceSmrg#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */ 130bbff01ceSmrg 131bbff01ceSmrg/* 1 bpp Red (direct relationship between channel value and brightness) */ 132bbff01ceSmrg#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 */ 133bbff01ceSmrg 134bbff01ceSmrg/* 2 bpp Red (direct relationship between channel value and brightness) */ 135bbff01ceSmrg#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */ 136bbff01ceSmrg 137bbff01ceSmrg/* 4 bpp Red (direct relationship between channel value and brightness) */ 138bbff01ceSmrg#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */ 139bbff01ceSmrg 140bbff01ceSmrg/* 8 bpp Red (direct relationship between channel value and brightness) */ 1413f012e29Smrg#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 1423f012e29Smrg 143bbff01ceSmrg/* 10 bpp Red (direct relationship between channel value and brightness) */ 144b0ab5608Smrg#define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */ 145b0ab5608Smrg 146bbff01ceSmrg/* 12 bpp Red (direct relationship between channel value and brightness) */ 147b0ab5608Smrg#define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */ 148b0ab5608Smrg 149bbff01ceSmrg/* 16 bpp Red (direct relationship between channel value and brightness) */ 150d8807b2fSmrg#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ 151d8807b2fSmrg 1523f012e29Smrg/* 16 bpp RG */ 1533f012e29Smrg#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 1543f012e29Smrg#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 1553f012e29Smrg 156d8807b2fSmrg/* 32 bpp RG */ 157d8807b2fSmrg#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ 158d8807b2fSmrg#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ 159d8807b2fSmrg 160e88f27b3Smrg/* 8 bpp RGB */ 161e88f27b3Smrg#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 162e88f27b3Smrg#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 163e88f27b3Smrg 164e88f27b3Smrg/* 16 bpp RGB */ 165e88f27b3Smrg#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 166e88f27b3Smrg#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 167e88f27b3Smrg#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 168e88f27b3Smrg#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 169e88f27b3Smrg 170e88f27b3Smrg#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 171e88f27b3Smrg#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 172e88f27b3Smrg#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 173e88f27b3Smrg#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 174e88f27b3Smrg 175e88f27b3Smrg#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 176e88f27b3Smrg#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 177e88f27b3Smrg#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 178e88f27b3Smrg#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 179e88f27b3Smrg 180e88f27b3Smrg#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 181e88f27b3Smrg#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 182e88f27b3Smrg#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 183e88f27b3Smrg#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 184e88f27b3Smrg 185e88f27b3Smrg#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 186e88f27b3Smrg#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 187e88f27b3Smrg 188e88f27b3Smrg/* 24 bpp RGB */ 189e88f27b3Smrg#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 190e88f27b3Smrg#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 191e88f27b3Smrg 192e88f27b3Smrg/* 32 bpp RGB */ 193e88f27b3Smrg#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 194e88f27b3Smrg#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 195e88f27b3Smrg#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 196e88f27b3Smrg#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 197e88f27b3Smrg 198e88f27b3Smrg#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 199e88f27b3Smrg#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 200e88f27b3Smrg#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 201e88f27b3Smrg#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 202e88f27b3Smrg 203e88f27b3Smrg#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 204e88f27b3Smrg#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 205e88f27b3Smrg#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 206e88f27b3Smrg#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 207e88f27b3Smrg 208e88f27b3Smrg#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 209e88f27b3Smrg#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 210e88f27b3Smrg#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 211e88f27b3Smrg#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 212e88f27b3Smrg 21349ef06a4Smrg/* 64 bpp RGB */ 21449ef06a4Smrg#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 21549ef06a4Smrg#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 21649ef06a4Smrg 21749ef06a4Smrg#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 21849ef06a4Smrg#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 21949ef06a4Smrg 2205324fb0dSmrg/* 2215324fb0dSmrg * Floating point 64bpp RGB 2225324fb0dSmrg * IEEE 754-2008 binary16 half-precision float 2235324fb0dSmrg * [15:0] sign:exponent:mantissa 1:5:10 2245324fb0dSmrg */ 2255324fb0dSmrg#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 2265324fb0dSmrg#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 2275324fb0dSmrg 2285324fb0dSmrg#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 2295324fb0dSmrg#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 2305324fb0dSmrg 23141687f09Smrg/* 23241687f09Smrg * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits 23341687f09Smrg * of unused padding per component: 23441687f09Smrg */ 23541687f09Smrg#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 */ 23641687f09Smrg 237e88f27b3Smrg/* packed YCbCr */ 238e88f27b3Smrg#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 239e88f27b3Smrg#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 240e88f27b3Smrg#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 241e88f27b3Smrg#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 242e88f27b3Smrg 243e88f27b3Smrg#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 244bbff01ceSmrg#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */ 2455324fb0dSmrg#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ 246bbff01ceSmrg#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */ 2475324fb0dSmrg#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */ 2485324fb0dSmrg#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */ 2495324fb0dSmrg 2505324fb0dSmrg/* 2515324fb0dSmrg * packed Y2xx indicate for each component, xx valid data occupy msb 2525324fb0dSmrg * 16-xx padding occupy lsb 2535324fb0dSmrg */ 2545324fb0dSmrg#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 */ 2555324fb0dSmrg#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 */ 2565324fb0dSmrg#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 */ 2575324fb0dSmrg 2585324fb0dSmrg/* 2595324fb0dSmrg * packed Y4xx indicate for each component, xx valid data occupy msb 2605324fb0dSmrg * 16-xx padding occupy lsb except Y410 2615324fb0dSmrg */ 2625324fb0dSmrg#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') /* [31:0] A:Cr:Y:Cb 2:10:10:10 little endian */ 2635324fb0dSmrg#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 */ 2645324fb0dSmrg#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6') /* [63:0] A:Cr:Y:Cb 16:16:16:16 little endian */ 2655324fb0dSmrg 2665324fb0dSmrg#define DRM_FORMAT_XVYU2101010 fourcc_code('X', 'V', '3', '0') /* [31:0] X:Cr:Y:Cb 2:10:10:10 little endian */ 2675324fb0dSmrg#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 */ 2685324fb0dSmrg#define DRM_FORMAT_XVYU16161616 fourcc_code('X', 'V', '4', '8') /* [63:0] X:Cr:Y:Cb 16:16:16:16 little endian */ 2695324fb0dSmrg 2705324fb0dSmrg/* 2715324fb0dSmrg * packed YCbCr420 2x2 tiled formats 2725324fb0dSmrg * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile 2735324fb0dSmrg */ 2745324fb0dSmrg/* [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 */ 2755324fb0dSmrg#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0') 2765324fb0dSmrg/* [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 */ 2775324fb0dSmrg#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0') 2785324fb0dSmrg 2795324fb0dSmrg/* [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 2805324fb0dSmrg#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 2815324fb0dSmrg/* [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 2825324fb0dSmrg#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2') 2835324fb0dSmrg 2845324fb0dSmrg/* 2855324fb0dSmrg * 1-plane YUV 4:2:0 2865324fb0dSmrg * In these formats, the component ordering is specified (Y, followed by U 2875324fb0dSmrg * then V), but the exact Linear layout is undefined. 2885324fb0dSmrg * These formats can only be used with a non-Linear modifier. 2895324fb0dSmrg */ 2905324fb0dSmrg#define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8') 2915324fb0dSmrg#define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') 292e88f27b3Smrg 293d8807b2fSmrg/* 294d8807b2fSmrg * 2 plane RGB + A 295d8807b2fSmrg * index 0 = RGB plane, same format as the corresponding non _A8 format has 296d8807b2fSmrg * index 1 = A plane, [7:0] A 297d8807b2fSmrg */ 298d8807b2fSmrg#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') 299d8807b2fSmrg#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') 300d8807b2fSmrg#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') 301d8807b2fSmrg#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') 302d8807b2fSmrg#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') 303d8807b2fSmrg#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') 304d8807b2fSmrg#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') 305d8807b2fSmrg#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') 306d8807b2fSmrg 307e88f27b3Smrg/* 308e88f27b3Smrg * 2 plane YCbCr 309e88f27b3Smrg * index 0 = Y plane, [7:0] Y 310e88f27b3Smrg * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 311e88f27b3Smrg * or 312e88f27b3Smrg * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 313e88f27b3Smrg */ 314e88f27b3Smrg#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 315e88f27b3Smrg#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 316e88f27b3Smrg#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 317e88f27b3Smrg#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 3183f012e29Smrg#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 3193f012e29Smrg#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 32041687f09Smrg/* 32141687f09Smrg * 2 plane YCbCr 32241687f09Smrg * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian 32341687f09Smrg * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian 32441687f09Smrg */ 32541687f09Smrg#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ 326bbff01ceSmrg#define DRM_FORMAT_NV20 fourcc_code('N', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane */ 327bbff01ceSmrg#define DRM_FORMAT_NV30 fourcc_code('N', 'V', '3', '0') /* non-subsampled Cr:Cb plane */ 328e88f27b3Smrg 3295324fb0dSmrg/* 3305324fb0dSmrg * 2 plane YCbCr MSB aligned 3315324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 3325324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 3335324fb0dSmrg */ 3345324fb0dSmrg#define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */ 3355324fb0dSmrg 3365324fb0dSmrg/* 3375324fb0dSmrg * 2 plane YCbCr MSB aligned 3385324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 3395324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 3405324fb0dSmrg */ 3415324fb0dSmrg#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */ 3425324fb0dSmrg 3435324fb0dSmrg/* 3445324fb0dSmrg * 2 plane YCbCr MSB aligned 3455324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [12:4] little endian 3465324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian 3475324fb0dSmrg */ 3485324fb0dSmrg#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */ 3495324fb0dSmrg 3505324fb0dSmrg/* 3515324fb0dSmrg * 2 plane YCbCr MSB aligned 3525324fb0dSmrg * index 0 = Y plane, [15:0] Y little endian 3535324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian 3545324fb0dSmrg */ 3555324fb0dSmrg#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ 3565324fb0dSmrg 357b0ab5608Smrg/* 2 plane YCbCr420. 358b0ab5608Smrg * 3 10 bit components and 2 padding bits packed into 4 bytes. 359b0ab5608Smrg * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian 360b0ab5608Smrg * 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 361b0ab5608Smrg */ 362b0ab5608Smrg#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel packed */ 363b0ab5608Smrg 36441687f09Smrg/* 3 plane non-subsampled (444) YCbCr 36541687f09Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 36641687f09Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 36741687f09Smrg * index 1: Cb plane, [15:0] Cb:x [10:6] little endian 36841687f09Smrg * index 2: Cr plane, [15:0] Cr:x [10:6] little endian 36941687f09Smrg */ 37041687f09Smrg#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') 37141687f09Smrg 37241687f09Smrg/* 3 plane non-subsampled (444) YCrCb 37341687f09Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 37441687f09Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 37541687f09Smrg * index 1: Cr plane, [15:0] Cr:x [10:6] little endian 37641687f09Smrg * index 2: Cb plane, [15:0] Cb:x [10:6] little endian 37741687f09Smrg */ 37841687f09Smrg#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') 37941687f09Smrg 380e88f27b3Smrg/* 381e88f27b3Smrg * 3 plane YCbCr 382e88f27b3Smrg * index 0: Y plane, [7:0] Y 383e88f27b3Smrg * index 1: Cb plane, [7:0] Cb 384e88f27b3Smrg * index 2: Cr plane, [7:0] Cr 385e88f27b3Smrg * or 386e88f27b3Smrg * index 1: Cr plane, [7:0] Cr 387e88f27b3Smrg * index 2: Cb plane, [7:0] Cb 388e88f27b3Smrg */ 389e88f27b3Smrg#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 390e88f27b3Smrg#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 391e88f27b3Smrg#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 392e88f27b3Smrg#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 393e88f27b3Smrg#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 394e88f27b3Smrg#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 395e88f27b3Smrg#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 396e88f27b3Smrg#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 397e88f27b3Smrg#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 398e88f27b3Smrg#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 399e88f27b3Smrg 4003f012e29Smrg 4013f012e29Smrg/* 4023f012e29Smrg * Format Modifiers: 4033f012e29Smrg * 4043f012e29Smrg * Format modifiers describe, typically, a re-ordering or modification 4053f012e29Smrg * of the data in a plane of an FB. This can be used to express tiled/ 4063f012e29Smrg * swizzled formats, or compression, or a combination of the two. 4073f012e29Smrg * 4083f012e29Smrg * The upper 8 bits of the format modifier are a vendor-id as assigned 4093f012e29Smrg * below. The lower 56 bits are assigned as vendor sees fit. 4103f012e29Smrg */ 4113f012e29Smrg 4123f012e29Smrg/* Vendor Ids: */ 413d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_NONE 0 4143f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 4153f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 41600a23bdaSmrg#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03 4173f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 4183f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 419d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 420d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 4217cdc0497Smrg#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 4225324fb0dSmrg#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 42341687f09Smrg#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a 4245324fb0dSmrg 4253f012e29Smrg/* add more to the end as needed */ 4263f012e29Smrg 427d8807b2fSmrg#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) 428d8807b2fSmrg 429b0ab5608Smrg#define fourcc_mod_get_vendor(modifier) \ 430b0ab5608Smrg (((modifier) >> 56) & 0xff) 431b0ab5608Smrg 432b0ab5608Smrg#define fourcc_mod_is_vendor(modifier, vendor) \ 433b0ab5608Smrg (fourcc_mod_get_vendor(modifier) == DRM_FORMAT_MOD_VENDOR_## vendor) 434b0ab5608Smrg 4353f012e29Smrg#define fourcc_mod_code(vendor, val) \ 43600a23bdaSmrg ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 4373f012e29Smrg 4383f012e29Smrg/* 4393f012e29Smrg * Format Modifier tokens: 4403f012e29Smrg * 4413f012e29Smrg * When adding a new token please document the layout with a code comment, 4423f012e29Smrg * similar to the fourcc codes above. drm_fourcc.h is considered the 4433f012e29Smrg * authoritative source for all of these. 44441687f09Smrg * 44541687f09Smrg * Generic modifier names: 44641687f09Smrg * 44741687f09Smrg * DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral names 44841687f09Smrg * for layouts which are common across multiple vendors. To preserve 44941687f09Smrg * compatibility, in cases where a vendor-specific definition already exists and 45041687f09Smrg * a generic name for it is desired, the common name is a purely symbolic alias 45141687f09Smrg * and must use the same numerical value as the original definition. 45241687f09Smrg * 45341687f09Smrg * Note that generic names should only be used for modifiers which describe 45441687f09Smrg * generic layouts (such as pixel re-ordering), which may have 45541687f09Smrg * independently-developed support across multiple vendors. 45641687f09Smrg * 45741687f09Smrg * In future cases where a generic layout is identified before merging with a 45841687f09Smrg * vendor-specific modifier, a new 'GENERIC' vendor or modifier using vendor 45941687f09Smrg * 'NONE' could be considered. This should only be for obvious, exceptional 46041687f09Smrg * cases to avoid polluting the 'GENERIC' namespace with modifiers which only 46141687f09Smrg * apply to a single vendor. 46241687f09Smrg * 46341687f09Smrg * Generic names should not be used for cases where multiple hardware vendors 46441687f09Smrg * have implementations of the same standardised compression scheme (such as 46541687f09Smrg * AFBC). In those cases, all implementations should use the same format 46641687f09Smrg * modifier(s), reflecting the vendor of the standard. 4673f012e29Smrg */ 4683f012e29Smrg 46941687f09Smrg#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE 47041687f09Smrg 471d8807b2fSmrg/* 472d8807b2fSmrg * Invalid Modifier 473d8807b2fSmrg * 474d8807b2fSmrg * This modifier can be used as a sentinel to terminate the format modifiers 475d8807b2fSmrg * list, or to initialize a variable with an invalid modifier. It might also be 476d8807b2fSmrg * used to report an error back to userspace for certain APIs. 477d8807b2fSmrg */ 478d8807b2fSmrg#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) 479d8807b2fSmrg 480d8807b2fSmrg/* 481d8807b2fSmrg * Linear Layout 482d8807b2fSmrg * 483d8807b2fSmrg * Just plain linear layout. Note that this is different from no specifying any 484d8807b2fSmrg * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), 485d8807b2fSmrg * which tells the driver to also take driver-internal information into account 486d8807b2fSmrg * and so might actually result in a tiled framebuffer. 487d8807b2fSmrg */ 488d8807b2fSmrg#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) 489d8807b2fSmrg 49041687f09Smrg/* 49141687f09Smrg * Deprecated: use DRM_FORMAT_MOD_LINEAR instead 49241687f09Smrg * 49341687f09Smrg * The "none" format modifier doesn't actually mean that the modifier is 49441687f09Smrg * implicit, instead it means that the layout is linear. Whether modifiers are 49541687f09Smrg * used is out-of-band information carried in an API-specific way (e.g. in a 49641687f09Smrg * flag for drm_mode_fb_cmd2). 49741687f09Smrg */ 49841687f09Smrg#define DRM_FORMAT_MOD_NONE 0 49941687f09Smrg 5003f012e29Smrg/* Intel framebuffer modifiers */ 5013f012e29Smrg 5023f012e29Smrg/* 5033f012e29Smrg * Intel X-tiling layout 5043f012e29Smrg * 5053f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 5063f012e29Smrg * in row-major layout. Within the tile bytes are laid out row-major, with 5073f012e29Smrg * a platform-dependent stride. On top of that the memory can apply 5083f012e29Smrg * platform-depending swizzling of some higher address bits into bit6. 5093f012e29Smrg * 51041687f09Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 51141687f09Smrg * On earlier platforms the is highly platforms specific and not useful for 51241687f09Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 51341687f09Smrg * identify the layout in a simple way for i915-specific userspace, which 51441687f09Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 51541687f09Smrg * format on some really old platforms is not known. 5163f012e29Smrg */ 5173f012e29Smrg#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 5183f012e29Smrg 5193f012e29Smrg/* 5203f012e29Smrg * Intel Y-tiling layout 5213f012e29Smrg * 5223f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 5233f012e29Smrg * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 5243f012e29Smrg * chunks column-major, with a platform-dependent height. On top of that the 5253f012e29Smrg * memory can apply platform-depending swizzling of some higher address bits 5263f012e29Smrg * into bit6. 5273f012e29Smrg * 52841687f09Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 52941687f09Smrg * On earlier platforms the is highly platforms specific and not useful for 53041687f09Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 53141687f09Smrg * identify the layout in a simple way for i915-specific userspace, which 53241687f09Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 53341687f09Smrg * format on some really old platforms is not known. 5343f012e29Smrg */ 5353f012e29Smrg#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 5363f012e29Smrg 5373f012e29Smrg/* 5383f012e29Smrg * Intel Yf-tiling layout 5393f012e29Smrg * 5403f012e29Smrg * This is a tiled layout using 4Kb tiles in row-major layout. 5413f012e29Smrg * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 5423f012e29Smrg * are arranged in four groups (two wide, two high) with column-major layout. 543bbff01ceSmrg * Each group therefore consists out of four 256 byte units, which are also laid 5443f012e29Smrg * out as 2x2 column-major. 5453f012e29Smrg * 256 byte units are made out of four 64 byte blocks of pixels, producing 5463f012e29Smrg * either a square block or a 2:1 unit. 5473f012e29Smrg * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 5483f012e29Smrg * in pixel depends on the pixel depth. 5493f012e29Smrg */ 5503f012e29Smrg#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 5513f012e29Smrg 552d8807b2fSmrg/* 553d8807b2fSmrg * Intel color control surface (CCS) for render compression 554d8807b2fSmrg * 555d8807b2fSmrg * The framebuffer format must be one of the 8:8:8:8 RGB formats. 556d8807b2fSmrg * The main surface will be plane index 0 and must be Y/Yf-tiled, 557d8807b2fSmrg * the CCS will be plane index 1. 558d8807b2fSmrg * 559d8807b2fSmrg * Each CCS tile matches a 1024x512 pixel area of the main surface. 560d8807b2fSmrg * To match certain aspects of the 3D hardware the CCS is 561d8807b2fSmrg * considered to be made up of normal 128Bx32 Y tiles, Thus 562d8807b2fSmrg * the CCS pitch must be specified in multiples of 128 bytes. 563d8807b2fSmrg * 564d8807b2fSmrg * In reality the CCS tile appears to be a 64Bx64 Y tile, composed 565d8807b2fSmrg * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. 566d8807b2fSmrg * But that fact is not relevant unless the memory is accessed 567d8807b2fSmrg * directly. 568d8807b2fSmrg */ 569d8807b2fSmrg#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) 570d8807b2fSmrg#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) 571d8807b2fSmrg 57241687f09Smrg/* 57341687f09Smrg * Intel color control surfaces (CCS) for Gen-12 render compression. 57441687f09Smrg * 57541687f09Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 57641687f09Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 57741687f09Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 57841687f09Smrg * line pair. The main surface pitch is required to be a multiple of four 57941687f09Smrg * Y-tile widths. 58041687f09Smrg */ 58141687f09Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6) 58241687f09Smrg 58341687f09Smrg/* 58441687f09Smrg * Intel color control surfaces (CCS) for Gen-12 media compression 58541687f09Smrg * 58641687f09Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 58741687f09Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 58841687f09Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 58941687f09Smrg * line pair. The main surface pitch is required to be a multiple of four 59041687f09Smrg * Y-tile widths. For semi-planar formats like NV12, CCS planes follow the 59141687f09Smrg * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 59241687f09Smrg * planes 2 and 3 for the respective CCS. 59341687f09Smrg */ 59441687f09Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7) 59541687f09Smrg 59649ef06a4Smrg/* 59749ef06a4Smrg * Intel Color Control Surface with Clear Color (CCS) for Gen-12 render 59849ef06a4Smrg * compression. 59949ef06a4Smrg * 60049ef06a4Smrg * The main surface is Y-tiled and is at plane index 0 whereas CCS is linear 60149ef06a4Smrg * and at index 1. The clear color is stored at index 2, and the pitch should 602b0ab5608Smrg * be 64 bytes aligned. The clear color structure is 256 bits. The first 128 bits 60349ef06a4Smrg * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 60449ef06a4Smrg * by 32 bits. The raw clear color is consumed by the 3d engine and generates 60549ef06a4Smrg * the converted clear color of size 64 bits. The first 32 bits store the Lower 60649ef06a4Smrg * Converted Clear Color value and the next 32 bits store the Higher Converted 60749ef06a4Smrg * Clear Color value when applicable. The Converted Clear Color values are 60849ef06a4Smrg * consumed by the DE. The last 64 bits are used to store Color Discard Enable 60949ef06a4Smrg * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 61049ef06a4Smrg * corresponds to an area of 4x1 tiles in the main surface. The main surface 61149ef06a4Smrg * pitch is required to be a multiple of 4 tile widths. 61249ef06a4Smrg */ 61349ef06a4Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8) 61449ef06a4Smrg 615b0ab5608Smrg/* 616b0ab5608Smrg * Intel Tile 4 layout 617b0ab5608Smrg * 618b0ab5608Smrg * This is a tiled layout using 4KB tiles in a row-major layout. It has the same 619b0ab5608Smrg * shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4). It 620b0ab5608Smrg * only differs from Tile Y at the 256B granularity in between. At this 621b0ab5608Smrg * granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a shape 622b0ab5608Smrg * of 64B x 8 rows. 623b0ab5608Smrg */ 624b0ab5608Smrg#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9) 625b0ab5608Smrg 626b0ab5608Smrg/* 627b0ab5608Smrg * Intel color control surfaces (CCS) for DG2 render compression. 628b0ab5608Smrg * 629b0ab5608Smrg * The main surface is Tile 4 and at plane index 0. The CCS data is stored 630b0ab5608Smrg * outside of the GEM object in a reserved memory area dedicated for the 631b0ab5608Smrg * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The 632b0ab5608Smrg * main surface pitch is required to be a multiple of four Tile 4 widths. 633b0ab5608Smrg */ 634b0ab5608Smrg#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS fourcc_mod_code(INTEL, 10) 635b0ab5608Smrg 636b0ab5608Smrg/* 637b0ab5608Smrg * Intel color control surfaces (CCS) for DG2 media compression. 638b0ab5608Smrg * 639b0ab5608Smrg * The main surface is Tile 4 and at plane index 0. For semi-planar formats 640b0ab5608Smrg * like NV12, the Y and UV planes are Tile 4 and are located at plane indices 641b0ab5608Smrg * 0 and 1, respectively. The CCS for all planes are stored outside of the 642b0ab5608Smrg * GEM object in a reserved memory area dedicated for the storage of the 643b0ab5608Smrg * CCS data for all RC/RC_CC/MC compressible GEM objects. The main surface 644b0ab5608Smrg * pitch is required to be a multiple of four Tile 4 widths. 645b0ab5608Smrg */ 646b0ab5608Smrg#define I915_FORMAT_MOD_4_TILED_DG2_MC_CCS fourcc_mod_code(INTEL, 11) 647b0ab5608Smrg 648b0ab5608Smrg/* 649b0ab5608Smrg * Intel Color Control Surface with Clear Color (CCS) for DG2 render compression. 650b0ab5608Smrg * 651b0ab5608Smrg * The main surface is Tile 4 and at plane index 0. The CCS data is stored 652b0ab5608Smrg * outside of the GEM object in a reserved memory area dedicated for the 653b0ab5608Smrg * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The 654b0ab5608Smrg * main surface pitch is required to be a multiple of four Tile 4 widths. The 655b0ab5608Smrg * clear color is stored at plane index 1 and the pitch should be 64 bytes 656b0ab5608Smrg * aligned. The format of the 256 bits of clear color data matches the one used 657b0ab5608Smrg * for the I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC modifier, see its description 658b0ab5608Smrg * for details. 659b0ab5608Smrg */ 660b0ab5608Smrg#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12) 661b0ab5608Smrg 662bbff01ceSmrg/* 663bbff01ceSmrg * Intel Color Control Surfaces (CCS) for display ver. 14 render compression. 664bbff01ceSmrg * 665bbff01ceSmrg * The main surface is tile4 and at plane index 0, the CCS is linear and 666bbff01ceSmrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 667bbff01ceSmrg * main surface. In other words, 4 bits in CCS map to a main surface cache 668bbff01ceSmrg * line pair. The main surface pitch is required to be a multiple of four 669bbff01ceSmrg * tile4 widths. 670bbff01ceSmrg */ 671bbff01ceSmrg#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS fourcc_mod_code(INTEL, 13) 672bbff01ceSmrg 673bbff01ceSmrg/* 674bbff01ceSmrg * Intel Color Control Surfaces (CCS) for display ver. 14 media compression 675bbff01ceSmrg * 676bbff01ceSmrg * The main surface is tile4 and at plane index 0, the CCS is linear and 677bbff01ceSmrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 678bbff01ceSmrg * main surface. In other words, 4 bits in CCS map to a main surface cache 679bbff01ceSmrg * line pair. The main surface pitch is required to be a multiple of four 680bbff01ceSmrg * tile4 widths. For semi-planar formats like NV12, CCS planes follow the 681bbff01ceSmrg * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 682bbff01ceSmrg * planes 2 and 3 for the respective CCS. 683bbff01ceSmrg */ 684bbff01ceSmrg#define I915_FORMAT_MOD_4_TILED_MTL_MC_CCS fourcc_mod_code(INTEL, 14) 685bbff01ceSmrg 686bbff01ceSmrg/* 687bbff01ceSmrg * Intel Color Control Surface with Clear Color (CCS) for display ver. 14 render 688bbff01ceSmrg * compression. 689bbff01ceSmrg * 690bbff01ceSmrg * The main surface is tile4 and is at plane index 0 whereas CCS is linear 691bbff01ceSmrg * and at index 1. The clear color is stored at index 2, and the pitch should 692bbff01ceSmrg * be ignored. The clear color structure is 256 bits. The first 128 bits 693bbff01ceSmrg * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 694bbff01ceSmrg * by 32 bits. The raw clear color is consumed by the 3d engine and generates 695bbff01ceSmrg * the converted clear color of size 64 bits. The first 32 bits store the Lower 696bbff01ceSmrg * Converted Clear Color value and the next 32 bits store the Higher Converted 697bbff01ceSmrg * Clear Color value when applicable. The Converted Clear Color values are 698bbff01ceSmrg * consumed by the DE. The last 64 bits are used to store Color Discard Enable 699bbff01ceSmrg * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 700bbff01ceSmrg * corresponds to an area of 4x1 tiles in the main surface. The main surface 701bbff01ceSmrg * pitch is required to be a multiple of 4 tile widths. 702bbff01ceSmrg */ 703bbff01ceSmrg#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC fourcc_mod_code(INTEL, 15) 704bbff01ceSmrg 7053f012e29Smrg/* 7063f012e29Smrg * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 7073f012e29Smrg * 7083f012e29Smrg * Macroblocks are laid in a Z-shape, and each pixel data is following the 7093f012e29Smrg * standard NV12 style. 7103f012e29Smrg * As for NV12, an image is the result of two frame buffers: one for Y, 7113f012e29Smrg * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 7123f012e29Smrg * Alignment requirements are (for each buffer): 7133f012e29Smrg * - multiple of 128 pixels for the width 7143f012e29Smrg * - multiple of 32 pixels for the height 7153f012e29Smrg * 7163f012e29Smrg * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 7173f012e29Smrg */ 7183f012e29Smrg#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 7193f012e29Smrg 7205324fb0dSmrg/* 7215324fb0dSmrg * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks 7225324fb0dSmrg * 7235324fb0dSmrg * This is a simple tiled layout using tiles of 16x16 pixels in a row-major 7245324fb0dSmrg * layout. For YCbCr formats Cb/Cr components are taken in such a way that 7255324fb0dSmrg * they correspond to their 16x16 luma block. 7265324fb0dSmrg */ 7275324fb0dSmrg#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) 7285324fb0dSmrg 7297cdc0497Smrg/* 7307cdc0497Smrg * Qualcomm Compressed Format 7317cdc0497Smrg * 7327cdc0497Smrg * Refers to a compressed variant of the base format that is compressed. 7337cdc0497Smrg * Implementation may be platform and base-format specific. 7347cdc0497Smrg * 7357cdc0497Smrg * Each macrotile consists of m x n (mostly 4 x 4) tiles. 7367cdc0497Smrg * Pixel data pitch/stride is aligned with macrotile width. 7377cdc0497Smrg * Pixel data height is aligned with macrotile height. 7387cdc0497Smrg * Entire pixel data buffer is aligned with 4k(bytes). 7397cdc0497Smrg */ 7407cdc0497Smrg#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) 7417cdc0497Smrg 742b0ab5608Smrg/* 743b0ab5608Smrg * Qualcomm Tiled Format 744b0ab5608Smrg * 745b0ab5608Smrg * Similar to DRM_FORMAT_MOD_QCOM_COMPRESSED but not compressed. 746b0ab5608Smrg * Implementation may be platform and base-format specific. 747b0ab5608Smrg * 748b0ab5608Smrg * Each macrotile consists of m x n (mostly 4 x 4) tiles. 749b0ab5608Smrg * Pixel data pitch/stride is aligned with macrotile width. 750b0ab5608Smrg * Pixel data height is aligned with macrotile height. 751b0ab5608Smrg * Entire pixel data buffer is aligned with 4k(bytes). 752b0ab5608Smrg */ 753b0ab5608Smrg#define DRM_FORMAT_MOD_QCOM_TILED3 fourcc_mod_code(QCOM, 3) 754b0ab5608Smrg 755b0ab5608Smrg/* 756b0ab5608Smrg * Qualcomm Alternate Tiled Format 757b0ab5608Smrg * 758b0ab5608Smrg * Alternate tiled format typically only used within GMEM. 759b0ab5608Smrg * Implementation may be platform and base-format specific. 760b0ab5608Smrg */ 761b0ab5608Smrg#define DRM_FORMAT_MOD_QCOM_TILED2 fourcc_mod_code(QCOM, 2) 762b0ab5608Smrg 763b0ab5608Smrg 764d8807b2fSmrg/* Vivante framebuffer modifiers */ 765d8807b2fSmrg 766d8807b2fSmrg/* 767d8807b2fSmrg * Vivante 4x4 tiling layout 768d8807b2fSmrg * 769d8807b2fSmrg * This is a simple tiled layout using tiles of 4x4 pixels in a row-major 770d8807b2fSmrg * layout. 771d8807b2fSmrg */ 772d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) 773d8807b2fSmrg 774d8807b2fSmrg/* 775d8807b2fSmrg * Vivante 64x64 super-tiling layout 776d8807b2fSmrg * 777d8807b2fSmrg * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile 778d8807b2fSmrg * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- 779d8807b2fSmrg * major layout. 780d8807b2fSmrg * 781d8807b2fSmrg * For more information: see 782d8807b2fSmrg * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling 783d8807b2fSmrg */ 784d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) 785d8807b2fSmrg 786d8807b2fSmrg/* 787d8807b2fSmrg * Vivante 4x4 tiling layout for dual-pipe 788d8807b2fSmrg * 789d8807b2fSmrg * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a 790d8807b2fSmrg * different base address. Offsets from the base addresses are therefore halved 791d8807b2fSmrg * compared to the non-split tiled layout. 792d8807b2fSmrg */ 793d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) 794d8807b2fSmrg 795d8807b2fSmrg/* 796d8807b2fSmrg * Vivante 64x64 super-tiling layout for dual-pipe 797d8807b2fSmrg * 798d8807b2fSmrg * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile 799d8807b2fSmrg * starts at a different base address. Offsets from the base addresses are 800d8807b2fSmrg * therefore halved compared to the non-split super-tiled layout. 801d8807b2fSmrg */ 802d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) 803d8807b2fSmrg 804bbff01ceSmrg/* 805bbff01ceSmrg * Vivante TS (tile-status) buffer modifiers. They can be combined with all of 806bbff01ceSmrg * the color buffer tiling modifiers defined above. When TS is present it's a 807bbff01ceSmrg * separate buffer containing the clear/compression status of each tile. The 808bbff01ceSmrg * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer 809bbff01ceSmrg * tile size in bytes covered by one entry in the status buffer and s is the 810bbff01ceSmrg * number of status bits per entry. 811bbff01ceSmrg * We reserve the top 8 bits of the Vivante modifier space for tile status 812bbff01ceSmrg * clear/compression modifiers, as future cores might add some more TS layout 813bbff01ceSmrg * variations. 814bbff01ceSmrg */ 815bbff01ceSmrg#define VIVANTE_MOD_TS_64_4 (1ULL << 48) 816bbff01ceSmrg#define VIVANTE_MOD_TS_64_2 (2ULL << 48) 817bbff01ceSmrg#define VIVANTE_MOD_TS_128_4 (3ULL << 48) 818bbff01ceSmrg#define VIVANTE_MOD_TS_256_4 (4ULL << 48) 819bbff01ceSmrg#define VIVANTE_MOD_TS_MASK (0xfULL << 48) 820bbff01ceSmrg 821bbff01ceSmrg/* 822bbff01ceSmrg * Vivante compression modifiers. Those depend on a TS modifier being present 823bbff01ceSmrg * as the TS bits get reinterpreted as compression tags instead of simple 824bbff01ceSmrg * clear markers when compression is enabled. 825bbff01ceSmrg */ 826bbff01ceSmrg#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52) 827bbff01ceSmrg#define VIVANTE_MOD_COMP_MASK (0xfULL << 52) 828bbff01ceSmrg 829bbff01ceSmrg/* Masking out the extension bits will yield the base modifier. */ 830bbff01ceSmrg#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \ 831bbff01ceSmrg VIVANTE_MOD_COMP_MASK) 832bbff01ceSmrg 83300a23bdaSmrg/* NVIDIA frame buffer modifiers */ 834d8807b2fSmrg 835d8807b2fSmrg/* 836d8807b2fSmrg * Tegra Tiled Layout, used by Tegra 2, 3 and 4. 837d8807b2fSmrg * 838d8807b2fSmrg * Pixels are arranged in simple tiles of 16 x 16 bytes. 839d8807b2fSmrg */ 84000a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1) 841d8807b2fSmrg 842d8807b2fSmrg/* 84341687f09Smrg * Generalized Block Linear layout, used by desktop GPUs starting with NV50/G80, 84441687f09Smrg * and Tegra GPUs starting with Tegra K1. 84541687f09Smrg * 84641687f09Smrg * Pixels are arranged in Groups of Bytes (GOBs). GOB size and layout varies 84741687f09Smrg * based on the architecture generation. GOBs themselves are then arranged in 84841687f09Smrg * 3D blocks, with the block dimensions (in terms of GOBs) always being a power 84941687f09Smrg * of two, and hence expressible as their log2 equivalent (E.g., "2" represents 85041687f09Smrg * a block depth or height of "4"). 85141687f09Smrg * 85241687f09Smrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 85341687f09Smrg * in full detail. 85441687f09Smrg * 85541687f09Smrg * Macro 85641687f09Smrg * Bits Param Description 85741687f09Smrg * ---- ----- ----------------------------------------------------------------- 85841687f09Smrg * 85941687f09Smrg * 3:0 h log2(height) of each block, in GOBs. Placed here for 86041687f09Smrg * compatibility with the existing 86141687f09Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 86241687f09Smrg * 86341687f09Smrg * 4:4 - Must be 1, to indicate block-linear layout. Necessary for 86441687f09Smrg * compatibility with the existing 86541687f09Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 86641687f09Smrg * 86741687f09Smrg * 8:5 - Reserved (To support 3D-surfaces with variable log2(depth) block 86841687f09Smrg * size). Must be zero. 86941687f09Smrg * 87041687f09Smrg * Note there is no log2(width) parameter. Some portions of the 87141687f09Smrg * hardware support a block width of two gobs, but it is impractical 87241687f09Smrg * to use due to lack of support elsewhere, and has no known 87341687f09Smrg * benefits. 87441687f09Smrg * 87541687f09Smrg * 11:9 - Reserved (To support 2D-array textures with variable array stride 87641687f09Smrg * in blocks, specified via log2(tile width in blocks)). Must be 87741687f09Smrg * zero. 87841687f09Smrg * 87941687f09Smrg * 19:12 k Page Kind. This value directly maps to a field in the page 88041687f09Smrg * tables of all GPUs >= NV50. It affects the exact layout of bits 88141687f09Smrg * in memory and can be derived from the tuple 88241687f09Smrg * 88341687f09Smrg * (format, GPU model, compression type, samples per pixel) 88441687f09Smrg * 88541687f09Smrg * Where compression type is defined below. If GPU model were 88641687f09Smrg * implied by the format modifier, format, or memory buffer, page 88741687f09Smrg * kind would not need to be included in the modifier itself, but 88841687f09Smrg * since the modifier should define the layout of the associated 88941687f09Smrg * memory buffer independent from any device or other context, it 89041687f09Smrg * must be included here. 89141687f09Smrg * 89241687f09Smrg * 21:20 g GOB Height and Page Kind Generation. The height of a GOB changed 89341687f09Smrg * starting with Fermi GPUs. Additionally, the mapping between page 89441687f09Smrg * kind and bit layout has changed at various points. 89541687f09Smrg * 89641687f09Smrg * 0 = Gob Height 8, Fermi - Volta, Tegra K1+ Page Kind mapping 89741687f09Smrg * 1 = Gob Height 4, G80 - GT2XX Page Kind mapping 89841687f09Smrg * 2 = Gob Height 8, Turing+ Page Kind mapping 89941687f09Smrg * 3 = Reserved for future use. 90041687f09Smrg * 90141687f09Smrg * 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further 90241687f09Smrg * bit remapping step that occurs at an even lower level than the 90341687f09Smrg * page kind and block linear swizzles. This causes the layout of 90441687f09Smrg * surfaces mapped in those SOC's GPUs to be incompatible with the 90541687f09Smrg * equivalent mapping on other GPUs in the same system. 90641687f09Smrg * 90741687f09Smrg * 0 = Tegra K1 - Tegra Parker/TX2 Layout. 90841687f09Smrg * 1 = Desktop GPU and Tegra Xavier+ Layout 90941687f09Smrg * 91041687f09Smrg * 25:23 c Lossless Framebuffer Compression type. 91141687f09Smrg * 91241687f09Smrg * 0 = none 91341687f09Smrg * 1 = ROP/3D, layout 1, exact compression format implied by Page 91441687f09Smrg * Kind field 91541687f09Smrg * 2 = ROP/3D, layout 2, exact compression format implied by Page 91641687f09Smrg * Kind field 91741687f09Smrg * 3 = CDE horizontal 91841687f09Smrg * 4 = CDE vertical 91941687f09Smrg * 5 = Reserved for future use 92041687f09Smrg * 6 = Reserved for future use 92141687f09Smrg * 7 = Reserved for future use 92241687f09Smrg * 92341687f09Smrg * 55:25 - Reserved for future use. Must be zero. 92441687f09Smrg */ 92541687f09Smrg#define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(c, s, g, k, h) \ 92641687f09Smrg fourcc_mod_code(NVIDIA, (0x10 | \ 92741687f09Smrg ((h) & 0xf) | \ 92841687f09Smrg (((k) & 0xff) << 12) | \ 92941687f09Smrg (((g) & 0x3) << 20) | \ 93041687f09Smrg (((s) & 0x1) << 22) | \ 93141687f09Smrg (((c) & 0x7) << 23))) 93241687f09Smrg 93341687f09Smrg/* To grandfather in prior block linear format modifiers to the above layout, 93441687f09Smrg * the page kind "0", which corresponds to "pitch/linear" and hence is unusable 93541687f09Smrg * with block-linear layouts, is remapped within drivers to the value 0xfe, 93641687f09Smrg * which corresponds to the "generic" kind used for simple single-sample 93741687f09Smrg * uncompressed color formats on Fermi - Volta GPUs. 93841687f09Smrg */ 93941687f09Smrgstatic __inline__ __u64 94041687f09Smrgdrm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) 94141687f09Smrg{ 94241687f09Smrg if (!(modifier & 0x10) || (modifier & (0xff << 12))) 94341687f09Smrg return modifier; 94441687f09Smrg else 94541687f09Smrg return modifier | (0xfe << 12); 94641687f09Smrg} 94741687f09Smrg 94841687f09Smrg/* 94941687f09Smrg * 16Bx2 Block Linear layout, used by Tegra K1 and later 950d8807b2fSmrg * 951d8807b2fSmrg * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked 952d8807b2fSmrg * vertically by a power of 2 (1 to 32 GOBs) to form a block. 953d8807b2fSmrg * 954d8807b2fSmrg * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. 955d8807b2fSmrg * 956d8807b2fSmrg * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. 957d8807b2fSmrg * Valid values are: 958d8807b2fSmrg * 959d8807b2fSmrg * 0 == ONE_GOB 960d8807b2fSmrg * 1 == TWO_GOBS 961d8807b2fSmrg * 2 == FOUR_GOBS 962d8807b2fSmrg * 3 == EIGHT_GOBS 963d8807b2fSmrg * 4 == SIXTEEN_GOBS 964d8807b2fSmrg * 5 == THIRTYTWO_GOBS 965d8807b2fSmrg * 966d8807b2fSmrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 967d8807b2fSmrg * in full detail. 968d8807b2fSmrg */ 96900a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \ 97041687f09Smrg DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0, (v)) 97100a23bdaSmrg 97200a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \ 97341687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0) 97400a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \ 97541687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1) 97600a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \ 97741687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2) 97800a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \ 97941687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3) 98000a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \ 98141687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4) 98200a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \ 98341687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5) 984d8807b2fSmrg 9857cdc0497Smrg/* 9867cdc0497Smrg * Some Broadcom modifiers take parameters, for example the number of 9877cdc0497Smrg * vertical lines in the image. Reserve the lower 32 bits for modifier 9887cdc0497Smrg * type, and the next 24 bits for parameters. Top 8 bits are the 9897cdc0497Smrg * vendor code. 9907cdc0497Smrg */ 9917cdc0497Smrg#define __fourcc_mod_broadcom_param_shift 8 9927cdc0497Smrg#define __fourcc_mod_broadcom_param_bits 48 9937cdc0497Smrg#define fourcc_mod_broadcom_code(val, params) \ 9947cdc0497Smrg fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) 9957cdc0497Smrg#define fourcc_mod_broadcom_param(m) \ 9967cdc0497Smrg ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ 9977cdc0497Smrg ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) 9987cdc0497Smrg#define fourcc_mod_broadcom_mod(m) \ 9997cdc0497Smrg ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ 10007cdc0497Smrg __fourcc_mod_broadcom_param_shift)) 10017cdc0497Smrg 1002d8807b2fSmrg/* 1003d8807b2fSmrg * Broadcom VC4 "T" format 1004d8807b2fSmrg * 1005d8807b2fSmrg * This is the primary layout that the V3D GPU can texture from (it 1006d8807b2fSmrg * can't do linear). The T format has: 1007d8807b2fSmrg * 1008d8807b2fSmrg * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 1009d8807b2fSmrg * pixels at 32 bit depth. 1010d8807b2fSmrg * 1011d8807b2fSmrg * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually 1012d8807b2fSmrg * 16x16 pixels). 1013d8807b2fSmrg * 1014d8807b2fSmrg * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On 1015d8807b2fSmrg * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows 1016d8807b2fSmrg * they're (TR, BR, BL, TL), where bottom left is start of memory. 1017d8807b2fSmrg * 1018d8807b2fSmrg * - an image made of 4k tiles in rows either left-to-right (even rows of 4k 1019d8807b2fSmrg * tiles) or right-to-left (odd rows of 4k tiles). 1020d8807b2fSmrg */ 1021d8807b2fSmrg#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) 1022d8807b2fSmrg 10237cdc0497Smrg/* 10247cdc0497Smrg * Broadcom SAND format 10257cdc0497Smrg * 10267cdc0497Smrg * This is the native format that the H.264 codec block uses. For VC4 10277cdc0497Smrg * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. 10287cdc0497Smrg * 10297cdc0497Smrg * The image can be considered to be split into columns, and the 10307cdc0497Smrg * columns are placed consecutively into memory. The width of those 10317cdc0497Smrg * columns can be either 32, 64, 128, or 256 pixels, but in practice 10327cdc0497Smrg * only 128 pixel columns are used. 10337cdc0497Smrg * 10347cdc0497Smrg * The pitch between the start of each column is set to optimally 10357cdc0497Smrg * switch between SDRAM banks. This is passed as the number of lines 10367cdc0497Smrg * of column width in the modifier (we can't use the stride value due 10377cdc0497Smrg * to various core checks that look at it , so you should set the 10387cdc0497Smrg * stride to width*cpp). 10397cdc0497Smrg * 10407cdc0497Smrg * Note that the column height for this format modifier is the same 10417cdc0497Smrg * for all of the planes, assuming that each column contains both Y 10427cdc0497Smrg * and UV. Some SAND-using hardware stores UV in a separate tiled 10437cdc0497Smrg * image from Y to reduce the column height, which is not supported 10447cdc0497Smrg * with these modifiers. 1045b0ab5608Smrg * 1046b0ab5608Smrg * The DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT modifier is also 1047b0ab5608Smrg * supported for DRM_FORMAT_P030 where the columns remain as 128 bytes 1048b0ab5608Smrg * wide, but as this is a 10 bpp format that translates to 96 pixels. 10497cdc0497Smrg */ 10507cdc0497Smrg 10517cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ 10527cdc0497Smrg fourcc_mod_broadcom_code(2, v) 10537cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ 10547cdc0497Smrg fourcc_mod_broadcom_code(3, v) 10557cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ 10567cdc0497Smrg fourcc_mod_broadcom_code(4, v) 10577cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ 10587cdc0497Smrg fourcc_mod_broadcom_code(5, v) 10597cdc0497Smrg 10607cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ 10617cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) 10627cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ 10637cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) 10647cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ 10657cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) 10667cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ 10677cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) 10687cdc0497Smrg 10697cdc0497Smrg/* Broadcom UIF format 10707cdc0497Smrg * 10717cdc0497Smrg * This is the common format for the current Broadcom multimedia 10727cdc0497Smrg * blocks, including V3D 3.x and newer, newer video codecs, and 10737cdc0497Smrg * displays. 10747cdc0497Smrg * 10757cdc0497Smrg * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), 10767cdc0497Smrg * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are 10777cdc0497Smrg * stored in columns, with padding between the columns to ensure that 10787cdc0497Smrg * moving from one column to the next doesn't hit the same SDRAM page 10797cdc0497Smrg * bank. 10807cdc0497Smrg * 10817cdc0497Smrg * To calculate the padding, it is assumed that each hardware block 10827cdc0497Smrg * and the software driving it knows the platform's SDRAM page size, 10837cdc0497Smrg * number of banks, and XOR address, and that it's identical between 10847cdc0497Smrg * all blocks using the format. This tiling modifier will use XOR as 10857cdc0497Smrg * necessary to reduce the padding. If a hardware block can't do XOR, 10867cdc0497Smrg * the assumption is that a no-XOR tiling modifier will be created. 10877cdc0497Smrg */ 10887cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) 10897cdc0497Smrg 10907cdc0497Smrg/* 10917cdc0497Smrg * Arm Framebuffer Compression (AFBC) modifiers 10927cdc0497Smrg * 10937cdc0497Smrg * AFBC is a proprietary lossless image compression protocol and format. 10947cdc0497Smrg * It provides fine-grained random access and minimizes the amount of data 10957cdc0497Smrg * transferred between IP blocks. 10967cdc0497Smrg * 10977cdc0497Smrg * AFBC has several features which may be supported and/or used, which are 10987cdc0497Smrg * represented using bits in the modifier. Not all combinations are valid, 10997cdc0497Smrg * and different devices or use-cases may support different combinations. 11005324fb0dSmrg * 11015324fb0dSmrg * Further information on the use of AFBC modifiers can be found in 11025324fb0dSmrg * Documentation/gpu/afbc.rst 11037cdc0497Smrg */ 110441687f09Smrg 110541687f09Smrg/* 1106bbff01ceSmrg * The top 4 bits (out of the 56 bits allotted for specifying vendor specific 110749ef06a4Smrg * modifiers) denote the category for modifiers. Currently we have three 110849ef06a4Smrg * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of 110949ef06a4Smrg * sixteen different categories. 111041687f09Smrg */ 111141687f09Smrg#define DRM_FORMAT_MOD_ARM_CODE(__type, __val) \ 111241687f09Smrg fourcc_mod_code(ARM, ((__u64)(__type) << 52) | ((__val) & 0x000fffffffffffffULL)) 111341687f09Smrg 111441687f09Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFBC 0x00 111541687f09Smrg#define DRM_FORMAT_MOD_ARM_TYPE_MISC 0x01 111641687f09Smrg 111741687f09Smrg#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) \ 111841687f09Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFBC, __afbc_mode) 11197cdc0497Smrg 11207cdc0497Smrg/* 11217cdc0497Smrg * AFBC superblock size 11227cdc0497Smrg * 11237cdc0497Smrg * Indicates the superblock size(s) used for the AFBC buffer. The buffer 11247cdc0497Smrg * size (in pixels) must be aligned to a multiple of the superblock size. 11257cdc0497Smrg * Four lowest significant bits(LSBs) are reserved for block size. 11265324fb0dSmrg * 11275324fb0dSmrg * Where one superblock size is specified, it applies to all planes of the 11285324fb0dSmrg * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified, 11295324fb0dSmrg * the first applies to the Luma plane and the second applies to the Chroma 11305324fb0dSmrg * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma). 11315324fb0dSmrg * Multiple superblock sizes are only valid for multi-plane YCbCr formats. 11327cdc0497Smrg */ 11337cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf 11347cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) 11357cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) 11365324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 (3ULL) 11375324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL) 11387cdc0497Smrg 11397cdc0497Smrg/* 11407cdc0497Smrg * AFBC lossless colorspace transform 11417cdc0497Smrg * 11427cdc0497Smrg * Indicates that the buffer makes use of the AFBC lossless colorspace 11437cdc0497Smrg * transform. 11447cdc0497Smrg */ 11457cdc0497Smrg#define AFBC_FORMAT_MOD_YTR (1ULL << 4) 11467cdc0497Smrg 11477cdc0497Smrg/* 11487cdc0497Smrg * AFBC block-split 11497cdc0497Smrg * 11507cdc0497Smrg * Indicates that the payload of each superblock is split. The second 11517cdc0497Smrg * half of the payload is positioned at a predefined offset from the start 11527cdc0497Smrg * of the superblock payload. 11537cdc0497Smrg */ 11547cdc0497Smrg#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) 11557cdc0497Smrg 11567cdc0497Smrg/* 11577cdc0497Smrg * AFBC sparse layout 11587cdc0497Smrg * 11597cdc0497Smrg * This flag indicates that the payload of each superblock must be stored at a 11607cdc0497Smrg * predefined position relative to the other superblocks in the same AFBC 11617cdc0497Smrg * buffer. This order is the same order used by the header buffer. In this mode 11627cdc0497Smrg * each superblock is given the same amount of space as an uncompressed 11637cdc0497Smrg * superblock of the particular format would require, rounding up to the next 11647cdc0497Smrg * multiple of 128 bytes in size. 11657cdc0497Smrg */ 11667cdc0497Smrg#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) 11677cdc0497Smrg 11687cdc0497Smrg/* 11697cdc0497Smrg * AFBC copy-block restrict 11707cdc0497Smrg * 11717cdc0497Smrg * Buffers with this flag must obey the copy-block restriction. The restriction 11727cdc0497Smrg * is such that there are no copy-blocks referring across the border of 8x8 11737cdc0497Smrg * blocks. For the subsampled data the 8x8 limitation is also subsampled. 11747cdc0497Smrg */ 11757cdc0497Smrg#define AFBC_FORMAT_MOD_CBR (1ULL << 7) 11767cdc0497Smrg 11777cdc0497Smrg/* 11787cdc0497Smrg * AFBC tiled layout 11797cdc0497Smrg * 11807cdc0497Smrg * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all 11817cdc0497Smrg * superblocks inside a tile are stored together in memory. 8x8 tiles are used 11827cdc0497Smrg * for pixel formats up to and including 32 bpp while 4x4 tiles are used for 11837cdc0497Smrg * larger bpp formats. The order between the tiles is scan line. 11847cdc0497Smrg * When the tiled layout is used, the buffer size (in pixels) must be aligned 11857cdc0497Smrg * to the tile size. 11867cdc0497Smrg */ 11877cdc0497Smrg#define AFBC_FORMAT_MOD_TILED (1ULL << 8) 11887cdc0497Smrg 11897cdc0497Smrg/* 11907cdc0497Smrg * AFBC solid color blocks 11917cdc0497Smrg * 11927cdc0497Smrg * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth 11937cdc0497Smrg * can be reduced if a whole superblock is a single color. 11947cdc0497Smrg */ 11957cdc0497Smrg#define AFBC_FORMAT_MOD_SC (1ULL << 9) 11967cdc0497Smrg 11975324fb0dSmrg/* 11985324fb0dSmrg * AFBC double-buffer 11995324fb0dSmrg * 12005324fb0dSmrg * Indicates that the buffer is allocated in a layout safe for front-buffer 12015324fb0dSmrg * rendering. 12025324fb0dSmrg */ 12035324fb0dSmrg#define AFBC_FORMAT_MOD_DB (1ULL << 10) 12045324fb0dSmrg 12055324fb0dSmrg/* 12065324fb0dSmrg * AFBC buffer content hints 12075324fb0dSmrg * 12085324fb0dSmrg * Indicates that the buffer includes per-superblock content hints. 12095324fb0dSmrg */ 12105324fb0dSmrg#define AFBC_FORMAT_MOD_BCH (1ULL << 11) 12115324fb0dSmrg 121241687f09Smrg/* AFBC uncompressed storage mode 121341687f09Smrg * 121441687f09Smrg * Indicates that the buffer is using AFBC uncompressed storage mode. 121541687f09Smrg * In this mode all superblock payloads in the buffer use the uncompressed 121641687f09Smrg * storage mode, which is usually only used for data which cannot be compressed. 121741687f09Smrg * The buffer layout is the same as for AFBC buffers without USM set, this only 121841687f09Smrg * affects the storage mode of the individual superblocks. Note that even a 121941687f09Smrg * buffer without USM set may use uncompressed storage mode for some or all 122041687f09Smrg * superblocks, USM just guarantees it for all. 122141687f09Smrg */ 122241687f09Smrg#define AFBC_FORMAT_MOD_USM (1ULL << 12) 122341687f09Smrg 122449ef06a4Smrg/* 122549ef06a4Smrg * Arm Fixed-Rate Compression (AFRC) modifiers 122649ef06a4Smrg * 122749ef06a4Smrg * AFRC is a proprietary fixed rate image compression protocol and format, 122849ef06a4Smrg * designed to provide guaranteed bandwidth and memory footprint 122949ef06a4Smrg * reductions in graphics and media use-cases. 123049ef06a4Smrg * 123149ef06a4Smrg * AFRC buffers consist of one or more planes, with the same components 123249ef06a4Smrg * and meaning as an uncompressed buffer using the same pixel format. 123349ef06a4Smrg * 123449ef06a4Smrg * Within each plane, the pixel/luma/chroma values are grouped into 123549ef06a4Smrg * "coding unit" blocks which are individually compressed to a 123649ef06a4Smrg * fixed size (in bytes). All coding units within a given plane of a buffer 123749ef06a4Smrg * store the same number of values, and have the same compressed size. 123849ef06a4Smrg * 123949ef06a4Smrg * The coding unit size is configurable, allowing different rates of compression. 124049ef06a4Smrg * 124149ef06a4Smrg * The start of each AFRC buffer plane must be aligned to an alignment granule which 124249ef06a4Smrg * depends on the coding unit size. 124349ef06a4Smrg * 124449ef06a4Smrg * Coding Unit Size Plane Alignment 124549ef06a4Smrg * ---------------- --------------- 124649ef06a4Smrg * 16 bytes 1024 bytes 124749ef06a4Smrg * 24 bytes 512 bytes 124849ef06a4Smrg * 32 bytes 2048 bytes 124949ef06a4Smrg * 125049ef06a4Smrg * Coding units are grouped into paging tiles. AFRC buffer dimensions must be aligned 125149ef06a4Smrg * to a multiple of the paging tile dimensions. 125249ef06a4Smrg * The dimensions of each paging tile depend on whether the buffer is optimised for 125349ef06a4Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 125449ef06a4Smrg * 125549ef06a4Smrg * Layout Paging Tile Width Paging Tile Height 125649ef06a4Smrg * ------ ----------------- ------------------ 125749ef06a4Smrg * SCAN 16 coding units 4 coding units 125849ef06a4Smrg * ROT 8 coding units 8 coding units 125949ef06a4Smrg * 126049ef06a4Smrg * The dimensions of each coding unit depend on the number of components 126149ef06a4Smrg * in the compressed plane and whether the buffer is optimised for 126249ef06a4Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 126349ef06a4Smrg * 126449ef06a4Smrg * Number of Components in Plane Layout Coding Unit Width Coding Unit Height 126549ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 126649ef06a4Smrg * 1 SCAN 16 samples 4 samples 126749ef06a4Smrg * Example: 16x4 luma samples in a 'Y' plane 126849ef06a4Smrg * 16x4 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 126949ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 127049ef06a4Smrg * 1 ROT 8 samples 8 samples 127149ef06a4Smrg * Example: 8x8 luma samples in a 'Y' plane 127249ef06a4Smrg * 8x8 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 127349ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 127449ef06a4Smrg * 2 DONT CARE 8 samples 4 samples 127549ef06a4Smrg * Example: 8x4 chroma pairs in the 'UV' plane of a semi-planar YUV buffer 127649ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 127749ef06a4Smrg * 3 DONT CARE 4 samples 4 samples 127849ef06a4Smrg * Example: 4x4 pixels in an RGB buffer without alpha 127949ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 128049ef06a4Smrg * 4 DONT CARE 4 samples 4 samples 128149ef06a4Smrg * Example: 4x4 pixels in an RGB buffer with alpha 128249ef06a4Smrg */ 128349ef06a4Smrg 128449ef06a4Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFRC 0x02 128549ef06a4Smrg 128649ef06a4Smrg#define DRM_FORMAT_MOD_ARM_AFRC(__afrc_mode) \ 128749ef06a4Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFRC, __afrc_mode) 128849ef06a4Smrg 128949ef06a4Smrg/* 129049ef06a4Smrg * AFRC coding unit size modifier. 129149ef06a4Smrg * 129249ef06a4Smrg * Indicates the number of bytes used to store each compressed coding unit for 129349ef06a4Smrg * one or more planes in an AFRC encoded buffer. The coding unit size for chrominance 129449ef06a4Smrg * is the same for both Cb and Cr, which may be stored in separate planes. 129549ef06a4Smrg * 129649ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P0 indicates the number of bytes used to store 129749ef06a4Smrg * each compressed coding unit in the first plane of the buffer. For RGBA buffers 129849ef06a4Smrg * this is the only plane, while for semi-planar and fully-planar YUV buffers, 129949ef06a4Smrg * this corresponds to the luma plane. 130049ef06a4Smrg * 130149ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 indicates the number of bytes used to store 130249ef06a4Smrg * each compressed coding unit in the second and third planes in the buffer. 130349ef06a4Smrg * For semi-planar and fully-planar YUV buffers, this corresponds to the chroma plane(s). 130449ef06a4Smrg * 130549ef06a4Smrg * For single-plane buffers, AFRC_FORMAT_MOD_CU_SIZE_P0 must be specified 130649ef06a4Smrg * and AFRC_FORMAT_MOD_CU_SIZE_P12 must be zero. 130749ef06a4Smrg * For semi-planar and fully-planar buffers, both AFRC_FORMAT_MOD_CU_SIZE_P0 and 130849ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 must be specified. 130949ef06a4Smrg */ 131049ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_MASK 0xf 131149ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_16 (1ULL) 131249ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_24 (2ULL) 131349ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_32 (3ULL) 131449ef06a4Smrg 131549ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P0(__afrc_cu_size) (__afrc_cu_size) 131649ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P12(__afrc_cu_size) ((__afrc_cu_size) << 4) 131749ef06a4Smrg 131849ef06a4Smrg/* 131949ef06a4Smrg * AFRC scanline memory layout. 132049ef06a4Smrg * 132149ef06a4Smrg * Indicates if the buffer uses the scanline-optimised layout 132249ef06a4Smrg * for an AFRC encoded buffer, otherwise, it uses the rotation-optimised layout. 132349ef06a4Smrg * The memory layout is the same for all planes. 132449ef06a4Smrg */ 132549ef06a4Smrg#define AFRC_FORMAT_MOD_LAYOUT_SCAN (1ULL << 8) 132649ef06a4Smrg 132741687f09Smrg/* 132841687f09Smrg * Arm 16x16 Block U-Interleaved modifier 132941687f09Smrg * 133041687f09Smrg * This is used by Arm Mali Utgard and Midgard GPUs. It divides the image 133141687f09Smrg * into 16x16 pixel blocks. Blocks are stored linearly in order, but pixels 133241687f09Smrg * in the block are reordered. 133341687f09Smrg */ 133441687f09Smrg#define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ 133541687f09Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) 133641687f09Smrg 13375324fb0dSmrg/* 13385324fb0dSmrg * Allwinner tiled modifier 13395324fb0dSmrg * 13405324fb0dSmrg * This tiling mode is implemented by the VPU found on all Allwinner platforms, 13415324fb0dSmrg * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 13425324fb0dSmrg * planes. 13435324fb0dSmrg * 13445324fb0dSmrg * With this tiling, the luminance samples are disposed in tiles representing 13455324fb0dSmrg * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. 13465324fb0dSmrg * The pixel order in each tile is linear and the tiles are disposed linearly, 13475324fb0dSmrg * both in row-major order. 13485324fb0dSmrg */ 13495324fb0dSmrg#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) 13505324fb0dSmrg 135141687f09Smrg/* 135241687f09Smrg * Amlogic Video Framebuffer Compression modifiers 135341687f09Smrg * 135441687f09Smrg * Amlogic uses a proprietary lossless image compression protocol and format 135541687f09Smrg * for their hardware video codec accelerators, either video decoders or 135641687f09Smrg * video input encoders. 135741687f09Smrg * 135841687f09Smrg * It considerably reduces memory bandwidth while writing and reading 135941687f09Smrg * frames in memory. 136041687f09Smrg * 136141687f09Smrg * The underlying storage is considered to be 3 components, 8bit or 10-bit 136241687f09Smrg * per component YCbCr 420, single plane : 136341687f09Smrg * - DRM_FORMAT_YUV420_8BIT 136441687f09Smrg * - DRM_FORMAT_YUV420_10BIT 136541687f09Smrg * 136641687f09Smrg * The first 8 bits of the mode defines the layout, then the following 8 bits 136741687f09Smrg * defines the options changing the layout. 136841687f09Smrg * 136941687f09Smrg * Not all combinations are valid, and different SoCs may support different 137041687f09Smrg * combinations of layout and options. 137141687f09Smrg */ 137249ef06a4Smrg#define __fourcc_mod_amlogic_layout_mask 0xff 137341687f09Smrg#define __fourcc_mod_amlogic_options_shift 8 137449ef06a4Smrg#define __fourcc_mod_amlogic_options_mask 0xff 137541687f09Smrg 137641687f09Smrg#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \ 137741687f09Smrg fourcc_mod_code(AMLOGIC, \ 137841687f09Smrg ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ 137941687f09Smrg (((__options) & __fourcc_mod_amlogic_options_mask) \ 138041687f09Smrg << __fourcc_mod_amlogic_options_shift)) 138141687f09Smrg 138241687f09Smrg/* Amlogic FBC Layouts */ 138341687f09Smrg 138441687f09Smrg/* 138541687f09Smrg * Amlogic FBC Basic Layout 138641687f09Smrg * 138741687f09Smrg * The basic layout is composed of: 138841687f09Smrg * - a body content organized in 64x32 superblocks with 4096 bytes per 138941687f09Smrg * superblock in default mode. 139041687f09Smrg * - a 32 bytes per 128x64 header block 139141687f09Smrg * 139241687f09Smrg * This layout is transferrable between Amlogic SoCs supporting this modifier. 139341687f09Smrg */ 139441687f09Smrg#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) 139541687f09Smrg 139641687f09Smrg/* 139741687f09Smrg * Amlogic FBC Scatter Memory layout 139841687f09Smrg * 139941687f09Smrg * Indicates the header contains IOMMU references to the compressed 140041687f09Smrg * frames content to optimize memory access and layout. 140141687f09Smrg * 140241687f09Smrg * In this mode, only the header memory address is needed, thus the 140341687f09Smrg * content memory organization is tied to the current producer 140441687f09Smrg * execution and cannot be saved/dumped neither transferrable between 140541687f09Smrg * Amlogic SoCs supporting this modifier. 140641687f09Smrg * 140741687f09Smrg * Due to the nature of the layout, these buffers are not expected to 140841687f09Smrg * be accessible by the user-space clients, but only accessible by the 140941687f09Smrg * hardware producers and consumers. 141041687f09Smrg * 141141687f09Smrg * The user-space clients should expect a failure while trying to mmap 141241687f09Smrg * the DMA-BUF handle returned by the producer. 141341687f09Smrg */ 141441687f09Smrg#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) 141541687f09Smrg 141641687f09Smrg/* Amlogic FBC Layout Options Bit Mask */ 141741687f09Smrg 141841687f09Smrg/* 141941687f09Smrg * Amlogic FBC Memory Saving mode 142041687f09Smrg * 142141687f09Smrg * Indicates the storage is packed when pixel size is multiple of word 1422bbff01ceSmrg * boundaries, i.e. 8bit should be stored in this mode to save allocation 142341687f09Smrg * memory. 142441687f09Smrg * 142541687f09Smrg * This mode reduces body layout to 3072 bytes per 64x32 superblock with 142641687f09Smrg * the basic layout and 3200 bytes per 64x32 superblock combined with 142741687f09Smrg * the scatter layout. 142841687f09Smrg */ 142941687f09Smrg#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) 143041687f09Smrg 143141687f09Smrg/* 143241687f09Smrg * AMD modifiers 143341687f09Smrg * 143441687f09Smrg * Memory layout: 143541687f09Smrg * 143641687f09Smrg * without DCC: 143741687f09Smrg * - main surface 143841687f09Smrg * 143941687f09Smrg * with DCC & without DCC_RETILE: 144041687f09Smrg * - main surface in plane 0 144141687f09Smrg * - DCC surface in plane 1 (RB-aligned, pipe-aligned if DCC_PIPE_ALIGN is set) 144241687f09Smrg * 144341687f09Smrg * with DCC & DCC_RETILE: 144441687f09Smrg * - main surface in plane 0 144541687f09Smrg * - displayable DCC surface in plane 1 (not RB-aligned & not pipe-aligned) 144641687f09Smrg * - pipe-aligned DCC surface in plane 2 (RB-aligned & pipe-aligned) 144741687f09Smrg * 144841687f09Smrg * For multi-plane formats the above surfaces get merged into one plane for 144941687f09Smrg * each format plane, based on the required alignment only. 145041687f09Smrg * 145141687f09Smrg * Bits Parameter Notes 145241687f09Smrg * ----- ------------------------ --------------------------------------------- 145341687f09Smrg * 145441687f09Smrg * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* 145541687f09Smrg * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* 145641687f09Smrg * 13 DCC 145741687f09Smrg * 14 DCC_RETILE 145841687f09Smrg * 15 DCC_PIPE_ALIGN 145941687f09Smrg * 16 DCC_INDEPENDENT_64B 146041687f09Smrg * 17 DCC_INDEPENDENT_128B 146141687f09Smrg * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* 146241687f09Smrg * 20 DCC_CONSTANT_ENCODE 146341687f09Smrg * 23:21 PIPE_XOR_BITS Only for some chips 146441687f09Smrg * 26:24 BANK_XOR_BITS Only for some chips 146541687f09Smrg * 29:27 PACKERS Only for some chips 146641687f09Smrg * 32:30 RB Only for some chips 146741687f09Smrg * 35:33 PIPE Only for some chips 146841687f09Smrg * 55:36 - Reserved for future use, must be zero 146941687f09Smrg */ 147041687f09Smrg#define AMD_FMT_MOD fourcc_mod_code(AMD, 0) 147141687f09Smrg 147241687f09Smrg#define IS_AMD_FMT_MOD(val) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD) 147341687f09Smrg 147441687f09Smrg/* Reserve 0 for GFX8 and older */ 147541687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX9 1 147641687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX10 2 147741687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3 1478b0ab5608Smrg#define AMD_FMT_MOD_TILE_VER_GFX11 4 1479bbff01ceSmrg#define AMD_FMT_MOD_TILE_VER_GFX12 5 148041687f09Smrg 148141687f09Smrg/* 148241687f09Smrg * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical 148341687f09Smrg * version. 148441687f09Smrg */ 148541687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S 9 148641687f09Smrg 148741687f09Smrg/* 148841687f09Smrg * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has 148941687f09Smrg * GFX9 as canonical version. 1490bbff01ceSmrg * 1491bbff01ceSmrg * 64K_D_2D on GFX12 is identical to 64K_D on GFX11. 149241687f09Smrg */ 149341687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D 10 149441687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25 149541687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26 149641687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27 1497b0ab5608Smrg#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31 149841687f09Smrg 1499bbff01ceSmrg/* Gfx12 swizzle modes: 1500bbff01ceSmrg * 0 - LINEAR 1501bbff01ceSmrg * 1 - 256B_2D - 2D block dimensions 1502bbff01ceSmrg * 2 - 4KB_2D 1503bbff01ceSmrg * 3 - 64KB_2D 1504bbff01ceSmrg * 4 - 256KB_2D 1505bbff01ceSmrg * 5 - 4KB_3D - 3D block dimensions 1506bbff01ceSmrg * 6 - 64KB_3D 1507bbff01ceSmrg * 7 - 256KB_3D 1508bbff01ceSmrg */ 1509bbff01ceSmrg#define AMD_FMT_MOD_TILE_GFX12_64K_2D 3 1510bbff01ceSmrg#define AMD_FMT_MOD_TILE_GFX12_256K_2D 4 1511bbff01ceSmrg 151241687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_64B 0 151341687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_128B 1 151441687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_256B 2 151541687f09Smrg 151641687f09Smrg#define AMD_FMT_MOD_TILE_VERSION_SHIFT 0 151741687f09Smrg#define AMD_FMT_MOD_TILE_VERSION_MASK 0xFF 151841687f09Smrg#define AMD_FMT_MOD_TILE_SHIFT 8 151941687f09Smrg#define AMD_FMT_MOD_TILE_MASK 0x1F 152041687f09Smrg 152141687f09Smrg/* Whether DCC compression is enabled. */ 152241687f09Smrg#define AMD_FMT_MOD_DCC_SHIFT 13 152341687f09Smrg#define AMD_FMT_MOD_DCC_MASK 0x1 152441687f09Smrg 152541687f09Smrg/* 152641687f09Smrg * Whether to include two DCC surfaces, one which is rb & pipe aligned, and 152741687f09Smrg * one which is not-aligned. 152841687f09Smrg */ 152941687f09Smrg#define AMD_FMT_MOD_DCC_RETILE_SHIFT 14 153041687f09Smrg#define AMD_FMT_MOD_DCC_RETILE_MASK 0x1 153141687f09Smrg 153241687f09Smrg/* Only set if DCC_RETILE = false */ 153341687f09Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_SHIFT 15 153441687f09Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_MASK 0x1 153541687f09Smrg 153641687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_SHIFT 16 153741687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_MASK 0x1 153841687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_SHIFT 17 153941687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_MASK 0x1 154041687f09Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_SHIFT 18 154141687f09Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 154241687f09Smrg 1543bbff01ceSmrg#define AMD_FMT_MOD_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT 3 1544bbff01ceSmrg#define AMD_FMT_MOD_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 /* 0:64B, 1:128B, 2:256B */ 1545bbff01ceSmrg 154641687f09Smrg/* 154741687f09Smrg * DCC supports embedding some clear colors directly in the DCC surface. 154841687f09Smrg * However, on older GPUs the rendering HW ignores the embedded clear color 154941687f09Smrg * and prefers the driver provided color. This necessitates doing a fastclear 155041687f09Smrg * eliminate operation before a process transfers control. 155141687f09Smrg * 155241687f09Smrg * If this bit is set that means the fastclear eliminate is not needed for these 155341687f09Smrg * embeddable colors. 155441687f09Smrg */ 155541687f09Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_SHIFT 20 155641687f09Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_MASK 0x1 155741687f09Smrg 155841687f09Smrg/* 155941687f09Smrg * The below fields are for accounting for per GPU differences. These are only 156041687f09Smrg * relevant for GFX9 and later and if the tile field is *_X/_T. 156141687f09Smrg * 156241687f09Smrg * PIPE_XOR_BITS = always needed 156341687f09Smrg * BANK_XOR_BITS = only for TILE_VER_GFX9 156441687f09Smrg * PACKERS = only for TILE_VER_GFX10_RBPLUS 156541687f09Smrg * RB = only for TILE_VER_GFX9 & DCC 156641687f09Smrg * PIPE = only for TILE_VER_GFX9 & DCC & (DCC_RETILE | DCC_PIPE_ALIGN) 156741687f09Smrg */ 156841687f09Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_SHIFT 21 156941687f09Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_MASK 0x7 157041687f09Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_SHIFT 24 157141687f09Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_MASK 0x7 157241687f09Smrg#define AMD_FMT_MOD_PACKERS_SHIFT 27 157341687f09Smrg#define AMD_FMT_MOD_PACKERS_MASK 0x7 157441687f09Smrg#define AMD_FMT_MOD_RB_SHIFT 30 157541687f09Smrg#define AMD_FMT_MOD_RB_MASK 0x7 157641687f09Smrg#define AMD_FMT_MOD_PIPE_SHIFT 33 157741687f09Smrg#define AMD_FMT_MOD_PIPE_MASK 0x7 157841687f09Smrg 157941687f09Smrg#define AMD_FMT_MOD_SET(field, value) \ 1580b0ab5608Smrg ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT) 158141687f09Smrg#define AMD_FMT_MOD_GET(field, value) \ 158241687f09Smrg (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK) 158341687f09Smrg#define AMD_FMT_MOD_CLEAR(field) \ 1584b0ab5608Smrg (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) 158541687f09Smrg 1586d8807b2fSmrg#if defined(__cplusplus) 1587d8807b2fSmrg} 1588d8807b2fSmrg#endif 1589d8807b2fSmrg 1590e88f27b3Smrg#endif /* DRM_FOURCC_H */ 1591