drm_fourcc.h revision 49ef06a4
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 577cdc0497Smrg * modifier is specific to the modifer 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. 8241687f09Smrg * These users musn'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` 917cdc0497Smrg */ 927cdc0497Smrg 933f012e29Smrg#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 943f012e29Smrg ((__u32)(c) << 16) | ((__u32)(d) << 24)) 95e88f27b3Smrg 9641687f09Smrg#define DRM_FORMAT_BIG_ENDIAN (1U<<31) /* format is big endian instead of little endian */ 97e88f27b3Smrg 987cdc0497Smrg/* Reserve 0 for the invalid format specifier */ 997cdc0497Smrg#define DRM_FORMAT_INVALID 0 1007cdc0497Smrg 101e88f27b3Smrg/* color index */ 102e88f27b3Smrg#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 103e88f27b3Smrg 1043f012e29Smrg/* 8 bpp Red */ 1053f012e29Smrg#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 1063f012e29Smrg 107d8807b2fSmrg/* 16 bpp Red */ 108d8807b2fSmrg#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ 109d8807b2fSmrg 1103f012e29Smrg/* 16 bpp RG */ 1113f012e29Smrg#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 1123f012e29Smrg#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 1133f012e29Smrg 114d8807b2fSmrg/* 32 bpp RG */ 115d8807b2fSmrg#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ 116d8807b2fSmrg#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ 117d8807b2fSmrg 118e88f27b3Smrg/* 8 bpp RGB */ 119e88f27b3Smrg#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 120e88f27b3Smrg#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 121e88f27b3Smrg 122e88f27b3Smrg/* 16 bpp RGB */ 123e88f27b3Smrg#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 124e88f27b3Smrg#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 125e88f27b3Smrg#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 126e88f27b3Smrg#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 127e88f27b3Smrg 128e88f27b3Smrg#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 129e88f27b3Smrg#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 130e88f27b3Smrg#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 131e88f27b3Smrg#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 132e88f27b3Smrg 133e88f27b3Smrg#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 134e88f27b3Smrg#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 135e88f27b3Smrg#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 136e88f27b3Smrg#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 137e88f27b3Smrg 138e88f27b3Smrg#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 139e88f27b3Smrg#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 140e88f27b3Smrg#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 141e88f27b3Smrg#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 142e88f27b3Smrg 143e88f27b3Smrg#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 144e88f27b3Smrg#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 145e88f27b3Smrg 146e88f27b3Smrg/* 24 bpp RGB */ 147e88f27b3Smrg#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 148e88f27b3Smrg#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 149e88f27b3Smrg 150e88f27b3Smrg/* 32 bpp RGB */ 151e88f27b3Smrg#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 152e88f27b3Smrg#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 153e88f27b3Smrg#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 154e88f27b3Smrg#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 155e88f27b3Smrg 156e88f27b3Smrg#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 157e88f27b3Smrg#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 158e88f27b3Smrg#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 159e88f27b3Smrg#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 160e88f27b3Smrg 161e88f27b3Smrg#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 162e88f27b3Smrg#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 163e88f27b3Smrg#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 164e88f27b3Smrg#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 165e88f27b3Smrg 166e88f27b3Smrg#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 167e88f27b3Smrg#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 168e88f27b3Smrg#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 169e88f27b3Smrg#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 170e88f27b3Smrg 17149ef06a4Smrg/* 64 bpp RGB */ 17249ef06a4Smrg#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 17349ef06a4Smrg#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 17449ef06a4Smrg 17549ef06a4Smrg#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 17649ef06a4Smrg#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 17749ef06a4Smrg 1785324fb0dSmrg/* 1795324fb0dSmrg * Floating point 64bpp RGB 1805324fb0dSmrg * IEEE 754-2008 binary16 half-precision float 1815324fb0dSmrg * [15:0] sign:exponent:mantissa 1:5:10 1825324fb0dSmrg */ 1835324fb0dSmrg#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 1845324fb0dSmrg#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 1855324fb0dSmrg 1865324fb0dSmrg#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 1875324fb0dSmrg#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 1885324fb0dSmrg 18941687f09Smrg/* 19041687f09Smrg * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits 19141687f09Smrg * of unused padding per component: 19241687f09Smrg */ 19341687f09Smrg#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 */ 19441687f09Smrg 195e88f27b3Smrg/* packed YCbCr */ 196e88f27b3Smrg#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 197e88f27b3Smrg#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 198e88f27b3Smrg#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 199e88f27b3Smrg#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 200e88f27b3Smrg 201e88f27b3Smrg#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 2025324fb0dSmrg#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ 2035324fb0dSmrg#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */ 2045324fb0dSmrg#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */ 2055324fb0dSmrg 2065324fb0dSmrg/* 2075324fb0dSmrg * packed Y2xx indicate for each component, xx valid data occupy msb 2085324fb0dSmrg * 16-xx padding occupy lsb 2095324fb0dSmrg */ 2105324fb0dSmrg#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 */ 2115324fb0dSmrg#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 */ 2125324fb0dSmrg#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 */ 2135324fb0dSmrg 2145324fb0dSmrg/* 2155324fb0dSmrg * packed Y4xx indicate for each component, xx valid data occupy msb 2165324fb0dSmrg * 16-xx padding occupy lsb except Y410 2175324fb0dSmrg */ 2185324fb0dSmrg#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') /* [31:0] A:Cr:Y:Cb 2:10:10:10 little endian */ 2195324fb0dSmrg#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 */ 2205324fb0dSmrg#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6') /* [63:0] A:Cr:Y:Cb 16:16:16:16 little endian */ 2215324fb0dSmrg 2225324fb0dSmrg#define DRM_FORMAT_XVYU2101010 fourcc_code('X', 'V', '3', '0') /* [31:0] X:Cr:Y:Cb 2:10:10:10 little endian */ 2235324fb0dSmrg#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 */ 2245324fb0dSmrg#define DRM_FORMAT_XVYU16161616 fourcc_code('X', 'V', '4', '8') /* [63:0] X:Cr:Y:Cb 16:16:16:16 little endian */ 2255324fb0dSmrg 2265324fb0dSmrg/* 2275324fb0dSmrg * packed YCbCr420 2x2 tiled formats 2285324fb0dSmrg * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile 2295324fb0dSmrg */ 2305324fb0dSmrg/* [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 */ 2315324fb0dSmrg#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0') 2325324fb0dSmrg/* [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 */ 2335324fb0dSmrg#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0') 2345324fb0dSmrg 2355324fb0dSmrg/* [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 2365324fb0dSmrg#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 2375324fb0dSmrg/* [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 2385324fb0dSmrg#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2') 2395324fb0dSmrg 2405324fb0dSmrg/* 2415324fb0dSmrg * 1-plane YUV 4:2:0 2425324fb0dSmrg * In these formats, the component ordering is specified (Y, followed by U 2435324fb0dSmrg * then V), but the exact Linear layout is undefined. 2445324fb0dSmrg * These formats can only be used with a non-Linear modifier. 2455324fb0dSmrg */ 2465324fb0dSmrg#define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8') 2475324fb0dSmrg#define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') 248e88f27b3Smrg 249d8807b2fSmrg/* 250d8807b2fSmrg * 2 plane RGB + A 251d8807b2fSmrg * index 0 = RGB plane, same format as the corresponding non _A8 format has 252d8807b2fSmrg * index 1 = A plane, [7:0] A 253d8807b2fSmrg */ 254d8807b2fSmrg#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') 255d8807b2fSmrg#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') 256d8807b2fSmrg#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') 257d8807b2fSmrg#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') 258d8807b2fSmrg#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') 259d8807b2fSmrg#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') 260d8807b2fSmrg#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') 261d8807b2fSmrg#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') 262d8807b2fSmrg 263e88f27b3Smrg/* 264e88f27b3Smrg * 2 plane YCbCr 265e88f27b3Smrg * index 0 = Y plane, [7:0] Y 266e88f27b3Smrg * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 267e88f27b3Smrg * or 268e88f27b3Smrg * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 269e88f27b3Smrg */ 270e88f27b3Smrg#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 271e88f27b3Smrg#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 272e88f27b3Smrg#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 273e88f27b3Smrg#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 2743f012e29Smrg#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 2753f012e29Smrg#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 27641687f09Smrg/* 27741687f09Smrg * 2 plane YCbCr 27841687f09Smrg * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian 27941687f09Smrg * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian 28041687f09Smrg */ 28141687f09Smrg#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ 282e88f27b3Smrg 2835324fb0dSmrg/* 2845324fb0dSmrg * 2 plane YCbCr MSB aligned 2855324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 2865324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 2875324fb0dSmrg */ 2885324fb0dSmrg#define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */ 2895324fb0dSmrg 2905324fb0dSmrg/* 2915324fb0dSmrg * 2 plane YCbCr MSB aligned 2925324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 2935324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 2945324fb0dSmrg */ 2955324fb0dSmrg#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */ 2965324fb0dSmrg 2975324fb0dSmrg/* 2985324fb0dSmrg * 2 plane YCbCr MSB aligned 2995324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [12:4] little endian 3005324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian 3015324fb0dSmrg */ 3025324fb0dSmrg#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */ 3035324fb0dSmrg 3045324fb0dSmrg/* 3055324fb0dSmrg * 2 plane YCbCr MSB aligned 3065324fb0dSmrg * index 0 = Y plane, [15:0] Y little endian 3075324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian 3085324fb0dSmrg */ 3095324fb0dSmrg#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ 3105324fb0dSmrg 31141687f09Smrg/* 3 plane non-subsampled (444) YCbCr 31241687f09Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 31341687f09Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 31441687f09Smrg * index 1: Cb plane, [15:0] Cb:x [10:6] little endian 31541687f09Smrg * index 2: Cr plane, [15:0] Cr:x [10:6] little endian 31641687f09Smrg */ 31741687f09Smrg#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') 31841687f09Smrg 31941687f09Smrg/* 3 plane non-subsampled (444) YCrCb 32041687f09Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 32141687f09Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 32241687f09Smrg * index 1: Cr plane, [15:0] Cr:x [10:6] little endian 32341687f09Smrg * index 2: Cb plane, [15:0] Cb:x [10:6] little endian 32441687f09Smrg */ 32541687f09Smrg#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') 32641687f09Smrg 327e88f27b3Smrg/* 328e88f27b3Smrg * 3 plane YCbCr 329e88f27b3Smrg * index 0: Y plane, [7:0] Y 330e88f27b3Smrg * index 1: Cb plane, [7:0] Cb 331e88f27b3Smrg * index 2: Cr plane, [7:0] Cr 332e88f27b3Smrg * or 333e88f27b3Smrg * index 1: Cr plane, [7:0] Cr 334e88f27b3Smrg * index 2: Cb plane, [7:0] Cb 335e88f27b3Smrg */ 336e88f27b3Smrg#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 337e88f27b3Smrg#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 338e88f27b3Smrg#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 339e88f27b3Smrg#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 340e88f27b3Smrg#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 341e88f27b3Smrg#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 342e88f27b3Smrg#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 343e88f27b3Smrg#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 344e88f27b3Smrg#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 345e88f27b3Smrg#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 346e88f27b3Smrg 3473f012e29Smrg 3483f012e29Smrg/* 3493f012e29Smrg * Format Modifiers: 3503f012e29Smrg * 3513f012e29Smrg * Format modifiers describe, typically, a re-ordering or modification 3523f012e29Smrg * of the data in a plane of an FB. This can be used to express tiled/ 3533f012e29Smrg * swizzled formats, or compression, or a combination of the two. 3543f012e29Smrg * 3553f012e29Smrg * The upper 8 bits of the format modifier are a vendor-id as assigned 3563f012e29Smrg * below. The lower 56 bits are assigned as vendor sees fit. 3573f012e29Smrg */ 3583f012e29Smrg 3593f012e29Smrg/* Vendor Ids: */ 360d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_NONE 0 3613f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 3623f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 36300a23bdaSmrg#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03 3643f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 3653f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 366d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 367d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 3687cdc0497Smrg#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 3695324fb0dSmrg#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 37041687f09Smrg#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a 3715324fb0dSmrg 3723f012e29Smrg/* add more to the end as needed */ 3733f012e29Smrg 374d8807b2fSmrg#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) 375d8807b2fSmrg 3763f012e29Smrg#define fourcc_mod_code(vendor, val) \ 37700a23bdaSmrg ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 3783f012e29Smrg 3793f012e29Smrg/* 3803f012e29Smrg * Format Modifier tokens: 3813f012e29Smrg * 3823f012e29Smrg * When adding a new token please document the layout with a code comment, 3833f012e29Smrg * similar to the fourcc codes above. drm_fourcc.h is considered the 3843f012e29Smrg * authoritative source for all of these. 38541687f09Smrg * 38641687f09Smrg * Generic modifier names: 38741687f09Smrg * 38841687f09Smrg * DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral names 38941687f09Smrg * for layouts which are common across multiple vendors. To preserve 39041687f09Smrg * compatibility, in cases where a vendor-specific definition already exists and 39141687f09Smrg * a generic name for it is desired, the common name is a purely symbolic alias 39241687f09Smrg * and must use the same numerical value as the original definition. 39341687f09Smrg * 39441687f09Smrg * Note that generic names should only be used for modifiers which describe 39541687f09Smrg * generic layouts (such as pixel re-ordering), which may have 39641687f09Smrg * independently-developed support across multiple vendors. 39741687f09Smrg * 39841687f09Smrg * In future cases where a generic layout is identified before merging with a 39941687f09Smrg * vendor-specific modifier, a new 'GENERIC' vendor or modifier using vendor 40041687f09Smrg * 'NONE' could be considered. This should only be for obvious, exceptional 40141687f09Smrg * cases to avoid polluting the 'GENERIC' namespace with modifiers which only 40241687f09Smrg * apply to a single vendor. 40341687f09Smrg * 40441687f09Smrg * Generic names should not be used for cases where multiple hardware vendors 40541687f09Smrg * have implementations of the same standardised compression scheme (such as 40641687f09Smrg * AFBC). In those cases, all implementations should use the same format 40741687f09Smrg * modifier(s), reflecting the vendor of the standard. 4083f012e29Smrg */ 4093f012e29Smrg 41041687f09Smrg#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE 41141687f09Smrg 412d8807b2fSmrg/* 413d8807b2fSmrg * Invalid Modifier 414d8807b2fSmrg * 415d8807b2fSmrg * This modifier can be used as a sentinel to terminate the format modifiers 416d8807b2fSmrg * list, or to initialize a variable with an invalid modifier. It might also be 417d8807b2fSmrg * used to report an error back to userspace for certain APIs. 418d8807b2fSmrg */ 419d8807b2fSmrg#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) 420d8807b2fSmrg 421d8807b2fSmrg/* 422d8807b2fSmrg * Linear Layout 423d8807b2fSmrg * 424d8807b2fSmrg * Just plain linear layout. Note that this is different from no specifying any 425d8807b2fSmrg * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), 426d8807b2fSmrg * which tells the driver to also take driver-internal information into account 427d8807b2fSmrg * and so might actually result in a tiled framebuffer. 428d8807b2fSmrg */ 429d8807b2fSmrg#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) 430d8807b2fSmrg 43141687f09Smrg/* 43241687f09Smrg * Deprecated: use DRM_FORMAT_MOD_LINEAR instead 43341687f09Smrg * 43441687f09Smrg * The "none" format modifier doesn't actually mean that the modifier is 43541687f09Smrg * implicit, instead it means that the layout is linear. Whether modifiers are 43641687f09Smrg * used is out-of-band information carried in an API-specific way (e.g. in a 43741687f09Smrg * flag for drm_mode_fb_cmd2). 43841687f09Smrg */ 43941687f09Smrg#define DRM_FORMAT_MOD_NONE 0 44041687f09Smrg 4413f012e29Smrg/* Intel framebuffer modifiers */ 4423f012e29Smrg 4433f012e29Smrg/* 4443f012e29Smrg * Intel X-tiling layout 4453f012e29Smrg * 4463f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 4473f012e29Smrg * in row-major layout. Within the tile bytes are laid out row-major, with 4483f012e29Smrg * a platform-dependent stride. On top of that the memory can apply 4493f012e29Smrg * platform-depending swizzling of some higher address bits into bit6. 4503f012e29Smrg * 45141687f09Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 45241687f09Smrg * On earlier platforms the is highly platforms specific and not useful for 45341687f09Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 45441687f09Smrg * identify the layout in a simple way for i915-specific userspace, which 45541687f09Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 45641687f09Smrg * format on some really old platforms is not known. 4573f012e29Smrg */ 4583f012e29Smrg#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 4593f012e29Smrg 4603f012e29Smrg/* 4613f012e29Smrg * Intel Y-tiling layout 4623f012e29Smrg * 4633f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 4643f012e29Smrg * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 4653f012e29Smrg * chunks column-major, with a platform-dependent height. On top of that the 4663f012e29Smrg * memory can apply platform-depending swizzling of some higher address bits 4673f012e29Smrg * into bit6. 4683f012e29Smrg * 46941687f09Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 47041687f09Smrg * On earlier platforms the is highly platforms specific and not useful for 47141687f09Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 47241687f09Smrg * identify the layout in a simple way for i915-specific userspace, which 47341687f09Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 47441687f09Smrg * format on some really old platforms is not known. 4753f012e29Smrg */ 4763f012e29Smrg#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 4773f012e29Smrg 4783f012e29Smrg/* 4793f012e29Smrg * Intel Yf-tiling layout 4803f012e29Smrg * 4813f012e29Smrg * This is a tiled layout using 4Kb tiles in row-major layout. 4823f012e29Smrg * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 4833f012e29Smrg * are arranged in four groups (two wide, two high) with column-major layout. 48449ef06a4Smrg * Each group therefore consits out of four 256 byte units, which are also laid 4853f012e29Smrg * out as 2x2 column-major. 4863f012e29Smrg * 256 byte units are made out of four 64 byte blocks of pixels, producing 4873f012e29Smrg * either a square block or a 2:1 unit. 4883f012e29Smrg * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 4893f012e29Smrg * in pixel depends on the pixel depth. 4903f012e29Smrg */ 4913f012e29Smrg#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 4923f012e29Smrg 493d8807b2fSmrg/* 494d8807b2fSmrg * Intel color control surface (CCS) for render compression 495d8807b2fSmrg * 496d8807b2fSmrg * The framebuffer format must be one of the 8:8:8:8 RGB formats. 497d8807b2fSmrg * The main surface will be plane index 0 and must be Y/Yf-tiled, 498d8807b2fSmrg * the CCS will be plane index 1. 499d8807b2fSmrg * 500d8807b2fSmrg * Each CCS tile matches a 1024x512 pixel area of the main surface. 501d8807b2fSmrg * To match certain aspects of the 3D hardware the CCS is 502d8807b2fSmrg * considered to be made up of normal 128Bx32 Y tiles, Thus 503d8807b2fSmrg * the CCS pitch must be specified in multiples of 128 bytes. 504d8807b2fSmrg * 505d8807b2fSmrg * In reality the CCS tile appears to be a 64Bx64 Y tile, composed 506d8807b2fSmrg * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. 507d8807b2fSmrg * But that fact is not relevant unless the memory is accessed 508d8807b2fSmrg * directly. 509d8807b2fSmrg */ 510d8807b2fSmrg#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) 511d8807b2fSmrg#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) 512d8807b2fSmrg 51341687f09Smrg/* 51441687f09Smrg * Intel color control surfaces (CCS) for Gen-12 render compression. 51541687f09Smrg * 51641687f09Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 51741687f09Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 51841687f09Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 51941687f09Smrg * line pair. The main surface pitch is required to be a multiple of four 52041687f09Smrg * Y-tile widths. 52141687f09Smrg */ 52241687f09Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6) 52341687f09Smrg 52441687f09Smrg/* 52541687f09Smrg * Intel color control surfaces (CCS) for Gen-12 media compression 52641687f09Smrg * 52741687f09Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 52841687f09Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 52941687f09Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 53041687f09Smrg * line pair. The main surface pitch is required to be a multiple of four 53141687f09Smrg * Y-tile widths. For semi-planar formats like NV12, CCS planes follow the 53241687f09Smrg * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 53341687f09Smrg * planes 2 and 3 for the respective CCS. 53441687f09Smrg */ 53541687f09Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7) 53641687f09Smrg 53749ef06a4Smrg/* 53849ef06a4Smrg * Intel Color Control Surface with Clear Color (CCS) for Gen-12 render 53949ef06a4Smrg * compression. 54049ef06a4Smrg * 54149ef06a4Smrg * The main surface is Y-tiled and is at plane index 0 whereas CCS is linear 54249ef06a4Smrg * and at index 1. The clear color is stored at index 2, and the pitch should 54349ef06a4Smrg * be ignored. The clear color structure is 256 bits. The first 128 bits 54449ef06a4Smrg * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 54549ef06a4Smrg * by 32 bits. The raw clear color is consumed by the 3d engine and generates 54649ef06a4Smrg * the converted clear color of size 64 bits. The first 32 bits store the Lower 54749ef06a4Smrg * Converted Clear Color value and the next 32 bits store the Higher Converted 54849ef06a4Smrg * Clear Color value when applicable. The Converted Clear Color values are 54949ef06a4Smrg * consumed by the DE. The last 64 bits are used to store Color Discard Enable 55049ef06a4Smrg * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 55149ef06a4Smrg * corresponds to an area of 4x1 tiles in the main surface. The main surface 55249ef06a4Smrg * pitch is required to be a multiple of 4 tile widths. 55349ef06a4Smrg */ 55449ef06a4Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8) 55549ef06a4Smrg 5563f012e29Smrg/* 5573f012e29Smrg * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 5583f012e29Smrg * 5593f012e29Smrg * Macroblocks are laid in a Z-shape, and each pixel data is following the 5603f012e29Smrg * standard NV12 style. 5613f012e29Smrg * As for NV12, an image is the result of two frame buffers: one for Y, 5623f012e29Smrg * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 5633f012e29Smrg * Alignment requirements are (for each buffer): 5643f012e29Smrg * - multiple of 128 pixels for the width 5653f012e29Smrg * - multiple of 32 pixels for the height 5663f012e29Smrg * 5673f012e29Smrg * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 5683f012e29Smrg */ 5693f012e29Smrg#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 5703f012e29Smrg 5715324fb0dSmrg/* 5725324fb0dSmrg * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks 5735324fb0dSmrg * 5745324fb0dSmrg * This is a simple tiled layout using tiles of 16x16 pixels in a row-major 5755324fb0dSmrg * layout. For YCbCr formats Cb/Cr components are taken in such a way that 5765324fb0dSmrg * they correspond to their 16x16 luma block. 5775324fb0dSmrg */ 5785324fb0dSmrg#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) 5795324fb0dSmrg 5807cdc0497Smrg/* 5817cdc0497Smrg * Qualcomm Compressed Format 5827cdc0497Smrg * 5837cdc0497Smrg * Refers to a compressed variant of the base format that is compressed. 5847cdc0497Smrg * Implementation may be platform and base-format specific. 5857cdc0497Smrg * 5867cdc0497Smrg * Each macrotile consists of m x n (mostly 4 x 4) tiles. 5877cdc0497Smrg * Pixel data pitch/stride is aligned with macrotile width. 5887cdc0497Smrg * Pixel data height is aligned with macrotile height. 5897cdc0497Smrg * Entire pixel data buffer is aligned with 4k(bytes). 5907cdc0497Smrg */ 5917cdc0497Smrg#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) 5927cdc0497Smrg 593d8807b2fSmrg/* Vivante framebuffer modifiers */ 594d8807b2fSmrg 595d8807b2fSmrg/* 596d8807b2fSmrg * Vivante 4x4 tiling layout 597d8807b2fSmrg * 598d8807b2fSmrg * This is a simple tiled layout using tiles of 4x4 pixels in a row-major 599d8807b2fSmrg * layout. 600d8807b2fSmrg */ 601d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) 602d8807b2fSmrg 603d8807b2fSmrg/* 604d8807b2fSmrg * Vivante 64x64 super-tiling layout 605d8807b2fSmrg * 606d8807b2fSmrg * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile 607d8807b2fSmrg * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- 608d8807b2fSmrg * major layout. 609d8807b2fSmrg * 610d8807b2fSmrg * For more information: see 611d8807b2fSmrg * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling 612d8807b2fSmrg */ 613d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) 614d8807b2fSmrg 615d8807b2fSmrg/* 616d8807b2fSmrg * Vivante 4x4 tiling layout for dual-pipe 617d8807b2fSmrg * 618d8807b2fSmrg * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a 619d8807b2fSmrg * different base address. Offsets from the base addresses are therefore halved 620d8807b2fSmrg * compared to the non-split tiled layout. 621d8807b2fSmrg */ 622d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) 623d8807b2fSmrg 624d8807b2fSmrg/* 625d8807b2fSmrg * Vivante 64x64 super-tiling layout for dual-pipe 626d8807b2fSmrg * 627d8807b2fSmrg * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile 628d8807b2fSmrg * starts at a different base address. Offsets from the base addresses are 629d8807b2fSmrg * therefore halved compared to the non-split super-tiled layout. 630d8807b2fSmrg */ 631d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) 632d8807b2fSmrg 63300a23bdaSmrg/* NVIDIA frame buffer modifiers */ 634d8807b2fSmrg 635d8807b2fSmrg/* 636d8807b2fSmrg * Tegra Tiled Layout, used by Tegra 2, 3 and 4. 637d8807b2fSmrg * 638d8807b2fSmrg * Pixels are arranged in simple tiles of 16 x 16 bytes. 639d8807b2fSmrg */ 64000a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1) 641d8807b2fSmrg 642d8807b2fSmrg/* 64341687f09Smrg * Generalized Block Linear layout, used by desktop GPUs starting with NV50/G80, 64441687f09Smrg * and Tegra GPUs starting with Tegra K1. 64541687f09Smrg * 64641687f09Smrg * Pixels are arranged in Groups of Bytes (GOBs). GOB size and layout varies 64741687f09Smrg * based on the architecture generation. GOBs themselves are then arranged in 64841687f09Smrg * 3D blocks, with the block dimensions (in terms of GOBs) always being a power 64941687f09Smrg * of two, and hence expressible as their log2 equivalent (E.g., "2" represents 65041687f09Smrg * a block depth or height of "4"). 65141687f09Smrg * 65241687f09Smrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 65341687f09Smrg * in full detail. 65441687f09Smrg * 65541687f09Smrg * Macro 65641687f09Smrg * Bits Param Description 65741687f09Smrg * ---- ----- ----------------------------------------------------------------- 65841687f09Smrg * 65941687f09Smrg * 3:0 h log2(height) of each block, in GOBs. Placed here for 66041687f09Smrg * compatibility with the existing 66141687f09Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 66241687f09Smrg * 66341687f09Smrg * 4:4 - Must be 1, to indicate block-linear layout. Necessary for 66441687f09Smrg * compatibility with the existing 66541687f09Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 66641687f09Smrg * 66741687f09Smrg * 8:5 - Reserved (To support 3D-surfaces with variable log2(depth) block 66841687f09Smrg * size). Must be zero. 66941687f09Smrg * 67041687f09Smrg * Note there is no log2(width) parameter. Some portions of the 67141687f09Smrg * hardware support a block width of two gobs, but it is impractical 67241687f09Smrg * to use due to lack of support elsewhere, and has no known 67341687f09Smrg * benefits. 67441687f09Smrg * 67541687f09Smrg * 11:9 - Reserved (To support 2D-array textures with variable array stride 67641687f09Smrg * in blocks, specified via log2(tile width in blocks)). Must be 67741687f09Smrg * zero. 67841687f09Smrg * 67941687f09Smrg * 19:12 k Page Kind. This value directly maps to a field in the page 68041687f09Smrg * tables of all GPUs >= NV50. It affects the exact layout of bits 68141687f09Smrg * in memory and can be derived from the tuple 68241687f09Smrg * 68341687f09Smrg * (format, GPU model, compression type, samples per pixel) 68441687f09Smrg * 68541687f09Smrg * Where compression type is defined below. If GPU model were 68641687f09Smrg * implied by the format modifier, format, or memory buffer, page 68741687f09Smrg * kind would not need to be included in the modifier itself, but 68841687f09Smrg * since the modifier should define the layout of the associated 68941687f09Smrg * memory buffer independent from any device or other context, it 69041687f09Smrg * must be included here. 69141687f09Smrg * 69241687f09Smrg * 21:20 g GOB Height and Page Kind Generation. The height of a GOB changed 69341687f09Smrg * starting with Fermi GPUs. Additionally, the mapping between page 69441687f09Smrg * kind and bit layout has changed at various points. 69541687f09Smrg * 69641687f09Smrg * 0 = Gob Height 8, Fermi - Volta, Tegra K1+ Page Kind mapping 69741687f09Smrg * 1 = Gob Height 4, G80 - GT2XX Page Kind mapping 69841687f09Smrg * 2 = Gob Height 8, Turing+ Page Kind mapping 69941687f09Smrg * 3 = Reserved for future use. 70041687f09Smrg * 70141687f09Smrg * 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further 70241687f09Smrg * bit remapping step that occurs at an even lower level than the 70341687f09Smrg * page kind and block linear swizzles. This causes the layout of 70441687f09Smrg * surfaces mapped in those SOC's GPUs to be incompatible with the 70541687f09Smrg * equivalent mapping on other GPUs in the same system. 70641687f09Smrg * 70741687f09Smrg * 0 = Tegra K1 - Tegra Parker/TX2 Layout. 70841687f09Smrg * 1 = Desktop GPU and Tegra Xavier+ Layout 70941687f09Smrg * 71041687f09Smrg * 25:23 c Lossless Framebuffer Compression type. 71141687f09Smrg * 71241687f09Smrg * 0 = none 71341687f09Smrg * 1 = ROP/3D, layout 1, exact compression format implied by Page 71441687f09Smrg * Kind field 71541687f09Smrg * 2 = ROP/3D, layout 2, exact compression format implied by Page 71641687f09Smrg * Kind field 71741687f09Smrg * 3 = CDE horizontal 71841687f09Smrg * 4 = CDE vertical 71941687f09Smrg * 5 = Reserved for future use 72041687f09Smrg * 6 = Reserved for future use 72141687f09Smrg * 7 = Reserved for future use 72241687f09Smrg * 72341687f09Smrg * 55:25 - Reserved for future use. Must be zero. 72441687f09Smrg */ 72541687f09Smrg#define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(c, s, g, k, h) \ 72641687f09Smrg fourcc_mod_code(NVIDIA, (0x10 | \ 72741687f09Smrg ((h) & 0xf) | \ 72841687f09Smrg (((k) & 0xff) << 12) | \ 72941687f09Smrg (((g) & 0x3) << 20) | \ 73041687f09Smrg (((s) & 0x1) << 22) | \ 73141687f09Smrg (((c) & 0x7) << 23))) 73241687f09Smrg 73341687f09Smrg/* To grandfather in prior block linear format modifiers to the above layout, 73441687f09Smrg * the page kind "0", which corresponds to "pitch/linear" and hence is unusable 73541687f09Smrg * with block-linear layouts, is remapped within drivers to the value 0xfe, 73641687f09Smrg * which corresponds to the "generic" kind used for simple single-sample 73741687f09Smrg * uncompressed color formats on Fermi - Volta GPUs. 73841687f09Smrg */ 73941687f09Smrgstatic __inline__ __u64 74041687f09Smrgdrm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) 74141687f09Smrg{ 74241687f09Smrg if (!(modifier & 0x10) || (modifier & (0xff << 12))) 74341687f09Smrg return modifier; 74441687f09Smrg else 74541687f09Smrg return modifier | (0xfe << 12); 74641687f09Smrg} 74741687f09Smrg 74841687f09Smrg/* 74941687f09Smrg * 16Bx2 Block Linear layout, used by Tegra K1 and later 750d8807b2fSmrg * 751d8807b2fSmrg * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked 752d8807b2fSmrg * vertically by a power of 2 (1 to 32 GOBs) to form a block. 753d8807b2fSmrg * 754d8807b2fSmrg * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. 755d8807b2fSmrg * 756d8807b2fSmrg * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. 757d8807b2fSmrg * Valid values are: 758d8807b2fSmrg * 759d8807b2fSmrg * 0 == ONE_GOB 760d8807b2fSmrg * 1 == TWO_GOBS 761d8807b2fSmrg * 2 == FOUR_GOBS 762d8807b2fSmrg * 3 == EIGHT_GOBS 763d8807b2fSmrg * 4 == SIXTEEN_GOBS 764d8807b2fSmrg * 5 == THIRTYTWO_GOBS 765d8807b2fSmrg * 766d8807b2fSmrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 767d8807b2fSmrg * in full detail. 768d8807b2fSmrg */ 76900a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \ 77041687f09Smrg DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0, (v)) 77100a23bdaSmrg 77200a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \ 77341687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0) 77400a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \ 77541687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1) 77600a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \ 77741687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2) 77800a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \ 77941687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3) 78000a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \ 78141687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4) 78200a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \ 78341687f09Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5) 784d8807b2fSmrg 7857cdc0497Smrg/* 7867cdc0497Smrg * Some Broadcom modifiers take parameters, for example the number of 7877cdc0497Smrg * vertical lines in the image. Reserve the lower 32 bits for modifier 7887cdc0497Smrg * type, and the next 24 bits for parameters. Top 8 bits are the 7897cdc0497Smrg * vendor code. 7907cdc0497Smrg */ 7917cdc0497Smrg#define __fourcc_mod_broadcom_param_shift 8 7927cdc0497Smrg#define __fourcc_mod_broadcom_param_bits 48 7937cdc0497Smrg#define fourcc_mod_broadcom_code(val, params) \ 7947cdc0497Smrg fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) 7957cdc0497Smrg#define fourcc_mod_broadcom_param(m) \ 7967cdc0497Smrg ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ 7977cdc0497Smrg ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) 7987cdc0497Smrg#define fourcc_mod_broadcom_mod(m) \ 7997cdc0497Smrg ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ 8007cdc0497Smrg __fourcc_mod_broadcom_param_shift)) 8017cdc0497Smrg 802d8807b2fSmrg/* 803d8807b2fSmrg * Broadcom VC4 "T" format 804d8807b2fSmrg * 805d8807b2fSmrg * This is the primary layout that the V3D GPU can texture from (it 806d8807b2fSmrg * can't do linear). The T format has: 807d8807b2fSmrg * 808d8807b2fSmrg * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 809d8807b2fSmrg * pixels at 32 bit depth. 810d8807b2fSmrg * 811d8807b2fSmrg * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually 812d8807b2fSmrg * 16x16 pixels). 813d8807b2fSmrg * 814d8807b2fSmrg * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On 815d8807b2fSmrg * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows 816d8807b2fSmrg * they're (TR, BR, BL, TL), where bottom left is start of memory. 817d8807b2fSmrg * 818d8807b2fSmrg * - an image made of 4k tiles in rows either left-to-right (even rows of 4k 819d8807b2fSmrg * tiles) or right-to-left (odd rows of 4k tiles). 820d8807b2fSmrg */ 821d8807b2fSmrg#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) 822d8807b2fSmrg 8237cdc0497Smrg/* 8247cdc0497Smrg * Broadcom SAND format 8257cdc0497Smrg * 8267cdc0497Smrg * This is the native format that the H.264 codec block uses. For VC4 8277cdc0497Smrg * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. 8287cdc0497Smrg * 8297cdc0497Smrg * The image can be considered to be split into columns, and the 8307cdc0497Smrg * columns are placed consecutively into memory. The width of those 8317cdc0497Smrg * columns can be either 32, 64, 128, or 256 pixels, but in practice 8327cdc0497Smrg * only 128 pixel columns are used. 8337cdc0497Smrg * 8347cdc0497Smrg * The pitch between the start of each column is set to optimally 8357cdc0497Smrg * switch between SDRAM banks. This is passed as the number of lines 8367cdc0497Smrg * of column width in the modifier (we can't use the stride value due 8377cdc0497Smrg * to various core checks that look at it , so you should set the 8387cdc0497Smrg * stride to width*cpp). 8397cdc0497Smrg * 8407cdc0497Smrg * Note that the column height for this format modifier is the same 8417cdc0497Smrg * for all of the planes, assuming that each column contains both Y 8427cdc0497Smrg * and UV. Some SAND-using hardware stores UV in a separate tiled 8437cdc0497Smrg * image from Y to reduce the column height, which is not supported 8447cdc0497Smrg * with these modifiers. 8457cdc0497Smrg */ 8467cdc0497Smrg 8477cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ 8487cdc0497Smrg fourcc_mod_broadcom_code(2, v) 8497cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ 8507cdc0497Smrg fourcc_mod_broadcom_code(3, v) 8517cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ 8527cdc0497Smrg fourcc_mod_broadcom_code(4, v) 8537cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ 8547cdc0497Smrg fourcc_mod_broadcom_code(5, v) 8557cdc0497Smrg 8567cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ 8577cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) 8587cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ 8597cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) 8607cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ 8617cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) 8627cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ 8637cdc0497Smrg DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) 8647cdc0497Smrg 8657cdc0497Smrg/* Broadcom UIF format 8667cdc0497Smrg * 8677cdc0497Smrg * This is the common format for the current Broadcom multimedia 8687cdc0497Smrg * blocks, including V3D 3.x and newer, newer video codecs, and 8697cdc0497Smrg * displays. 8707cdc0497Smrg * 8717cdc0497Smrg * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), 8727cdc0497Smrg * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are 8737cdc0497Smrg * stored in columns, with padding between the columns to ensure that 8747cdc0497Smrg * moving from one column to the next doesn't hit the same SDRAM page 8757cdc0497Smrg * bank. 8767cdc0497Smrg * 8777cdc0497Smrg * To calculate the padding, it is assumed that each hardware block 8787cdc0497Smrg * and the software driving it knows the platform's SDRAM page size, 8797cdc0497Smrg * number of banks, and XOR address, and that it's identical between 8807cdc0497Smrg * all blocks using the format. This tiling modifier will use XOR as 8817cdc0497Smrg * necessary to reduce the padding. If a hardware block can't do XOR, 8827cdc0497Smrg * the assumption is that a no-XOR tiling modifier will be created. 8837cdc0497Smrg */ 8847cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) 8857cdc0497Smrg 8867cdc0497Smrg/* 8877cdc0497Smrg * Arm Framebuffer Compression (AFBC) modifiers 8887cdc0497Smrg * 8897cdc0497Smrg * AFBC is a proprietary lossless image compression protocol and format. 8907cdc0497Smrg * It provides fine-grained random access and minimizes the amount of data 8917cdc0497Smrg * transferred between IP blocks. 8927cdc0497Smrg * 8937cdc0497Smrg * AFBC has several features which may be supported and/or used, which are 8947cdc0497Smrg * represented using bits in the modifier. Not all combinations are valid, 8957cdc0497Smrg * and different devices or use-cases may support different combinations. 8965324fb0dSmrg * 8975324fb0dSmrg * Further information on the use of AFBC modifiers can be found in 8985324fb0dSmrg * Documentation/gpu/afbc.rst 8997cdc0497Smrg */ 90041687f09Smrg 90141687f09Smrg/* 90241687f09Smrg * The top 4 bits (out of the 56 bits alloted for specifying vendor specific 90349ef06a4Smrg * modifiers) denote the category for modifiers. Currently we have three 90449ef06a4Smrg * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of 90549ef06a4Smrg * sixteen different categories. 90641687f09Smrg */ 90741687f09Smrg#define DRM_FORMAT_MOD_ARM_CODE(__type, __val) \ 90841687f09Smrg fourcc_mod_code(ARM, ((__u64)(__type) << 52) | ((__val) & 0x000fffffffffffffULL)) 90941687f09Smrg 91041687f09Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFBC 0x00 91141687f09Smrg#define DRM_FORMAT_MOD_ARM_TYPE_MISC 0x01 91241687f09Smrg 91341687f09Smrg#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) \ 91441687f09Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFBC, __afbc_mode) 9157cdc0497Smrg 9167cdc0497Smrg/* 9177cdc0497Smrg * AFBC superblock size 9187cdc0497Smrg * 9197cdc0497Smrg * Indicates the superblock size(s) used for the AFBC buffer. The buffer 9207cdc0497Smrg * size (in pixels) must be aligned to a multiple of the superblock size. 9217cdc0497Smrg * Four lowest significant bits(LSBs) are reserved for block size. 9225324fb0dSmrg * 9235324fb0dSmrg * Where one superblock size is specified, it applies to all planes of the 9245324fb0dSmrg * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified, 9255324fb0dSmrg * the first applies to the Luma plane and the second applies to the Chroma 9265324fb0dSmrg * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma). 9275324fb0dSmrg * Multiple superblock sizes are only valid for multi-plane YCbCr formats. 9287cdc0497Smrg */ 9297cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf 9307cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) 9317cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) 9325324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 (3ULL) 9335324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL) 9347cdc0497Smrg 9357cdc0497Smrg/* 9367cdc0497Smrg * AFBC lossless colorspace transform 9377cdc0497Smrg * 9387cdc0497Smrg * Indicates that the buffer makes use of the AFBC lossless colorspace 9397cdc0497Smrg * transform. 9407cdc0497Smrg */ 9417cdc0497Smrg#define AFBC_FORMAT_MOD_YTR (1ULL << 4) 9427cdc0497Smrg 9437cdc0497Smrg/* 9447cdc0497Smrg * AFBC block-split 9457cdc0497Smrg * 9467cdc0497Smrg * Indicates that the payload of each superblock is split. The second 9477cdc0497Smrg * half of the payload is positioned at a predefined offset from the start 9487cdc0497Smrg * of the superblock payload. 9497cdc0497Smrg */ 9507cdc0497Smrg#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) 9517cdc0497Smrg 9527cdc0497Smrg/* 9537cdc0497Smrg * AFBC sparse layout 9547cdc0497Smrg * 9557cdc0497Smrg * This flag indicates that the payload of each superblock must be stored at a 9567cdc0497Smrg * predefined position relative to the other superblocks in the same AFBC 9577cdc0497Smrg * buffer. This order is the same order used by the header buffer. In this mode 9587cdc0497Smrg * each superblock is given the same amount of space as an uncompressed 9597cdc0497Smrg * superblock of the particular format would require, rounding up to the next 9607cdc0497Smrg * multiple of 128 bytes in size. 9617cdc0497Smrg */ 9627cdc0497Smrg#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) 9637cdc0497Smrg 9647cdc0497Smrg/* 9657cdc0497Smrg * AFBC copy-block restrict 9667cdc0497Smrg * 9677cdc0497Smrg * Buffers with this flag must obey the copy-block restriction. The restriction 9687cdc0497Smrg * is such that there are no copy-blocks referring across the border of 8x8 9697cdc0497Smrg * blocks. For the subsampled data the 8x8 limitation is also subsampled. 9707cdc0497Smrg */ 9717cdc0497Smrg#define AFBC_FORMAT_MOD_CBR (1ULL << 7) 9727cdc0497Smrg 9737cdc0497Smrg/* 9747cdc0497Smrg * AFBC tiled layout 9757cdc0497Smrg * 9767cdc0497Smrg * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all 9777cdc0497Smrg * superblocks inside a tile are stored together in memory. 8x8 tiles are used 9787cdc0497Smrg * for pixel formats up to and including 32 bpp while 4x4 tiles are used for 9797cdc0497Smrg * larger bpp formats. The order between the tiles is scan line. 9807cdc0497Smrg * When the tiled layout is used, the buffer size (in pixels) must be aligned 9817cdc0497Smrg * to the tile size. 9827cdc0497Smrg */ 9837cdc0497Smrg#define AFBC_FORMAT_MOD_TILED (1ULL << 8) 9847cdc0497Smrg 9857cdc0497Smrg/* 9867cdc0497Smrg * AFBC solid color blocks 9877cdc0497Smrg * 9887cdc0497Smrg * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth 9897cdc0497Smrg * can be reduced if a whole superblock is a single color. 9907cdc0497Smrg */ 9917cdc0497Smrg#define AFBC_FORMAT_MOD_SC (1ULL << 9) 9927cdc0497Smrg 9935324fb0dSmrg/* 9945324fb0dSmrg * AFBC double-buffer 9955324fb0dSmrg * 9965324fb0dSmrg * Indicates that the buffer is allocated in a layout safe for front-buffer 9975324fb0dSmrg * rendering. 9985324fb0dSmrg */ 9995324fb0dSmrg#define AFBC_FORMAT_MOD_DB (1ULL << 10) 10005324fb0dSmrg 10015324fb0dSmrg/* 10025324fb0dSmrg * AFBC buffer content hints 10035324fb0dSmrg * 10045324fb0dSmrg * Indicates that the buffer includes per-superblock content hints. 10055324fb0dSmrg */ 10065324fb0dSmrg#define AFBC_FORMAT_MOD_BCH (1ULL << 11) 10075324fb0dSmrg 100841687f09Smrg/* AFBC uncompressed storage mode 100941687f09Smrg * 101041687f09Smrg * Indicates that the buffer is using AFBC uncompressed storage mode. 101141687f09Smrg * In this mode all superblock payloads in the buffer use the uncompressed 101241687f09Smrg * storage mode, which is usually only used for data which cannot be compressed. 101341687f09Smrg * The buffer layout is the same as for AFBC buffers without USM set, this only 101441687f09Smrg * affects the storage mode of the individual superblocks. Note that even a 101541687f09Smrg * buffer without USM set may use uncompressed storage mode for some or all 101641687f09Smrg * superblocks, USM just guarantees it for all. 101741687f09Smrg */ 101841687f09Smrg#define AFBC_FORMAT_MOD_USM (1ULL << 12) 101941687f09Smrg 102049ef06a4Smrg/* 102149ef06a4Smrg * Arm Fixed-Rate Compression (AFRC) modifiers 102249ef06a4Smrg * 102349ef06a4Smrg * AFRC is a proprietary fixed rate image compression protocol and format, 102449ef06a4Smrg * designed to provide guaranteed bandwidth and memory footprint 102549ef06a4Smrg * reductions in graphics and media use-cases. 102649ef06a4Smrg * 102749ef06a4Smrg * AFRC buffers consist of one or more planes, with the same components 102849ef06a4Smrg * and meaning as an uncompressed buffer using the same pixel format. 102949ef06a4Smrg * 103049ef06a4Smrg * Within each plane, the pixel/luma/chroma values are grouped into 103149ef06a4Smrg * "coding unit" blocks which are individually compressed to a 103249ef06a4Smrg * fixed size (in bytes). All coding units within a given plane of a buffer 103349ef06a4Smrg * store the same number of values, and have the same compressed size. 103449ef06a4Smrg * 103549ef06a4Smrg * The coding unit size is configurable, allowing different rates of compression. 103649ef06a4Smrg * 103749ef06a4Smrg * The start of each AFRC buffer plane must be aligned to an alignment granule which 103849ef06a4Smrg * depends on the coding unit size. 103949ef06a4Smrg * 104049ef06a4Smrg * Coding Unit Size Plane Alignment 104149ef06a4Smrg * ---------------- --------------- 104249ef06a4Smrg * 16 bytes 1024 bytes 104349ef06a4Smrg * 24 bytes 512 bytes 104449ef06a4Smrg * 32 bytes 2048 bytes 104549ef06a4Smrg * 104649ef06a4Smrg * Coding units are grouped into paging tiles. AFRC buffer dimensions must be aligned 104749ef06a4Smrg * to a multiple of the paging tile dimensions. 104849ef06a4Smrg * The dimensions of each paging tile depend on whether the buffer is optimised for 104949ef06a4Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 105049ef06a4Smrg * 105149ef06a4Smrg * Layout Paging Tile Width Paging Tile Height 105249ef06a4Smrg * ------ ----------------- ------------------ 105349ef06a4Smrg * SCAN 16 coding units 4 coding units 105449ef06a4Smrg * ROT 8 coding units 8 coding units 105549ef06a4Smrg * 105649ef06a4Smrg * The dimensions of each coding unit depend on the number of components 105749ef06a4Smrg * in the compressed plane and whether the buffer is optimised for 105849ef06a4Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 105949ef06a4Smrg * 106049ef06a4Smrg * Number of Components in Plane Layout Coding Unit Width Coding Unit Height 106149ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 106249ef06a4Smrg * 1 SCAN 16 samples 4 samples 106349ef06a4Smrg * Example: 16x4 luma samples in a 'Y' plane 106449ef06a4Smrg * 16x4 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 106549ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 106649ef06a4Smrg * 1 ROT 8 samples 8 samples 106749ef06a4Smrg * Example: 8x8 luma samples in a 'Y' plane 106849ef06a4Smrg * 8x8 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 106949ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 107049ef06a4Smrg * 2 DONT CARE 8 samples 4 samples 107149ef06a4Smrg * Example: 8x4 chroma pairs in the 'UV' plane of a semi-planar YUV buffer 107249ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 107349ef06a4Smrg * 3 DONT CARE 4 samples 4 samples 107449ef06a4Smrg * Example: 4x4 pixels in an RGB buffer without alpha 107549ef06a4Smrg * ----------------------------- --------- ----------------- ------------------ 107649ef06a4Smrg * 4 DONT CARE 4 samples 4 samples 107749ef06a4Smrg * Example: 4x4 pixels in an RGB buffer with alpha 107849ef06a4Smrg */ 107949ef06a4Smrg 108049ef06a4Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFRC 0x02 108149ef06a4Smrg 108249ef06a4Smrg#define DRM_FORMAT_MOD_ARM_AFRC(__afrc_mode) \ 108349ef06a4Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFRC, __afrc_mode) 108449ef06a4Smrg 108549ef06a4Smrg/* 108649ef06a4Smrg * AFRC coding unit size modifier. 108749ef06a4Smrg * 108849ef06a4Smrg * Indicates the number of bytes used to store each compressed coding unit for 108949ef06a4Smrg * one or more planes in an AFRC encoded buffer. The coding unit size for chrominance 109049ef06a4Smrg * is the same for both Cb and Cr, which may be stored in separate planes. 109149ef06a4Smrg * 109249ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P0 indicates the number of bytes used to store 109349ef06a4Smrg * each compressed coding unit in the first plane of the buffer. For RGBA buffers 109449ef06a4Smrg * this is the only plane, while for semi-planar and fully-planar YUV buffers, 109549ef06a4Smrg * this corresponds to the luma plane. 109649ef06a4Smrg * 109749ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 indicates the number of bytes used to store 109849ef06a4Smrg * each compressed coding unit in the second and third planes in the buffer. 109949ef06a4Smrg * For semi-planar and fully-planar YUV buffers, this corresponds to the chroma plane(s). 110049ef06a4Smrg * 110149ef06a4Smrg * For single-plane buffers, AFRC_FORMAT_MOD_CU_SIZE_P0 must be specified 110249ef06a4Smrg * and AFRC_FORMAT_MOD_CU_SIZE_P12 must be zero. 110349ef06a4Smrg * For semi-planar and fully-planar buffers, both AFRC_FORMAT_MOD_CU_SIZE_P0 and 110449ef06a4Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 must be specified. 110549ef06a4Smrg */ 110649ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_MASK 0xf 110749ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_16 (1ULL) 110849ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_24 (2ULL) 110949ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_32 (3ULL) 111049ef06a4Smrg 111149ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P0(__afrc_cu_size) (__afrc_cu_size) 111249ef06a4Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P12(__afrc_cu_size) ((__afrc_cu_size) << 4) 111349ef06a4Smrg 111449ef06a4Smrg/* 111549ef06a4Smrg * AFRC scanline memory layout. 111649ef06a4Smrg * 111749ef06a4Smrg * Indicates if the buffer uses the scanline-optimised layout 111849ef06a4Smrg * for an AFRC encoded buffer, otherwise, it uses the rotation-optimised layout. 111949ef06a4Smrg * The memory layout is the same for all planes. 112049ef06a4Smrg */ 112149ef06a4Smrg#define AFRC_FORMAT_MOD_LAYOUT_SCAN (1ULL << 8) 112249ef06a4Smrg 112341687f09Smrg/* 112441687f09Smrg * Arm 16x16 Block U-Interleaved modifier 112541687f09Smrg * 112641687f09Smrg * This is used by Arm Mali Utgard and Midgard GPUs. It divides the image 112741687f09Smrg * into 16x16 pixel blocks. Blocks are stored linearly in order, but pixels 112841687f09Smrg * in the block are reordered. 112941687f09Smrg */ 113041687f09Smrg#define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ 113141687f09Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) 113241687f09Smrg 11335324fb0dSmrg/* 11345324fb0dSmrg * Allwinner tiled modifier 11355324fb0dSmrg * 11365324fb0dSmrg * This tiling mode is implemented by the VPU found on all Allwinner platforms, 11375324fb0dSmrg * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 11385324fb0dSmrg * planes. 11395324fb0dSmrg * 11405324fb0dSmrg * With this tiling, the luminance samples are disposed in tiles representing 11415324fb0dSmrg * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. 11425324fb0dSmrg * The pixel order in each tile is linear and the tiles are disposed linearly, 11435324fb0dSmrg * both in row-major order. 11445324fb0dSmrg */ 11455324fb0dSmrg#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) 11465324fb0dSmrg 114741687f09Smrg/* 114841687f09Smrg * Amlogic Video Framebuffer Compression modifiers 114941687f09Smrg * 115041687f09Smrg * Amlogic uses a proprietary lossless image compression protocol and format 115141687f09Smrg * for their hardware video codec accelerators, either video decoders or 115241687f09Smrg * video input encoders. 115341687f09Smrg * 115441687f09Smrg * It considerably reduces memory bandwidth while writing and reading 115541687f09Smrg * frames in memory. 115641687f09Smrg * 115741687f09Smrg * The underlying storage is considered to be 3 components, 8bit or 10-bit 115841687f09Smrg * per component YCbCr 420, single plane : 115941687f09Smrg * - DRM_FORMAT_YUV420_8BIT 116041687f09Smrg * - DRM_FORMAT_YUV420_10BIT 116141687f09Smrg * 116241687f09Smrg * The first 8 bits of the mode defines the layout, then the following 8 bits 116341687f09Smrg * defines the options changing the layout. 116441687f09Smrg * 116541687f09Smrg * Not all combinations are valid, and different SoCs may support different 116641687f09Smrg * combinations of layout and options. 116741687f09Smrg */ 116849ef06a4Smrg#define __fourcc_mod_amlogic_layout_mask 0xff 116941687f09Smrg#define __fourcc_mod_amlogic_options_shift 8 117049ef06a4Smrg#define __fourcc_mod_amlogic_options_mask 0xff 117141687f09Smrg 117241687f09Smrg#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \ 117341687f09Smrg fourcc_mod_code(AMLOGIC, \ 117441687f09Smrg ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ 117541687f09Smrg (((__options) & __fourcc_mod_amlogic_options_mask) \ 117641687f09Smrg << __fourcc_mod_amlogic_options_shift)) 117741687f09Smrg 117841687f09Smrg/* Amlogic FBC Layouts */ 117941687f09Smrg 118041687f09Smrg/* 118141687f09Smrg * Amlogic FBC Basic Layout 118241687f09Smrg * 118341687f09Smrg * The basic layout is composed of: 118441687f09Smrg * - a body content organized in 64x32 superblocks with 4096 bytes per 118541687f09Smrg * superblock in default mode. 118641687f09Smrg * - a 32 bytes per 128x64 header block 118741687f09Smrg * 118841687f09Smrg * This layout is transferrable between Amlogic SoCs supporting this modifier. 118941687f09Smrg */ 119041687f09Smrg#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) 119141687f09Smrg 119241687f09Smrg/* 119341687f09Smrg * Amlogic FBC Scatter Memory layout 119441687f09Smrg * 119541687f09Smrg * Indicates the header contains IOMMU references to the compressed 119641687f09Smrg * frames content to optimize memory access and layout. 119741687f09Smrg * 119841687f09Smrg * In this mode, only the header memory address is needed, thus the 119941687f09Smrg * content memory organization is tied to the current producer 120041687f09Smrg * execution and cannot be saved/dumped neither transferrable between 120141687f09Smrg * Amlogic SoCs supporting this modifier. 120241687f09Smrg * 120341687f09Smrg * Due to the nature of the layout, these buffers are not expected to 120441687f09Smrg * be accessible by the user-space clients, but only accessible by the 120541687f09Smrg * hardware producers and consumers. 120641687f09Smrg * 120741687f09Smrg * The user-space clients should expect a failure while trying to mmap 120841687f09Smrg * the DMA-BUF handle returned by the producer. 120941687f09Smrg */ 121041687f09Smrg#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) 121141687f09Smrg 121241687f09Smrg/* Amlogic FBC Layout Options Bit Mask */ 121341687f09Smrg 121441687f09Smrg/* 121541687f09Smrg * Amlogic FBC Memory Saving mode 121641687f09Smrg * 121741687f09Smrg * Indicates the storage is packed when pixel size is multiple of word 121841687f09Smrg * boudaries, i.e. 8bit should be stored in this mode to save allocation 121941687f09Smrg * memory. 122041687f09Smrg * 122141687f09Smrg * This mode reduces body layout to 3072 bytes per 64x32 superblock with 122241687f09Smrg * the basic layout and 3200 bytes per 64x32 superblock combined with 122341687f09Smrg * the scatter layout. 122441687f09Smrg */ 122541687f09Smrg#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) 122641687f09Smrg 122741687f09Smrg/* 122841687f09Smrg * AMD modifiers 122941687f09Smrg * 123041687f09Smrg * Memory layout: 123141687f09Smrg * 123241687f09Smrg * without DCC: 123341687f09Smrg * - main surface 123441687f09Smrg * 123541687f09Smrg * with DCC & without DCC_RETILE: 123641687f09Smrg * - main surface in plane 0 123741687f09Smrg * - DCC surface in plane 1 (RB-aligned, pipe-aligned if DCC_PIPE_ALIGN is set) 123841687f09Smrg * 123941687f09Smrg * with DCC & DCC_RETILE: 124041687f09Smrg * - main surface in plane 0 124141687f09Smrg * - displayable DCC surface in plane 1 (not RB-aligned & not pipe-aligned) 124241687f09Smrg * - pipe-aligned DCC surface in plane 2 (RB-aligned & pipe-aligned) 124341687f09Smrg * 124441687f09Smrg * For multi-plane formats the above surfaces get merged into one plane for 124541687f09Smrg * each format plane, based on the required alignment only. 124641687f09Smrg * 124741687f09Smrg * Bits Parameter Notes 124841687f09Smrg * ----- ------------------------ --------------------------------------------- 124941687f09Smrg * 125041687f09Smrg * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* 125141687f09Smrg * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* 125241687f09Smrg * 13 DCC 125341687f09Smrg * 14 DCC_RETILE 125441687f09Smrg * 15 DCC_PIPE_ALIGN 125541687f09Smrg * 16 DCC_INDEPENDENT_64B 125641687f09Smrg * 17 DCC_INDEPENDENT_128B 125741687f09Smrg * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* 125841687f09Smrg * 20 DCC_CONSTANT_ENCODE 125941687f09Smrg * 23:21 PIPE_XOR_BITS Only for some chips 126041687f09Smrg * 26:24 BANK_XOR_BITS Only for some chips 126141687f09Smrg * 29:27 PACKERS Only for some chips 126241687f09Smrg * 32:30 RB Only for some chips 126341687f09Smrg * 35:33 PIPE Only for some chips 126441687f09Smrg * 55:36 - Reserved for future use, must be zero 126541687f09Smrg */ 126641687f09Smrg#define AMD_FMT_MOD fourcc_mod_code(AMD, 0) 126741687f09Smrg 126841687f09Smrg#define IS_AMD_FMT_MOD(val) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD) 126941687f09Smrg 127041687f09Smrg/* Reserve 0 for GFX8 and older */ 127141687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX9 1 127241687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX10 2 127341687f09Smrg#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3 127441687f09Smrg 127541687f09Smrg/* 127641687f09Smrg * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical 127741687f09Smrg * version. 127841687f09Smrg */ 127941687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S 9 128041687f09Smrg 128141687f09Smrg/* 128241687f09Smrg * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has 128341687f09Smrg * GFX9 as canonical version. 128441687f09Smrg */ 128541687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D 10 128641687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25 128741687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26 128841687f09Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27 128941687f09Smrg 129041687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_64B 0 129141687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_128B 1 129241687f09Smrg#define AMD_FMT_MOD_DCC_BLOCK_256B 2 129341687f09Smrg 129441687f09Smrg#define AMD_FMT_MOD_TILE_VERSION_SHIFT 0 129541687f09Smrg#define AMD_FMT_MOD_TILE_VERSION_MASK 0xFF 129641687f09Smrg#define AMD_FMT_MOD_TILE_SHIFT 8 129741687f09Smrg#define AMD_FMT_MOD_TILE_MASK 0x1F 129841687f09Smrg 129941687f09Smrg/* Whether DCC compression is enabled. */ 130041687f09Smrg#define AMD_FMT_MOD_DCC_SHIFT 13 130141687f09Smrg#define AMD_FMT_MOD_DCC_MASK 0x1 130241687f09Smrg 130341687f09Smrg/* 130441687f09Smrg * Whether to include two DCC surfaces, one which is rb & pipe aligned, and 130541687f09Smrg * one which is not-aligned. 130641687f09Smrg */ 130741687f09Smrg#define AMD_FMT_MOD_DCC_RETILE_SHIFT 14 130841687f09Smrg#define AMD_FMT_MOD_DCC_RETILE_MASK 0x1 130941687f09Smrg 131041687f09Smrg/* Only set if DCC_RETILE = false */ 131141687f09Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_SHIFT 15 131241687f09Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_MASK 0x1 131341687f09Smrg 131441687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_SHIFT 16 131541687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_MASK 0x1 131641687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_SHIFT 17 131741687f09Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_MASK 0x1 131841687f09Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_SHIFT 18 131941687f09Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 132041687f09Smrg 132141687f09Smrg/* 132241687f09Smrg * DCC supports embedding some clear colors directly in the DCC surface. 132341687f09Smrg * However, on older GPUs the rendering HW ignores the embedded clear color 132441687f09Smrg * and prefers the driver provided color. This necessitates doing a fastclear 132541687f09Smrg * eliminate operation before a process transfers control. 132641687f09Smrg * 132741687f09Smrg * If this bit is set that means the fastclear eliminate is not needed for these 132841687f09Smrg * embeddable colors. 132941687f09Smrg */ 133041687f09Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_SHIFT 20 133141687f09Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_MASK 0x1 133241687f09Smrg 133341687f09Smrg/* 133441687f09Smrg * The below fields are for accounting for per GPU differences. These are only 133541687f09Smrg * relevant for GFX9 and later and if the tile field is *_X/_T. 133641687f09Smrg * 133741687f09Smrg * PIPE_XOR_BITS = always needed 133841687f09Smrg * BANK_XOR_BITS = only for TILE_VER_GFX9 133941687f09Smrg * PACKERS = only for TILE_VER_GFX10_RBPLUS 134041687f09Smrg * RB = only for TILE_VER_GFX9 & DCC 134141687f09Smrg * PIPE = only for TILE_VER_GFX9 & DCC & (DCC_RETILE | DCC_PIPE_ALIGN) 134241687f09Smrg */ 134341687f09Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_SHIFT 21 134441687f09Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_MASK 0x7 134541687f09Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_SHIFT 24 134641687f09Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_MASK 0x7 134741687f09Smrg#define AMD_FMT_MOD_PACKERS_SHIFT 27 134841687f09Smrg#define AMD_FMT_MOD_PACKERS_MASK 0x7 134941687f09Smrg#define AMD_FMT_MOD_RB_SHIFT 30 135041687f09Smrg#define AMD_FMT_MOD_RB_MASK 0x7 135141687f09Smrg#define AMD_FMT_MOD_PIPE_SHIFT 33 135241687f09Smrg#define AMD_FMT_MOD_PIPE_MASK 0x7 135341687f09Smrg 135441687f09Smrg#define AMD_FMT_MOD_SET(field, value) \ 135541687f09Smrg ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT) 135641687f09Smrg#define AMD_FMT_MOD_GET(field, value) \ 135741687f09Smrg (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK) 135841687f09Smrg#define AMD_FMT_MOD_CLEAR(field) \ 135941687f09Smrg (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) 136041687f09Smrg 1361d8807b2fSmrg#if defined(__cplusplus) 1362d8807b2fSmrg} 1363d8807b2fSmrg#endif 1364d8807b2fSmrg 1365e88f27b3Smrg#endif /* DRM_FOURCC_H */ 1366