Skip to content

Commit

Permalink
GPU (FreeBSD): detect correct AMD card names
Browse files Browse the repository at this point in the history
  • Loading branch information
Carter committed Feb 12, 2024
1 parent f4cb3bb commit 7ea8882
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/detection/gpu/gpu_bsd.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "gpu_driver_specific.h"

#include "common/io/io.h"
#include "common/properties.h"
#include "3rdparty/nvml/nvml.h"
#include "util/mallocHelper.h"
#include "common/io/io.h"

#include <dev/pci/pcireg.h>
#include <sys/pciio.h>
Expand Down Expand Up @@ -46,7 +46,6 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
return "ioctl(fd, PCIOCGETCONF, &pc) returned error";

FF_STRBUF_AUTO_DESTROY pciids = ffStrbufCreate();
loadPciIds(&pciids);

for (uint32_t i = 0; i < pcio.num_matches; ++i)
{
Expand All @@ -64,7 +63,19 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
gpu->deviceId = ((uint64_t) pc->pc_sel.pc_domain << 6) | ((uint64_t) pc->pc_sel.pc_bus << 4) | ((uint64_t) pc->pc_sel.pc_dev << 2) | pc->pc_sel.pc_func;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;

ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, pc->pc_subvendor, pc->pc_subdevice, gpu);
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
{
char query[32];
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid);
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
}

if (gpu->name.length == 0)
{
if (pciids.length == 0)
loadPciIds(&pciids);
ffGPUParsePciIds(&pciids, pc->pc_subclass, pc->pc_vendor, pc->pc_device, pc->pc_subvendor, pc->pc_subdevice, gpu);
}

#ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->driverSpecific))
Expand Down
4 changes: 4 additions & 0 deletions src/util/platform/FFPlatform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <pwd.h>
#include <limits.h>
#include <sys/utsname.h>
#include <paths.h>

#ifdef __APPLE__
#include <libproc.h>
Expand Down Expand Up @@ -135,6 +136,9 @@ static void getDataDirs(FFPlatform* platform)

ffPlatformPathAddHome(&platform->dataDirs, platform, "");
platformPathAddEnv(&platform->dataDirs, "XDG_DATA_DIRS");
#ifdef _PATH_LOCALBASE
ffPlatformPathAddAbsolute(&platform->dataDirs, _PATH_LOCALBASE "/share/");
#endif
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/");
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/");
}
Expand Down

0 comments on commit 7ea8882

Please sign in to comment.