Skip to content

Commit a4cace4

Browse files
committed
CMake: add CUSTOM_AMDGPU_IDS_PATH
1 parent c6d2467 commit a4cace4

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions
7979

8080
if (LINUX)
8181
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
82+
set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`")
8283
endif()
8384

8485
####################
@@ -784,6 +785,10 @@ if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
784785
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
785786
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
786787
endif()
788+
if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "")
789+
message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}")
790+
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH})
791+
endif()
787792

788793
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
789794
if(NOT ENABLE_${VARNAME})

src/detection/gpu/gpu_linux.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf*
123123
static bool loadPciIds(FFstrbuf* pciids)
124124
{
125125
#ifdef FF_CUSTOM_PCI_IDS_PATH
126+
126127
ffReadFileBuffer(FF_STR(FF_CUSTOM_PCI_IDS_PATH), pciids);
127128
if (pciids->length > 0) return true;
128-
#endif
129+
130+
#else
129131

130132
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", pciids);
131133
if (pciids->length > 0) return true;
@@ -136,6 +138,8 @@ static bool loadPciIds(FFstrbuf* pciids)
136138
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", pciids);
137139
if (pciids->length > 0) return true;
138140

141+
#endif
142+
139143
return false;
140144
}
141145

@@ -188,7 +192,11 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
188192
{
189193
char query[32];
190194
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
195+
#ifdef FF_CUSTOM_AMDGPU_IDS_PATH
196+
ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name);
197+
#else
191198
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
199+
#endif
192200
}
193201
}
194202
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
@@ -202,8 +210,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
202210
ffStrbufInit(&pciids);
203211
loadPciIds(&pciids);
204212
}
205-
if (pciids.length)
206-
ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
213+
ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
207214
}
208215

209216
pciDetectDriver(gpu, drmDir, buffer);

0 commit comments

Comments
 (0)