broadcom/common: retrieve V3D revision number
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 9 Nov 2021 07:50:51 +0000 (08:50 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 13 Oct 2023 22:37:41 +0000 (22:37 +0000)
The subrev field from the hub ident3 register is bumped with every
hardware revision doing backwards incompatible changes so we want to
keep track of this.

Instead of modifying the 'ver' field info to acommodate subrev info,
which would require a lot of changes, simply add a new 'rev' field in
devinfo that we can use when we need to make changes based on the
revision number of a hardware release.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25450>

src/broadcom/common/v3d_device_info.c
src/broadcom/common/v3d_device_info.h

index 7e0862f..7512fe3 100644 (file)
@@ -36,6 +36,9 @@ v3d_get_device_info(int fd, struct v3d_device_info* devinfo, v3d_ioctl_fun drm_i
     struct drm_v3d_get_param ident1 = {
             .param = DRM_V3D_PARAM_V3D_CORE0_IDENT1,
     };
+    struct drm_v3d_get_param hub_ident3 = {
+            .param = DRM_V3D_PARAM_V3D_HUB_IDENT3,
+    };
     int ret;
 
     ret = drm_ioctl(fd, DRM_IOCTL_V3D_GET_PARAM, &ident0);
@@ -76,5 +79,14 @@ v3d_get_device_info(int fd, struct v3d_device_info* devinfo, v3d_ioctl_fun drm_i
                 return false;
     }
 
-    return true;
+    ret = drm_ioctl(fd, DRM_IOCTL_V3D_GET_PARAM, &hub_ident3);
+    if (ret != 0) {
+            fprintf(stderr, "Couldn't get V3D core HUB IDENT3: %s\n",
+                    strerror(errno));
+            return false;
+    }
+
+   devinfo->rev = (hub_ident3.value >> 8) & 0xff;
+
+   return true;
 }
index 97abd9b..32cb65c 100644 (file)
@@ -34,6 +34,9 @@ struct v3d_device_info {
         /** Simple V3D version: major * 10 + minor */
         uint8_t ver;
 
+        /** V3D revision number */
+        uint8_t rev;
+
         /** Size of the VPM, in bytes. */
         int vpm_size;