@@ -50,6 +50,9 @@ struct FFAdlData {
5050 FF_LIBRARY_SYMBOL (ADL2_Adapter_VRAMUsage_Get )
5151 FF_LIBRARY_SYMBOL (ADL2_Adapter_ASICFamilyType_Get )
5252 FF_LIBRARY_SYMBOL (ADL2_Overdrive_Caps )
53+ FF_LIBRARY_SYMBOL (ADL2_OverdriveN_Capabilities_Get )
54+ FF_LIBRARY_SYMBOL (ADL2_OverdriveN_PerformanceStatus_Get )
55+ FF_LIBRARY_SYMBOL (ADL2_OverdriveN_Temperature_Get )
5356 FF_LIBRARY_SYMBOL (ADL2_Overdrive6_CurrentStatus_Get )
5457 FF_LIBRARY_SYMBOL (ADL2_Overdrive6_Temperature_Get )
5558 FF_LIBRARY_SYMBOL (ADL2_Overdrive6_StateInfo_Get )
@@ -77,27 +80,20 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
7780 adlData .inited = true;
7881 FF_DEBUG ("Initializing ADL library" );
7982 FF_LIBRARY_LOAD (atiadl , "dlopen atiadlxx failed" , soName , 1 );
80- FF_DEBUG ("Loading ADL2_Main_Control_Create" );
8183 FF_LIBRARY_LOAD_SYMBOL_MESSAGE (atiadl , ADL2_Main_Control_Create )
82- FF_DEBUG ("Loading ADL2_Main_Control_Destroy" );
8384 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Main_Control_Destroy )
84- FF_DEBUG ("Loading ADL2_Adapter_AdapterInfoX3_Get" );
8585 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_AdapterInfoX3_Get )
86- FF_DEBUG ("Loading ADL2_Adapter_Graphic_Core_Info_Get" );
8786 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_Graphic_Core_Info_Get )
88- FF_DEBUG ("Loading ADL2_Adapter_MemoryInfo2_Get" );
8987 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_MemoryInfo2_Get )
90- FF_DEBUG ("Loading ADL2_Adapter_DedicatedVRAMUsage_Get" );
9188 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_DedicatedVRAMUsage_Get )
92- FF_DEBUG ("Loading ADL2_Adapter_VRAMUsage_Get" );
9389 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_VRAMUsage_Get )
94- FF_DEBUG ("Loading ADL2_Adapter_ASICFamilyType_Get" );
9590 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_ASICFamilyType_Get )
96- FF_DEBUG ("Loading ADL2_Overdrive6_CurrentStatus_Get" );
91+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive_Caps )
92+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_Capabilities_Get )
93+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_PerformanceStatus_Get )
94+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_Temperature_Get )
9795 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive6_CurrentStatus_Get )
98- FF_DEBUG ("Loading ADL2_Overdrive6_Temperature_Get" );
9996 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive6_Temperature_Get )
100- FF_DEBUG ("Loading ADL2_Overdrive6_StateInfo_Get" );
10197 FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive6_StateInfo_Get )
10298 FF_DEBUG ("ADL library loaded" );
10399
@@ -247,71 +243,139 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
247243 FF_DEBUG ("Setting adapter name: %s" , device -> strAdapterName );
248244 }
249245
250- adlData .ffADL2_Overdrive_Caps (adlData .apiHandle , device -> iAdapterIndex , NULL , NULL , NULL );
246+ int overdrive_supported = 0 ;
247+ int odParam = 0 ;
248+ int activity_supported = 0 ;
249+ int caps_status = adlData .ffADL2_Overdrive_Caps (adlData .apiHandle , device -> iAdapterIndex , & overdrive_supported , & odParam , & activity_supported );
250+ FF_DEBUG ("ADL2_Overdrive_Caps returned %s (%d), overdrive_supported: %d" , ffAdlStatusToString (caps_status ), caps_status , overdrive_supported );
251251
252- if (result . frequency )
252+ if (overdrive_supported >= 7 )
253253 {
254- ADLOD6StateInfo stateInfo ;
255- int status = adlData .ffADL2_Overdrive6_StateInfo_Get (adlData .apiHandle , device -> iAdapterIndex , ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE , & stateInfo );
256- FF_DEBUG ("ADL2_Overdrive6_StateInfo_Get returned %s (%d), performance levels: %d" ,
257- ffAdlStatusToString (status ), status , stateInfo .iNumberOfPerformanceLevels );
254+ FF_DEBUG ("Using OverdriveN API" );
258255
259- if (status == ADL_OK )
256+ if (result . frequency )
260257 {
261- int clock = 0 ; // assume in 10 kHz
262- for (int i = 0 ; i < stateInfo .iNumberOfPerformanceLevels ; i ++ )
258+ ADLODNCapabilities odCapabilities ;
259+ int status = adlData .ffADL2_OverdriveN_Capabilities_Get (adlData .apiHandle , device -> iAdapterIndex , & odCapabilities );
260+ FF_DEBUG ("ADL2_OverdriveN_Capabilities_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
261+
262+ if (status == ADL_OK )
263263 {
264- FF_DEBUG ("Performance level %d: engine clock = %d" , i , stateInfo .aLevels [i ].iEngineClock );
265- if (stateInfo .aLevels [i ].iEngineClock > clock )
266- clock = stateInfo .aLevels [i ].iEngineClock ;
264+ * result .frequency = (uint32_t ) odCapabilities .sEngineClockRange .iMax / 100 ; // assume in 10 KHz
265+ FF_DEBUG ("Got max engine clock: %u MHz" , * result .frequency );
266+ }
267+ else
268+ {
269+ FF_DEBUG ("Failed to get frequency information" );
267270 }
268- * result .frequency = (uint32_t ) clock / 100 ;
269- FF_DEBUG ("Using max engine clock: %u MHz" , * result .frequency );
270- }
271- else
272- {
273- FF_DEBUG ("Failed to get frequency information" );
274271 }
275- }
276-
277- if (result .coreUsage )
278- {
279- ADLOD6CurrentStatus status ;
280- int apiStatus = adlData .ffADL2_Overdrive6_CurrentStatus_Get (adlData .apiHandle , device -> iAdapterIndex , & status );
281- FF_DEBUG ("ADL2_Overdrive6_CurrentStatus_Get returned %s (%d)" , ffAdlStatusToString (apiStatus ), apiStatus );
282272
283- if (apiStatus == ADL_OK )
273+ if (result . coreUsage )
284274 {
285- if (result .coreUsage )
275+ ADLODNPerformanceStatus performanceStatus ;
276+ int status = adlData .ffADL2_OverdriveN_PerformanceStatus_Get (adlData .apiHandle , device -> iAdapterIndex , & performanceStatus );
277+ FF_DEBUG ("ADL2_OverdriveN_PerformanceStatus_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
278+
279+ if (status == ADL_OK )
286280 {
287- * result .coreUsage = status .iActivityPercent ;
288- FF_DEBUG ("Got GPU activity: %d%%" , status .iActivityPercent );
281+ * result .coreUsage = performanceStatus .iGPUActivityPercent ;
282+ FF_DEBUG ("Got GPU activity: %d%%" , performanceStatus .iGPUActivityPercent );
283+ }
284+ else
285+ {
286+ FF_DEBUG ("Failed to get GPU activity" );
289287 }
290288 }
291- else
289+
290+ if (result .temp )
292291 {
293- FF_DEBUG ("Failed to get GPU activity" );
292+ int milliDegrees = 0 ;
293+ int status = adlData .ffADL2_OverdriveN_Temperature_Get (adlData .apiHandle , device -> iAdapterIndex , 1 , & milliDegrees );
294+ FF_DEBUG ("ADL2_OverdriveN_Temperature_Get returned %s (%d), temperature: %d milliC" ,
295+ ffAdlStatusToString (status ), status , milliDegrees );
296+
297+ if (status == ADL_OK )
298+ {
299+ * result .temp = milliDegrees / 1000.0 ;
300+ FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
301+ }
302+ else
303+ {
304+ FF_DEBUG ("Failed to get temperature" );
305+ }
294306 }
295307 }
296-
297- if (result .temp )
308+ else if (overdrive_supported >= 6 )
298309 {
299- int milliDegrees = 0 ;
300- int status = adlData .ffADL2_Overdrive6_Temperature_Get (adlData .apiHandle , device -> iAdapterIndex , & milliDegrees );
301- FF_DEBUG ("ADL2_Overdrive6_Temperature_Get returned %s (%d), temperature: %d milliC" ,
302- ffAdlStatusToString (status ), status , milliDegrees );
310+ FF_DEBUG ("Using Overdrive8 API; to be supported" );
311+ }
312+ else
313+ {
314+ FF_DEBUG ("Using Overdrive6 API" );
303315
304- if (status == ADL_OK )
316+ if (result . frequency )
305317 {
306- * result .temp = milliDegrees / 1000.0 ;
307- FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
318+ ADLOD6StateInfo stateInfo ;
319+ int status = adlData .ffADL2_Overdrive6_StateInfo_Get (adlData .apiHandle , device -> iAdapterIndex , ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE , & stateInfo );
320+ FF_DEBUG ("ADL2_Overdrive6_StateInfo_Get returned %s (%d), performance levels: %d" ,
321+ ffAdlStatusToString (status ), status , stateInfo .iNumberOfPerformanceLevels );
322+
323+ if (status == ADL_OK )
324+ {
325+ int clock = 0 ; // assume in 10 kHz
326+ for (int i = 0 ; i < stateInfo .iNumberOfPerformanceLevels ; i ++ )
327+ {
328+ FF_DEBUG ("Performance level %d: engine clock = %d" , i , stateInfo .aLevels [i ].iEngineClock );
329+ if (stateInfo .aLevels [i ].iEngineClock > clock )
330+ clock = stateInfo .aLevels [i ].iEngineClock ;
331+ }
332+ * result .frequency = (uint32_t ) clock / 100 ;
333+ FF_DEBUG ("Using max engine clock: %u MHz" , * result .frequency );
334+ }
335+ else
336+ {
337+ FF_DEBUG ("Failed to get frequency information" );
338+ }
308339 }
309- else
340+
341+ if (result .coreUsage )
310342 {
311- FF_DEBUG ("Failed to get temperature" );
343+ ADLOD6CurrentStatus status ;
344+ int apiStatus = adlData .ffADL2_Overdrive6_CurrentStatus_Get (adlData .apiHandle , device -> iAdapterIndex , & status );
345+ FF_DEBUG ("ADL2_Overdrive6_CurrentStatus_Get returned %s (%d)" , ffAdlStatusToString (apiStatus ), apiStatus );
346+
347+ if (apiStatus == ADL_OK )
348+ {
349+ if (result .coreUsage )
350+ {
351+ * result .coreUsage = status .iActivityPercent ;
352+ FF_DEBUG ("Got GPU activity: %d%%" , status .iActivityPercent );
353+ }
354+ }
355+ else
356+ {
357+ FF_DEBUG ("Failed to get GPU activity" );
358+ }
312359 }
313- }
314360
361+ if (result .temp )
362+ {
363+ int milliDegrees = 0 ;
364+ int status = adlData .ffADL2_Overdrive6_Temperature_Get (adlData .apiHandle , device -> iAdapterIndex , & milliDegrees );
365+ FF_DEBUG ("ADL2_Overdrive6_Temperature_Get returned %s (%d), temperature: %d milliC" ,
366+ ffAdlStatusToString (status ), status , milliDegrees );
367+
368+ if (status == ADL_OK )
369+ {
370+ * result .temp = milliDegrees / 1000.0 ;
371+ FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
372+ }
373+ else
374+ {
375+ FF_DEBUG ("Failed to get temperature" );
376+ }
377+ }
378+ }
315379 FF_DEBUG ("AMD GPU detection complete" );
316380 return NULL ;
317381}
0 commit comments