drm_fourcc.h revision 3f012e29
11.1Scgd/* 21.1Scgd * Copyright 2011 Intel Corporation 31.1Scgd * 41.1Scgd * Permission is hereby granted, free of charge, to any person obtaining a 51.1Scgd * copy of this software and associated documentation files (the "Software"), 61.1Scgd * to deal in the Software without restriction, including without limitation 71.1Scgd * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81.1Scgd * and/or sell copies of the Software, and to permit persons to whom the 91.1Scgd * Software is furnished to do so, subject to the following conditions: 101.1Scgd * 111.1Scgd * The above copyright notice and this permission notice (including the next 121.1Scgd * paragraph) shall be included in all copies or substantial portions of the 131.1Scgd * Software. 141.1Scgd * 151.1Scgd * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161.1Scgd * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171.1Scgd * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181.1Scgd * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 191.1Scgd * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 201.1Scgd * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 211.1Scgd * OTHER DEALINGS IN THE SOFTWARE. 221.1Scgd */ 231.17Smycroft 241.1Scgd#ifndef DRM_FOURCC_H 251.1Scgd#define DRM_FOURCC_H 261.1Scgd 271.1Scgd#include "drm.h" 281.1Scgd 291.1Scgd#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ 301.1Scgd ((__u32)(c) << 16) | ((__u32)(d) << 24)) 311.1Scgd 321.1Scgd#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */ 331.1Scgd 341.1Scgd/* color index */ 351.17Smycroft#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ 361.17Smycroft 371.17Smycroft/* 8 bpp Red */ 381.18Smycroft#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ 391.17Smycroft 401.17Smycroft/* 16 bpp RG */ 411.17Smycroft#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ 421.17Smycroft#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ 431.18Smycroft 441.17Smycroft/* 8 bpp RGB */ 451.1Scgd#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ 461.1Scgd#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ 471.1Scgd 481.1Scgd/* 16 bpp RGB */ 491.1Scgd#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ 501.1Scgd#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ 511.1Scgd#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ 521.1Scgd#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ 531.1Scgd 541.1Scgd#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ 551.1Scgd#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ 561.1Scgd#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ 571.1Scgd#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ 581.1Scgd 591.1Scgd#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ 601.10Smycroft#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ 611.1Scgd#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ 621.10Smycroft#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ 631.1Scgd 641.1Scgd#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ 651.1Scgd#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ 661.1Scgd#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ 671.1Scgd#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ 681.1Scgd 691.1Scgd#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ 701.1Scgd#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ 711.1Scgd 721.21Smycroft/* 24 bpp RGB */ 731.1Scgd#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ 741.1Scgd#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ 751.1Scgd 761.1Scgd/* 32 bpp RGB */ 771.16Smycroft#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ 781.13Scgd#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ 791.1Scgd#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ 801.1Scgd#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ 811.1Scgd 821.1Scgd#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ 831.1Scgd#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ 841.16Smycroft#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ 851.13Scgd#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ 861.1Scgd 871.1Scgd#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ 881.1Scgd#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ 891.1Scgd#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ 901.1Scgd#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ 911.1Scgd 921.9Scgd#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ 931.9Scgd#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ 941.9Scgd#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ 951.9Scgd#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ 961.1Scgd 971.1Scgd/* packed YCbCr */ 981.1Scgd#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ 991.1Scgd#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ 1001.9Scgd#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ 1011.9Scgd#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ 1021.9Scgd 1031.9Scgd#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ 1041.1Scgd 1051.1Scgd/* 1061.1Scgd * 2 plane YCbCr 1071.1Scgd * index 0 = Y plane, [7:0] Y 1081.1Scgd * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian 1091.1Scgd * or 1101.19Smycroft * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian 1111.19Smycroft */ 1121.19Smycroft#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ 1131.19Smycroft#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ 1141.19Smycroft#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ 1151.19Smycroft#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ 1161.19Smycroft#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ 1171.19Smycroft#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ 1181.19Smycroft 1191.1Scgd/* 1201.14Scgd * 3 plane YCbCr 1211.1Scgd * index 0: Y plane, [7:0] Y 1221.1Scgd * index 1: Cb plane, [7:0] Cb 1231.1Scgd * index 2: Cr plane, [7:0] Cr 1241.1Scgd * or 1251.1Scgd * index 1: Cr plane, [7:0] Cr 1261.1Scgd * index 2: Cb plane, [7:0] Cb 1271.7Scgd */ 1281.6Scgd#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ 1291.5Scgd#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ 1301.5Scgd#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ 1311.5Scgd#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ 1321.5Scgd#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ 1331.5Scgd#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ 1341.5Scgd#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ 1351.1Scgd#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ 1361.1Scgd#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ 1371.11Smycroft#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ 1381.13Scgd 1391.8Scgd 1401.1Scgd/* 1411.1Scgd * Format Modifiers: 1421.12Scgd * 1431.13Scgd * Format modifiers describe, typically, a re-ordering or modification 1441.8Scgd * of the data in a plane of an FB. This can be used to express tiled/ 1451.1Scgd * swizzled formats, or compression, or a combination of the two. 1461.1Scgd * 1471.12Scgd * The upper 8 bits of the format modifier are a vendor-id as assigned 1481.8Scgd * below. The lower 56 bits are assigned as vendor sees fit. 1491.1Scgd */ 1501.1Scgd 1511.1Scgd/* Vendor Ids: */ 1521.1Scgd#define DRM_FORMAT_MOD_NONE 0 1531.1Scgd#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 1541.1Scgd#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 1551.1Scgd#define DRM_FORMAT_MOD_VENDOR_NV 0x03 1561.1Scgd#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 1571.1Scgd#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 1581.1Scgd/* add more to the end as needed */ 1591.1Scgd 1601.1Scgd#define fourcc_mod_code(vendor, val) \ 1611.1Scgd ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL)) 1621.1Scgd 1631.11Smycroft/* 1641.11Smycroft * Format Modifier tokens: 1651.11Smycroft * 1661.11Smycroft * When adding a new token please document the layout with a code comment, 1671.1Scgd * similar to the fourcc codes above. drm_fourcc.h is considered the 1681.1Scgd * authoritative source for all of these. 1691.1Scgd */ 1701.1Scgd 1711.1Scgd/* Intel framebuffer modifiers */ 1721.1Scgd 1731.1Scgd/* 1741.1Scgd * Intel X-tiling layout 1751.1Scgd * 1761.1Scgd * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 1771.1Scgd * in row-major layout. Within the tile bytes are laid out row-major, with 1781.1Scgd * a platform-dependent stride. On top of that the memory can apply 1791.10Smycroft * platform-depending swizzling of some higher address bits into bit6. 1801.1Scgd * 1811.10Smycroft * This format is highly platforms specific and not useful for cross-driver 1821.10Smycroft * sharing. It exists since on a given platform it does uniquely identify the 1831.1Scgd * layout in a simple way for i915-specific userspace. 1841.1Scgd */ 1851.1Scgd#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) 1861.1Scgd 1871.1Scgd/* 1881.3Scgd * Intel Y-tiling layout 1891.2Scgd * 1901.2Scgd * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) 1911.2Scgd * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) 1921.2Scgd * chunks column-major, with a platform-dependent height. On top of that the 1931.2Scgd * memory can apply platform-depending swizzling of some higher address bits 1941.2Scgd * into bit6. 1951.2Scgd * 1961.2Scgd * This format is highly platforms specific and not useful for cross-driver 1971.2Scgd * sharing. It exists since on a given platform it does uniquely identify the 1981.1Scgd * layout in a simple way for i915-specific userspace. 1991.2Scgd */ 2001.2Scgd#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) 2011.2Scgd 2021.20Smycroft/* 2031.20Smycroft * Intel Yf-tiling layout 2041.2Scgd * 2051.1Scgd * This is a tiled layout using 4Kb tiles in row-major layout. 2061.1Scgd * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which 2071.1Scgd * are arranged in four groups (two wide, two high) with column-major layout. 208 * Each group therefore consits out of four 256 byte units, which are also laid 209 * out as 2x2 column-major. 210 * 256 byte units are made out of four 64 byte blocks of pixels, producing 211 * either a square block or a 2:1 unit. 212 * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width 213 * in pixel depends on the pixel depth. 214 */ 215#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) 216 217/* 218 * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks 219 * 220 * Macroblocks are laid in a Z-shape, and each pixel data is following the 221 * standard NV12 style. 222 * As for NV12, an image is the result of two frame buffers: one for Y, 223 * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). 224 * Alignment requirements are (for each buffer): 225 * - multiple of 128 pixels for the width 226 * - multiple of 32 pixels for the height 227 * 228 * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html 229 */ 230#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) 231 232#endif /* DRM_FOURCC_H */ 233