From f80f983226a800e3a82976420e4070645ea1dd8a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 5 Oct 2021 16:01:00 -0400 Subject: [PATCH] panfrost: Detect implementations support AFBC AFBC is an optional feature on Bifrost. If it is missing, a bit will be set in the poorly named AFBC_FEATURES register. Check this so we can act appropriately. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: (cherry picked from commit 3e168b97cc7d38e757fa5cd51ecd25c18d84daf6) --- .pick_status.json | 2 +- src/panfrost/lib/pan_device.h | 1 + src/panfrost/lib/pan_props.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 54c27586e84..c4a535ad8a6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -121,7 +121,7 @@ "description": "panfrost: Detect implementations support AFBC", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/panfrost/lib/pan_device.h b/src/panfrost/lib/pan_device.h index 699449c0a55..7c2e9135677 100644 --- a/src/panfrost/lib/pan_device.h +++ b/src/panfrost/lib/pan_device.h @@ -157,6 +157,7 @@ struct panfrost_device { unsigned thread_tls_alloc; struct panfrost_tiler_features tiler_features; unsigned quirks; + bool has_afbc; /* Table of formats, indexed by a PIPE format */ const struct panfrost_format *formats; diff --git a/src/panfrost/lib/pan_props.c b/src/panfrost/lib/pan_props.c index 08596cb3906..8afe44e461a 100644 --- a/src/panfrost/lib/pan_props.c +++ b/src/panfrost/lib/pan_props.c @@ -237,6 +237,19 @@ panfrost_model_name(unsigned gpu_id) } } +/* Check for AFBC hardware support. AFBC is introduced in v5. Implementations + * may omit it, signaled as a nonzero value in the AFBC_FEATURES property. */ + +static bool +panfrost_query_afbc(int fd, unsigned arch) +{ + unsigned reg = panfrost_query_raw(fd, + DRM_PANFROST_PARAM_AFBC_FEATURES, + false, 0); + + return (arch >= 5) && (reg == 0); +} + void panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev) { @@ -251,6 +264,7 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev) dev->quirks = panfrost_get_quirks(dev->gpu_id, revision); dev->compressed_formats = panfrost_query_compressed_formats(fd); dev->tiler_features = panfrost_query_tiler_features(fd); + dev->has_afbc = panfrost_query_afbc(fd, dev->arch); if (dev->quirks & HAS_SWIZZLES) dev->formats = panfrost_pipe_format_v6;