xf86drm: Add support for decoding Vivante format modifiers

Allow applications to pretty-print Vivante format modifiers.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
main
Philipp Zabel 2022-10-13 13:44:38 +02:00
parent 329eebcf32
commit 874af99463
1 changed files with 68 additions and 0 deletions

View File

@ -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;