drm_fourcc.h revision 5324fb0d
1e88f27b3Smrg/*
2e88f27b3Smrg * Copyright 2011 Intel Corporation
3e88f27b3Smrg *
4e88f27b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5e88f27b3Smrg * copy of this software and associated documentation files (the "Software"),
6e88f27b3Smrg * to deal in the Software without restriction, including without limitation
7e88f27b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8e88f27b3Smrg * and/or sell copies of the Software, and to permit persons to whom the
9e88f27b3Smrg * Software is furnished to do so, subject to the following conditions:
10e88f27b3Smrg *
11e88f27b3Smrg * The above copyright notice and this permission notice (including the next
12e88f27b3Smrg * paragraph) shall be included in all copies or substantial portions of the
13e88f27b3Smrg * Software.
14e88f27b3Smrg *
15e88f27b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16e88f27b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17e88f27b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18e88f27b3Smrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19e88f27b3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20e88f27b3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21e88f27b3Smrg * OTHER DEALINGS IN THE SOFTWARE.
22e88f27b3Smrg */
23e88f27b3Smrg
24e88f27b3Smrg#ifndef DRM_FOURCC_H
25e88f27b3Smrg#define DRM_FOURCC_H
26e88f27b3Smrg
273f012e29Smrg#include "drm.h"
28e88f27b3Smrg
29d8807b2fSmrg#if defined(__cplusplus)
30d8807b2fSmrgextern "C" {
31d8807b2fSmrg#endif
32d8807b2fSmrg
337cdc0497Smrg/**
347cdc0497Smrg * DOC: overview
357cdc0497Smrg *
367cdc0497Smrg * In the DRM subsystem, framebuffer pixel formats are described using the
377cdc0497Smrg * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the
387cdc0497Smrg * fourcc code, a Format Modifier may optionally be provided, in order to
397cdc0497Smrg * further describe the buffer's format - for example tiling or compression.
407cdc0497Smrg *
417cdc0497Smrg * Format Modifiers
427cdc0497Smrg * ----------------
437cdc0497Smrg *
447cdc0497Smrg * Format modifiers are used in conjunction with a fourcc code, forming a
457cdc0497Smrg * unique fourcc:modifier pair. This format:modifier pair must fully define the
467cdc0497Smrg * format and data layout of the buffer, and should be the only way to describe
477cdc0497Smrg * that particular buffer.
487cdc0497Smrg *
497cdc0497Smrg * Having multiple fourcc:modifier pairs which describe the same layout should
507cdc0497Smrg * be avoided, as such aliases run the risk of different drivers exposing
517cdc0497Smrg * different names for the same data format, forcing userspace to understand
527cdc0497Smrg * that they are aliases.
537cdc0497Smrg *
547cdc0497Smrg * Format modifiers may change any property of the buffer, including the number
557cdc0497Smrg * of planes and/or the required allocation size. Format modifiers are
567cdc0497Smrg * vendor-namespaced, and as such the relationship between a fourcc code and a
577cdc0497Smrg * modifier is specific to the modifer being used. For example, some modifiers
587cdc0497Smrg * may preserve meaning - such as number of planes - from the fourcc code,
597cdc0497Smrg * whereas others may not.
607cdc0497Smrg *
617cdc0497Smrg * Vendors should document their modifier usage in as much detail as
627cdc0497Smrg * possible, to ensure maximum compatibility across devices, drivers and
637cdc0497Smrg * applications.
647cdc0497Smrg *
657cdc0497Smrg * The authoritative list of format modifier codes is found in
667cdc0497Smrg * `include/uapi/drm/drm_fourcc.h`
677cdc0497Smrg */
687cdc0497Smrg
693f012e29Smrg#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
703f012e29Smrg				 ((__u32)(c) << 16) | ((__u32)(d) << 24))
71e88f27b3Smrg
72e88f27b3Smrg#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
73e88f27b3Smrg
747cdc0497Smrg/* Reserve 0 for the invalid format specifier */
757cdc0497Smrg#define DRM_FORMAT_INVALID	0
767cdc0497Smrg
77e88f27b3Smrg/* color index */
78e88f27b3Smrg#define DRM_FORMAT_C8		fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
79e88f27b3Smrg
803f012e29Smrg/* 8 bpp Red */
813f012e29Smrg#define DRM_FORMAT_R8		fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
823f012e29Smrg
83d8807b2fSmrg/* 16 bpp Red */
84d8807b2fSmrg#define DRM_FORMAT_R16		fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
85d8807b2fSmrg
863f012e29Smrg/* 16 bpp RG */
873f012e29Smrg#define DRM_FORMAT_RG88		fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */
883f012e29Smrg#define DRM_FORMAT_GR88		fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */
893f012e29Smrg
90d8807b2fSmrg/* 32 bpp RG */
91d8807b2fSmrg#define DRM_FORMAT_RG1616	fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */
92d8807b2fSmrg#define DRM_FORMAT_GR1616	fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */
93d8807b2fSmrg
94e88f27b3Smrg/* 8 bpp RGB */
95e88f27b3Smrg#define DRM_FORMAT_RGB332	fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
96e88f27b3Smrg#define DRM_FORMAT_BGR233	fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
97e88f27b3Smrg
98e88f27b3Smrg/* 16 bpp RGB */
99e88f27b3Smrg#define DRM_FORMAT_XRGB4444	fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */
100e88f27b3Smrg#define DRM_FORMAT_XBGR4444	fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */
101e88f27b3Smrg#define DRM_FORMAT_RGBX4444	fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */
102e88f27b3Smrg#define DRM_FORMAT_BGRX4444	fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */
103e88f27b3Smrg
104e88f27b3Smrg#define DRM_FORMAT_ARGB4444	fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */
105e88f27b3Smrg#define DRM_FORMAT_ABGR4444	fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */
106e88f27b3Smrg#define DRM_FORMAT_RGBA4444	fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */
107e88f27b3Smrg#define DRM_FORMAT_BGRA4444	fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */
108e88f27b3Smrg
109e88f27b3Smrg#define DRM_FORMAT_XRGB1555	fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */
110e88f27b3Smrg#define DRM_FORMAT_XBGR1555	fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */
111e88f27b3Smrg#define DRM_FORMAT_RGBX5551	fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */
112e88f27b3Smrg#define DRM_FORMAT_BGRX5551	fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */
113e88f27b3Smrg
114e88f27b3Smrg#define DRM_FORMAT_ARGB1555	fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */
115e88f27b3Smrg#define DRM_FORMAT_ABGR1555	fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */
116e88f27b3Smrg#define DRM_FORMAT_RGBA5551	fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */
117e88f27b3Smrg#define DRM_FORMAT_BGRA5551	fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */
118e88f27b3Smrg
119e88f27b3Smrg#define DRM_FORMAT_RGB565	fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
120e88f27b3Smrg#define DRM_FORMAT_BGR565	fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */
121e88f27b3Smrg
122e88f27b3Smrg/* 24 bpp RGB */
123e88f27b3Smrg#define DRM_FORMAT_RGB888	fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */
124e88f27b3Smrg#define DRM_FORMAT_BGR888	fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */
125e88f27b3Smrg
126e88f27b3Smrg/* 32 bpp RGB */
127e88f27b3Smrg#define DRM_FORMAT_XRGB8888	fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
128e88f27b3Smrg#define DRM_FORMAT_XBGR8888	fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
129e88f27b3Smrg#define DRM_FORMAT_RGBX8888	fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
130e88f27b3Smrg#define DRM_FORMAT_BGRX8888	fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */
131e88f27b3Smrg
132e88f27b3Smrg#define DRM_FORMAT_ARGB8888	fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */
133e88f27b3Smrg#define DRM_FORMAT_ABGR8888	fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */
134e88f27b3Smrg#define DRM_FORMAT_RGBA8888	fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */
135e88f27b3Smrg#define DRM_FORMAT_BGRA8888	fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */
136e88f27b3Smrg
137e88f27b3Smrg#define DRM_FORMAT_XRGB2101010	fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */
138e88f27b3Smrg#define DRM_FORMAT_XBGR2101010	fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */
139e88f27b3Smrg#define DRM_FORMAT_RGBX1010102	fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */
140e88f27b3Smrg#define DRM_FORMAT_BGRX1010102	fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */
141e88f27b3Smrg
142e88f27b3Smrg#define DRM_FORMAT_ARGB2101010	fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */
143e88f27b3Smrg#define DRM_FORMAT_ABGR2101010	fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */
144e88f27b3Smrg#define DRM_FORMAT_RGBA1010102	fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
145e88f27b3Smrg#define DRM_FORMAT_BGRA1010102	fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
146e88f27b3Smrg
1475324fb0dSmrg/*
1485324fb0dSmrg * Floating point 64bpp RGB
1495324fb0dSmrg * IEEE 754-2008 binary16 half-precision float
1505324fb0dSmrg * [15:0] sign:exponent:mantissa 1:5:10
1515324fb0dSmrg */
1525324fb0dSmrg#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */
1535324fb0dSmrg#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */
1545324fb0dSmrg
1555324fb0dSmrg#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */
1565324fb0dSmrg#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */
1575324fb0dSmrg
158e88f27b3Smrg/* packed YCbCr */
159e88f27b3Smrg#define DRM_FORMAT_YUYV		fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
160e88f27b3Smrg#define DRM_FORMAT_YVYU		fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
161e88f27b3Smrg#define DRM_FORMAT_UYVY		fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
162e88f27b3Smrg#define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
163e88f27b3Smrg
164e88f27b3Smrg#define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
1655324fb0dSmrg#define DRM_FORMAT_XYUV8888	fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
1665324fb0dSmrg#define DRM_FORMAT_VUY888	fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */
1675324fb0dSmrg#define DRM_FORMAT_VUY101010	fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */
1685324fb0dSmrg
1695324fb0dSmrg/*
1705324fb0dSmrg * packed Y2xx indicate for each component, xx valid data occupy msb
1715324fb0dSmrg * 16-xx padding occupy lsb
1725324fb0dSmrg */
1735324fb0dSmrg#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 */
1745324fb0dSmrg#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 */
1755324fb0dSmrg#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 */
1765324fb0dSmrg
1775324fb0dSmrg/*
1785324fb0dSmrg * packed Y4xx indicate for each component, xx valid data occupy msb
1795324fb0dSmrg * 16-xx padding occupy lsb except Y410
1805324fb0dSmrg */
1815324fb0dSmrg#define DRM_FORMAT_Y410         fourcc_code('Y', '4', '1', '0') /* [31:0] A:Cr:Y:Cb 2:10:10:10 little endian */
1825324fb0dSmrg#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 */
1835324fb0dSmrg#define DRM_FORMAT_Y416         fourcc_code('Y', '4', '1', '6') /* [63:0] A:Cr:Y:Cb 16:16:16:16 little endian */
1845324fb0dSmrg
1855324fb0dSmrg#define DRM_FORMAT_XVYU2101010	fourcc_code('X', 'V', '3', '0') /* [31:0] X:Cr:Y:Cb 2:10:10:10 little endian */
1865324fb0dSmrg#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 */
1875324fb0dSmrg#define DRM_FORMAT_XVYU16161616	fourcc_code('X', 'V', '4', '8') /* [63:0] X:Cr:Y:Cb 16:16:16:16 little endian */
1885324fb0dSmrg
1895324fb0dSmrg/*
1905324fb0dSmrg * packed YCbCr420 2x2 tiled formats
1915324fb0dSmrg * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile
1925324fb0dSmrg */
1935324fb0dSmrg/* [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 */
1945324fb0dSmrg#define DRM_FORMAT_Y0L0		fourcc_code('Y', '0', 'L', '0')
1955324fb0dSmrg/* [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 */
1965324fb0dSmrg#define DRM_FORMAT_X0L0		fourcc_code('X', '0', 'L', '0')
1975324fb0dSmrg
1985324fb0dSmrg/* [63:0]   A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian */
1995324fb0dSmrg#define DRM_FORMAT_Y0L2		fourcc_code('Y', '0', 'L', '2')
2005324fb0dSmrg/* [63:0]   X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian */
2015324fb0dSmrg#define DRM_FORMAT_X0L2		fourcc_code('X', '0', 'L', '2')
2025324fb0dSmrg
2035324fb0dSmrg/*
2045324fb0dSmrg * 1-plane YUV 4:2:0
2055324fb0dSmrg * In these formats, the component ordering is specified (Y, followed by U
2065324fb0dSmrg * then V), but the exact Linear layout is undefined.
2075324fb0dSmrg * These formats can only be used with a non-Linear modifier.
2085324fb0dSmrg */
2095324fb0dSmrg#define DRM_FORMAT_YUV420_8BIT	fourcc_code('Y', 'U', '0', '8')
2105324fb0dSmrg#define DRM_FORMAT_YUV420_10BIT	fourcc_code('Y', 'U', '1', '0')
211e88f27b3Smrg
212d8807b2fSmrg/*
213d8807b2fSmrg * 2 plane RGB + A
214d8807b2fSmrg * index 0 = RGB plane, same format as the corresponding non _A8 format has
215d8807b2fSmrg * index 1 = A plane, [7:0] A
216d8807b2fSmrg */
217d8807b2fSmrg#define DRM_FORMAT_XRGB8888_A8	fourcc_code('X', 'R', 'A', '8')
218d8807b2fSmrg#define DRM_FORMAT_XBGR8888_A8	fourcc_code('X', 'B', 'A', '8')
219d8807b2fSmrg#define DRM_FORMAT_RGBX8888_A8	fourcc_code('R', 'X', 'A', '8')
220d8807b2fSmrg#define DRM_FORMAT_BGRX8888_A8	fourcc_code('B', 'X', 'A', '8')
221d8807b2fSmrg#define DRM_FORMAT_RGB888_A8	fourcc_code('R', '8', 'A', '8')
222d8807b2fSmrg#define DRM_FORMAT_BGR888_A8	fourcc_code('B', '8', 'A', '8')
223d8807b2fSmrg#define DRM_FORMAT_RGB565_A8	fourcc_code('R', '5', 'A', '8')
224d8807b2fSmrg#define DRM_FORMAT_BGR565_A8	fourcc_code('B', '5', 'A', '8')
225d8807b2fSmrg
226e88f27b3Smrg/*
227e88f27b3Smrg * 2 plane YCbCr
228e88f27b3Smrg * index 0 = Y plane, [7:0] Y
229e88f27b3Smrg * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
230e88f27b3Smrg * or
231e88f27b3Smrg * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
232e88f27b3Smrg */
233e88f27b3Smrg#define DRM_FORMAT_NV12		fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
234e88f27b3Smrg#define DRM_FORMAT_NV21		fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
235e88f27b3Smrg#define DRM_FORMAT_NV16		fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
236e88f27b3Smrg#define DRM_FORMAT_NV61		fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
2373f012e29Smrg#define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
2383f012e29Smrg#define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
239e88f27b3Smrg
2405324fb0dSmrg/*
2415324fb0dSmrg * 2 plane YCbCr MSB aligned
2425324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian
2435324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian
2445324fb0dSmrg */
2455324fb0dSmrg#define DRM_FORMAT_P210		fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */
2465324fb0dSmrg
2475324fb0dSmrg/*
2485324fb0dSmrg * 2 plane YCbCr MSB aligned
2495324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [10:6] little endian
2505324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian
2515324fb0dSmrg */
2525324fb0dSmrg#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel */
2535324fb0dSmrg
2545324fb0dSmrg/*
2555324fb0dSmrg * 2 plane YCbCr MSB aligned
2565324fb0dSmrg * index 0 = Y plane, [15:0] Y:x [12:4] little endian
2575324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian
2585324fb0dSmrg */
2595324fb0dSmrg#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */
2605324fb0dSmrg
2615324fb0dSmrg/*
2625324fb0dSmrg * 2 plane YCbCr MSB aligned
2635324fb0dSmrg * index 0 = Y plane, [15:0] Y little endian
2645324fb0dSmrg * index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian
2655324fb0dSmrg */
2665324fb0dSmrg#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */
2675324fb0dSmrg
268e88f27b3Smrg/*
269e88f27b3Smrg * 3 plane YCbCr
270e88f27b3Smrg * index 0: Y plane, [7:0] Y
271e88f27b3Smrg * index 1: Cb plane, [7:0] Cb
272e88f27b3Smrg * index 2: Cr plane, [7:0] Cr
273e88f27b3Smrg * or
274e88f27b3Smrg * index 1: Cr plane, [7:0] Cr
275e88f27b3Smrg * index 2: Cb plane, [7:0] Cb
276e88f27b3Smrg */
277e88f27b3Smrg#define DRM_FORMAT_YUV410	fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
278e88f27b3Smrg#define DRM_FORMAT_YVU410	fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
279e88f27b3Smrg#define DRM_FORMAT_YUV411	fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
280e88f27b3Smrg#define DRM_FORMAT_YVU411	fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
281e88f27b3Smrg#define DRM_FORMAT_YUV420	fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
282e88f27b3Smrg#define DRM_FORMAT_YVU420	fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
283e88f27b3Smrg#define DRM_FORMAT_YUV422	fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
284e88f27b3Smrg#define DRM_FORMAT_YVU422	fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
285e88f27b3Smrg#define DRM_FORMAT_YUV444	fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
286e88f27b3Smrg#define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
287e88f27b3Smrg
2883f012e29Smrg
2893f012e29Smrg/*
2903f012e29Smrg * Format Modifiers:
2913f012e29Smrg *
2923f012e29Smrg * Format modifiers describe, typically, a re-ordering or modification
2933f012e29Smrg * of the data in a plane of an FB.  This can be used to express tiled/
2943f012e29Smrg * swizzled formats, or compression, or a combination of the two.
2953f012e29Smrg *
2963f012e29Smrg * The upper 8 bits of the format modifier are a vendor-id as assigned
2973f012e29Smrg * below.  The lower 56 bits are assigned as vendor sees fit.
2983f012e29Smrg */
2993f012e29Smrg
3003f012e29Smrg/* Vendor Ids: */
3013f012e29Smrg#define DRM_FORMAT_MOD_NONE           0
302d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_NONE    0
3033f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_INTEL   0x01
3043f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_AMD     0x02
30500a23bdaSmrg#define DRM_FORMAT_MOD_VENDOR_NVIDIA  0x03
3063f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04
3073f012e29Smrg#define DRM_FORMAT_MOD_VENDOR_QCOM    0x05
308d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06
309d8807b2fSmrg#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
3107cdc0497Smrg#define DRM_FORMAT_MOD_VENDOR_ARM     0x08
3115324fb0dSmrg#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
3125324fb0dSmrg
3133f012e29Smrg/* add more to the end as needed */
3143f012e29Smrg
315d8807b2fSmrg#define DRM_FORMAT_RESERVED	      ((1ULL << 56) - 1)
316d8807b2fSmrg
3173f012e29Smrg#define fourcc_mod_code(vendor, val) \
31800a23bdaSmrg	((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL))
3193f012e29Smrg
3203f012e29Smrg/*
3213f012e29Smrg * Format Modifier tokens:
3223f012e29Smrg *
3233f012e29Smrg * When adding a new token please document the layout with a code comment,
3243f012e29Smrg * similar to the fourcc codes above. drm_fourcc.h is considered the
3253f012e29Smrg * authoritative source for all of these.
3263f012e29Smrg */
3273f012e29Smrg
328d8807b2fSmrg/*
329d8807b2fSmrg * Invalid Modifier
330d8807b2fSmrg *
331d8807b2fSmrg * This modifier can be used as a sentinel to terminate the format modifiers
332d8807b2fSmrg * list, or to initialize a variable with an invalid modifier. It might also be
333d8807b2fSmrg * used to report an error back to userspace for certain APIs.
334d8807b2fSmrg */
335d8807b2fSmrg#define DRM_FORMAT_MOD_INVALID	fourcc_mod_code(NONE, DRM_FORMAT_RESERVED)
336d8807b2fSmrg
337d8807b2fSmrg/*
338d8807b2fSmrg * Linear Layout
339d8807b2fSmrg *
340d8807b2fSmrg * Just plain linear layout. Note that this is different from no specifying any
341d8807b2fSmrg * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl),
342d8807b2fSmrg * which tells the driver to also take driver-internal information into account
343d8807b2fSmrg * and so might actually result in a tiled framebuffer.
344d8807b2fSmrg */
345d8807b2fSmrg#define DRM_FORMAT_MOD_LINEAR	fourcc_mod_code(NONE, 0)
346d8807b2fSmrg
3473f012e29Smrg/* Intel framebuffer modifiers */
3483f012e29Smrg
3493f012e29Smrg/*
3503f012e29Smrg * Intel X-tiling layout
3513f012e29Smrg *
3523f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb)
3533f012e29Smrg * in row-major layout. Within the tile bytes are laid out row-major, with
3543f012e29Smrg * a platform-dependent stride. On top of that the memory can apply
3553f012e29Smrg * platform-depending swizzling of some higher address bits into bit6.
3563f012e29Smrg *
3573f012e29Smrg * This format is highly platforms specific and not useful for cross-driver
3583f012e29Smrg * sharing. It exists since on a given platform it does uniquely identify the
3593f012e29Smrg * layout in a simple way for i915-specific userspace.
3603f012e29Smrg */
3613f012e29Smrg#define I915_FORMAT_MOD_X_TILED	fourcc_mod_code(INTEL, 1)
3623f012e29Smrg
3633f012e29Smrg/*
3643f012e29Smrg * Intel Y-tiling layout
3653f012e29Smrg *
3663f012e29Smrg * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb)
3673f012e29Smrg * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes)
3683f012e29Smrg * chunks column-major, with a platform-dependent height. On top of that the
3693f012e29Smrg * memory can apply platform-depending swizzling of some higher address bits
3703f012e29Smrg * into bit6.
3713f012e29Smrg *
3723f012e29Smrg * This format is highly platforms specific and not useful for cross-driver
3733f012e29Smrg * sharing. It exists since on a given platform it does uniquely identify the
3743f012e29Smrg * layout in a simple way for i915-specific userspace.
3753f012e29Smrg */
3763f012e29Smrg#define I915_FORMAT_MOD_Y_TILED	fourcc_mod_code(INTEL, 2)
3773f012e29Smrg
3783f012e29Smrg/*
3793f012e29Smrg * Intel Yf-tiling layout
3803f012e29Smrg *
3813f012e29Smrg * This is a tiled layout using 4Kb tiles in row-major layout.
3823f012e29Smrg * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
3833f012e29Smrg * are arranged in four groups (two wide, two high) with column-major layout.
3845324fb0dSmrg * Each group therefore consists out of four 256 byte units, which are also laid
3853f012e29Smrg * out as 2x2 column-major.
3863f012e29Smrg * 256 byte units are made out of four 64 byte blocks of pixels, producing
3873f012e29Smrg * either a square block or a 2:1 unit.
3883f012e29Smrg * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width
3893f012e29Smrg * in pixel depends on the pixel depth.
3903f012e29Smrg */
3913f012e29Smrg#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
3923f012e29Smrg
393d8807b2fSmrg/*
394d8807b2fSmrg * Intel color control surface (CCS) for render compression
395d8807b2fSmrg *
396d8807b2fSmrg * The framebuffer format must be one of the 8:8:8:8 RGB formats.
397d8807b2fSmrg * The main surface will be plane index 0 and must be Y/Yf-tiled,
398d8807b2fSmrg * the CCS will be plane index 1.
399d8807b2fSmrg *
400d8807b2fSmrg * Each CCS tile matches a 1024x512 pixel area of the main surface.
401d8807b2fSmrg * To match certain aspects of the 3D hardware the CCS is
402d8807b2fSmrg * considered to be made up of normal 128Bx32 Y tiles, Thus
403d8807b2fSmrg * the CCS pitch must be specified in multiples of 128 bytes.
404d8807b2fSmrg *
405d8807b2fSmrg * In reality the CCS tile appears to be a 64Bx64 Y tile, composed
406d8807b2fSmrg * of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks.
407d8807b2fSmrg * But that fact is not relevant unless the memory is accessed
408d8807b2fSmrg * directly.
409d8807b2fSmrg */
410d8807b2fSmrg#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
411d8807b2fSmrg#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
412d8807b2fSmrg
4133f012e29Smrg/*
4143f012e29Smrg * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
4153f012e29Smrg *
4163f012e29Smrg * Macroblocks are laid in a Z-shape, and each pixel data is following the
4173f012e29Smrg * standard NV12 style.
4183f012e29Smrg * As for NV12, an image is the result of two frame buffers: one for Y,
4193f012e29Smrg * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer).
4203f012e29Smrg * Alignment requirements are (for each buffer):
4213f012e29Smrg * - multiple of 128 pixels for the width
4223f012e29Smrg * - multiple of  32 pixels for the height
4233f012e29Smrg *
4243f012e29Smrg * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html
4253f012e29Smrg */
4263f012e29Smrg#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE	fourcc_mod_code(SAMSUNG, 1)
4273f012e29Smrg
4285324fb0dSmrg/*
4295324fb0dSmrg * Tiled, 16 (pixels) x 16 (lines) - sized macroblocks
4305324fb0dSmrg *
4315324fb0dSmrg * This is a simple tiled layout using tiles of 16x16 pixels in a row-major
4325324fb0dSmrg * layout. For YCbCr formats Cb/Cr components are taken in such a way that
4335324fb0dSmrg * they correspond to their 16x16 luma block.
4345324fb0dSmrg */
4355324fb0dSmrg#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE	fourcc_mod_code(SAMSUNG, 2)
4365324fb0dSmrg
4377cdc0497Smrg/*
4387cdc0497Smrg * Qualcomm Compressed Format
4397cdc0497Smrg *
4407cdc0497Smrg * Refers to a compressed variant of the base format that is compressed.
4417cdc0497Smrg * Implementation may be platform and base-format specific.
4427cdc0497Smrg *
4437cdc0497Smrg * Each macrotile consists of m x n (mostly 4 x 4) tiles.
4447cdc0497Smrg * Pixel data pitch/stride is aligned with macrotile width.
4457cdc0497Smrg * Pixel data height is aligned with macrotile height.
4467cdc0497Smrg * Entire pixel data buffer is aligned with 4k(bytes).
4477cdc0497Smrg */
4487cdc0497Smrg#define DRM_FORMAT_MOD_QCOM_COMPRESSED	fourcc_mod_code(QCOM, 1)
4497cdc0497Smrg
450d8807b2fSmrg/* Vivante framebuffer modifiers */
451d8807b2fSmrg
452d8807b2fSmrg/*
453d8807b2fSmrg * Vivante 4x4 tiling layout
454d8807b2fSmrg *
455d8807b2fSmrg * This is a simple tiled layout using tiles of 4x4 pixels in a row-major
456d8807b2fSmrg * layout.
457d8807b2fSmrg */
458d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_TILED		fourcc_mod_code(VIVANTE, 1)
459d8807b2fSmrg
460d8807b2fSmrg/*
461d8807b2fSmrg * Vivante 64x64 super-tiling layout
462d8807b2fSmrg *
463d8807b2fSmrg * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile
464d8807b2fSmrg * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row-
465d8807b2fSmrg * major layout.
466d8807b2fSmrg *
467d8807b2fSmrg * For more information: see
468d8807b2fSmrg * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling
469d8807b2fSmrg */
470d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED	fourcc_mod_code(VIVANTE, 2)
471d8807b2fSmrg
472d8807b2fSmrg/*
473d8807b2fSmrg * Vivante 4x4 tiling layout for dual-pipe
474d8807b2fSmrg *
475d8807b2fSmrg * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a
476d8807b2fSmrg * different base address. Offsets from the base addresses are therefore halved
477d8807b2fSmrg * compared to the non-split tiled layout.
478d8807b2fSmrg */
479d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED	fourcc_mod_code(VIVANTE, 3)
480d8807b2fSmrg
481d8807b2fSmrg/*
482d8807b2fSmrg * Vivante 64x64 super-tiling layout for dual-pipe
483d8807b2fSmrg *
484d8807b2fSmrg * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile
485d8807b2fSmrg * starts at a different base address. Offsets from the base addresses are
486d8807b2fSmrg * therefore halved compared to the non-split super-tiled layout.
487d8807b2fSmrg */
488d8807b2fSmrg#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4)
489d8807b2fSmrg
49000a23bdaSmrg/* NVIDIA frame buffer modifiers */
491d8807b2fSmrg
492d8807b2fSmrg/*
493d8807b2fSmrg * Tegra Tiled Layout, used by Tegra 2, 3 and 4.
494d8807b2fSmrg *
495d8807b2fSmrg * Pixels are arranged in simple tiles of 16 x 16 bytes.
496d8807b2fSmrg */
49700a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1)
498d8807b2fSmrg
499d8807b2fSmrg/*
50000a23bdaSmrg * 16Bx2 Block Linear layout, used by desktop GPUs, and Tegra K1 and later
501d8807b2fSmrg *
502d8807b2fSmrg * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked
503d8807b2fSmrg * vertically by a power of 2 (1 to 32 GOBs) to form a block.
504d8807b2fSmrg *
505d8807b2fSmrg * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape.
506d8807b2fSmrg *
507d8807b2fSmrg * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically.
508d8807b2fSmrg * Valid values are:
509d8807b2fSmrg *
510d8807b2fSmrg * 0 == ONE_GOB
511d8807b2fSmrg * 1 == TWO_GOBS
512d8807b2fSmrg * 2 == FOUR_GOBS
513d8807b2fSmrg * 3 == EIGHT_GOBS
514d8807b2fSmrg * 4 == SIXTEEN_GOBS
515d8807b2fSmrg * 5 == THIRTYTWO_GOBS
516d8807b2fSmrg *
517d8807b2fSmrg * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format
518d8807b2fSmrg * in full detail.
519d8807b2fSmrg */
52000a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \
52100a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x10 | ((v) & 0xf))
52200a23bdaSmrg
52300a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \
52400a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x10)
52500a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \
52600a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x11)
52700a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \
52800a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x12)
52900a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \
53000a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x13)
53100a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \
53200a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x14)
53300a23bdaSmrg#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \
53400a23bdaSmrg	fourcc_mod_code(NVIDIA, 0x15)
535d8807b2fSmrg
5367cdc0497Smrg/*
5377cdc0497Smrg * Some Broadcom modifiers take parameters, for example the number of
5387cdc0497Smrg * vertical lines in the image. Reserve the lower 32 bits for modifier
5397cdc0497Smrg * type, and the next 24 bits for parameters. Top 8 bits are the
5407cdc0497Smrg * vendor code.
5417cdc0497Smrg */
5427cdc0497Smrg#define __fourcc_mod_broadcom_param_shift 8
5437cdc0497Smrg#define __fourcc_mod_broadcom_param_bits 48
5447cdc0497Smrg#define fourcc_mod_broadcom_code(val, params) \
5457cdc0497Smrg	fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val))
5467cdc0497Smrg#define fourcc_mod_broadcom_param(m) \
5477cdc0497Smrg	((int)(((m) >> __fourcc_mod_broadcom_param_shift) &	\
5487cdc0497Smrg	       ((1ULL << __fourcc_mod_broadcom_param_bits) - 1)))
5497cdc0497Smrg#define fourcc_mod_broadcom_mod(m) \
5507cdc0497Smrg	((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) <<	\
5517cdc0497Smrg		 __fourcc_mod_broadcom_param_shift))
5527cdc0497Smrg
553d8807b2fSmrg/*
554d8807b2fSmrg * Broadcom VC4 "T" format
555d8807b2fSmrg *
556d8807b2fSmrg * This is the primary layout that the V3D GPU can texture from (it
557d8807b2fSmrg * can't do linear).  The T format has:
558d8807b2fSmrg *
559d8807b2fSmrg * - 64b utiles of pixels in a raster-order grid according to cpp.  It's 4x4
560d8807b2fSmrg *   pixels at 32 bit depth.
561d8807b2fSmrg *
562d8807b2fSmrg * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually
563d8807b2fSmrg *   16x16 pixels).
564d8807b2fSmrg *
565d8807b2fSmrg * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels).  On
566d8807b2fSmrg *   even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows
567d8807b2fSmrg *   they're (TR, BR, BL, TL), where bottom left is start of memory.
568d8807b2fSmrg *
569d8807b2fSmrg * - an image made of 4k tiles in rows either left-to-right (even rows of 4k
570d8807b2fSmrg *   tiles) or right-to-left (odd rows of 4k tiles).
571d8807b2fSmrg */
572d8807b2fSmrg#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1)
573d8807b2fSmrg
5747cdc0497Smrg/*
5757cdc0497Smrg * Broadcom SAND format
5767cdc0497Smrg *
5777cdc0497Smrg * This is the native format that the H.264 codec block uses.  For VC4
5787cdc0497Smrg * HVS, it is only valid for H.264 (NV12/21) and RGBA modes.
5797cdc0497Smrg *
5807cdc0497Smrg * The image can be considered to be split into columns, and the
5817cdc0497Smrg * columns are placed consecutively into memory.  The width of those
5827cdc0497Smrg * columns can be either 32, 64, 128, or 256 pixels, but in practice
5837cdc0497Smrg * only 128 pixel columns are used.
5847cdc0497Smrg *
5857cdc0497Smrg * The pitch between the start of each column is set to optimally
5867cdc0497Smrg * switch between SDRAM banks. This is passed as the number of lines
5877cdc0497Smrg * of column width in the modifier (we can't use the stride value due
5887cdc0497Smrg * to various core checks that look at it , so you should set the
5897cdc0497Smrg * stride to width*cpp).
5907cdc0497Smrg *
5917cdc0497Smrg * Note that the column height for this format modifier is the same
5927cdc0497Smrg * for all of the planes, assuming that each column contains both Y
5937cdc0497Smrg * and UV.  Some SAND-using hardware stores UV in a separate tiled
5947cdc0497Smrg * image from Y to reduce the column height, which is not supported
5957cdc0497Smrg * with these modifiers.
5967cdc0497Smrg */
5977cdc0497Smrg
5987cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \
5997cdc0497Smrg	fourcc_mod_broadcom_code(2, v)
6007cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \
6017cdc0497Smrg	fourcc_mod_broadcom_code(3, v)
6027cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \
6037cdc0497Smrg	fourcc_mod_broadcom_code(4, v)
6047cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \
6057cdc0497Smrg	fourcc_mod_broadcom_code(5, v)
6067cdc0497Smrg
6077cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND32 \
6087cdc0497Smrg	DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0)
6097cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND64 \
6107cdc0497Smrg	DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0)
6117cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND128 \
6127cdc0497Smrg	DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0)
6137cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_SAND256 \
6147cdc0497Smrg	DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0)
6157cdc0497Smrg
6167cdc0497Smrg/* Broadcom UIF format
6177cdc0497Smrg *
6187cdc0497Smrg * This is the common format for the current Broadcom multimedia
6197cdc0497Smrg * blocks, including V3D 3.x and newer, newer video codecs, and
6207cdc0497Smrg * displays.
6217cdc0497Smrg *
6227cdc0497Smrg * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles),
6237cdc0497Smrg * and macroblocks (4x4 UIF blocks).  Those 4x4 UIF block groups are
6247cdc0497Smrg * stored in columns, with padding between the columns to ensure that
6257cdc0497Smrg * moving from one column to the next doesn't hit the same SDRAM page
6267cdc0497Smrg * bank.
6277cdc0497Smrg *
6287cdc0497Smrg * To calculate the padding, it is assumed that each hardware block
6297cdc0497Smrg * and the software driving it knows the platform's SDRAM page size,
6307cdc0497Smrg * number of banks, and XOR address, and that it's identical between
6317cdc0497Smrg * all blocks using the format.  This tiling modifier will use XOR as
6327cdc0497Smrg * necessary to reduce the padding.  If a hardware block can't do XOR,
6337cdc0497Smrg * the assumption is that a no-XOR tiling modifier will be created.
6347cdc0497Smrg */
6357cdc0497Smrg#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6)
6367cdc0497Smrg
6377cdc0497Smrg/*
6387cdc0497Smrg * Arm Framebuffer Compression (AFBC) modifiers
6397cdc0497Smrg *
6407cdc0497Smrg * AFBC is a proprietary lossless image compression protocol and format.
6417cdc0497Smrg * It provides fine-grained random access and minimizes the amount of data
6427cdc0497Smrg * transferred between IP blocks.
6437cdc0497Smrg *
6447cdc0497Smrg * AFBC has several features which may be supported and/or used, which are
6457cdc0497Smrg * represented using bits in the modifier. Not all combinations are valid,
6467cdc0497Smrg * and different devices or use-cases may support different combinations.
6475324fb0dSmrg *
6485324fb0dSmrg * Further information on the use of AFBC modifiers can be found in
6495324fb0dSmrg * Documentation/gpu/afbc.rst
6507cdc0497Smrg */
6517cdc0497Smrg#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode)	fourcc_mod_code(ARM, __afbc_mode)
6527cdc0497Smrg
6537cdc0497Smrg/*
6547cdc0497Smrg * AFBC superblock size
6557cdc0497Smrg *
6567cdc0497Smrg * Indicates the superblock size(s) used for the AFBC buffer. The buffer
6577cdc0497Smrg * size (in pixels) must be aligned to a multiple of the superblock size.
6587cdc0497Smrg * Four lowest significant bits(LSBs) are reserved for block size.
6595324fb0dSmrg *
6605324fb0dSmrg * Where one superblock size is specified, it applies to all planes of the
6615324fb0dSmrg * buffer (e.g. 16x16, 32x8). When multiple superblock sizes are specified,
6625324fb0dSmrg * the first applies to the Luma plane and the second applies to the Chroma
6635324fb0dSmrg * plane(s). e.g. (32x8_64x4 means 32x8 Luma, with 64x4 Chroma).
6645324fb0dSmrg * Multiple superblock sizes are only valid for multi-plane YCbCr formats.
6657cdc0497Smrg */
6667cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK      0xf
6677cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16     (1ULL)
6687cdc0497Smrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8      (2ULL)
6695324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4      (3ULL)
6705324fb0dSmrg#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 (4ULL)
6717cdc0497Smrg
6727cdc0497Smrg/*
6737cdc0497Smrg * AFBC lossless colorspace transform
6747cdc0497Smrg *
6757cdc0497Smrg * Indicates that the buffer makes use of the AFBC lossless colorspace
6767cdc0497Smrg * transform.
6777cdc0497Smrg */
6787cdc0497Smrg#define AFBC_FORMAT_MOD_YTR     (1ULL <<  4)
6797cdc0497Smrg
6807cdc0497Smrg/*
6817cdc0497Smrg * AFBC block-split
6827cdc0497Smrg *
6837cdc0497Smrg * Indicates that the payload of each superblock is split. The second
6847cdc0497Smrg * half of the payload is positioned at a predefined offset from the start
6857cdc0497Smrg * of the superblock payload.
6867cdc0497Smrg */
6877cdc0497Smrg#define AFBC_FORMAT_MOD_SPLIT   (1ULL <<  5)
6887cdc0497Smrg
6897cdc0497Smrg/*
6907cdc0497Smrg * AFBC sparse layout
6917cdc0497Smrg *
6927cdc0497Smrg * This flag indicates that the payload of each superblock must be stored at a
6937cdc0497Smrg * predefined position relative to the other superblocks in the same AFBC
6947cdc0497Smrg * buffer. This order is the same order used by the header buffer. In this mode
6957cdc0497Smrg * each superblock is given the same amount of space as an uncompressed
6967cdc0497Smrg * superblock of the particular format would require, rounding up to the next
6977cdc0497Smrg * multiple of 128 bytes in size.
6987cdc0497Smrg */
6997cdc0497Smrg#define AFBC_FORMAT_MOD_SPARSE  (1ULL <<  6)
7007cdc0497Smrg
7017cdc0497Smrg/*
7027cdc0497Smrg * AFBC copy-block restrict
7037cdc0497Smrg *
7047cdc0497Smrg * Buffers with this flag must obey the copy-block restriction. The restriction
7057cdc0497Smrg * is such that there are no copy-blocks referring across the border of 8x8
7067cdc0497Smrg * blocks. For the subsampled data the 8x8 limitation is also subsampled.
7077cdc0497Smrg */
7087cdc0497Smrg#define AFBC_FORMAT_MOD_CBR     (1ULL <<  7)
7097cdc0497Smrg
7107cdc0497Smrg/*
7117cdc0497Smrg * AFBC tiled layout
7127cdc0497Smrg *
7137cdc0497Smrg * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all
7147cdc0497Smrg * superblocks inside a tile are stored together in memory. 8x8 tiles are used
7157cdc0497Smrg * for pixel formats up to and including 32 bpp while 4x4 tiles are used for
7167cdc0497Smrg * larger bpp formats. The order between the tiles is scan line.
7177cdc0497Smrg * When the tiled layout is used, the buffer size (in pixels) must be aligned
7187cdc0497Smrg * to the tile size.
7197cdc0497Smrg */
7207cdc0497Smrg#define AFBC_FORMAT_MOD_TILED   (1ULL <<  8)
7217cdc0497Smrg
7227cdc0497Smrg/*
7237cdc0497Smrg * AFBC solid color blocks
7247cdc0497Smrg *
7257cdc0497Smrg * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth
7267cdc0497Smrg * can be reduced if a whole superblock is a single color.
7277cdc0497Smrg */
7287cdc0497Smrg#define AFBC_FORMAT_MOD_SC      (1ULL <<  9)
7297cdc0497Smrg
7305324fb0dSmrg/*
7315324fb0dSmrg * AFBC double-buffer
7325324fb0dSmrg *
7335324fb0dSmrg * Indicates that the buffer is allocated in a layout safe for front-buffer
7345324fb0dSmrg * rendering.
7355324fb0dSmrg */
7365324fb0dSmrg#define AFBC_FORMAT_MOD_DB      (1ULL << 10)
7375324fb0dSmrg
7385324fb0dSmrg/*
7395324fb0dSmrg * AFBC buffer content hints
7405324fb0dSmrg *
7415324fb0dSmrg * Indicates that the buffer includes per-superblock content hints.
7425324fb0dSmrg */
7435324fb0dSmrg#define AFBC_FORMAT_MOD_BCH     (1ULL << 11)
7445324fb0dSmrg
7455324fb0dSmrg/*
7465324fb0dSmrg * Allwinner tiled modifier
7475324fb0dSmrg *
7485324fb0dSmrg * This tiling mode is implemented by the VPU found on all Allwinner platforms,
7495324fb0dSmrg * codenamed sunxi. It is associated with a YUV format that uses either 2 or 3
7505324fb0dSmrg * planes.
7515324fb0dSmrg *
7525324fb0dSmrg * With this tiling, the luminance samples are disposed in tiles representing
7535324fb0dSmrg * 32x32 pixels and the chrominance samples in tiles representing 32x64 pixels.
7545324fb0dSmrg * The pixel order in each tile is linear and the tiles are disposed linearly,
7555324fb0dSmrg * both in row-major order.
7565324fb0dSmrg */
7575324fb0dSmrg#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
7585324fb0dSmrg
759d8807b2fSmrg#if defined(__cplusplus)
760d8807b2fSmrg}
761d8807b2fSmrg#endif
762d8807b2fSmrg
763e88f27b3Smrg#endif /* DRM_FOURCC_H */
764