@@ -57,6 +57,30 @@ extern "C" {
57
57
* may preserve meaning - such as number of planes - from the fourcc code,
58
58
* whereas others may not.
59
59
*
60
+ * Modifiers must uniquely encode buffer layout. In other words, a buffer must
61
+ * match only a single modifier. A modifier must not be a subset of layouts of
62
+ * another modifier. For instance, it's incorrect to encode pitch alignment in
63
+ * a modifier: a buffer may match a 64-pixel aligned modifier and a 32-pixel
64
+ * aligned modifier. That said, modifiers can have implicit minimal
65
+ * requirements.
66
+ *
67
+ * For modifiers where the combination of fourcc code and modifier can alias,
68
+ * a canonical pair needs to be defined and used by all drivers. Preferred
69
+ * combinations are also encouraged where all combinations might lead to
70
+ * confusion and unnecessarily reduced interoperability. An example for the
71
+ * latter is AFBC, where the ABGR layouts are preferred over ARGB layouts.
72
+ *
73
+ * There are two kinds of modifier users:
74
+ *
75
+ * - Kernel and user-space drivers: for drivers it's important that modifiers
76
+ * don't alias, otherwise two drivers might support the same format but use
77
+ * different aliases, preventing them from sharing buffers in an efficient
78
+ * format.
79
+ * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
80
+ * see modifiers as opaque tokens they can check for equality and intersect.
81
+ * These users musn't need to know to reason about the modifier value
82
+ * (i.e. they are not expected to extract information out of the modifier).
83
+ *
60
84
* Vendors should document their modifier usage in as much detail as
61
85
* possible, to ensure maximum compatibility across devices, drivers and
62
86
* applications.
@@ -154,6 +178,12 @@ extern "C" {
154
178
#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */
155
179
#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */
156
180
181
+ /*
182
+ * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits
183
+ * of unused padding per component:
184
+ */
185
+ #define DRM_FORMAT_AXBXGXRX106106106106 fourcc_code('A', 'B', '1', '0') /* [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian */
186
+
157
187
/* packed YCbCr */
158
188
#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
159
189
#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
@@ -319,7 +349,6 @@ extern "C" {
319
349
*/
320
350
321
351
/* Vendor Ids: */
322
- #define DRM_FORMAT_MOD_NONE 0
323
352
#define DRM_FORMAT_MOD_VENDOR_NONE 0
324
353
#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01
325
354
#define DRM_FORMAT_MOD_VENDOR_AMD 0x02
@@ -391,6 +420,16 @@ extern "C" {
391
420
*/
392
421
#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
393
422
423
+ /*
424
+ * Deprecated: use DRM_FORMAT_MOD_LINEAR instead
425
+ *
426
+ * The "none" format modifier doesn't actually mean that the modifier is
427
+ * implicit, instead it means that the layout is linear. Whether modifiers are
428
+ * used is out-of-band information carried in an API-specific way (e.g. in a
429
+ * flag for drm_mode_fb_cmd2).
430
+ */
431
+ #define DRM_FORMAT_MOD_NONE 0
432
+
394
433
/* Intel framebuffer modifiers */
395
434
396
435
/*
@@ -1055,6 +1094,140 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t modifier)
1055
1094
*/
1056
1095
#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0)
1057
1096
1097
+ /*
1098
+ * AMD modifiers
1099
+ *
1100
+ * Memory layout:
1101
+ *
1102
+ * without DCC:
1103
+ * - main surface
1104
+ *
1105
+ * with DCC & without DCC_RETILE:
1106
+ * - main surface in plane 0
1107
+ * - DCC surface in plane 1 (RB-aligned, pipe-aligned if DCC_PIPE_ALIGN is set)
1108
+ *
1109
+ * with DCC & DCC_RETILE:
1110
+ * - main surface in plane 0
1111
+ * - displayable DCC surface in plane 1 (not RB-aligned & not pipe-aligned)
1112
+ * - pipe-aligned DCC surface in plane 2 (RB-aligned & pipe-aligned)
1113
+ *
1114
+ * For multi-plane formats the above surfaces get merged into one plane for
1115
+ * each format plane, based on the required alignment only.
1116
+ *
1117
+ * Bits Parameter Notes
1118
+ * ----- ------------------------ ---------------------------------------------
1119
+ *
1120
+ * 7:0 TILE_VERSION Values are AMD_FMT_MOD_TILE_VER_*
1121
+ * 12:8 TILE Values are AMD_FMT_MOD_TILE_<version>_*
1122
+ * 13 DCC
1123
+ * 14 DCC_RETILE
1124
+ * 15 DCC_PIPE_ALIGN
1125
+ * 16 DCC_INDEPENDENT_64B
1126
+ * 17 DCC_INDEPENDENT_128B
1127
+ * 19:18 DCC_MAX_COMPRESSED_BLOCK Values are AMD_FMT_MOD_DCC_BLOCK_*
1128
+ * 20 DCC_CONSTANT_ENCODE
1129
+ * 23:21 PIPE_XOR_BITS Only for some chips
1130
+ * 26:24 BANK_XOR_BITS Only for some chips
1131
+ * 29:27 PACKERS Only for some chips
1132
+ * 32:30 RB Only for some chips
1133
+ * 35:33 PIPE Only for some chips
1134
+ * 55:36 - Reserved for future use, must be zero
1135
+ */
1136
+ #define AMD_FMT_MOD fourcc_mod_code(AMD, 0)
1137
+
1138
+ #define IS_AMD_FMT_MOD (val ) (((val) >> 56) == DRM_FORMAT_MOD_VENDOR_AMD)
1139
+
1140
+ /* Reserve 0 for GFX8 and older */
1141
+ #define AMD_FMT_MOD_TILE_VER_GFX9 1
1142
+ #define AMD_FMT_MOD_TILE_VER_GFX10 2
1143
+ #define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3
1144
+
1145
+ /*
1146
+ * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical
1147
+ * version.
1148
+ */
1149
+ #define AMD_FMT_MOD_TILE_GFX9_64K_S 9
1150
+
1151
+ /*
1152
+ * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has
1153
+ * GFX9 as canonical version.
1154
+ */
1155
+ #define AMD_FMT_MOD_TILE_GFX9_64K_D 10
1156
+ #define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25
1157
+ #define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26
1158
+ #define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27
1159
+
1160
+ #define AMD_FMT_MOD_DCC_BLOCK_64B 0
1161
+ #define AMD_FMT_MOD_DCC_BLOCK_128B 1
1162
+ #define AMD_FMT_MOD_DCC_BLOCK_256B 2
1163
+
1164
+ #define AMD_FMT_MOD_TILE_VERSION_SHIFT 0
1165
+ #define AMD_FMT_MOD_TILE_VERSION_MASK 0xFF
1166
+ #define AMD_FMT_MOD_TILE_SHIFT 8
1167
+ #define AMD_FMT_MOD_TILE_MASK 0x1F
1168
+
1169
+ /* Whether DCC compression is enabled. */
1170
+ #define AMD_FMT_MOD_DCC_SHIFT 13
1171
+ #define AMD_FMT_MOD_DCC_MASK 0x1
1172
+
1173
+ /*
1174
+ * Whether to include two DCC surfaces, one which is rb & pipe aligned, and
1175
+ * one which is not-aligned.
1176
+ */
1177
+ #define AMD_FMT_MOD_DCC_RETILE_SHIFT 14
1178
+ #define AMD_FMT_MOD_DCC_RETILE_MASK 0x1
1179
+
1180
+ /* Only set if DCC_RETILE = false */
1181
+ #define AMD_FMT_MOD_DCC_PIPE_ALIGN_SHIFT 15
1182
+ #define AMD_FMT_MOD_DCC_PIPE_ALIGN_MASK 0x1
1183
+
1184
+ #define AMD_FMT_MOD_DCC_INDEPENDENT_64B_SHIFT 16
1185
+ #define AMD_FMT_MOD_DCC_INDEPENDENT_64B_MASK 0x1
1186
+ #define AMD_FMT_MOD_DCC_INDEPENDENT_128B_SHIFT 17
1187
+ #define AMD_FMT_MOD_DCC_INDEPENDENT_128B_MASK 0x1
1188
+ #define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_SHIFT 18
1189
+ #define AMD_FMT_MOD_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3
1190
+
1191
+ /*
1192
+ * DCC supports embedding some clear colors directly in the DCC surface.
1193
+ * However, on older GPUs the rendering HW ignores the embedded clear color
1194
+ * and prefers the driver provided color. This necessitates doing a fastclear
1195
+ * eliminate operation before a process transfers control.
1196
+ *
1197
+ * If this bit is set that means the fastclear eliminate is not needed for these
1198
+ * embeddable colors.
1199
+ */
1200
+ #define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_SHIFT 20
1201
+ #define AMD_FMT_MOD_DCC_CONSTANT_ENCODE_MASK 0x1
1202
+
1203
+ /*
1204
+ * The below fields are for accounting for per GPU differences. These are only
1205
+ * relevant for GFX9 and later and if the tile field is *_X/_T.
1206
+ *
1207
+ * PIPE_XOR_BITS = always needed
1208
+ * BANK_XOR_BITS = only for TILE_VER_GFX9
1209
+ * PACKERS = only for TILE_VER_GFX10_RBPLUS
1210
+ * RB = only for TILE_VER_GFX9 & DCC
1211
+ * PIPE = only for TILE_VER_GFX9 & DCC & (DCC_RETILE | DCC_PIPE_ALIGN)
1212
+ */
1213
+ #define AMD_FMT_MOD_PIPE_XOR_BITS_SHIFT 21
1214
+ #define AMD_FMT_MOD_PIPE_XOR_BITS_MASK 0x7
1215
+ #define AMD_FMT_MOD_BANK_XOR_BITS_SHIFT 24
1216
+ #define AMD_FMT_MOD_BANK_XOR_BITS_MASK 0x7
1217
+ #define AMD_FMT_MOD_PACKERS_SHIFT 27
1218
+ #define AMD_FMT_MOD_PACKERS_MASK 0x7
1219
+ #define AMD_FMT_MOD_RB_SHIFT 30
1220
+ #define AMD_FMT_MOD_RB_MASK 0x7
1221
+ #define AMD_FMT_MOD_PIPE_SHIFT 33
1222
+ #define AMD_FMT_MOD_PIPE_MASK 0x7
1223
+
1224
+ #define AMD_FMT_MOD_SET (field , value ) \
1225
+ ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
1226
+ #define AMD_FMT_MOD_GET (field , value ) \
1227
+ (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
1228
+ #define AMD_FMT_MOD_CLEAR (field ) \
1229
+ (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
1230
+
1058
1231
#if defined(__cplusplus )
1059
1232
}
1060
1233
#endif
0 commit comments