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