From: GitLab M. <git...@ke...> - 2022-12-07 18:02:29
|
include/drm/drm_fourcc.h | 63 ++++++++++++++++++++++++++++++++++++++++--- xf86drm.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 4 deletions(-) New commits: commit 874af994636a534236a747a88aec086b9b35b001 Author: Philipp Zabel <p....@pe...> Date: Thu Oct 13 13:44:38 2022 +0200 xf86drm: Add support for decoding Vivante format modifiers Allow applications to pretty-print Vivante format modifiers. Signed-off-by: Philipp Zabel <p....@pe...> diff --git a/xf86drm.c b/xf86drm.c index 0faa5972..33d55a7f 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -175,11 +175,15 @@ drmGetFormatModifierNameFromAmd(uint64_t modifier); static char * drmGetFormatModifierNameFromAmlogic(uint64_t modifier); +static char * +drmGetFormatModifierNameFromVivante(uint64_t modifier); + static const struct drmVendorInfo modifier_format_vendor_table[] = { { DRM_FORMAT_MOD_VENDOR_ARM, drmGetFormatModifierNameFromArm }, { DRM_FORMAT_MOD_VENDOR_NVIDIA, drmGetFormatModifierNameFromNvidia }, { DRM_FORMAT_MOD_VENDOR_AMD, drmGetFormatModifierNameFromAmd }, { DRM_FORMAT_MOD_VENDOR_AMLOGIC, drmGetFormatModifierNameFromAmlogic }, + { DRM_FORMAT_MOD_VENDOR_VIVANTE, drmGetFormatModifierNameFromVivante }, }; #ifndef AFBC_FORMAT_MOD_MODE_VALUE_MASK @@ -547,6 +551,70 @@ drmGetFormatModifierNameFromAmlogic(uint64_t modifier) return mod_amlogic; } +static char * +drmGetFormatModifierNameFromVivante(uint64_t modifier) +{ + const char *color_tiling, *tile_status, *compression; + const char *mod_vivante = NULL; + + switch (modifier & VIVANTE_MOD_TS_MASK) { + case 0: + tile_status = ""; + break; + case VIVANTE_MOD_TS_64_4: + tile_status = ",TS=64B_4"; + break; + case VIVANTE_MOD_TS_64_2: + tile_status = ",TS=64B_2"; + break; + case VIVANTE_MOD_TS_128_4: + tile_status = ",TS=128B_4"; + break; + case VIVANTE_MOD_TS_256_4: + tile_status = ",TS=256B_4"; + break; + default: + tile_status = ",TS=UNKNOWN"; + break; + } + + switch (modifier & VIVANTE_MOD_COMP_MASK) { + case 0: + compression = ""; + break; + case VIVANTE_MOD_COMP_DEC400: + compression = ",COMP=DEC400"; + break; + default: + compression = ",COMP=UNKNOWN"; + break; + } + + switch (modifier & ~VIVANTE_MOD_EXT_MASK) { + case 0: + color_tiling = "LINEAR"; + break; + case DRM_FORMAT_MOD_VIVANTE_TILED: + color_tiling = "TILED"; + break; + case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED: + color_tiling = "SUPER_TILED"; + break; + case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED: + color_tiling = "SPLIT_TILED"; + break; + case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED: + color_tiling = "SPLIT_SUPER_TILED"; + break; + default: + color_tiling = "UNKNOWN"; + break; + } + + asprintf(&mod_vivante, "%s%s%s", color_tiling, tile_status, compression); + return mod_vivante; +} + static unsigned log2_int(unsigned x) { unsigned l; commit 329eebcf32793361390edfc95ffcbc51fbec2043 Author: Philipp Zabel <p....@pe...> Date: Wed Nov 30 18:13:37 2022 +0100 drm_fourcc: sync drm_fourcc with latest drm-next kernel Update drm_fourcc.h to include latest changes from drm-next branch. This brings in sub-8bpp formats, AVUY and XVUY 8:8:8:8, and Vivante tile-status and compression modifiers. Generated using make headers_install. Generated from drm-next branch commit 077bd80083ab Signed-off-by: Philipp Zabel <p....@pe...> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 2c9051ff..0e70e36c 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -99,18 +99,42 @@ extern "C" { #define DRM_FORMAT_INVALID 0 /* color index */ +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ -/* 8 bpp Red */ +/* 1 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */ + +/* 8 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */ + +/* 1 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */ + +/* 8 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ -/* 10 bpp Red */ +/* 10 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */ -/* 12 bpp Red */ +/* 12 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */ -/* 16 bpp Red */ +/* 16 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ /* 16 bpp RG */ @@ -205,7 +229,9 @@ extern "C" { #define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */ #define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */ @@ -718,6 +744,35 @@ extern "C" { */ #define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) +/* + * Vivante TS (tile-status) buffer modifiers. They can be combined with all of + * the color buffer tiling modifiers defined above. When TS is present it's a + * separate buffer containing the clear/compression status of each tile. The + * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer + * tile size in bytes covered by one entry in the status buffer and s is the + * number of status bits per entry. + * We reserve the top 8 bits of the Vivante modifier space for tile status + * clear/compression modifiers, as future cores might add some more TS layout + * variations. + */ +#define VIVANTE_MOD_TS_64_4 (1ULL << 48) +#define VIVANTE_MOD_TS_64_2 (2ULL << 48) +#define VIVANTE_MOD_TS_128_4 (3ULL << 48) +#define VIVANTE_MOD_TS_256_4 (4ULL << 48) +#define VIVANTE_MOD_TS_MASK (0xfULL << 48) + +/* + * Vivante compression modifiers. Those depend on a TS modifier being present + * as the TS bits get reinterpreted as compression tags instead of simple + * clear markers when compression is enabled. + */ +#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52) +#define VIVANTE_MOD_COMP_MASK (0xfULL << 52) + +/* Masking out the extension bits will yield the base modifier. */ +#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \ + VIVANTE_MOD_COMP_MASK) + /* NVIDIA frame buffer modifiers */ /* |