I wrote this code in response to a issue someone on mesa-users had (https://lists.freedesktop.org/archives/mesa-users/2016-October/001231.html). They didn't reply so I don't know if the patch resolved the issue. Can someone please determine its usefulness. Also please check if drmCommandWrite() is the correct function to use. I can't test the code, I don't have amdgpu.
diff --git a/mesa/src/loader/loader.c b/mesa2/src/loader/loader.c index 3e60e4c..4a89ba4 100644 --- a/mesa/src/loader/loader.c +++ b/mesa2/src/loader/loader.c @@ -515,6 +515,8 @@ sysfs_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id) #include <i915_drm.h> /* for radeon */ #include <radeon_drm.h> +/* for amdgpu */ +#include <amdgpu_drm.h> static int drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id) @@ -564,6 +566,26 @@ drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id) *chip_id = -1; } } + else if (strcmp(version->name, "amdgpu") == 0) { + struct drm_amdgpu_info info; + struct drm_amdgpu_info_device info_device; + int ret; + + *vendor_id = 0x1002; + + memset(&info, 0, sizeof(info)); + memset(&info_device, 0, sizeof(info_device)); + info.query = AMDGPU_INFO_DEV_INFO; + info.return_pointer = (uint64_t) &info_device; + info.return_size = sizeof(struct drm_amdgpu_info_device); + ret = drmCommandWrite(fd, DRM_AMDGPU_INFO, &info, sizeof(info)); + if (ret) { + log_(_LOADER_WARNING, "MESA-LOADER: failed to get info for amdgpu\n"); + *chip_id = -1; + } else { + *chip_id = info_device.device_id; + } + } else if (strcmp(version->name, "nouveau") == 0) { *vendor_id = 0x10de; /* not used */
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev