22#include "detection/vulkan/vulkan.h"
33#include "detection/temps/temps_linux.h"
44#include "common/io/io.h"
5+ #include "common/properties.h"
56#include "util/stringUtils.h"
67
78#ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API
@@ -80,7 +81,6 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
8081
8182 FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate ();
8283 FF_STRBUF_AUTO_DESTROY pciids = ffStrbufCreate ();
83- loadPciIds (& pciids );
8484
8585 struct dirent * entry ;
8686 while ((entry = readdir (dirp )) != NULL )
@@ -98,9 +98,9 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
9898 continue ;
9999 ffStrbufSubstrBefore (& pciDir , pciDevDirLength );
100100
101- uint32_t vendorId , deviceId ;
101+ uint32_t vendorId , deviceId , subVendorId , subDeviceId ;
102102 uint8_t classId , subclassId ;
103- if (sscanf (buffer .chars , "pci:v%8" SCNx32 "d%8" SCNx32 "sv%*8ssd%*8sbc %2" SCNx8 "sc%2" SCNx8 , & vendorId , & deviceId , & classId , & subclassId ) != 4 )
103+ if (sscanf (buffer .chars , "pci:v%8" SCNx32 "d%8" SCNx32 "sv%8" SCNx32 "sd%8" SCNx32 "bc %2" SCNx8 "sc%2" SCNx8 , & vendorId , & deviceId , & subVendorId , & subDeviceId , & classId , & subclassId ) != 6 )
104104 continue ;
105105
106106 if (classId != 0x03 /*PCI_BASE_CLASS_DISPLAY*/ )
@@ -122,7 +122,29 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
122122 gpu -> deviceId = ((uint64_t ) pciDomain << 6 ) | ((uint64_t ) pciBus << 4 ) | (deviceId << 2 ) | pciFunc ;
123123 gpu -> frequency = FF_GPU_FREQUENCY_UNSET ;
124124
125- ffGPUParsePciIds (& pciids , subclassId , (uint16_t ) vendorId , (uint16_t ) deviceId , gpu );
125+ if (gpu -> vendor .chars == FF_GPU_VENDOR_NAME_AMD )
126+ {
127+ ffStrbufAppendS (& pciDir , "/revision" );
128+ if (ffReadFileBuffer (pciDir .chars , & buffer ))
129+ {
130+ char * pend ;
131+ uint64_t revision = strtoul (buffer .chars , & pend , 16 );
132+ if (pend != buffer .chars )
133+ {
134+ char query [32 ];
135+ snprintf (query , sizeof (query ), "%X,\t%X," , (unsigned ) deviceId , (unsigned ) revision );
136+ ffParsePropFileData ("libdrm/amdgpu.ids" , query , & gpu -> name );
137+ }
138+ }
139+ ffStrbufSubstrBefore (& pciDir , pciDevDirLength );
140+ }
141+
142+ if (gpu -> name .length == 0 )
143+ {
144+ if (!pciids .length )
145+ loadPciIds (& pciids );
146+ ffGPUParsePciIds (& pciids , subclassId , (uint16_t ) vendorId , (uint16_t ) deviceId , (uint16_t ) subVendorId , (uint16_t ) subDeviceId , gpu );
147+ }
126148
127149 pciDetectDriver (gpu , & pciDir , & buffer );
128150 ffStrbufSubstrBefore (& pciDir , pciDevDirLength );
0 commit comments