Mesa (main): pvr: Add TI AM62 as a supported device.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 20 17:05:48 UTC 2022
Module: Mesa
Branch: main
Commit: 62cc9bba06a1a3479558267e70f46e321f73f486
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=62cc9bba06a1a3479558267e70f46e321f73f486
Author: Frank Binns <frank.binns at imgtec.com>
Date: Thu Mar 24 14:47:03 2022 +0000
pvr: Add TI AM62 as a supported device.
The AM62 platform contains an IMG AXE-1-16M GPU.
Co-Authored-By: Karmjit Mahil <Karmjit.Mahil at imgtec.com>
Signed-off-by: Frank Binns <frank.binns at imgtec.com>
Signed-off-by: Karmjit Mahil <Karmjit.Mahil at imgtec.com>
Reviewed-by: Rajnesh Kanwal <rajnesh.kanwal at imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17106>
---
src/imagination/vulkan/pvr_device.c | 101 ++++++++++++++++++++++++++----------
1 file changed, 75 insertions(+), 26 deletions(-)
diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c
index 14cb853f054..2756302a44a 100644
--- a/src/imagination/vulkan/pvr_device.c
+++ b/src/imagination/vulkan/pvr_device.c
@@ -76,6 +76,30 @@
#define PVR_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION)
+#define DEF_DRIVER(str_name) \
+ { \
+ .name = str_name, .len = sizeof(str_name) - 1 \
+ }
+
+struct pvr_drm_device_info {
+ const char *name;
+ size_t len;
+};
+
+/* This is the list of supported DRM display drivers. */
+static const struct pvr_drm_device_info pvr_display_devices[] = {
+ DEF_DRIVER("mediatek-drm"),
+ DEF_DRIVER("ti,am65x-dss"),
+};
+
+/* This is the list of supported DRM render drivers. */
+static const struct pvr_drm_device_info pvr_render_devices[] = {
+ DEF_DRIVER("mediatek,mt8173-gpu"),
+ DEF_DRIVER("ti,am62-gpu"),
+};
+
+#undef DEF_DRIVER
+
static const struct vk_instance_extension_table pvr_instance_extensions = {
#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
.KHR_display = true,
@@ -439,6 +463,48 @@ err_vk_physical_device_finish:
return result;
}
+static bool pvr_drm_device_is_supported(drmDevicePtr drm_dev, int node_type)
+{
+ char **compat = drm_dev->deviceinfo.platform->compatible;
+
+ if (!(drm_dev->available_nodes & BITFIELD_BIT(node_type))) {
+ assert(node_type == DRM_NODE_RENDER || node_type == DRM_NODE_PRIMARY);
+ return false;
+ }
+
+ if (node_type == DRM_NODE_RENDER) {
+ while (*compat) {
+ for (size_t i = 0U; i < ARRAY_SIZE(pvr_render_devices); i++) {
+ const char *const name = pvr_render_devices[i].name;
+ const size_t len = pvr_render_devices[i].len;
+
+ if (strncmp(*compat, name, len) == 0)
+ return true;
+ }
+
+ compat++;
+ }
+
+ return false;
+ } else if (node_type == DRM_NODE_PRIMARY) {
+ while (*compat) {
+ for (size_t i = 0U; i < ARRAY_SIZE(pvr_display_devices); i++) {
+ const char *const name = pvr_display_devices[i].name;
+ const size_t len = pvr_display_devices[i].len;
+
+ if (strncmp(*compat, name, len) == 0)
+ return true;
+ }
+
+ compat++;
+ }
+
+ return false;
+ }
+
+ unreachable("Incorrect node_type.");
+}
+
static VkResult pvr_enumerate_devices(struct pvr_instance *instance)
{
/* FIXME: It should be possible to query the number of devices via
@@ -463,34 +529,17 @@ static VkResult pvr_enumerate_devices(struct pvr_instance *instance)
if (drm_devices[i]->bustype != DRM_BUS_PLATFORM)
continue;
- if (drm_devices[i]->available_nodes & (1 << DRM_NODE_RENDER)) {
- char **compat;
+ if (pvr_drm_device_is_supported(drm_devices[i], DRM_NODE_RENDER)) {
+ drm_render_device = drm_devices[i];
- compat = drm_devices[i]->deviceinfo.platform->compatible;
- while (*compat) {
- if (strncmp(*compat, "mediatek,mt8173-gpu", 19) == 0) {
- drm_render_device = drm_devices[i];
+ mesa_logd("Found compatible render device '%s'.",
+ drm_render_device->nodes[DRM_NODE_RENDER]);
+ } else if (pvr_drm_device_is_supported(drm_devices[i],
+ DRM_NODE_PRIMARY)) {
+ drm_primary_device = drm_devices[i];
- mesa_logd("Found compatible render device '%s'.",
- drm_render_device->nodes[DRM_NODE_RENDER]);
- break;
- }
- compat++;
- }
- } else if (drm_devices[i]->available_nodes & 1 << DRM_NODE_PRIMARY) {
- char **compat;
-
- compat = drm_devices[i]->deviceinfo.platform->compatible;
- while (*compat) {
- if (strncmp(*compat, "mediatek-drm", 12) == 0) {
- drm_primary_device = drm_devices[i];
-
- mesa_logd("Found compatible primary device '%s'.",
- drm_primary_device->nodes[DRM_NODE_PRIMARY]);
- break;
- }
- compat++;
- }
+ mesa_logd("Found compatible primary device '%s'.",
+ drm_primary_device->nodes[DRM_NODE_PRIMARY]);
}
}
More information about the mesa-commit
mailing list