1b8e80941Smrg/* 2b8e80941Smrg * Copyright 2011 Intel Corporation 3b8e80941Smrg * 4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5b8e80941Smrg * copy of this software and associated documentation files (the "Software"), 6b8e80941Smrg * to deal in the Software without restriction, including without limitation 7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the 9b8e80941Smrg * Software is furnished to do so, subject to the following conditions: 10b8e80941Smrg * 11b8e80941Smrg * The above copyright notice and this permission notice (including the next 12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the 13b8e80941Smrg * Software. 14b8e80941Smrg * 15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18b8e80941Smrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19b8e80941Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20b8e80941Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21b8e80941Smrg * OTHER DEALINGS IN THE SOFTWARE. 22b8e80941Smrg */ 23b8e80941Smrg 24b8e80941Smrg#ifndef DRM_FOURCC_H 25b8e80941Smrg#define DRM_FOURCC_H 26b8e80941Smrg 27b8e80941Smrg#include "drm.h" 28b8e80941Smrg 29b8e80941Smrg#if defined(__cplusplus) 30b8e80941Smrgextern "C" { 31b8e80941Smrg#endif 32b8e80941Smrg 33b8e80941Smrg/** 34b8e80941Smrg * DOC: overview 35b8e80941Smrg * 36b8e80941Smrg * In the DRM subsystem, framebuffer pixel formats are described using the 37b8e80941Smrg * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the 38b8e80941Smrg * fourcc code, a Format Modifier may optionally be provided, in order to 39b8e80941Smrg * further describe the buffer's format - for example tiling or compression. 40b8e80941Smrg * 41b8e80941Smrg * Format Modifiers 42b8e80941Smrg * ---------------- 43b8e80941Smrg * 44b8e80941Smrg * Format modifiers are used in conjunction with a fourcc code, forming a 45b8e80941Smrg * unique fourcc:modifier pair. This format:modifier pair must fully define the 46b8e80941Smrg * format and data layout of the buffer, and should be the only way to describe 47b8e80941Smrg * that particular buffer. 48b8e80941Smrg * 49b8e80941Smrg * Having multiple fourcc:modifier pairs which describe the same layout should 50b8e80941Smrg * be avoided, as such aliases run the risk of different drivers exposing 51b8e80941Smrg * different names for the same data format, forcing userspace to understand 52b8e80941Smrg * that they are aliases. 53b8e80941Smrg * 54b8e80941Smrg * Format modifiers may change any property of the buffer, including the number 55b8e80941Smrg * of planes and/or the required allocation size. Format modifiers are 56b8e80941Smrg * vendor-namespaced, and as such the relationship between a fourcc code and a 57b8e80941Smrg * modifier is specific to the modifer being used. For example, some modifiers 58b8e80941Smrg * may preserve meaning - such as number of planes - from the fourcc code, 59b8e80941Smrg * whereas others may not. 60b8e80941Smrg * 61b8e80941Smrg * Vendors should document their modifier usage in as much detail as 62b8e80941Smrg * possible, to ensure maximum compatibility across devices, drivers and 63b8e80941Smrg * applications. 64b8e80941Smrg * 65b8e80941Smrg * The authoritative list of format modifier codes is found in 66b8e80941Smrg * `include/uapi/drm/drm_fourcc.h` 67b8e80941Smrg */ 68b8e80941Smrg 69b8e80941Smrg#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 70b8e80941Smrg ((__u32)(c) << 16) | ((__u32)(d) << 24)) 71b8e80941Smrg 72b8e80941Smrg#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */ 73b8e80941Smrg 74b8e80941Smrg/* Reserve 0 for the invalid format specifier */ 75b8e80941Smrg#define DRM_FORMAT_INVALID 0 76b8e80941Smrg 77b8e80941Smrg/* color index */ 78b8e80941Smrg#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 79b8e80941Smrg 80b8e80941Smrg/* 8 bpp Red */ 81b8e80941Smrg#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 82b8e80941Smrg 83b8e80941Smrg/* 16 bpp Red */ 84b8e80941Smrg#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ 85b8e80941Smrg 86b8e80941Smrg/* 16 bpp RG */ 87b8e80941Smrg#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 88b8e80941Smrg#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 89b8e80941Smrg 90b8e80941Smrg/* 32 bpp RG */ 91b8e80941Smrg#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ 92b8e80941Smrg#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ 93b8e80941Smrg 94b8e80941Smrg/* 8 bpp RGB */ 95b8e80941Smrg#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 96b8e80941Smrg#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 97b8e80941Smrg 98b8e80941Smrg/* 16 bpp RGB */ 99b8e80941Smrg#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 100b8e80941Smrg#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 101b8e80941Smrg#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 102b8e80941Smrg#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 103b8e80941Smrg 104b8e80941Smrg#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 105b8e80941Smrg#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 106b8e80941Smrg#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 107b8e80941Smrg#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 108b8e80941Smrg 109b8e80941Smrg#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 110b8e80941Smrg#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 111b8e80941Smrg#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 112b8e80941Smrg#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 113b8e80941Smrg 114b8e80941Smrg#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 115b8e80941Smrg#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 116b8e80941Smrg#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 117b8e80941Smrg#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 118b8e80941Smrg 119b8e80941Smrg#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 120b8e80941Smrg#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 121b8e80941Smrg 122b8e80941Smrg/* 24 bpp RGB */ 123b8e80941Smrg#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 124b8e80941Smrg#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 125b8e80941Smrg 126b8e80941Smrg/* 32 bpp RGB */ 127b8e80941Smrg#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 128b8e80941Smrg#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 129b8e80941Smrg#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 130b8e80941Smrg#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 131b8e80941Smrg 132b8e80941Smrg#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 133b8e80941Smrg#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 134b8e80941Smrg#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 135b8e80941Smrg#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 136b8e80941Smrg 137b8e80941Smrg#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 138b8e80941Smrg#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 139b8e80941Smrg#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 140b8e80941Smrg#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 141b8e80941Smrg 142b8e80941Smrg#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 143b8e80941Smrg#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 144b8e80941Smrg#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 145b8e80941Smrg#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 146b8e80941Smrg 147b8e80941Smrg/* packed YCbCr */ 148b8e80941Smrg#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 149b8e80941Smrg#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 150b8e80941Smrg#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 151b8e80941Smrg#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 152b8e80941Smrg 153b8e80941Smrg#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 154b8e80941Smrg#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ 155b8e80941Smrg 156b8e80941Smrg/* 157b8e80941Smrg * packed YCbCr420 2x2 tiled formats 158b8e80941Smrg * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile 159b8e80941Smrg */ 160b8e80941Smrg/* [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 */ 161b8e80941Smrg#define DRM_FORMAT_Y0L0 fourcc_code('Y', '0', 'L', '0') 162b8e80941Smrg/* [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 */ 163b8e80941Smrg#define DRM_FORMAT_X0L0 fourcc_code('X', '0', 'L', '0') 164b8e80941Smrg 165b8e80941Smrg/* [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 166b8e80941Smrg#define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 167b8e80941Smrg/* [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian */ 168b8e80941Smrg#define DRM_FORMAT_X0L2 fourcc_code('X', '0', 'L', '2') 169b8e80941Smrg 170b8e80941Smrg/* 171b8e80941Smrg * 2 plane RGB + A 172b8e80941Smrg * index 0 = RGB plane, same format as the corresponding non _A8 format has 173b8e80941Smrg * index 1 = A plane, [7:0] A 174b8e80941Smrg */ 175b8e80941Smrg#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') 176b8e80941Smrg#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') 177b8e80941Smrg#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') 178b8e80941Smrg#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') 179b8e80941Smrg#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') 180b8e80941Smrg#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') 181b8e80941Smrg#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') 182b8e80941Smrg#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') 183b8e80941Smrg 184b8e80941Smrg/* 185b8e80941Smrg * 2 plane YCbCr 186b8e80941Smrg * index 0 = Y plane, [7:0] Y 187b8e80941Smrg * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 188b8e80941Smrg * or 189b8e80941Smrg * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 190b8e80941Smrg */ 191b8e80941Smrg#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 192b8e80941Smrg#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 193b8e80941Smrg#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 194b8e80941Smrg#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 195b8e80941Smrg#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 196b8e80941Smrg#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 197b8e80941Smrg 198b8e80941Smrg/* 199b8e80941Smrg * 2 plane YCbCr MSB aligned 200b8e80941Smrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian 201b8e80941Smrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian 202b8e80941Smrg */ 203b8e80941Smrg#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */ 204b8e80941Smrg 205b8e80941Smrg/* 206b8e80941Smrg * 2 plane YCbCr MSB aligned 207b8e80941Smrg * index 0 = Y plane, [15:0] Y:x [12:4] little endian 208b8e80941Smrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian 209b8e80941Smrg */ 210b8e80941Smrg#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */ 211b8e80941Smrg 212b8e80941Smrg/* 213b8e80941Smrg * 2 plane YCbCr MSB aligned 214b8e80941Smrg * index 0 = Y plane, [15:0] Y little endian 215b8e80941Smrg * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian 216b8e80941Smrg */ 217b8e80941Smrg#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ 218b8e80941Smrg 219b8e80941Smrg/* 220b8e80941Smrg * 3 plane YCbCr 221b8e80941Smrg * index 0: Y plane, [7:0] Y 222b8e80941Smrg * index 1: Cb plane, [7:0] Cb 223b8e80941Smrg * index 2: Cr plane, [7:0] Cr 224b8e80941Smrg * or 225b8e80941Smrg * index 1: Cr plane, [7:0] Cr 226b8e80941Smrg * index 2: Cb plane, [7:0] Cb 227b8e80941Smrg */ 228b8e80941Smrg#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 229b8e80941Smrg#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 230b8e80941Smrg#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 231b8e80941Smrg#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 232b8e80941Smrg#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 233b8e80941Smrg#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 234b8e80941Smrg#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 235b8e80941Smrg#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 236b8e80941Smrg#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 237b8e80941Smrg#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 238b8e80941Smrg 239b8e80941Smrg 240b8e80941Smrg/* 241b8e80941Smrg * Format Modifiers: 242b8e80941Smrg * 243b8e80941Smrg * Format modifiers describe, typically, a re-ordering or modification 244b8e80941Smrg * of the data in a plane of an FB. This can be used to express tiled/ 245b8e80941Smrg * swizzled formats, or compression, or a combination of the two. 246b8e80941Smrg * 247b8e80941Smrg * The upper 8 bits of the format modifier are a vendor-id as assigned 248b8e80941Smrg * below. The lower 56 bits are assigned as vendor sees fit. 249b8e80941Smrg */ 250b8e80941Smrg 251b8e80941Smrg/* Vendor Ids: */ 252b8e80941Smrg#define DRM_FORMAT_MOD_NONE 0 253b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_NONE 0 254b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 255b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 256b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03 257b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 258b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 259b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 260b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 261b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 262b8e80941Smrg#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 263b8e80941Smrg 264b8e80941Smrg/* add more to the end as needed */ 265b8e80941Smrg 266b8e80941Smrg#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) 267b8e80941Smrg 268b8e80941Smrg#define fourcc_mod_code(vendor, val) \ 269b8e80941Smrg ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 270b8e80941Smrg 271b8e80941Smrg/* 272b8e80941Smrg * Format Modifier tokens: 273b8e80941Smrg * 274b8e80941Smrg * When adding a new token please document the layout with a code comment, 275b8e80941Smrg * similar to the fourcc codes above. drm_fourcc.h is considered the 276b8e80941Smrg * authoritative source for all of these. 277b8e80941Smrg */ 278b8e80941Smrg 279b8e80941Smrg/* 280b8e80941Smrg * Invalid Modifier 281b8e80941Smrg * 282b8e80941Smrg * This modifier can be used as a sentinel to terminate the format modifiers 283b8e80941Smrg * list, or to initialize a variable with an invalid modifier. It might also be 284b8e80941Smrg * used to report an error back to userspace for certain APIs. 285b8e80941Smrg */ 286b8e80941Smrg#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) 287b8e80941Smrg 288b8e80941Smrg/* 289b8e80941Smrg * Linear Layout 290b8e80941Smrg * 291b8e80941Smrg * Just plain linear layout. Note that this is different from no specifying any 292b8e80941Smrg * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), 293b8e80941Smrg * which tells the driver to also take driver-internal information into account 294b8e80941Smrg * and so might actually result in a tiled framebuffer. 295b8e80941Smrg */ 296b8e80941Smrg#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) 297b8e80941Smrg 298b8e80941Smrg/* Intel framebuffer modifiers */ 299b8e80941Smrg 300b8e80941Smrg/* 301b8e80941Smrg * Intel X-tiling layout 302b8e80941Smrg * 303b8e80941Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 304b8e80941Smrg * in row-major layout. Within the tile bytes are laid out row-major, with 305b8e80941Smrg * a platform-dependent stride. On top of that the memory can apply 306b8e80941Smrg * platform-depending swizzling of some higher address bits into bit6. 307b8e80941Smrg * 308b8e80941Smrg * This format is highly platforms specific and not useful for cross-driver 309b8e80941Smrg * sharing. It exists since on a given platform it does uniquely identify the 310b8e80941Smrg * layout in a simple way for i915-specific userspace. 311b8e80941Smrg */ 312b8e80941Smrg#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 313b8e80941Smrg 314b8e80941Smrg/* 315b8e80941Smrg * Intel Y-tiling layout 316b8e80941Smrg * 317b8e80941Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 318b8e80941Smrg * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 319b8e80941Smrg * chunks column-major, with a platform-dependent height. On top of that the 320b8e80941Smrg * memory can apply platform-depending swizzling of some higher address bits 321b8e80941Smrg * into bit6. 322b8e80941Smrg * 323b8e80941Smrg * This format is highly platforms specific and not useful for cross-driver 324b8e80941Smrg * sharing. It exists since on a given platform it does uniquely identify the 325b8e80941Smrg * layout in a simple way for i915-specific userspace. 326b8e80941Smrg */ 327b8e80941Smrg#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 328b8e80941Smrg 329b8e80941Smrg/* 330b8e80941Smrg * Intel Yf-tiling layout 331b8e80941Smrg * 332b8e80941Smrg * This is a tiled layout using 4Kb tiles in row-major layout. 333b8e80941Smrg * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 334b8e80941Smrg * are arranged in four groups (two wide, two high) with column-major layout. 335b8e80941Smrg * Each group therefore consits out of four 256 byte units, which are also laid 336b8e80941Smrg * out as 2x2 column-major. 337b8e80941Smrg * 256 byte units are made out of four 64 byte blocks of pixels, producing 338b8e80941Smrg * either a square block or a 2:1 unit. 339b8e80941Smrg * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 340b8e80941Smrg * in pixel depends on the pixel depth. 341b8e80941Smrg */ 342b8e80941Smrg#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 343b8e80941Smrg 344b8e80941Smrg/* 345b8e80941Smrg * Intel color control surface (CCS) for render compression 346b8e80941Smrg * 347b8e80941Smrg * The framebuffer format must be one of the 8:8:8:8 RGB formats. 348b8e80941Smrg * The main surface will be plane index 0 and must be Y/Yf-tiled, 349b8e80941Smrg * the CCS will be plane index 1. 350b8e80941Smrg * 351b8e80941Smrg * Each CCS tile matches a 1024x512 pixel area of the main surface. 352b8e80941Smrg * To match certain aspects of the 3D hardware the CCS is 353b8e80941Smrg * considered to be made up of normal 128Bx32 Y tiles, Thus 354b8e80941Smrg * the CCS pitch must be specified in multiples of 128 bytes. 355b8e80941Smrg * 356b8e80941Smrg * In reality the CCS tile appears to be a 64Bx64 Y tile, composed 357b8e80941Smrg * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. 358b8e80941Smrg * But that fact is not relevant unless the memory is accessed 359b8e80941Smrg * directly. 360b8e80941Smrg */ 361b8e80941Smrg#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) 362b8e80941Smrg#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) 363b8e80941Smrg 364b8e80941Smrg/* 365b8e80941Smrg * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 366b8e80941Smrg * 367b8e80941Smrg * Macroblocks are laid in a Z-shape, and each pixel data is following the 368b8e80941Smrg * standard NV12 style. 369b8e80941Smrg * As for NV12, an image is the result of two frame buffers: one for Y, 370b8e80941Smrg * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 371b8e80941Smrg * Alignment requirements are (for each buffer): 372b8e80941Smrg * - multiple of 128 pixels for the width 373b8e80941Smrg * - multiple of 32 pixels for the height 374b8e80941Smrg * 375b8e80941Smrg * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 376b8e80941Smrg */ 377b8e80941Smrg#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 378b8e80941Smrg 379b8e80941Smrg/* 380b8e80941Smrg * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks 381b8e80941Smrg * 382b8e80941Smrg * This is a simple tiled layout using tiles of 16x16 pixels in a row-major 383b8e80941Smrg * layout. For YCbCr formats Cb/Cr components are taken in such a way that 384b8e80941Smrg * they correspond to their 16x16 luma block. 385b8e80941Smrg */ 386b8e80941Smrg#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) 387b8e80941Smrg 388b8e80941Smrg/* 389b8e80941Smrg * Qualcomm Compressed Format 390b8e80941Smrg * 391b8e80941Smrg * Refers to a compressed variant of the base format that is compressed. 392b8e80941Smrg * Implementation may be platform and base-format specific. 393b8e80941Smrg * 394b8e80941Smrg * Each macrotile consists of m x n (mostly 4 x 4) tiles. 395b8e80941Smrg * Pixel data pitch/stride is aligned with macrotile width. 396b8e80941Smrg * Pixel data height is aligned with macrotile height. 397b8e80941Smrg * Entire pixel data buffer is aligned with 4k(bytes). 398b8e80941Smrg */ 399b8e80941Smrg#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) 400b8e80941Smrg 401b8e80941Smrg/* Vivante framebuffer modifiers */ 402b8e80941Smrg 403b8e80941Smrg/* 404b8e80941Smrg * Vivante 4x4 tiling layout 405b8e80941Smrg * 406b8e80941Smrg * This is a simple tiled layout using tiles of 4x4 pixels in a row-major 407b8e80941Smrg * layout. 408b8e80941Smrg */ 409b8e80941Smrg#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) 410b8e80941Smrg 411b8e80941Smrg/* 412b8e80941Smrg * Vivante 64x64 super-tiling layout 413b8e80941Smrg * 414b8e80941Smrg * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile 415b8e80941Smrg * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- 416b8e80941Smrg * major layout. 417b8e80941Smrg * 418b8e80941Smrg * For more information: see 419b8e80941Smrg * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling 420b8e80941Smrg */ 421b8e80941Smrg#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) 422b8e80941Smrg 423b8e80941Smrg/* 424b8e80941Smrg * Vivante 4x4 tiling layout for dual-pipe 425b8e80941Smrg * 426b8e80941Smrg * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a 427b8e80941Smrg * different base address. Offsets from the base addresses are therefore halved 428b8e80941Smrg * compared to the non-split tiled layout. 429b8e80941Smrg */ 430b8e80941Smrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) 431b8e80941Smrg 432b8e80941Smrg/* 433b8e80941Smrg * Vivante 64x64 super-tiling layout for dual-pipe 434b8e80941Smrg * 435b8e80941Smrg * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile 436b8e80941Smrg * starts at a different base address. Offsets from the base addresses are 437b8e80941Smrg * therefore halved compared to the non-split super-tiled layout. 438b8e80941Smrg */ 439b8e80941Smrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) 440b8e80941Smrg 441b8e80941Smrg/* NVIDIA frame buffer modifiers */ 442b8e80941Smrg 443b8e80941Smrg/* 444b8e80941Smrg * Tegra Tiled Layout, used by Tegra 2, 3 and 4. 445b8e80941Smrg * 446b8e80941Smrg * Pixels are arranged in simple tiles of 16 x 16 bytes. 447b8e80941Smrg */ 448b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1) 449b8e80941Smrg 450b8e80941Smrg/* 451b8e80941Smrg * 16Bx2 Block Linear layout, used by desktop GPUs, and Tegra K1 and later 452b8e80941Smrg * 453b8e80941Smrg * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked 454b8e80941Smrg * vertically by a power of 2 (1 to 32 GOBs) to form a block. 455b8e80941Smrg * 456b8e80941Smrg * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. 457b8e80941Smrg * 458b8e80941Smrg * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. 459b8e80941Smrg * Valid values are: 460b8e80941Smrg * 461b8e80941Smrg * 0 == ONE_GOB 462b8e80941Smrg * 1 == TWO_GOBS 463b8e80941Smrg * 2 == FOUR_GOBS 464b8e80941Smrg * 3 == EIGHT_GOBS 465b8e80941Smrg * 4 == SIXTEEN_GOBS 466b8e80941Smrg * 5 == THIRTYTWO_GOBS 467b8e80941Smrg * 468b8e80941Smrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format 469b8e80941Smrg * in full detail. 470b8e80941Smrg */ 471b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \ 472b8e80941Smrg fourcc_mod_code(NVIDIA, 0x10 | ((v) & 0xf)) 473b8e80941Smrg 474b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \ 475b8e80941Smrg fourcc_mod_code(NVIDIA, 0x10) 476b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \ 477b8e80941Smrg fourcc_mod_code(NVIDIA, 0x11) 478b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \ 479b8e80941Smrg fourcc_mod_code(NVIDIA, 0x12) 480b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \ 481b8e80941Smrg fourcc_mod_code(NVIDIA, 0x13) 482b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \ 483b8e80941Smrg fourcc_mod_code(NVIDIA, 0x14) 484b8e80941Smrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \ 485b8e80941Smrg fourcc_mod_code(NVIDIA, 0x15) 486b8e80941Smrg 487b8e80941Smrg/* 488b8e80941Smrg * Some Broadcom modifiers take parameters, for example the number of 489b8e80941Smrg * vertical lines in the image. Reserve the lower 32 bits for modifier 490b8e80941Smrg * type, and the next 24 bits for parameters. Top 8 bits are the 491b8e80941Smrg * vendor code. 492b8e80941Smrg */ 493b8e80941Smrg#define __fourcc_mod_broadcom_param_shift 8 494b8e80941Smrg#define __fourcc_mod_broadcom_param_bits 48 495b8e80941Smrg#define fourcc_mod_broadcom_code(val, params) \ 496b8e80941Smrg fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) 497b8e80941Smrg#define fourcc_mod_broadcom_param(m) \ 498b8e80941Smrg ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ 499b8e80941Smrg ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) 500b8e80941Smrg#define fourcc_mod_broadcom_mod(m) \ 501b8e80941Smrg ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ 502b8e80941Smrg __fourcc_mod_broadcom_param_shift)) 503b8e80941Smrg 504b8e80941Smrg/* 505b8e80941Smrg * Broadcom VC4 "T" format 506b8e80941Smrg * 507b8e80941Smrg * This is the primary layout that the V3D GPU can texture from (it 508b8e80941Smrg * can't do linear). The T format has: 509b8e80941Smrg * 510b8e80941Smrg * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 511b8e80941Smrg * pixels at 32 bit depth. 512b8e80941Smrg * 513b8e80941Smrg * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually 514b8e80941Smrg * 16x16 pixels). 515b8e80941Smrg * 516b8e80941Smrg * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On 517b8e80941Smrg * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows 518b8e80941Smrg * they're (TR, BR, BL, TL), where bottom left is start of memory. 519b8e80941Smrg * 520b8e80941Smrg * - an image made of 4k tiles in rows either left-to-right (even rows of 4k 521b8e80941Smrg * tiles) or right-to-left (odd rows of 4k tiles). 522b8e80941Smrg */ 523b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) 524b8e80941Smrg 525b8e80941Smrg/* 526b8e80941Smrg * Broadcom SAND format 527b8e80941Smrg * 528b8e80941Smrg * This is the native format that the H.264 codec block uses. For VC4 529b8e80941Smrg * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. 530b8e80941Smrg * 531b8e80941Smrg * The image can be considered to be split into columns, and the 532b8e80941Smrg * columns are placed consecutively into memory. The width of those 533b8e80941Smrg * columns can be either 32, 64, 128, or 256 pixels, but in practice 534b8e80941Smrg * only 128 pixel columns are used. 535b8e80941Smrg * 536b8e80941Smrg * The pitch between the start of each column is set to optimally 537b8e80941Smrg * switch between SDRAM banks. This is passed as the number of lines 538b8e80941Smrg * of column width in the modifier (we can't use the stride value due 539b8e80941Smrg * to various core checks that look at it , so you should set the 540b8e80941Smrg * stride to width*cpp). 541b8e80941Smrg * 542b8e80941Smrg * Note that the column height for this format modifier is the same 543b8e80941Smrg * for all of the planes, assuming that each column contains both Y 544b8e80941Smrg * and UV. Some SAND-using hardware stores UV in a separate tiled 545b8e80941Smrg * image from Y to reduce the column height, which is not supported 546b8e80941Smrg * with these modifiers. 547b8e80941Smrg */ 548b8e80941Smrg 549b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ 550b8e80941Smrg fourcc_mod_broadcom_code(2, v) 551b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ 552b8e80941Smrg fourcc_mod_broadcom_code(3, v) 553b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ 554b8e80941Smrg fourcc_mod_broadcom_code(4, v) 555b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ 556b8e80941Smrg fourcc_mod_broadcom_code(5, v) 557b8e80941Smrg 558b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ 559b8e80941Smrg DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) 560b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ 561b8e80941Smrg DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) 562b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ 563b8e80941Smrg DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) 564b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ 565b8e80941Smrg DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) 566b8e80941Smrg 567b8e80941Smrg/* Broadcom UIF format 568b8e80941Smrg * 569b8e80941Smrg * This is the common format for the current Broadcom multimedia 570b8e80941Smrg * blocks, including V3D 3.x and newer, newer video codecs, and 571b8e80941Smrg * displays. 572b8e80941Smrg * 573b8e80941Smrg * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), 574b8e80941Smrg * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are 575b8e80941Smrg * stored in columns, with padding between the columns to ensure that 576b8e80941Smrg * moving from one column to the next doesn't hit the same SDRAM page 577b8e80941Smrg * bank. 578b8e80941Smrg * 579b8e80941Smrg * To calculate the padding, it is assumed that each hardware block 580b8e80941Smrg * and the software driving it knows the platform's SDRAM page size, 581b8e80941Smrg * number of banks, and XOR address, and that it's identical between 582b8e80941Smrg * all blocks using the format. This tiling modifier will use XOR as 583b8e80941Smrg * necessary to reduce the padding. If a hardware block can't do XOR, 584b8e80941Smrg * the assumption is that a no-XOR tiling modifier will be created. 585b8e80941Smrg */ 586b8e80941Smrg#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) 587b8e80941Smrg 588b8e80941Smrg/* 589b8e80941Smrg * Arm Framebuffer Compression (AFBC) modifiers 590b8e80941Smrg * 591b8e80941Smrg * AFBC is a proprietary lossless image compression protocol and format. 592b8e80941Smrg * It provides fine-grained random access and minimizes the amount of data 593b8e80941Smrg * transferred between IP blocks. 594b8e80941Smrg * 595b8e80941Smrg * AFBC has several features which may be supported and/or used, which are 596b8e80941Smrg * represented using bits in the modifier. Not all combinations are valid, 597b8e80941Smrg * and different devices or use-cases may support different combinations. 598b8e80941Smrg * 599b8e80941Smrg * Further information on the use of AFBC modifiers can be found in 600b8e80941Smrg * Documentation/gpu/afbc.rst 601b8e80941Smrg */ 602b8e80941Smrg#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) fourcc_mod_code(ARM, __afbc_mode) 603b8e80941Smrg 604b8e80941Smrg/* 605b8e80941Smrg * AFBC superblock size 606b8e80941Smrg * 607b8e80941Smrg * Indicates the superblock size(s) used for the AFBC buffer. The buffer 608b8e80941Smrg * size (in pixels) must be aligned to a multiple of the superblock size. 609b8e80941Smrg * Four lowest significant bits(LSBs) are reserved for block size. 610b8e80941Smrg * 611b8e80941Smrg * Where one superblock size is specified, it applies to all planes of the 612b8e80941Smrg * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified, 613b8e80941Smrg * the first applies to the Luma plane and the second applies to the Chroma 614b8e80941Smrg * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma). 615b8e80941Smrg * Multiple superblock sizes are only valid for multi-plane YCbCr formats. 616b8e80941Smrg */ 617b8e80941Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf 618b8e80941Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) 619b8e80941Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) 620b8e80941Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 (3ULL) 621b8e80941Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL) 622b8e80941Smrg 623b8e80941Smrg/* 624b8e80941Smrg * AFBC lossless colorspace transform 625b8e80941Smrg * 626b8e80941Smrg * Indicates that the buffer makes use of the AFBC lossless colorspace 627b8e80941Smrg * transform. 628b8e80941Smrg */ 629b8e80941Smrg#define AFBC_FORMAT_MOD_YTR (1ULL << 4) 630b8e80941Smrg 631b8e80941Smrg/* 632b8e80941Smrg * AFBC block-split 633b8e80941Smrg * 634b8e80941Smrg * Indicates that the payload of each superblock is split. The second 635b8e80941Smrg * half of the payload is positioned at a predefined offset from the start 636b8e80941Smrg * of the superblock payload. 637b8e80941Smrg */ 638b8e80941Smrg#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) 639b8e80941Smrg 640b8e80941Smrg/* 641b8e80941Smrg * AFBC sparse layout 642b8e80941Smrg * 643b8e80941Smrg * This flag indicates that the payload of each superblock must be stored at a 644b8e80941Smrg * predefined position relative to the other superblocks in the same AFBC 645b8e80941Smrg * buffer. This order is the same order used by the header buffer. In this mode 646b8e80941Smrg * each superblock is given the same amount of space as an uncompressed 647b8e80941Smrg * superblock of the particular format would require, rounding up to the next 648b8e80941Smrg * multiple of 128 bytes in size. 649b8e80941Smrg */ 650b8e80941Smrg#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) 651b8e80941Smrg 652b8e80941Smrg/* 653b8e80941Smrg * AFBC copy-block restrict 654b8e80941Smrg * 655b8e80941Smrg * Buffers with this flag must obey the copy-block restriction. The restriction 656b8e80941Smrg * is such that there are no copy-blocks referring across the border of 8x8 657b8e80941Smrg * blocks. For the subsampled data the 8x8 limitation is also subsampled. 658b8e80941Smrg */ 659b8e80941Smrg#define AFBC_FORMAT_MOD_CBR (1ULL << 7) 660b8e80941Smrg 661b8e80941Smrg/* 662b8e80941Smrg * AFBC tiled layout 663b8e80941Smrg * 664b8e80941Smrg * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all 665b8e80941Smrg * superblocks inside a tile are stored together in memory. 8x8 tiles are used 666b8e80941Smrg * for pixel formats up to and including 32 bpp while 4x4 tiles are used for 667b8e80941Smrg * larger bpp formats. The order between the tiles is scan line. 668b8e80941Smrg * When the tiled layout is used, the buffer size (in pixels) must be aligned 669b8e80941Smrg * to the tile size. 670b8e80941Smrg */ 671b8e80941Smrg#define AFBC_FORMAT_MOD_TILED (1ULL << 8) 672b8e80941Smrg 673b8e80941Smrg/* 674b8e80941Smrg * AFBC solid color blocks 675b8e80941Smrg * 676b8e80941Smrg * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth 677b8e80941Smrg * can be reduced if a whole superblock is a single color. 678b8e80941Smrg */ 679b8e80941Smrg#define AFBC_FORMAT_MOD_SC (1ULL << 9) 680b8e80941Smrg 681b8e80941Smrg/* 682b8e80941Smrg * AFBC double-buffer 683b8e80941Smrg * 684b8e80941Smrg * Indicates that the buffer is allocated in a layout safe for front-buffer 685b8e80941Smrg * rendering. 686b8e80941Smrg */ 687b8e80941Smrg#define AFBC_FORMAT_MOD_DB (1ULL << 10) 688b8e80941Smrg 689b8e80941Smrg/* 690b8e80941Smrg * AFBC buffer content hints 691b8e80941Smrg * 692b8e80941Smrg * Indicates that the buffer includes per-superblock content hints. 693b8e80941Smrg */ 694b8e80941Smrg#define AFBC_FORMAT_MOD_BCH (1ULL << 11) 695b8e80941Smrg 696b8e80941Smrg/* 697b8e80941Smrg * Allwinner tiled modifier 698b8e80941Smrg * 699b8e80941Smrg * This tiling mode is implemented by the VPU found on all Allwinner platforms, 700b8e80941Smrg * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3 701b8e80941Smrg * planes. 702b8e80941Smrg * 703b8e80941Smrg * With this tiling, the luminance samples are disposed in tiles representing 704b8e80941Smrg * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels. 705b8e80941Smrg * The pixel order in each tile is linear and the tiles are disposed linearly, 706b8e80941Smrg * both in row-major order. 707b8e80941Smrg */ 708b8e80941Smrg#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) 709b8e80941Smrg 710b8e80941Smrg#if defined(__cplusplus) 711b8e80941Smrg} 712b8e80941Smrg#endif 713b8e80941Smrg 714b8e80941Smrg#endif /* DRM_FOURCC_H */ 715