2
2
#include "detection/vulkan/vulkan.h"
3
3
#include "detection/temps/temps_linux.h"
4
4
#include "common/io/io.h"
5
+ #include "common/properties.h"
5
6
#include "util/stringUtils.h"
6
7
7
8
#ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API
@@ -80,7 +81,6 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
80
81
81
82
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate ();
82
83
FF_STRBUF_AUTO_DESTROY pciids = ffStrbufCreate ();
83
- loadPciIds (& pciids );
84
84
85
85
struct dirent * entry ;
86
86
while ((entry = readdir (dirp )) != NULL )
@@ -98,9 +98,9 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
98
98
continue ;
99
99
ffStrbufSubstrBefore (& pciDir , pciDevDirLength );
100
100
101
- uint32_t vendorId , deviceId ;
101
+ uint32_t vendorId , deviceId , subVendorId , subDeviceId ;
102
102
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 )
104
104
continue ;
105
105
106
106
if (classId != 0x03 /*PCI_BASE_CLASS_DISPLAY*/ )
@@ -122,7 +122,29 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
122
122
gpu -> deviceId = ((uint64_t ) pciDomain << 6 ) | ((uint64_t ) pciBus << 4 ) | (deviceId << 2 ) | pciFunc ;
123
123
gpu -> frequency = FF_GPU_FREQUENCY_UNSET ;
124
124
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
+ }
126
148
127
149
pciDetectDriver (gpu , & pciDir , & buffer );
128
150
ffStrbufSubstrBefore (& pciDir , pciDevDirLength );
0 commit comments