From: Marius Vlad Date: Tue, 23 Feb 2021 22:51:45 +0000 (+0200) Subject: xf86drm: Add support for decoding AMLOGIC format modifiers X-Git-Tag: libdrm-2.4.107~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65d89398081b33b7498bccaee6915e977f589ec2;p=platform%2Fupstream%2Flibdrm.git xf86drm: Add support for decoding AMLOGIC format modifiers Signed-off-by: Marius Vlad --- diff --git a/xf86drm.c b/xf86drm.c index 7b4dbf0..1f0b847 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -172,10 +172,14 @@ drmGetFormatModifierNameFromNvidia(uint64_t modifier); static char * drmGetFormatModifierNameFromAmd(uint64_t modifier); +static char * +drmGetFormatModifierNameFromAmlogic(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 }, }; #ifndef AFBC_FORMAT_MOD_MODE_VALUE_MASK @@ -447,6 +451,37 @@ drmGetFormatModifierNameFromAmd(uint64_t modifier) return mod_amd; } +static char * +drmGetFormatModifierNameFromAmlogic(uint64_t modifier) +{ + uint64_t layout = modifier & 0xff; + uint64_t options = (modifier >> 8) & 0xff; + char *mod_amlogic = NULL; + + const char *layout_str; + const char *opts_str; + + switch (layout) { + case AMLOGIC_FBC_LAYOUT_BASIC: + layout_str = "BASIC"; + break; + case AMLOGIC_FBC_LAYOUT_SCATTER: + layout_str = "SCATTER"; + break; + default: + layout_str = "INVALID_LAYOUT"; + break; + } + + if (options & AMLOGIC_FBC_OPTION_MEM_SAVING) + opts_str = "MEM_SAVING"; + else + opts_str = "0"; + + asprintf(&mod_amlogic, "FBC,LAYOUT=%s,OPTIONS=%s", layout_str, opts_str); + return mod_amlogic; +} + static unsigned log2_int(unsigned x) { unsigned l;