summaryrefslogtreecommitdiffstats
path: root/src/detection/gpu/gpu_sunos.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_sunos.c
Add the files
Diffstat (limited to 'src/detection/gpu/gpu_sunos.c')
-rw-r--r--src/detection/gpu/gpu_sunos.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c
new file mode 100644
index 0000000..13d4998
--- /dev/null
+++ b/src/detection/gpu/gpu_sunos.c
@@ -0,0 +1,54 @@
+#include "gpu.h"
+#include "common/strutil.h"
+
+#include <libdevinfo.h>
+
+static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpus) {
+ int* vendorId;
+ int* deviceId;
+ if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "vendor-id", &vendorId) > 0 && di_prop_lookup_ints(DDI_DEV_T_ANY, node, "device-id", &deviceId) > 0) {
+ FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
+ ffStrbufInitS(&gpu->vendor, ffGPUGetVendorString((uint16_t) *vendorId));
+ ffStrbufInit(&gpu->name);
+ ffStrbufInitS(&gpu->driver, di_driver_name(node));
+ ffStrbufInitStatic(&gpu->platformApi, "libdevinfo");
+ ffStrbufInit(&gpu->memoryType);
+ gpu->index = FF_GPU_INDEX_UNSET;
+ 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 = strtoul(di_bus_addr(node), NULL, 16);
+ gpu->frequency = FF_GPU_FREQUENCY_UNSET;
+
+ if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) {
+ int* revId;
+ if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "revision-id", &revId) > 0) {
+ ffGPUQueryAmdGpuName((uint16_t) *deviceId, (uint8_t) *revId, gpu);
+ }
+ }
+
+ if (gpu->name.length == 0) {
+ uint8_t subclass = 0; // assume VGA
+ int* classCode;
+ if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "class-code", &classCode) > 0) {
+ subclass = (uint8_t) (*classCode & 0xFFFF);
+ }
+ ffGPUFillVendorAndName(subclass, (uint16_t) *vendorId, (uint16_t) *deviceId, gpu);
+ }
+ }
+
+ return DI_WALK_CONTINUE;
+}
+
+const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) {
+ di_node_t rootNode = di_init("/", DINFOCPYALL);
+ if (rootNode == DI_NODE_NIL) {
+ return "di_init() failed";
+ }
+ di_walk_minor(rootNode, DDI_NT_DISPLAY, DI_WALK_CLDFIRST, gpus, (void*) walkDevTree);
+ di_fini(rootNode);
+
+ return NULL;
+}