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 <alyssa@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13497>
This commit is contained in:
Alyssa Rosenzweig 2021-10-05 16:01:00 -04:00
parent ebe9494b61
commit 3e168b97cc
2 changed files with 15 additions and 0 deletions

View File

@ -160,6 +160,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;

View File

@ -214,6 +214,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)
{
@ -228,6 +241,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;