101e04c3fSmrg/* 201e04c3fSmrg * Copyright 2011 Intel Corporation 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the 901e04c3fSmrg * Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 1901e04c3fSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2001e04c3fSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2101e04c3fSmrg * OTHER DEALINGS IN THE SOFTWARE. 2201e04c3fSmrg */ 2301e04c3fSmrg 2401e04c3fSmrg#ifndef DRM_FOURCC_H 2501e04c3fSmrg#define DRM_FOURCC_H 2601e04c3fSmrg 2701e04c3fSmrg#include "drm.h" 2801e04c3fSmrg 2901e04c3fSmrg#if defined(__cplusplus) 3001e04c3fSmrgextern "C" { 3101e04c3fSmrg#endif 3201e04c3fSmrg 3353c12917Smaya/** 3453c12917Smaya * DOC: overview 3553c12917Smaya * 3653c12917Smaya * In the DRM subsystem, framebuffer pixel formats are described using the 3753c12917Smaya * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the 3853c12917Smaya * fourcc code, a Format Modifier may optionally be provided, in order to 3953c12917Smaya * further describe the buffer's format - for example tiling or compression. 4053c12917Smaya * 4153c12917Smaya * Format Modifiers 4253c12917Smaya * ---------------- 4353c12917Smaya * 4453c12917Smaya * Format modifiers are used in conjunction with a fourcc code, forming a 4553c12917Smaya * unique fourcc:modifier pair. This format:modifier pair must fully define the 4653c12917Smaya * format and data layout of the buffer, and should be the only way to describe 4753c12917Smaya * that particular buffer. 4853c12917Smaya * 4953c12917Smaya * Having multiple fourcc:modifier pairs which describe the same layout should 5053c12917Smaya * be avoided, as such aliases run the risk of different drivers exposing 5153c12917Smaya * different names for the same data format, forcing userspace to understand 5253c12917Smaya * that they are aliases. 5353c12917Smaya * 5453c12917Smaya * Format modifiers may change any property of the buffer, including the number 5553c12917Smaya * of planes and/or the required allocation size. Format modifiers are 5653c12917Smaya * vendor-namespaced, and as such the relationship between a fourcc code and a 5753c12917Smaya * modifier is specific to the modifer being used. For example, some modifiers 5853c12917Smaya * may preserve meaning - such as number of planes - from the fourcc code, 5953c12917Smaya * whereas others may not. 6053c12917Smaya * 617ec681f3Smrg * Modifiers must uniquely encode buffer layout. In other words, a buffer must 627ec681f3Smrg * match only a single modifier. A modifier must not be a subset of layouts of 637ec681f3Smrg * another modifier. For instance, it's incorrect to encode pitch alignment in 647ec681f3Smrg * a modifier: a buffer may match a 64-pixel aligned modifier and a 32-pixel 657ec681f3Smrg * aligned modifier. That said, modifiers can have implicit minimal 667ec681f3Smrg * requirements. 677ec681f3Smrg * 687ec681f3Smrg * For modifiers where the combination of fourcc code and modifier can alias, 697ec681f3Smrg * a canonical pair needs to be defined and used by all drivers. Preferred 707ec681f3Smrg * combinations are also encouraged where all combinations might lead to 717ec681f3Smrg * confusion and unnecessarily reduced interoperability. An example for the 727ec681f3Smrg * latter is AFBC, where the ABGR layouts are preferred over ARGB layouts. 737ec681f3Smrg * 747ec681f3Smrg * There are two kinds of modifier users: 757ec681f3Smrg * 767ec681f3Smrg * - Kernel and user-space drivers: for drivers it's important that modifiers 777ec681f3Smrg * don't alias, otherwise two drivers might support the same format but use 787ec681f3Smrg * different aliases, preventing them from sharing buffers in an efficient 797ec681f3Smrg * format. 807ec681f3Smrg * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users 817ec681f3Smrg * see modifiers as opaque tokens they can check for equality and intersect. 827ec681f3Smrg * These users musn't need to know to reason about the modifier value 837ec681f3Smrg * (i.e. they are not expected to extract information out of the modifier). 847ec681f3Smrg * 8553c12917Smaya * Vendors should document their modifier usage in as much detail as 8653c12917Smaya * possible, to ensure maximum compatibility across devices, drivers and 8753c12917Smaya * applications. 8853c12917Smaya * 8953c12917Smaya * The authoritative list of format modifier codes is found in 9053c12917Smaya * `include/uapi/drm/drm_fourcc.h` 9153c12917Smaya */ 9253c12917Smaya 9301e04c3fSmrg#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 9401e04c3fSmrg ((__u32)(c) << 16) | ((__u32)(d) << 24)) 9501e04c3fSmrg 967ec681f3Smrg#define DRM_FORMAT_BIG_ENDIAN (1U<<31) /* format is big endian instead of little endian */ 9701e04c3fSmrg 9853c12917Smaya/* Reserve 0 for the invalid format specifier */ 9953c12917Smaya#define DRM_FORMAT_INVALID 0 10053c12917Smaya 10101e04c3fSmrg/* color index */ 10201e04c3fSmrg#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 10301e04c3fSmrg 10401e04c3fSmrg/* 8 bpp Red */ 10501e04c3fSmrg#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 10601e04c3fSmrg 10701e04c3fSmrg/* 16 bpp Red */ 10801e04c3fSmrg#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ 10901e04c3fSmrg 11001e04c3fSmrg/* 16 bpp RG */ 11101e04c3fSmrg#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 11201e04c3fSmrg#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 11301e04c3fSmrg 11401e04c3fSmrg/* 32 bpp RG */ 11501e04c3fSmrg#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ 11601e04c3fSmrg#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ 11701e04c3fSmrg 11801e04c3fSmrg/* 8 bpp RGB */ 11901e04c3fSmrg#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 12001e04c3fSmrg#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 12101e04c3fSmrg 12201e04c3fSmrg/* 16 bpp RGB */ 12301e04c3fSmrg#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 12401e04c3fSmrg#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 12501e04c3fSmrg#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 12601e04c3fSmrg#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 12701e04c3fSmrg 12801e04c3fSmrg#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 12901e04c3fSmrg#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 13001e04c3fSmrg#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 13101e04c3fSmrg#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 13201e04c3fSmrg 13301e04c3fSmrg#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 13401e04c3fSmrg#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 13501e04c3fSmrg#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 13601e04c3fSmrg#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 13701e04c3fSmrg 13801e04c3fSmrg#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 13901e04c3fSmrg#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 14001e04c3fSmrg#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 14101e04c3fSmrg#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 14201e04c3fSmrg 14301e04c3fSmrg#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 14401e04c3fSmrg#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 14501e04c3fSmrg 14601e04c3fSmrg/* 24 bpp RGB */ 14701e04c3fSmrg#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 14801e04c3fSmrg#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 14901e04c3fSmrg 15001e04c3fSmrg/* 32 bpp RGB */ 15101e04c3fSmrg#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 15201e04c3fSmrg#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 15301e04c3fSmrg#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 15401e04c3fSmrg#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 15501e04c3fSmrg 15601e04c3fSmrg#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 15701e04c3fSmrg#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 15801e04c3fSmrg#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 15901e04c3fSmrg#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 16001e04c3fSmrg 16101e04c3fSmrg#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 16201e04c3fSmrg#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 16301e04c3fSmrg#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 16401e04c3fSmrg#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 16501e04c3fSmrg 16601e04c3fSmrg#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 16701e04c3fSmrg#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 16801e04c3fSmrg#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 16901e04c3fSmrg#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 17001e04c3fSmrg 1717ec681f3Smrg/* 64 bpp RGB */ 1727ec681f3Smrg#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 1737ec681f3Smrg#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 1747ec681f3Smrg 1757ec681f3Smrg#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 1767ec681f3Smrg#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 1777ec681f3Smrg 1787ec681f3Smrg/* 1797ec681f3Smrg * Floating point 64bpp RGB 1807ec681f3Smrg * IEEE 754-2008 binary16 half-precision float 1817ec681f3Smrg * [15:0] sign:exponent:mantissa 1:5:10 1827ec681f3Smrg */ 1837ec681f3Smrg#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */ 1847ec681f3Smrg#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */ 1857ec681f3Smrg 1867ec681f3Smrg#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */ 1877ec681f3Smrg#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */ 1887ec681f3Smrg 1897ec681f3Smrg/* 1907ec681f3Smrg * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits 1917ec681f3Smrg * of unused padding per component: 1927ec681f3Smrg */ 1937ec681f3Smrg#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 */ 1947ec681f3Smrg 19501e04c3fSmrg/* packed YCbCr */ 19601e04c3fSmrg#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 19701e04c3fSmrg#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 19801e04c3fSmrg#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 19901e04c3fSmrg#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 20001e04c3fSmrg 20101e04c3fSmrg#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 2027ec681f3Smrg#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ 2037ec681f3Smrg#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */ 2047ec681f3Smrg#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */ 2057ec681f3Smrg 2067ec681f3Smrg/* 2077ec681f3Smrg * packed Y2xx indicate for each component, xx valid data occupy msb 2087ec681f3Smrg * 16-xx padding occupy lsb 2097ec681f3Smrg */ 2107ec681f3Smrg#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 */ 2117ec681f3Smrg#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 */ 2127ec681f3Smrg#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 */ 2137ec681f3Smrg 2147ec681f3Smrg/* 2157ec681f3Smrg * packed Y4xx indicate for each component, xx valid data occupy msb 2167ec681f3Smrg * 16-xx padding occupy lsb except Y410 2177ec681f3Smrg */ 2187ec681f3Smrg#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') /* [31:0] A:Cr:Y:Cb 2:10:10:10 little endian */ 2197ec681f3Smrg#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 */ 2207ec681f3Smrg#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6') /* [63:0] A:Cr:Y:Cb 16:16:16:16 little endian */ 2217ec681f3Smrg 2227ec681f3Smrg#define DRM_FORMAT_XVYU2101010 fourcc_code('X', 'V', '3', '0') /* [31:0] X:Cr:Y:Cb 2:10:10:10 little endian */ 2237ec681f3Smrg#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 */ 2247ec681f3Smrg#define DRM_FORMAT_XVYU16161616 fourcc_code('X', 'V', '4', '8') /* [63:0] X:Cr:Y:Cb 16:16:16:16 little endian */ 22553c12917Smaya 22653c12917Smaya/* 22753c12917Smaya * packed YCbCr420 2x2 tiled formats 22853c12917Smaya * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile 22953c12917Smaya */ 23053c12917Smaya/* [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 */ 23153c12917Smaya#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0') 23253c12917Smaya/* [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 */ 23353c12917Smaya#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0') 23453c12917Smaya 23553c12917Smaya/* [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 23653c12917Smaya#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 23753c12917Smaya/* [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 23853c12917Smaya#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2') 23901e04c3fSmrg 2407ec681f3Smrg/* 2417ec681f3Smrg * 1-plane YUV 4:2:0 2427ec681f3Smrg * In these formats, the component ordering is specified (Y, followed by U 2437ec681f3Smrg * then V), but the exact Linear layout is undefined. 2447ec681f3Smrg * These formats can only be used with a non-Linear modifier. 2457ec681f3Smrg */ 2467ec681f3Smrg#define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8') 2477ec681f3Smrg#define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') 2487ec681f3Smrg 24901e04c3fSmrg/* 25001e04c3fSmrg * 2 plane RGB + A 25101e04c3fSmrg * index 0 = RGB plane, same format as the corresponding non _A8 format has 25201e04c3fSmrg * index 1 = A plane, [7:0] A 25301e04c3fSmrg */ 25401e04c3fSmrg#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') 25501e04c3fSmrg#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') 25601e04c3fSmrg#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') 25701e04c3fSmrg#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') 25801e04c3fSmrg#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') 25901e04c3fSmrg#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') 26001e04c3fSmrg#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') 26101e04c3fSmrg#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') 26201e04c3fSmrg 26301e04c3fSmrg/* 26401e04c3fSmrg * 2 plane YCbCr 26501e04c3fSmrg * index 0 = Y plane, [7:0] Y 26601e04c3fSmrg * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 26701e04c3fSmrg * or 26801e04c3fSmrg * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 26901e04c3fSmrg */ 27001e04c3fSmrg#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 27101e04c3fSmrg#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 27201e04c3fSmrg#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 27301e04c3fSmrg#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 27401e04c3fSmrg#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 27501e04c3fSmrg#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 2767ec681f3Smrg/* 2777ec681f3Smrg * 2 plane YCbCr 2787ec681f3Smrg * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian 2797ec681f3Smrg * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian 2807ec681f3Smrg */ 2817ec681f3Smrg#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ 2827ec681f3Smrg 2837ec681f3Smrg/* 2847ec681f3Smrg * 2 plane YCbCr MSB aligned 2857ec681f3Smrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 2867ec681f3Smrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 2877ec681f3Smrg */ 2887ec681f3Smrg#define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */ 28901e04c3fSmrg 29053c12917Smaya/* 29153c12917Smaya * 2 plane YCbCr MSB aligned 29253c12917Smaya * index 0 = Y plane, [15:0] Y:x [10:6] little endian 29353c12917Smaya * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 29453c12917Smaya */ 29553c12917Smaya#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */ 29653c12917Smaya 29753c12917Smaya/* 29853c12917Smaya * 2 plane YCbCr MSB aligned 29953c12917Smaya * index 0 = Y plane, [15:0] Y:x [12:4] little endian 30053c12917Smaya * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian 30153c12917Smaya */ 30253c12917Smaya#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */ 30353c12917Smaya 30453c12917Smaya/* 30553c12917Smaya * 2 plane YCbCr MSB aligned 30653c12917Smaya * index 0 = Y plane, [15:0] Y little endian 30753c12917Smaya * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian 30853c12917Smaya */ 30953c12917Smaya#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ 31053c12917Smaya 3117ec681f3Smrg/* 3 plane non-subsampled (444) YCbCr 3127ec681f3Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 3137ec681f3Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 3147ec681f3Smrg * index 1: Cb plane, [15:0] Cb:x [10:6] little endian 3157ec681f3Smrg * index 2: Cr plane, [15:0] Cr:x [10:6] little endian 3167ec681f3Smrg */ 3177ec681f3Smrg#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') 3187ec681f3Smrg 3197ec681f3Smrg/* 3 plane non-subsampled (444) YCrCb 3207ec681f3Smrg * 16 bits per component, but only 10 bits are used and 6 bits are padded 3217ec681f3Smrg * index 0: Y plane, [15:0] Y:x [10:6] little endian 3227ec681f3Smrg * index 1: Cr plane, [15:0] Cr:x [10:6] little endian 3237ec681f3Smrg * index 2: Cb plane, [15:0] Cb:x [10:6] little endian 3247ec681f3Smrg */ 3257ec681f3Smrg#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') 3267ec681f3Smrg 32701e04c3fSmrg/* 32801e04c3fSmrg * 3 plane YCbCr 32901e04c3fSmrg * index 0: Y plane, [7:0] Y 33001e04c3fSmrg * index 1: Cb plane, [7:0] Cb 33101e04c3fSmrg * index 2: Cr plane, [7:0] Cr 33201e04c3fSmrg * or 33301e04c3fSmrg * index 1: Cr plane, [7:0] Cr 33401e04c3fSmrg * index 2: Cb plane, [7:0] Cb 33501e04c3fSmrg */ 33601e04c3fSmrg#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 33701e04c3fSmrg#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 33801e04c3fSmrg#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 33901e04c3fSmrg#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 34001e04c3fSmrg#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 34101e04c3fSmrg#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 34201e04c3fSmrg#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 34301e04c3fSmrg#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 34401e04c3fSmrg#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 34501e04c3fSmrg#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 34601e04c3fSmrg 34701e04c3fSmrg 34801e04c3fSmrg/* 34901e04c3fSmrg * Format Modifiers: 35001e04c3fSmrg * 35101e04c3fSmrg * Format modifiers describe, typically, a re-ordering or modification 35201e04c3fSmrg * of the data in a plane of an FB. This can be used to express tiled/ 35301e04c3fSmrg * swizzled formats, or compression, or a combination of the two. 35401e04c3fSmrg * 35501e04c3fSmrg * The upper 8 bits of the format modifier are a vendor-id as assigned 35601e04c3fSmrg * below. The lower 56 bits are assigned as vendor sees fit. 35701e04c3fSmrg */ 35801e04c3fSmrg 35901e04c3fSmrg/* Vendor Ids: */ 36001e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_NONE 0 36101e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 36201e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 36301e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03 36401e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 36501e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 36601e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 36701e04c3fSmrg#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 36853c12917Smaya#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 36953c12917Smaya#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 3707ec681f3Smrg#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a 37153c12917Smaya 37201e04c3fSmrg/* add more to the end as needed */ 37301e04c3fSmrg 37401e04c3fSmrg#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) 37501e04c3fSmrg 37601e04c3fSmrg#define fourcc_mod_code(vendor, val) \ 37701e04c3fSmrg ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 37801e04c3fSmrg 37901e04c3fSmrg/* 38001e04c3fSmrg * Format Modifier tokens: 38101e04c3fSmrg * 38201e04c3fSmrg * When adding a new token please document the layout with a code comment, 38301e04c3fSmrg * similar to the fourcc codes above. drm_fourcc.h is considered the 38401e04c3fSmrg * authoritative source for all of these. 3857ec681f3Smrg * 3867ec681f3Smrg * Generic modifier names: 3877ec681f3Smrg * 3887ec681f3Smrg * DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral names 3897ec681f3Smrg * for layouts which are common across multiple vendors. To preserve 3907ec681f3Smrg * compatibility, in cases where a vendor-specific definition already exists and 3917ec681f3Smrg * a generic name for it is desired, the common name is a purely symbolic alias 3927ec681f3Smrg * and must use the same numerical value as the original definition. 3937ec681f3Smrg * 3947ec681f3Smrg * Note that generic names should only be used for modifiers which describe 3957ec681f3Smrg * generic layouts (such as pixel re-ordering), which may have 3967ec681f3Smrg * independently-developed support across multiple vendors. 3977ec681f3Smrg * 3987ec681f3Smrg * In future cases where a generic layout is identified before merging with a 3997ec681f3Smrg * vendor-specific modifier, a new 'GENERIC' vendor or modifier using vendor 4007ec681f3Smrg * 'NONE' could be considered. This should only be for obvious, exceptional 4017ec681f3Smrg * cases to avoid polluting the 'GENERIC' namespace with modifiers which only 4027ec681f3Smrg * apply to a single vendor. 4037ec681f3Smrg * 4047ec681f3Smrg * Generic names should not be used for cases where multiple hardware vendors 4057ec681f3Smrg * have implementations of the same standardised compression scheme (such as 4067ec681f3Smrg * AFBC). In those cases, all implementations should use the same format 4077ec681f3Smrg * modifier(s), reflecting the vendor of the standard. 40801e04c3fSmrg */ 40901e04c3fSmrg 4107ec681f3Smrg#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE 4117ec681f3Smrg 41201e04c3fSmrg/* 41301e04c3fSmrg * Invalid Modifier 41401e04c3fSmrg * 41501e04c3fSmrg * This modifier can be used as a sentinel to terminate the format modifiers 41601e04c3fSmrg * list, or to initialize a variable with an invalid modifier. It might also be 41701e04c3fSmrg * used to report an error back to userspace for certain APIs. 41801e04c3fSmrg */ 41901e04c3fSmrg#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) 42001e04c3fSmrg 42101e04c3fSmrg/* 42201e04c3fSmrg * Linear Layout 42301e04c3fSmrg * 42401e04c3fSmrg * Just plain linear layout. Note that this is different from no specifying any 42501e04c3fSmrg * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), 42601e04c3fSmrg * which tells the driver to also take driver-internal information into account 42701e04c3fSmrg * and so might actually result in a tiled framebuffer. 42801e04c3fSmrg */ 42901e04c3fSmrg#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) 43001e04c3fSmrg 4317ec681f3Smrg/* 4327ec681f3Smrg * Deprecated: use DRM_FORMAT_MOD_LINEAR instead 4337ec681f3Smrg * 4347ec681f3Smrg * The "none" format modifier doesn't actually mean that the modifier is 4357ec681f3Smrg * implicit, instead it means that the layout is linear. Whether modifiers are 4367ec681f3Smrg * used is out-of-band information carried in an API-specific way (e.g. in a 4377ec681f3Smrg * flag for drm_mode_fb_cmd2). 4387ec681f3Smrg */ 4397ec681f3Smrg#define DRM_FORMAT_MOD_NONE 0 4407ec681f3Smrg 44101e04c3fSmrg/* Intel framebuffer modifiers */ 44201e04c3fSmrg 44301e04c3fSmrg/* 44401e04c3fSmrg * Intel X-tiling layout 44501e04c3fSmrg * 44601e04c3fSmrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 44701e04c3fSmrg * in row-major layout. Within the tile bytes are laid out row-major, with 44801e04c3fSmrg * a platform-dependent stride. On top of that the memory can apply 44901e04c3fSmrg * platform-depending swizzling of some higher address bits into bit6. 45001e04c3fSmrg * 4517ec681f3Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 4527ec681f3Smrg * On earlier platforms the is highly platforms specific and not useful for 4537ec681f3Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 4547ec681f3Smrg * identify the layout in a simple way for i915-specific userspace, which 4557ec681f3Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 4567ec681f3Smrg * format on some really old platforms is not known. 45701e04c3fSmrg */ 45801e04c3fSmrg#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 45901e04c3fSmrg 46001e04c3fSmrg/* 46101e04c3fSmrg * Intel Y-tiling layout 46201e04c3fSmrg * 46301e04c3fSmrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 46401e04c3fSmrg * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 46501e04c3fSmrg * chunks column-major, with a platform-dependent height. On top of that the 46601e04c3fSmrg * memory can apply platform-depending swizzling of some higher address bits 46701e04c3fSmrg * into bit6. 46801e04c3fSmrg * 4697ec681f3Smrg * Note that this layout is only accurate on intel gen 8+ or valleyview chipsets. 4707ec681f3Smrg * On earlier platforms the is highly platforms specific and not useful for 4717ec681f3Smrg * cross-driver sharing. It exists since on a given platform it does uniquely 4727ec681f3Smrg * identify the layout in a simple way for i915-specific userspace, which 4737ec681f3Smrg * facilitated conversion of userspace to modifiers. Additionally the exact 4747ec681f3Smrg * format on some really old platforms is not known. 47501e04c3fSmrg */ 47601e04c3fSmrg#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 47701e04c3fSmrg 47801e04c3fSmrg/* 47901e04c3fSmrg * Intel Yf-tiling layout 48001e04c3fSmrg * 48101e04c3fSmrg * This is a tiled layout using 4Kb tiles in row-major layout. 48201e04c3fSmrg * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 48301e04c3fSmrg * are arranged in four groups (two wide, two high) with column-major layout. 48401e04c3fSmrg * Each group therefore consits out of four 256 byte units, which are also laid 48501e04c3fSmrg * out as 2x2 column-major. 48601e04c3fSmrg * 256 byte units are made out of four 64 byte blocks of pixels, producing 48701e04c3fSmrg * either a square block or a 2:1 unit. 48801e04c3fSmrg * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 48901e04c3fSmrg * in pixel depends on the pixel depth. 49001e04c3fSmrg */ 49101e04c3fSmrg#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 49201e04c3fSmrg 49301e04c3fSmrg/* 49401e04c3fSmrg * Intel color control surface (CCS) for render compression 49501e04c3fSmrg * 49601e04c3fSmrg * The framebuffer format must be one of the 8:8:8:8 RGB formats. 49701e04c3fSmrg * The main surface will be plane index 0 and must be Y/Yf-tiled, 49801e04c3fSmrg * the CCS will be plane index 1. 49901e04c3fSmrg * 50001e04c3fSmrg * Each CCS tile matches a 1024x512 pixel area of the main surface. 50101e04c3fSmrg * To match certain aspects of the 3D hardware the CCS is 50201e04c3fSmrg * considered to be made up of normal 128Bx32 Y tiles, Thus 50301e04c3fSmrg * the CCS pitch must be specified in multiples of 128 bytes. 50401e04c3fSmrg * 50501e04c3fSmrg * In reality the CCS tile appears to be a 64Bx64 Y tile, composed 50601e04c3fSmrg * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. 50701e04c3fSmrg * But that fact is not relevant unless the memory is accessed 50801e04c3fSmrg * directly. 50901e04c3fSmrg */ 51001e04c3fSmrg#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) 51101e04c3fSmrg#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) 51201e04c3fSmrg 5137ec681f3Smrg/* 5147ec681f3Smrg * Intel color control surfaces (CCS) for Gen-12 render compression. 5157ec681f3Smrg * 5167ec681f3Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 5177ec681f3Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 5187ec681f3Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 5197ec681f3Smrg * line pair. The main surface pitch is required to be a multiple of four 5207ec681f3Smrg * Y-tile widths. 5217ec681f3Smrg */ 5227ec681f3Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6) 5237ec681f3Smrg 5247ec681f3Smrg/* 5257ec681f3Smrg * Intel color control surfaces (CCS) for Gen-12 media compression 5267ec681f3Smrg * 5277ec681f3Smrg * The main surface is Y-tiled and at plane index 0, the CCS is linear and 5287ec681f3Smrg * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in 5297ec681f3Smrg * main surface. In other words, 4 bits in CCS map to a main surface cache 5307ec681f3Smrg * line pair. The main surface pitch is required to be a multiple of four 5317ec681f3Smrg * Y-tile widths. For semi-planar formats like NV12, CCS planes follow the 5327ec681f3Smrg * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces, 5337ec681f3Smrg * planes 2 and 3 for the respective CCS. 5347ec681f3Smrg */ 5357ec681f3Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7) 5367ec681f3Smrg 5377ec681f3Smrg/* 5387ec681f3Smrg * Intel Color Control Surface with Clear Color (CCS) for Gen-12 render 5397ec681f3Smrg * compression. 5407ec681f3Smrg * 5417ec681f3Smrg * The main surface is Y-tiled and is at plane index 0 whereas CCS is linear 5427ec681f3Smrg * and at index 1. The clear color is stored at index 2, and the pitch should 5437ec681f3Smrg * be ignored. The clear color structure is 256 bits. The first 128 bits 5447ec681f3Smrg * represents Raw Clear Color Red, Green, Blue and Alpha color each represented 5457ec681f3Smrg * by 32 bits. The raw clear color is consumed by the 3d engine and generates 5467ec681f3Smrg * the converted clear color of size 64 bits. The first 32 bits store the Lower 5477ec681f3Smrg * Converted Clear Color value and the next 32 bits store the Higher Converted 5487ec681f3Smrg * Clear Color value when applicable. The Converted Clear Color values are 5497ec681f3Smrg * consumed by the DE. The last 64 bits are used to store Color Discard Enable 5507ec681f3Smrg * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line 5517ec681f3Smrg * corresponds to an area of 4x1 tiles in the main surface. The main surface 5527ec681f3Smrg * pitch is required to be a multiple of 4 tile widths. 5537ec681f3Smrg */ 5547ec681f3Smrg#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8) 5557ec681f3Smrg 55601e04c3fSmrg/* 55701e04c3fSmrg * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 55801e04c3fSmrg * 55901e04c3fSmrg * Macroblocks are laid in a Z-shape, and each pixel data is following the 56001e04c3fSmrg * standard NV12 style. 56101e04c3fSmrg * As for NV12, an image is the result of two frame buffers: one for Y, 56201e04c3fSmrg * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 56301e04c3fSmrg * Alignment requirements are (for each buffer): 56401e04c3fSmrg * - multiple of 128 pixels for the width 56501e04c3fSmrg * - multiple of 32 pixels for the height 56601e04c3fSmrg * 56701e04c3fSmrg * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 56801e04c3fSmrg */ 56901e04c3fSmrg#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 57001e04c3fSmrg 57153c12917Smaya/* 57253c12917Smaya * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks 57353c12917Smaya * 57453c12917Smaya * This is a simple tiled layout using tiles of 16x16 pixels in a row-major 57553c12917Smaya * layout. For YCbCr formats Cb/Cr components are taken in such a way that 57653c12917Smaya * they correspond to their 16x16 luma block. 57753c12917Smaya */ 57853c12917Smaya#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) 57953c12917Smaya 58053c12917Smaya/* 58153c12917Smaya * Qualcomm Compressed Format 58253c12917Smaya * 58353c12917Smaya * Refers to a compressed variant of the base format that is compressed. 58453c12917Smaya * Implementation may be platform and base-format specific. 58553c12917Smaya * 58653c12917Smaya * Each macrotile consists of m x n (mostly 4 x 4) tiles. 58753c12917Smaya * Pixel data pitch/stride is aligned with macrotile width. 58853c12917Smaya * Pixel data height is aligned with macrotile height. 58953c12917Smaya * Entire pixel data buffer is aligned with 4k(bytes). 59053c12917Smaya */ 59153c12917Smaya#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) 59253c12917Smaya 59301e04c3fSmrg/* Vivante framebuffer modifiers */ 59401e04c3fSmrg 59501e04c3fSmrg/* 59601e04c3fSmrg * Vivante 4x4 tiling layout 59701e04c3fSmrg * 59801e04c3fSmrg * This is a simple tiled layout using tiles of 4x4 pixels in a row-major 59901e04c3fSmrg * layout. 60001e04c3fSmrg */ 60101e04c3fSmrg#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) 60201e04c3fSmrg 60301e04c3fSmrg/* 60401e04c3fSmrg * Vivante 64x64 super-tiling layout 60501e04c3fSmrg * 60601e04c3fSmrg * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile 60701e04c3fSmrg * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- 60801e04c3fSmrg * major layout. 60901e04c3fSmrg * 61001e04c3fSmrg * For more information: see 61101e04c3fSmrg * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling 61201e04c3fSmrg */ 61301e04c3fSmrg#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) 61401e04c3fSmrg 61501e04c3fSmrg/* 61601e04c3fSmrg * Vivante 4x4 tiling layout for dual-pipe 61701e04c3fSmrg * 61801e04c3fSmrg * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a 61901e04c3fSmrg * different base address. Offsets from the base addresses are therefore halved 62001e04c3fSmrg * compared to the non-split tiled layout. 62101e04c3fSmrg */ 62201e04c3fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) 62301e04c3fSmrg 62401e04c3fSmrg/* 62501e04c3fSmrg * Vivante 64x64 super-tiling layout for dual-pipe 62601e04c3fSmrg * 62701e04c3fSmrg * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile 62801e04c3fSmrg * starts at a different base address. Offsets from the base addresses are 62901e04c3fSmrg * therefore halved compared to the non-split super-tiled layout. 63001e04c3fSmrg */ 63101e04c3fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) 63201e04c3fSmrg 63301e04c3fSmrg/* NVIDIA frame buffer modifiers */ 63401e04c3fSmrg 63501e04c3fSmrg/* 63601e04c3fSmrg * Tegra Tiled Layout, used by Tegra 2, 3 and 4. 63701e04c3fSmrg * 63801e04c3fSmrg * Pixels are arranged in simple tiles of 16 x 16 bytes. 63901e04c3fSmrg */ 64001e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1) 64101e04c3fSmrg 64201e04c3fSmrg/* 6437ec681f3Smrg * Generalized Block Linear layout, used by desktop GPUs starting with NV50/G80, 6447ec681f3Smrg * and Tegra GPUs starting with Tegra K1. 6457ec681f3Smrg * 6467ec681f3Smrg * Pixels are arranged in Groups of Bytes (GOBs). GOB size and layout varies 6477ec681f3Smrg * based on the architecture generation. GOBs themselves are then arranged in 6487ec681f3Smrg * 3D blocks, with the block dimensions (in terms of GOBs) always being a power 6497ec681f3Smrg * of two, and hence expressible as their log2 equivalent (E.g., "2" represents 6507ec681f3Smrg * a block depth or height of "4"). 6517ec681f3Smrg * 6527ec681f3Smrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 6537ec681f3Smrg * in full detail. 6547ec681f3Smrg * 6557ec681f3Smrg * Macro 6567ec681f3Smrg * Bits Param Description 6577ec681f3Smrg * ---- ----- ----------------------------------------------------------------- 6587ec681f3Smrg * 6597ec681f3Smrg * 3:0 h log2(height) of each block, in GOBs. Placed here for 6607ec681f3Smrg * compatibility with the existing 6617ec681f3Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 6627ec681f3Smrg * 6637ec681f3Smrg * 4:4 - Must be 1, to indicate block-linear layout. Necessary for 6647ec681f3Smrg * compatibility with the existing 6657ec681f3Smrg * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers. 6667ec681f3Smrg * 6677ec681f3Smrg * 8:5 - Reserved (To support 3D-surfaces with variable log2(depth) block 6687ec681f3Smrg * size). Must be zero. 6697ec681f3Smrg * 6707ec681f3Smrg * Note there is no log2(width) parameter. Some portions of the 6717ec681f3Smrg * hardware support a block width of two gobs, but it is impractical 6727ec681f3Smrg * to use due to lack of support elsewhere, and has no known 6737ec681f3Smrg * benefits. 6747ec681f3Smrg * 6757ec681f3Smrg * 11:9 - Reserved (To support 2D-array textures with variable array stride 6767ec681f3Smrg * in blocks, specified via log2(tile width in blocks)). Must be 6777ec681f3Smrg * zero. 6787ec681f3Smrg * 6797ec681f3Smrg * 19:12 k Page Kind. This value directly maps to a field in the page 6807ec681f3Smrg * tables of all GPUs >= NV50. It affects the exact layout of bits 6817ec681f3Smrg * in memory and can be derived from the tuple 6827ec681f3Smrg * 6837ec681f3Smrg * (format, GPU model, compression type, samples per pixel) 6847ec681f3Smrg * 6857ec681f3Smrg * Where compression type is defined below. If GPU model were 6867ec681f3Smrg * implied by the format modifier, format, or memory buffer, page 6877ec681f3Smrg * kind would not need to be included in the modifier itself, but 6887ec681f3Smrg * since the modifier should define the layout of the associated 6897ec681f3Smrg * memory buffer independent from any device or other context, it 6907ec681f3Smrg * must be included here. 6917ec681f3Smrg * 6927ec681f3Smrg * 21:20 g GOB Height and Page Kind Generation. The height of a GOB changed 6937ec681f3Smrg * starting with Fermi GPUs. Additionally, the mapping between page 6947ec681f3Smrg * kind and bit layout has changed at various points. 6957ec681f3Smrg * 6967ec681f3Smrg * 0 = Gob Height 8, Fermi - Volta, Tegra K1+ Page Kind mapping 6977ec681f3Smrg * 1 = Gob Height 4, G80 - GT2XX Page Kind mapping 6987ec681f3Smrg * 2 = Gob Height 8, Turing+ Page Kind mapping 6997ec681f3Smrg * 3 = Reserved for future use. 7007ec681f3Smrg * 7017ec681f3Smrg * 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further 7027ec681f3Smrg * bit remapping step that occurs at an even lower level than the 7037ec681f3Smrg * page kind and block linear swizzles. This causes the layout of 7047ec681f3Smrg * surfaces mapped in those SOC's GPUs to be incompatible with the 7057ec681f3Smrg * equivalent mapping on other GPUs in the same system. 7067ec681f3Smrg * 7077ec681f3Smrg * 0 = Tegra K1 - Tegra Parker/TX2 Layout. 7087ec681f3Smrg * 1 = Desktop GPU and Tegra Xavier+ Layout 7097ec681f3Smrg * 7107ec681f3Smrg * 25:23 c Lossless Framebuffer Compression type. 7117ec681f3Smrg * 7127ec681f3Smrg * 0 = none 7137ec681f3Smrg * 1 = ROP/3D, layout 1, exact compression format implied by Page 7147ec681f3Smrg * Kind field 7157ec681f3Smrg * 2 = ROP/3D, layout 2, exact compression format implied by Page 7167ec681f3Smrg * Kind field 7177ec681f3Smrg * 3 = CDE horizontal 7187ec681f3Smrg * 4 = CDE vertical 7197ec681f3Smrg * 5 = Reserved for future use 7207ec681f3Smrg * 6 = Reserved for future use 7217ec681f3Smrg * 7 = Reserved for future use 7227ec681f3Smrg * 7237ec681f3Smrg * 55:25 - Reserved for future use. Must be zero. 7247ec681f3Smrg */ 7257ec681f3Smrg#define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(c, s, g, k, h) \ 7267ec681f3Smrg fourcc_mod_code(NVIDIA, (0x10 | \ 7277ec681f3Smrg ((h) & 0xf) | \ 7287ec681f3Smrg (((k) & 0xff) << 12) | \ 7297ec681f3Smrg (((g) & 0x3) << 20) | \ 7307ec681f3Smrg (((s) & 0x1) << 22) | \ 7317ec681f3Smrg (((c) & 0x7) << 23))) 7327ec681f3Smrg 7337ec681f3Smrg/* To grandfather in prior block linear format modifiers to the above layout, 7347ec681f3Smrg * the page kind "0", which corresponds to "pitch/linear" and hence is unusable 7357ec681f3Smrg * with block-linear layouts, is remapped within drivers to the value 0xfe, 7367ec681f3Smrg * which corresponds to the "generic" kind used for simple single-sample 7377ec681f3Smrg * uncompressed color formats on Fermi - Volta GPUs. 7387ec681f3Smrg */ 7397ec681f3Smrgstatic __inline__ __u64 7407ec681f3Smrgdrm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) 7417ec681f3Smrg{ 7427ec681f3Smrg if (!(modifier & 0x10) || (modifier & (0xff << 12))) 7437ec681f3Smrg return modifier; 7447ec681f3Smrg else 7457ec681f3Smrg return modifier | (0xfe << 12); 7467ec681f3Smrg} 7477ec681f3Smrg 7487ec681f3Smrg/* 7497ec681f3Smrg * 16Bx2 Block Linear layout, used by Tegra K1 and later 75001e04c3fSmrg * 75101e04c3fSmrg * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked 75201e04c3fSmrg * vertically by a power of 2 (1 to 32 GOBs) to form a block. 75301e04c3fSmrg * 75401e04c3fSmrg * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. 75501e04c3fSmrg * 75601e04c3fSmrg * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. 75701e04c3fSmrg * Valid values are: 75801e04c3fSmrg * 75901e04c3fSmrg * 0 == ONE_GOB 76001e04c3fSmrg * 1 == TWO_GOBS 76101e04c3fSmrg * 2 == FOUR_GOBS 76201e04c3fSmrg * 3 == EIGHT_GOBS 76301e04c3fSmrg * 4 == SIXTEEN_GOBS 76401e04c3fSmrg * 5 == THIRTYTWO_GOBS 76501e04c3fSmrg * 76601e04c3fSmrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 76701e04c3fSmrg * in full detail. 76801e04c3fSmrg */ 76901e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \ 7707ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0, (v)) 77101e04c3fSmrg 77201e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \ 7737ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0) 77401e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \ 7757ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1) 77601e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \ 7777ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2) 77801e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \ 7797ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3) 78001e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \ 7817ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4) 78201e04c3fSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \ 7837ec681f3Smrg DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5) 78401e04c3fSmrg 78501e04c3fSmrg/* 78601e04c3fSmrg * Some Broadcom modifiers take parameters, for example the number of 78701e04c3fSmrg * vertical lines in the image. Reserve the lower 32 bits for modifier 78801e04c3fSmrg * type, and the next 24 bits for parameters. Top 8 bits are the 78901e04c3fSmrg * vendor code. 79001e04c3fSmrg */ 79101e04c3fSmrg#define __fourcc_mod_broadcom_param_shift 8 79201e04c3fSmrg#define __fourcc_mod_broadcom_param_bits 48 79301e04c3fSmrg#define fourcc_mod_broadcom_code(val, params) \ 79401e04c3fSmrg fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) 79501e04c3fSmrg#define fourcc_mod_broadcom_param(m) \ 79601e04c3fSmrg ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ 79701e04c3fSmrg ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) 79801e04c3fSmrg#define fourcc_mod_broadcom_mod(m) \ 79901e04c3fSmrg ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ 80001e04c3fSmrg __fourcc_mod_broadcom_param_shift)) 80101e04c3fSmrg 80201e04c3fSmrg/* 80301e04c3fSmrg * Broadcom VC4 "T" format 80401e04c3fSmrg * 80501e04c3fSmrg * This is the primary layout that the V3D GPU can texture from (it 80601e04c3fSmrg * can't do linear). The T format has: 80701e04c3fSmrg * 80801e04c3fSmrg * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 80901e04c3fSmrg * pixels at 32 bit depth. 81001e04c3fSmrg * 81101e04c3fSmrg * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually 81201e04c3fSmrg * 16x16 pixels). 81301e04c3fSmrg * 81401e04c3fSmrg * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On 81501e04c3fSmrg * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows 81601e04c3fSmrg * they're (TR, BR, BL, TL), where bottom left is start of memory. 81701e04c3fSmrg * 81801e04c3fSmrg * - an image made of 4k tiles in rows either left-to-right (even rows of 4k 81901e04c3fSmrg * tiles) or right-to-left (odd rows of 4k tiles). 82001e04c3fSmrg */ 82101e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) 82201e04c3fSmrg 82301e04c3fSmrg/* 82401e04c3fSmrg * Broadcom SAND format 82501e04c3fSmrg * 82601e04c3fSmrg * This is the native format that the H.264 codec block uses. For VC4 82701e04c3fSmrg * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. 82801e04c3fSmrg * 82901e04c3fSmrg * The image can be considered to be split into columns, and the 83001e04c3fSmrg * columns are placed consecutively into memory. The width of those 83101e04c3fSmrg * columns can be either 32, 64, 128, or 256 pixels, but in practice 83201e04c3fSmrg * only 128 pixel columns are used. 83301e04c3fSmrg * 83401e04c3fSmrg * The pitch between the start of each column is set to optimally 83501e04c3fSmrg * switch between SDRAM banks. This is passed as the number of lines 83601e04c3fSmrg * of column width in the modifier (we can't use the stride value due 83701e04c3fSmrg * to various core checks that look at it , so you should set the 83801e04c3fSmrg * stride to width*cpp). 83901e04c3fSmrg * 84001e04c3fSmrg * Note that the column height for this format modifier is the same 84101e04c3fSmrg * for all of the planes, assuming that each column contains both Y 84201e04c3fSmrg * and UV. Some SAND-using hardware stores UV in a separate tiled 84301e04c3fSmrg * image from Y to reduce the column height, which is not supported 84401e04c3fSmrg * with these modifiers. 84501e04c3fSmrg */ 84601e04c3fSmrg 84701e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ 84801e04c3fSmrg fourcc_mod_broadcom_code(2, v) 84901e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ 85001e04c3fSmrg fourcc_mod_broadcom_code(3, v) 85101e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ 85201e04c3fSmrg fourcc_mod_broadcom_code(4, v) 85301e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ 85401e04c3fSmrg fourcc_mod_broadcom_code(5, v) 85501e04c3fSmrg 85601e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ 85701e04c3fSmrg DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) 85801e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ 85901e04c3fSmrg DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) 86001e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ 86101e04c3fSmrg DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) 86201e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ 86301e04c3fSmrg DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) 86401e04c3fSmrg 86501e04c3fSmrg/* Broadcom UIF format 86601e04c3fSmrg * 86701e04c3fSmrg * This is the common format for the current Broadcom multimedia 86801e04c3fSmrg * blocks, including V3D 3.x and newer, newer video codecs, and 86901e04c3fSmrg * displays. 87001e04c3fSmrg * 87101e04c3fSmrg * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), 87201e04c3fSmrg * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are 87301e04c3fSmrg * stored in columns, with padding between the columns to ensure that 87401e04c3fSmrg * moving from one column to the next doesn't hit the same SDRAM page 87501e04c3fSmrg * bank. 87601e04c3fSmrg * 87701e04c3fSmrg * To calculate the padding, it is assumed that each hardware block 87801e04c3fSmrg * and the software driving it knows the platform's SDRAM page size, 87901e04c3fSmrg * number of banks, and XOR address, and that it's identical between 88001e04c3fSmrg * all blocks using the format. This tiling modifier will use XOR as 88101e04c3fSmrg * necessary to reduce the padding. If a hardware block can't do XOR, 88201e04c3fSmrg * the assumption is that a no-XOR tiling modifier will be created. 88301e04c3fSmrg */ 88401e04c3fSmrg#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) 88501e04c3fSmrg 88653c12917Smaya/* 88753c12917Smaya * Arm Framebuffer Compression (AFBC) modifiers 88853c12917Smaya * 88953c12917Smaya * AFBC is a proprietary lossless image compression protocol and format. 89053c12917Smaya * It provides fine-grained random access and minimizes the amount of data 89153c12917Smaya * transferred between IP blocks. 89253c12917Smaya * 89353c12917Smaya * AFBC has several features which may be supported and/or used, which are 89453c12917Smaya * represented using bits in the modifier. Not all combinations are valid, 89553c12917Smaya * and different devices or use-cases may support different combinations. 89653c12917Smaya * 89753c12917Smaya * Further information on the use of AFBC modifiers can be found in 89853c12917Smaya * Documentation/gpu/afbc.rst 89953c12917Smaya */ 9007ec681f3Smrg 9017ec681f3Smrg/* 9027ec681f3Smrg * The top 4 bits (out of the 56 bits alloted for specifying vendor specific 9037ec681f3Smrg * modifiers) denote the category for modifiers. Currently we have three 9047ec681f3Smrg * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of 9057ec681f3Smrg * sixteen different categories. 9067ec681f3Smrg */ 9077ec681f3Smrg#define DRM_FORMAT_MOD_ARM_CODE(__type, __val) \ 9087ec681f3Smrg fourcc_mod_code(ARM, ((__u64)(__type) << 52) | ((__val) & 0x000fffffffffffffULL)) 9097ec681f3Smrg 9107ec681f3Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFBC 0x00 9117ec681f3Smrg#define DRM_FORMAT_MOD_ARM_TYPE_MISC 0x01 9127ec681f3Smrg 9137ec681f3Smrg#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) \ 9147ec681f3Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFBC, __afbc_mode) 91553c12917Smaya 91653c12917Smaya/* 91753c12917Smaya * AFBC superblock size 91853c12917Smaya * 91953c12917Smaya * Indicates the superblock size(s) used for the AFBC buffer. The buffer 92053c12917Smaya * size (in pixels) must be aligned to a multiple of the superblock size. 92153c12917Smaya * Four lowest significant bits(LSBs) are reserved for block size. 92253c12917Smaya * 92353c12917Smaya * Where one superblock size is specified, it applies to all planes of the 92453c12917Smaya * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified, 92553c12917Smaya * the first applies to the Luma plane and the second applies to the Chroma 92653c12917Smaya * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma). 92753c12917Smaya * Multiple superblock sizes are only valid for multi-plane YCbCr formats. 92853c12917Smaya */ 92953c12917Smaya#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf 93053c12917Smaya#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) 93153c12917Smaya#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) 93253c12917Smaya#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 (3ULL) 93353c12917Smaya#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL) 93453c12917Smaya 93553c12917Smaya/* 93653c12917Smaya * AFBC lossless colorspace transform 93753c12917Smaya * 93853c12917Smaya * Indicates that the buffer makes use of the AFBC lossless colorspace 93953c12917Smaya * transform. 94053c12917Smaya */ 94153c12917Smaya#define AFBC_FORMAT_MOD_YTR (1ULL << 4) 94253c12917Smaya 94353c12917Smaya/* 94453c12917Smaya * AFBC block-split 94553c12917Smaya * 94653c12917Smaya * Indicates that the payload of each superblock is split. The second 94753c12917Smaya * half of the payload is positioned at a predefined offset from the start 94853c12917Smaya * of the superblock payload. 94953c12917Smaya */ 95053c12917Smaya#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) 95153c12917Smaya 95253c12917Smaya/* 95353c12917Smaya * AFBC sparse layout 95453c12917Smaya * 95553c12917Smaya * This flag indicates that the payload of each superblock must be stored at a 95653c12917Smaya * predefined position relative to the other superblocks in the same AFBC 95753c12917Smaya * buffer. This order is the same order used by the header buffer. In this mode 95853c12917Smaya * each superblock is given the same amount of space as an uncompressed 95953c12917Smaya * superblock of the particular format would require, rounding up to the next 96053c12917Smaya * multiple of 128 bytes in size. 96153c12917Smaya */ 96253c12917Smaya#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) 96353c12917Smaya 96453c12917Smaya/* 96553c12917Smaya * AFBC copy-block restrict 96653c12917Smaya * 96753c12917Smaya * Buffers with this flag must obey the copy-block restriction. The restriction 96853c12917Smaya * is such that there are no copy-blocks referring across the border of 8x8 96953c12917Smaya * blocks. For the subsampled data the 8x8 limitation is also subsampled. 97053c12917Smaya */ 97153c12917Smaya#define AFBC_FORMAT_MOD_CBR (1ULL << 7) 97253c12917Smaya 97353c12917Smaya/* 97453c12917Smaya * AFBC tiled layout 97553c12917Smaya * 97653c12917Smaya * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all 97753c12917Smaya * superblocks inside a tile are stored together in memory. 8x8 tiles are used 97853c12917Smaya * for pixel formats up to and including 32 bpp while 4x4 tiles are used for 97953c12917Smaya * larger bpp formats. The order between the tiles is scan line. 98053c12917Smaya * When the tiled layout is used, the buffer size (in pixels) must be aligned 98153c12917Smaya * to the tile size. 98253c12917Smaya */ 98353c12917Smaya#define AFBC_FORMAT_MOD_TILED (1ULL << 8) 98453c12917Smaya 98553c12917Smaya/* 98653c12917Smaya * AFBC solid color blocks 98753c12917Smaya * 98853c12917Smaya * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth 98953c12917Smaya * can be reduced if a whole superblock is a single color. 99053c12917Smaya */ 99153c12917Smaya#define AFBC_FORMAT_MOD_SC (1ULL << 9) 99253c12917Smaya 99353c12917Smaya/* 99453c12917Smaya * AFBC double-buffer 99553c12917Smaya * 99653c12917Smaya * Indicates that the buffer is allocated in a layout safe for front-buffer 99753c12917Smaya * rendering. 99853c12917Smaya */ 99953c12917Smaya#define AFBC_FORMAT_MOD_DB (1ULL << 10) 100053c12917Smaya 100153c12917Smaya/* 100253c12917Smaya * AFBC buffer content hints 100353c12917Smaya * 100453c12917Smaya * Indicates that the buffer includes per-superblock content hints. 100553c12917Smaya */ 100653c12917Smaya#define AFBC_FORMAT_MOD_BCH (1ULL << 11) 100753c12917Smaya 10087ec681f3Smrg/* AFBC uncompressed storage mode 10097ec681f3Smrg * 10107ec681f3Smrg * Indicates that the buffer is using AFBC uncompressed storage mode. 10117ec681f3Smrg * In this mode all superblock payloads in the buffer use the uncompressed 10127ec681f3Smrg * storage mode, which is usually only used for data which cannot be compressed. 10137ec681f3Smrg * The buffer layout is the same as for AFBC buffers without USM set, this only 10147ec681f3Smrg * affects the storage mode of the individual superblocks. Note that even a 10157ec681f3Smrg * buffer without USM set may use uncompressed storage mode for some or all 10167ec681f3Smrg * superblocks, USM just guarantees it for all. 10177ec681f3Smrg */ 10187ec681f3Smrg#define AFBC_FORMAT_MOD_USM (1ULL << 12) 10197ec681f3Smrg 10207ec681f3Smrg/* 10217ec681f3Smrg * Arm Fixed-Rate Compression (AFRC) modifiers 10227ec681f3Smrg * 10237ec681f3Smrg * AFRC is a proprietary fixed rate image compression protocol and format, 10247ec681f3Smrg * designed to provide guaranteed bandwidth and memory footprint 10257ec681f3Smrg * reductions in graphics and media use-cases. 10267ec681f3Smrg * 10277ec681f3Smrg * AFRC buffers consist of one or more planes, with the same components 10287ec681f3Smrg * and meaning as an uncompressed buffer using the same pixel format. 10297ec681f3Smrg * 10307ec681f3Smrg * Within each plane, the pixel/luma/chroma values are grouped into 10317ec681f3Smrg * "coding unit" blocks which are individually compressed to a 10327ec681f3Smrg * fixed size (in bytes). All coding units within a given plane of a buffer 10337ec681f3Smrg * store the same number of values, and have the same compressed size. 10347ec681f3Smrg * 10357ec681f3Smrg * The coding unit size is configurable, allowing different rates of compression. 10367ec681f3Smrg * 10377ec681f3Smrg * The start of each AFRC buffer plane must be aligned to an alignment granule which 10387ec681f3Smrg * depends on the coding unit size. 10397ec681f3Smrg * 10407ec681f3Smrg * Coding Unit Size Plane Alignment 10417ec681f3Smrg * ---------------- --------------- 10427ec681f3Smrg * 16 bytes 1024 bytes 10437ec681f3Smrg * 24 bytes 512 bytes 10447ec681f3Smrg * 32 bytes 2048 bytes 10457ec681f3Smrg * 10467ec681f3Smrg * Coding units are grouped into paging tiles. AFRC buffer dimensions must be aligned 10477ec681f3Smrg * to a multiple of the paging tile dimensions. 10487ec681f3Smrg * The dimensions of each paging tile depend on whether the buffer is optimised for 10497ec681f3Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 10507ec681f3Smrg * 10517ec681f3Smrg * Layout Paging Tile Width Paging Tile Height 10527ec681f3Smrg * ------ ----------------- ------------------ 10537ec681f3Smrg * SCAN 16 coding units 4 coding units 10547ec681f3Smrg * ROT 8 coding units 8 coding units 10557ec681f3Smrg * 10567ec681f3Smrg * The dimensions of each coding unit depend on the number of components 10577ec681f3Smrg * in the compressed plane and whether the buffer is optimised for 10587ec681f3Smrg * scanline (SCAN layout) or rotated (ROT layout) access. 10597ec681f3Smrg * 10607ec681f3Smrg * Number of Components in Plane Layout Coding Unit Width Coding Unit Height 10617ec681f3Smrg * ----------------------------- --------- ----------------- ------------------ 10627ec681f3Smrg * 1 SCAN 16 samples 4 samples 10637ec681f3Smrg * Example: 16x4 luma samples in a 'Y' plane 10647ec681f3Smrg * 16x4 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 10657ec681f3Smrg * ----------------------------- --------- ----------------- ------------------ 10667ec681f3Smrg * 1 ROT 8 samples 8 samples 10677ec681f3Smrg * Example: 8x8 luma samples in a 'Y' plane 10687ec681f3Smrg * 8x8 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer 10697ec681f3Smrg * ----------------------------- --------- ----------------- ------------------ 10707ec681f3Smrg * 2 DONT CARE 8 samples 4 samples 10717ec681f3Smrg * Example: 8x4 chroma pairs in the 'UV' plane of a semi-planar YUV buffer 10727ec681f3Smrg * ----------------------------- --------- ----------------- ------------------ 10737ec681f3Smrg * 3 DONT CARE 4 samples 4 samples 10747ec681f3Smrg * Example: 4x4 pixels in an RGB buffer without alpha 10757ec681f3Smrg * ----------------------------- --------- ----------------- ------------------ 10767ec681f3Smrg * 4 DONT CARE 4 samples 4 samples 10777ec681f3Smrg * Example: 4x4 pixels in an RGB buffer with alpha 10787ec681f3Smrg */ 10797ec681f3Smrg 10807ec681f3Smrg#define DRM_FORMAT_MOD_ARM_TYPE_AFRC 0x02 10817ec681f3Smrg 10827ec681f3Smrg#define DRM_FORMAT_MOD_ARM_AFRC(__afrc_mode) \ 10837ec681f3Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFRC, __afrc_mode) 10847ec681f3Smrg 10857ec681f3Smrg/* 10867ec681f3Smrg * AFRC coding unit size modifier. 10877ec681f3Smrg * 10887ec681f3Smrg * Indicates the number of bytes used to store each compressed coding unit for 10897ec681f3Smrg * one or more planes in an AFRC encoded buffer. The coding unit size for chrominance 10907ec681f3Smrg * is the same for both Cb and Cr, which may be stored in separate planes. 10917ec681f3Smrg * 10927ec681f3Smrg * AFRC_FORMAT_MOD_CU_SIZE_P0 indicates the number of bytes used to store 10937ec681f3Smrg * each compressed coding unit in the first plane of the buffer. For RGBA buffers 10947ec681f3Smrg * this is the only plane, while for semi-planar and fully-planar YUV buffers, 10957ec681f3Smrg * this corresponds to the luma plane. 10967ec681f3Smrg * 10977ec681f3Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 indicates the number of bytes used to store 10987ec681f3Smrg * each compressed coding unit in the second and third planes in the buffer. 10997ec681f3Smrg * For semi-planar and fully-planar YUV buffers, this corresponds to the chroma plane(s). 11007ec681f3Smrg * 11017ec681f3Smrg * For single-plane buffers, AFRC_FORMAT_MOD_CU_SIZE_P0 must be specified 11027ec681f3Smrg * and AFRC_FORMAT_MOD_CU_SIZE_P12 must be zero. 11037ec681f3Smrg * For semi-planar and fully-planar buffers, both AFRC_FORMAT_MOD_CU_SIZE_P0 and 11047ec681f3Smrg * AFRC_FORMAT_MOD_CU_SIZE_P12 must be specified. 11057ec681f3Smrg */ 11067ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_MASK 0xf 11077ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_16 (1ULL) 11087ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_24 (2ULL) 11097ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_32 (3ULL) 11107ec681f3Smrg 11117ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P0(__afrc_cu_size) (__afrc_cu_size) 11127ec681f3Smrg#define AFRC_FORMAT_MOD_CU_SIZE_P12(__afrc_cu_size) ((__afrc_cu_size) << 4) 11137ec681f3Smrg 11147ec681f3Smrg/* 11157ec681f3Smrg * AFRC scanline memory layout. 11167ec681f3Smrg * 11177ec681f3Smrg * Indicates if the buffer uses the scanline-optimised layout 11187ec681f3Smrg * for an AFRC encoded buffer, otherwise, it uses the rotation-optimised layout. 11197ec681f3Smrg * The memory layout is the same for all planes. 11207ec681f3Smrg */ 11217ec681f3Smrg#define AFRC_FORMAT_MOD_LAYOUT_SCAN (1ULL << 8) 11227ec681f3Smrg 11237ec681f3Smrg/* 11247ec681f3Smrg * Arm 16x16 Block U-Interleaved modifier 11257ec681f3Smrg * 11267ec681f3Smrg * This is used by Arm Mali Utgard and Midgard GPUs. It divides the image 11277ec681f3Smrg * into 16x16 pixel blocks. Blocks are stored linearly in order, but pixels 11287ec681f3Smrg * in the block are reordered. 11297ec681f3Smrg */ 11307ec681f3Smrg#define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ 11317ec681f3Smrg DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) 11327ec681f3Smrg 113353c12917Smaya/* 113453c12917Smaya * Allwinner tiled modifier 113553c12917Smaya * 113653c12917Smaya * This tiling mode is implemented by the VPU found on all Allwinner platforms, 113753c12917Smaya * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 113853c12917Smaya * planes. 113953c12917Smaya * 114053c12917Smaya * With this tiling, the luminance samples are disposed in tiles representing 114153c12917Smaya * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. 114253c12917Smaya * The pixel order in each tile is linear and the tiles are disposed linearly, 114353c12917Smaya * both in row-major order. 114453c12917Smaya */ 114553c12917Smaya#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) 114653c12917Smaya 11477ec681f3Smrg/* 11487ec681f3Smrg * Amlogic Video Framebuffer Compression modifiers 11497ec681f3Smrg * 11507ec681f3Smrg * Amlogic uses a proprietary lossless image compression protocol and format 11517ec681f3Smrg * for their hardware video codec accelerators, either video decoders or 11527ec681f3Smrg * video input encoders. 11537ec681f3Smrg * 11547ec681f3Smrg * It considerably reduces memory bandwidth while writing and reading 11557ec681f3Smrg * frames in memory. 11567ec681f3Smrg * 11577ec681f3Smrg * The underlying storage is considered to be 3 components, 8bit or 10-bit 11587ec681f3Smrg * per component YCbCr 420, single plane : 11597ec681f3Smrg * - DRM_FORMAT_YUV420_8BIT 11607ec681f3Smrg * - DRM_FORMAT_YUV420_10BIT 11617ec681f3Smrg * 11627ec681f3Smrg * The first 8 bits of the mode defines the layout, then the following 8 bits 11637ec681f3Smrg * defines the options changing the layout. 11647ec681f3Smrg * 11657ec681f3Smrg * Not all combinations are valid, and different SoCs may support different 11667ec681f3Smrg * combinations of layout and options. 11677ec681f3Smrg */ 11687ec681f3Smrg#define __fourcc_mod_amlogic_layout_mask 0xff 11697ec681f3Smrg#define __fourcc_mod_amlogic_options_shift 8 11707ec681f3Smrg#define __fourcc_mod_amlogic_options_mask 0xff 11717ec681f3Smrg 11727ec681f3Smrg#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \ 11737ec681f3Smrg fourcc_mod_code(AMLOGIC, \ 11747ec681f3Smrg ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ 11757ec681f3Smrg (((__options) & __fourcc_mod_amlogic_options_mask) \ 11767ec681f3Smrg << __fourcc_mod_amlogic_options_shift)) 11777ec681f3Smrg 11787ec681f3Smrg/* Amlogic FBC Layouts */ 11797ec681f3Smrg 11807ec681f3Smrg/* 11817ec681f3Smrg * Amlogic FBC Basic Layout 11827ec681f3Smrg * 11837ec681f3Smrg * The basic layout is composed of: 11847ec681f3Smrg * - a body content organized in 64x32 superblocks with 4096 bytes per 11857ec681f3Smrg * superblock in default mode. 11867ec681f3Smrg * - a 32 bytes per 128x64 header block 11877ec681f3Smrg * 11887ec681f3Smrg * This layout is transferrable between Amlogic SoCs supporting this modifier. 11897ec681f3Smrg */ 11907ec681f3Smrg#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) 11917ec681f3Smrg 11927ec681f3Smrg/* 11937ec681f3Smrg * Amlogic FBC Scatter Memory layout 11947ec681f3Smrg * 11957ec681f3Smrg * Indicates the header contains IOMMU references to the compressed 11967ec681f3Smrg * frames content to optimize memory access and layout. 11977ec681f3Smrg * 11987ec681f3Smrg * In this mode, only the header memory address is needed, thus the 11997ec681f3Smrg * content memory organization is tied to the current producer 12007ec681f3Smrg * execution and cannot be saved/dumped neither transferrable between 12017ec681f3Smrg * Amlogic SoCs supporting this modifier. 12027ec681f3Smrg * 12037ec681f3Smrg * Due to the nature of the layout, these buffers are not expected to 12047ec681f3Smrg * be accessible by the user-space clients, but only accessible by the 12057ec681f3Smrg * hardware producers and consumers. 12067ec681f3Smrg * 12077ec681f3Smrg * The user-space clients should expect a failure while trying to mmap 12087ec681f3Smrg * the DMA-BUF handle returned by the producer. 12097ec681f3Smrg */ 12107ec681f3Smrg#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) 12117ec681f3Smrg 12127ec681f3Smrg/* Amlogic FBC Layout Options Bit Mask */ 12137ec681f3Smrg 12147ec681f3Smrg/* 12157ec681f3Smrg * Amlogic FBC Memory Saving mode 12167ec681f3Smrg * 12177ec681f3Smrg * Indicates the storage is packed when pixel size is multiple of word 12187ec681f3Smrg * boudaries, i.e. 8bit should be stored in this mode to save allocation 12197ec681f3Smrg * memory. 12207ec681f3Smrg * 12217ec681f3Smrg * This mode reduces body layout to 3072 bytes per 64x32 superblock with 12227ec681f3Smrg * the basic layout and 3200 bytes per 64x32 superblock combined with 12237ec681f3Smrg * the scatter layout. 12247ec681f3Smrg */ 12257ec681f3Smrg#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) 12267ec681f3Smrg 12277ec681f3Smrg/* 12287ec681f3Smrg * AMD modifiers 12297ec681f3Smrg * 12307ec681f3Smrg * Memory layout: 12317ec681f3Smrg * 12327ec681f3Smrg * without DCC: 12337ec681f3Smrg * - main surface 12347ec681f3Smrg * 12357ec681f3Smrg * with DCC & without DCC_RETILE: 12367ec681f3Smrg * - main surface in plane 0 12377ec681f3Smrg * - DCC surface in plane 1 (RB-aligned, pipe-aligned if DCC_PIPE_ALIGN is set) 12387ec681f3Smrg * 12397ec681f3Smrg * with DCC & DCC_RETILE: 12407ec681f3Smrg * - main surface in plane 0 12417ec681f3Smrg * - displayable DCC surface in plane 1 (not RB-aligned & not pipe-aligned) 12427ec681f3Smrg * - pipe-aligned DCC surface in plane 2 (RB-aligned & pipe-aligned) 12437ec681f3Smrg * 12447ec681f3Smrg * For multi-plane formats the above surfaces get merged into one plane for 12457ec681f3Smrg * each format plane, based on the required alignment only. 12467ec681f3Smrg * 12477ec681f3Smrg * Bits Parameter Notes 12487ec681f3Smrg * ----- ------------------------ --------------------------------------------- 12497ec681f3Smrg * 12507ec681f3Smrg * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_* 12517ec681f3Smrg * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_* 12527ec681f3Smrg * 13 DCC 12537ec681f3Smrg * 14 DCC_RETILE 12547ec681f3Smrg * 15 DCC_PIPE_ALIGN 12557ec681f3Smrg * 16 DCC_INDEPENDENT_64B 12567ec681f3Smrg * 17 DCC_INDEPENDENT_128B 12577ec681f3Smrg * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_* 12587ec681f3Smrg * 20 DCC_CONSTANT_ENCODE 12597ec681f3Smrg * 23:21 PIPE_XOR_BITS Only for some chips 12607ec681f3Smrg * 26:24 BANK_XOR_BITS Only for some chips 12617ec681f3Smrg * 29:27 PACKERS Only for some chips 12627ec681f3Smrg * 32:30 RB Only for some chips 12637ec681f3Smrg * 35:33 PIPE Only for some chips 12647ec681f3Smrg * 55:36 - Reserved for future use, must be zero 12657ec681f3Smrg */ 12667ec681f3Smrg#define AMD_FMT_MOD fourcc_mod_code(AMD, 0) 12677ec681f3Smrg 12687ec681f3Smrg#define IS_AMD_FMT_MOD(val) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD) 12697ec681f3Smrg 12707ec681f3Smrg/* Reserve 0 for GFX8 and older */ 12717ec681f3Smrg#define AMD_FMT_MOD_TILE_VER_GFX9 1 12727ec681f3Smrg#define AMD_FMT_MOD_TILE_VER_GFX10 2 12737ec681f3Smrg#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3 12747ec681f3Smrg 12757ec681f3Smrg/* 12767ec681f3Smrg * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical 12777ec681f3Smrg * version. 12787ec681f3Smrg */ 12797ec681f3Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S 9 12807ec681f3Smrg 12817ec681f3Smrg/* 12827ec681f3Smrg * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has 12837ec681f3Smrg * GFX9 as canonical version. 12847ec681f3Smrg */ 12857ec681f3Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D 10 12867ec681f3Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25 12877ec681f3Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26 12887ec681f3Smrg#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27 12897ec681f3Smrg 12907ec681f3Smrg#define AMD_FMT_MOD_DCC_BLOCK_64B 0 12917ec681f3Smrg#define AMD_FMT_MOD_DCC_BLOCK_128B 1 12927ec681f3Smrg#define AMD_FMT_MOD_DCC_BLOCK_256B 2 12937ec681f3Smrg 12947ec681f3Smrg#define AMD_FMT_MOD_TILE_VERSION_SHIFT 0 12957ec681f3Smrg#define AMD_FMT_MOD_TILE_VERSION_MASK 0xFF 12967ec681f3Smrg#define AMD_FMT_MOD_TILE_SHIFT 8 12977ec681f3Smrg#define AMD_FMT_MOD_TILE_MASK 0x1F 12987ec681f3Smrg 12997ec681f3Smrg/* Whether DCC compression is enabled. */ 13007ec681f3Smrg#define AMD_FMT_MOD_DCC_SHIFT 13 13017ec681f3Smrg#define AMD_FMT_MOD_DCC_MASK 0x1 13027ec681f3Smrg 13037ec681f3Smrg/* 13047ec681f3Smrg * Whether to include two DCC surfaces, one which is rb & pipe aligned, and 13057ec681f3Smrg * one which is not-aligned. 13067ec681f3Smrg */ 13077ec681f3Smrg#define AMD_FMT_MOD_DCC_RETILE_SHIFT 14 13087ec681f3Smrg#define AMD_FMT_MOD_DCC_RETILE_MASK 0x1 13097ec681f3Smrg 13107ec681f3Smrg/* Only set if DCC_RETILE = false */ 13117ec681f3Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_SHIFT 15 13127ec681f3Smrg#define AMD_FMT_MOD_DCC_PIPE_ALIGN_MASK 0x1 13137ec681f3Smrg 13147ec681f3Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_SHIFT 16 13157ec681f3Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_64B_MASK 0x1 13167ec681f3Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_SHIFT 17 13177ec681f3Smrg#define AMD_FMT_MOD_DCC_INDEPENDENT_128B_MASK 0x1 13187ec681f3Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_SHIFT 18 13197ec681f3Smrg#define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 13207ec681f3Smrg 13217ec681f3Smrg/* 13227ec681f3Smrg * DCC supports embedding some clear colors directly in the DCC surface. 13237ec681f3Smrg * However, on older GPUs the rendering HW ignores the embedded clear color 13247ec681f3Smrg * and prefers the driver provided color. This necessitates doing a fastclear 13257ec681f3Smrg * eliminate operation before a process transfers control. 13267ec681f3Smrg * 13277ec681f3Smrg * If this bit is set that means the fastclear eliminate is not needed for these 13287ec681f3Smrg * embeddable colors. 13297ec681f3Smrg */ 13307ec681f3Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_SHIFT 20 13317ec681f3Smrg#define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_MASK 0x1 13327ec681f3Smrg 13337ec681f3Smrg/* 13347ec681f3Smrg * The below fields are for accounting for per GPU differences. These are only 13357ec681f3Smrg * relevant for GFX9 and later and if the tile field is *_X/_T. 13367ec681f3Smrg * 13377ec681f3Smrg * PIPE_XOR_BITS = always needed 13387ec681f3Smrg * BANK_XOR_BITS = only for TILE_VER_GFX9 13397ec681f3Smrg * PACKERS = only for TILE_VER_GFX10_RBPLUS 13407ec681f3Smrg * RB = only for TILE_VER_GFX9 & DCC 13417ec681f3Smrg * PIPE = only for TILE_VER_GFX9 & DCC & (DCC_RETILE | DCC_PIPE_ALIGN) 13427ec681f3Smrg */ 13437ec681f3Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_SHIFT 21 13447ec681f3Smrg#define AMD_FMT_MOD_PIPE_XOR_BITS_MASK 0x7 13457ec681f3Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_SHIFT 24 13467ec681f3Smrg#define AMD_FMT_MOD_BANK_XOR_BITS_MASK 0x7 13477ec681f3Smrg#define AMD_FMT_MOD_PACKERS_SHIFT 27 13487ec681f3Smrg#define AMD_FMT_MOD_PACKERS_MASK 0x7 13497ec681f3Smrg#define AMD_FMT_MOD_RB_SHIFT 30 13507ec681f3Smrg#define AMD_FMT_MOD_RB_MASK 0x7 13517ec681f3Smrg#define AMD_FMT_MOD_PIPE_SHIFT 33 13527ec681f3Smrg#define AMD_FMT_MOD_PIPE_MASK 0x7 13537ec681f3Smrg 13547ec681f3Smrg#define AMD_FMT_MOD_SET(field, value) \ 13557ec681f3Smrg ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT) 13567ec681f3Smrg#define AMD_FMT_MOD_GET(field, value) \ 13577ec681f3Smrg (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK) 13587ec681f3Smrg#define AMD_FMT_MOD_CLEAR(field) \ 13597ec681f3Smrg (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT)) 13607ec681f3Smrg 136101e04c3fSmrg#if defined(__cplusplus) 136201e04c3fSmrg} 136301e04c3fSmrg#endif 136401e04c3fSmrg 136501e04c3fSmrg#endif /* DRM_FOURCC_H */ 1366