Module: Mesa
Branch: main
Commit: 502b94294413a3e4ff707afa79c4fd9b6cde356a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=502b94294413a3e4ff707afa79c4fd9b6cde356a

Author: Boris Brezillon <[email protected]>
Date:   Fri Aug  6 10:12:31 2021 +0200

panfrost: Move panfrost_major_version() to gen_macros.h

So we can use this function in decode_common.c when transitioning to
per-gen XML. While at it rename the function pan_arch().

Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12935>

---

 src/panfrost/lib/gen_macros.h | 23 +++++++++++++++++++++++
 src/panfrost/lib/pan_props.c  | 25 +------------------------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/panfrost/lib/gen_macros.h b/src/panfrost/lib/gen_macros.h
index bef174f9fa7..4dea1e9a82b 100644
--- a/src/panfrost/lib/gen_macros.h
+++ b/src/panfrost/lib/gen_macros.h
@@ -49,6 +49,29 @@
  * possible.
  */
 
+/* Returns the architecture version given a GPU ID, either from a table for
+ * old-style Midgard versions or directly for new-style Bifrost/Valhall
+ * versions */
+
+static inline unsigned
+pan_arch(unsigned gpu_id)
+{
+        switch (gpu_id) {
+        case 0x600:
+        case 0x620:
+        case 0x720:
+                return 4;
+        case 0x750:
+        case 0x820:
+        case 0x830:
+        case 0x860:
+        case 0x880:
+                return 5;
+        default:
+                return gpu_id >> 12;
+        }
+}
+
 /* Base macro defined on the command line. */
 #ifndef PAN_ARCH
 /* This will be replaced by a minimal definition header as soon as the
diff --git a/src/panfrost/lib/pan_props.c b/src/panfrost/lib/pan_props.c
index 5b2827bc74d..551d9713d3e 100644
--- a/src/panfrost/lib/pan_props.c
+++ b/src/panfrost/lib/pan_props.c
@@ -191,29 +191,6 @@ panfrost_supports_compressed_format(struct panfrost_device 
*dev, unsigned fmt)
         return dev->compressed_formats & (1 << idx);
 }
 
-/* Returns the architecture version given a GPU ID, either from a table for
- * old-style Midgard versions or directly for new-style Bifrost/Valhall
- * versions */
-
-static unsigned
-panfrost_major_version(unsigned gpu_id)
-{
-        switch (gpu_id) {
-        case 0x600:
-        case 0x620:
-        case 0x720:
-                return 4;
-        case 0x750:
-        case 0x820:
-        case 0x830:
-        case 0x860:
-        case 0x880:
-                return 5;
-        default:
-                return gpu_id >> 12;
-        }
-}
-
 /* Given a GPU ID like 0x860, return a prettified model name */
 
 const char *
@@ -243,7 +220,7 @@ panfrost_open_device(void *memctx, int fd, struct 
panfrost_device *dev)
         dev->fd = fd;
         dev->memctx = memctx;
         dev->gpu_id = panfrost_query_gpu_version(fd);
-        dev->arch = panfrost_major_version(dev->gpu_id);
+        dev->arch = pan_arch(dev->gpu_id);
         dev->core_count = panfrost_query_core_count(fd);
         dev->thread_tls_alloc = panfrost_query_thread_tls_alloc(fd, dev->arch);
         dev->kernel_version = drmGetVersion(fd);

Reply via email to