master ohmu/fastfetch-openbsd / src / detection / gpu / adl.h
ohmu  ·  2026-10-15
 1#pragma once
 2
 3#include "3rdparty/display-library/adl_sdk.h"
 4
 5// https://gpuopen-librariesandsdks.github.io/adl/modules.html
 6
 7// Function to initialize the ADL2 interface and to obtain client's context handle.
 8extern int ADL2_Main_Control_Create(ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADL_CONTEXT_HANDLE* context);
 9
10// Destroy client's ADL context.
11extern int ADL2_Main_Control_Destroy(ADL_CONTEXT_HANDLE context);
12
13// Retrieves adapter information for given adapter or all OS-known adapters.
14// Return ADL_OK on success, DESPITE THE OFFICIAL DOCUMENT SAYS IT RETURNS 1 FOR SUCCESS!
15extern int ADL2_Adapter_AdapterInfoX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* numAdapters, AdapterInfo** lppAdapterInfo);
16
17// Function to retrieve Graphic Core Info.
18extern int ADL2_Adapter_Graphic_Core_Info_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLGraphicCoreInfo* pGraphicCoreInfo);
19
20// Function to retrieve memory information from the adapter. Version 2
21extern int ADL2_Adapter_MemoryInfo2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLMemoryInfo2* lpMemoryInfo2);
22
23// This function retrieves the Dedicated VRAM usage of given adapter.
24extern int ADL2_Adapter_DedicatedVRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVRAMUsageInMB);
25
26// Function to get the ASICFamilyType from the adapter.
27extern int ADL2_Adapter_ASICFamilyType_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpAsicTypes, int* lpValids);
28
29// This function retrieves the chipset information for a specified adapter.
30extern int ADL2_Adapter_ChipSetInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLChipSetInfo* lpChipSetInfo);
31
32// Function to retrieve current power management capabilities.
33extern int ADL2_Overdrive_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iSupported, int* iEnabled, int* iVersion);
34
35/////////// Overdrive 6 functions
36
37// Function to retrieve current Overdrive and performance-related activity.
38extern int ADL2_Overdrive6_CurrentStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6CurrentStatus* lpCurrentStatus);
39
40// Function to retrieve GPU temperature from the thermal controller.
41extern int ADL2_Overdrive6_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpTemperature);
42
43// Function to retrieve the current or default Overdrive clock ranges.
44extern int ADL2_Overdrive6_StateInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, ADLOD6StateInfo* lpStateInfo);
45
46/// Overdrive N functions
47
48// Despite the name (N means Next), this is actually Overdrive7 API
49// https://github.com/GPUOpen-LibrariesAndSDKs/display-library/blob/master/Sample/OverdriveN/OverdriveN.cpp#L209
50
51// Function to retrieve the OverdriveN capabilities.
52extern int ADL2_OverdriveN_CapabilitiesX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNCapabilitiesX2* lpODCapabilities);
53
54// Function to retrieve the current OD performance status.
55extern int ADL2_OverdriveN_PerformanceStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceStatus* lpODPerformanceStatus);
56
57// Function to retrieve the current temperature.
58extern int ADL2_OverdriveN_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iTemperatureType, int* iTemperature);
59
60// Function to retrieve the current GPU clocks settings.
61extern int ADL2_OverdriveN_SystemClocksX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2* lpODPerformanceLevels);
62
63/// Overdrive 8 functions
64
65// Function to retrieve the Overdrive8 current settings.
66extern int ADL2_Overdrive8_Current_Setting_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD8CurrentSetting* lpCurrentSetting);
67
68// Function to retrieve the Overdrive8 current settings.
69extern int ADL2_New_QueryPMLogData_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogDataOutput* lpDataOutput);