diff --git a/CMakeLists.txt b/CMakeLists.txt index b0ff2ce40..e8b6cae65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions if (LINUX) set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`") + set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`") endif() #################### @@ -784,6 +785,10 @@ if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "") message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}") target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH}) endif() +if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "") + message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}") + target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH}) +endif() function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) if(NOT ENABLE_${VARNAME}) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index ff4decbba..1d0c612da 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -123,9 +123,11 @@ static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* static bool loadPciIds(FFstrbuf* pciids) { #ifdef FF_CUSTOM_PCI_IDS_PATH + ffReadFileBuffer(FF_STR(FF_CUSTOM_PCI_IDS_PATH), pciids); if (pciids->length > 0) return true; - #endif + + #else ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", pciids); if (pciids->length > 0) return true; @@ -136,6 +138,8 @@ static bool loadPciIds(FFstrbuf* pciids) ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", pciids); if (pciids->length > 0) return true; + #endif + return false; } @@ -188,7 +192,11 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf { char query[32]; snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision); + #ifdef FF_CUSTOM_AMDGPU_IDS_PATH + ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name); + #else ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); + #endif } } ffStrbufSubstrBefore(drmDir, drmDirPathLength); @@ -202,8 +210,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffStrbufInit(&pciids); loadPciIds(&pciids); } - if (pciids.length) - ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu); + ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu); } pciDetectDriver(gpu, drmDir, buffer);