summaryrefslogtreecommitdiffstats
path: root/src/detection/gpu/gpu_haiku.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/gpu/gpu_haiku.c
Add the files
Diffstat (limited to 'src/detection/gpu/gpu_haiku.c')
-rw-r--r--src/detection/gpu/gpu_haiku.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c
new file mode 100644
index 0000000..f75f039
--- /dev/null
+++ b/src/detection/gpu/gpu_haiku.c
@@ -0,0 +1,51 @@
+#include "gpu.h"
+#include "common/io.h"
+
+#include <private/drivers/poke.h>
+
+const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) {
+ FF_AUTO_CLOSE_FD int pokefd = open(POKE_DEVICE_FULLNAME, O_RDWR | O_CLOEXEC);
+ if (pokefd < 0) {
+ return "open(POKE_DEVICE_FULLNAME) failed";
+ }
+
+ pci_info dev;
+ pci_info_args cmd = {
+ .signature = POKE_SIGNATURE,
+ .info = &dev,
+ };
+
+ for (cmd.index = 0; ioctl(pokefd, POKE_GET_NTH_PCI_INFO, &cmd, sizeof(cmd)) == B_OK && cmd.status == B_OK; ++cmd.index) {
+ if (dev.class_base != 0x03 /*PCI_BASE_CLASS_DISPLAY*/) {
+ continue;
+ }
+
+ if (dev.function > 0 && dev.class_sub == 0x80 /*PCI_CLASS_DISPLAY_OTHER*/) {
+ continue; // Likely an auxiliary display controller (#2034)
+ }
+
+ FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
+ ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev.vendor_id));
+ ffStrbufInit(&gpu->name);
+ ffStrbufInit(&gpu->driver);
+ ffStrbufInitStatic(&gpu->platformApi, POKE_DEVICE_FULLNAME);
+ ffStrbufInit(&gpu->memoryType);
+ gpu->temperature = FF_GPU_TEMP_UNSET;
+ gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
+ gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
+ gpu->type = FF_GPU_TYPE_UNKNOWN;
+ gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
+ gpu->deviceId = ffGPUPciAddr2Id(0, dev.bus, dev.device, dev.function);
+ gpu->frequency = FF_GPU_FREQUENCY_UNSET;
+
+ if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) {
+ ffGPUQueryAmdGpuName(dev.device_id, dev.revision, gpu);
+ }
+
+ if (gpu->name.length == 0) {
+ ffGPUFillVendorAndName(dev.class_sub, dev.vendor_id, dev.device_id, gpu);
+ }
+ }
+
+ return NULL;
+}