Skip to content

Commit

Permalink
Added Support for the OD7(N) API Drivers/Cards.
Browse files Browse the repository at this point in the history
  • Loading branch information
nalilord committed Jun 9, 2022
1 parent 67abfee commit f43ef85
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 1,086 deletions.
101 changes: 82 additions & 19 deletions Common/adl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
{ }
{ TADL Class for the AMD Display Library }
{ }
{ Version 0.2 }
{ Version 0.3 }
{ }
{ 2022-10-05 - 0.3 }
{ Added APIVersion to TADLAdapter }
{ Added support for OD7(N) Drivers/Cards }
{ 2020-10-05 - 0.2 }
{ Added PNP String to TADLAdapter }
{ 2020-10-03 - 0.1 }
{ Initial Release }
{ }
{ (c) 2020 by NaliLord }
{ (c) 2022 by NaliLord }
{ }
{*******************************************************}

Expand Down Expand Up @@ -37,7 +40,7 @@ TADLAdapter = class
FBusNumber: Integer;
FDeviceNumber: Integer;
FFunctionNumber: Integer;
FTemp: Byte;
FTemp: Integer;
FFan: Byte;
FFanRPM: Integer;
FFanMaxRPM: Integer;
Expand All @@ -54,8 +57,10 @@ TADLAdapter = class
FBusLanesMax: Integer;
FDriverDate: String;
FDriverVersion: String;
FAPIVersion: Integer;
public
function IsLocation(ABusNumber, ADeviceNumber, AFunctionNumber: Integer): Boolean;
property APIVersion: Integer read FAPIVersion;
property PNP: String read FPNP;
property BiosPartNumber: String read FBiosPartNumber;
property BiosVersion: String read FBiosVersion;
Expand All @@ -68,7 +73,7 @@ TADLAdapter = class
property BusNumber: Integer read FBusNumber;
property DeviceNumber: Integer read FDeviceNumber;
property FunctionNumber: Integer read FFunctionNumber;
property Temp: Byte read FTemp;
property Temp: Integer read FTemp;
property Fan: Byte read FFan;
property FanRPM: Integer read FFanRPM;
property FanMaxRPM: Integer read FFanMaxRPM;
Expand All @@ -91,7 +96,10 @@ TADL = class
private
FInitialized: Boolean;
FDLLHandle: NativeUInt;
FNumberAdapters: Integer;
FAdapters: TObjectList<TADLAdapter>;
// -- ADL --
FAdapterInfo: PAdapterInfo;
FMain_Control_Create: ADL_MAIN_CONTROL_CREATE;
FMain_Control_Destroy: ADL_MAIN_CONTROL_DESTROY;
FAdapter_NumberOfAdapters: ADL_ADAPTER_NUMBEROFADAPTERS_GET;
Expand All @@ -100,21 +108,29 @@ TADL = class
FAdapter_MemoryInfo: ADL_ADAPTER_MEMORYINFO_GET;
FAdapter_Active: ADL_ADAPTER_ACTIVE_GET;
FOverdrive_Caps: ADL_OVERDRIVE_CAPS;
// -- ADL2 --
FADL2Context: Pointer;
FMain_Control_Create2: ADL2_MAIN_CONTROL_CREATE;
FMain_Control_Destroy2: ADL2_MAIN_CONTROL_DESTROY;
FNew_QueryPMLogData: ADL2_NEW_QUERYPMLOGDATA_GET;
// -- OD5 --
FOverdrive5_ThermalDevices: ADL_OVERDRIVE5_THERMALDEVICES_ENUM;
FOverdrive5_Temperature: ADL_OVERDRIVE5_TEMPERATURE_GET;
FOverdrive5_FanSpeed: ADL_OVERDRIVE5_FANSPEED_GET;
FOverdrive5_FanSpeedInfo: ADL_OVERDRIVE5_FANSPEEDINFO_GET;
FOverdrive5_CurrentActivity: ADL_OVERDRIVE5_CURRENTACTIVITY_GET;
FOverdrive5_ODParameters: ADL_OVERDRIVE5_ODPARAMETERS_GET;
FMain_Control_Create2: ADL2_MAIN_CONTROL_CREATE;
FMain_Control_Destroy2: ADL2_MAIN_CONTROL_DESTROY;
FOverdriveN_Temperature: ADL2_OVERDRIVEN_TEMPERATURE_GET;
// -- OD6 --
FOverdrive6_Temperature: ADL_OVERDRIVE6_TEMPERATURE_GET;
// -- OD8 --
FOverdrive8_Init_Setting: ADL2_OVERDRIVE8_INIT_SETTINGX2_GET;
FOverdrive8_Current_Setting: ADL2_OVERDRIVE8_CURRENT_SETTINGX2_GET;
FNew_QueryPMLogData: ADL2_NEW_QUERYPMLOGDATA_GET;
FAdapterInfo: PAdapterInfo;
FNumberAdapters: Integer;
FADL2Context: Pointer;
// -- ODN --
FOverdriveN_Capabilities: ADL2_OVERDRIVEN_CAPABILITIES_GET;
FOverdriveN_Temperature: ADL2_OVERDRIVEN_TEMPERATURE_GET;
FOverdriveN_FanControlGet: ADL2_OVERDRIVEN_FANCONTROL_GET;
FOverdriveN_PerformanceStatus :ADL2_OVERDRIVEN_PERFORMANCESTATUS_GET;
// -- <<<
function GetAdapterCount: Integer;
function GetAdapters(Index: Integer): TADLAdapter;
protected
Expand Down Expand Up @@ -200,9 +216,17 @@ procedure TADL.Initialize;
FOverdrive5_CurrentActivity:=GetProcAddress(FDLLHandle, 'ADL_Overdrive5_CurrentActivity_Get');
FOverdrive5_ODParameters:=GetProcAddress(FDLLHandle, 'ADL_Overdrive5_ODParameters_Get');

FOverdrive6_Temperature:=GetProcAddress(FDLLHandle, 'ADL_Overdrive6_Temperature_Get');

FMain_Control_Create2:=GetProcAddress(FDLLHandle, 'ADL2_Main_Control_Create');
FMain_Control_Destroy2:=GetProcAddress(FDLLHandle, 'ADL2_Main_Control_Destroy');

FOverdriveN_Capabilities:=GetProcAddress(FDLLHandle, 'ADL2_OverdriveN_Capabilities_Get');
FOverdriveN_Temperature:=GetProcAddress(FDLLHandle, 'ADL2_OverdriveN_Temperature_Get');
FOverdriveN_FanControlGet:=GetProcAddress(FDLLHandle, 'ADL2_OverdriveN_FanControl_Get');
FOverdriveN_PerformanceStatus:=GetProcAddress(FDLLHandle, 'ADL2_OverdriveN_PerformanceStatus_Get');


FOverdrive8_Init_Setting:=GetProcAddress(FDLLHandle, 'ADL2_Overdrive8_Init_SettingX2_Get');
FOverdrive8_Current_Setting:=GetProcAddress(FDLLHandle, 'ADL2_Overdrive8_Current_SettingX2_Get');
FNew_QueryPMLogData:=GetProcAddress(FDLLHandle, 'ADL2_New_QueryPMLogData_Get');
Expand All @@ -221,9 +245,13 @@ procedure TADL.Initialize;
(@FOverdrive5_FanSpeedInfo <> nil) AND
(@FOverdrive5_CurrentActivity <> nil) AND
(@FOverdrive5_ODParameters <> nil) AND
(@FOverdrive6_Temperature <> nil) AND
(@FMain_Control_Create2 <> nil) AND
(@FMain_Control_Destroy2 <> nil) AND
(@FOverdriveN_Capabilities <> nil) AND
(@FOverdriveN_Temperature <> nil) AND
(@FOverdriveN_FanControlGet <> nil) AND
(@FOverdriveN_PerformanceStatus <> nil) AND
(@FOverdrive8_Init_Setting <> nil) AND
(@FOverdrive8_Current_Setting <> nil) AND
(@FNew_QueryPMLogData <> nil) then
Expand Down Expand Up @@ -258,8 +286,7 @@ procedure TADL.Update;
Registry: TRegistry;
Adapter: TADLAdapter;
S: ADLSensorType;
D: ADLOD8SettingId;
I, J, AdapterActive, IsSupported, IsEnabled, Version, Capabilities, FeatureCount: Integer;
I, AdapterActive, IsSupported, IsEnabled, Version, Caps, FeatureCount: Integer;
BiosInfo: TADLBiosInfo;
MemoryInfo: TADLMemoryInfo;
AdapterInfo: TAdapterInfo;
Expand All @@ -268,11 +295,12 @@ procedure TADL.Update;
AdapterFanSpeedInfo: TADLFanSpeedInfo;
AdapterActivity: TADLPMActivity;
ODParameters: TADLODParameters;
ThermalControllerInfo: TADLThermalControllerInfo;
LogData: TADLPMLogDataOutput;
SettingsInit: TADLOD8InitSetting;
SettingsCurr: TADLOD8CurrentSetting;
SettingList: PADLOD8SingleInitSetting;
FanControl: TADLODNFanControl;
PerformanceStats: TADLODNPerformanceStatus;
Capabilities: TADLODNCapabilities;
begin
if FInitialized then
begin
Expand Down Expand Up @@ -318,17 +346,27 @@ procedure TADL.Update;
begin
SettingList:=nil;
FeatureCount:=Integer(ADLOD8SettingId.OD8_COUNT);
if FOverdrive8_Init_Setting(FADL2Context, AdapterInfo.iAdapterIndex, Capabilities, FeatureCount, SettingList) = ADL_OK then
if FOverdrive8_Init_Setting(FADL2Context, AdapterInfo.iAdapterIndex, Caps, FeatureCount, SettingList) = ADL_OK then
begin
SettingsInit.count:=IfThen(FeatureCount > Integer(ADLOD8SettingId.OD8_COUNT), Integer(ADLOD8SettingId.OD8_COUNT), FeatureCount);
SettingsInit.overdrive8Capabilities:=Capabilities;
SettingsInit.overdrive8Capabilities:=Caps;

CopyMemory(@SettingsInit.od8SettingTable[OD8_GFXCLK_FMAX], SettingList, Min(FeatureCount * SizeOf(TADLOD8SingleInitSetting), SizeOf(SettingsInit.od8SettingTable)));

Adapter.FClockMax:=SettingsInit.od8SettingTable[OD8_GFXCLK_FMAX].maxValue;
Adapter.FMemoryMax:=SettingsInit.od8SettingTable[OD8_UCLK_FMAX].maxValue;
Adapter.FFanMaxRPM:=SettingsInit.od8SettingTable[OD8_FAN_MIN_SPEED].maxValue;
end;
end else
if Version = 7 then
begin
if FOverdriveN_Capabilities(FADL2Context, AdapterInfo.iAdapterIndex, Capabilities) = ADL_OK then
begin
Adapter.FClockMax:=Capabilities.sEngineClockRange.iMax;
Adapter.FMemoryMax:=Capabilities.sMemoryClockRange.iMax;
Adapter.FVddcMax:=Capabilities.svddcRange.iMax;
Adapter.FFanMaxRPM:=Capabilities.fanSpeed.iMax;
end;
end;

Registry:=TRegistry.Create(KEY_READ);
Expand All @@ -352,6 +390,8 @@ procedure TADL.Update;

if Assigned(Adapter) AND Adapter.FUpdate then
begin
Adapter.FAPIVersion:=Version;

if Version >= 8 then
begin
ZeroMemory(@LogData, SizeOf(LogData));
Expand Down Expand Up @@ -411,13 +451,32 @@ procedure TADL.Update;
end;
end;
end else
if Version = 7 then
begin
ThermalControllerInfo.iSize:=SizeOf(ThermalControllerInfo);
if FOverdrive5_ThermalDevices(AdapterInfo.iAdapterIndex, 0, ThermalControllerInfo) = ADL_OK then
if FOverdriveN_Temperature(FADL2Context, AdapterInfo.iAdapterIndex, Integer(CORE), Adapter.FTemp) = ADL_OK then
begin
Adapter.FTemp:=Adapter.FTemp div 1000;
end;

if FOverdriveN_FanControlGet(FADL2Context, AdapterInfo.iAdapterIndex, FanControl) = ADL_OK then
begin
Adapter.FFanRPM:=FanControl.iCurrentFanSpeed;
Adapter.FFan:=Round(100 / Adapter.FFanMaxRPM * Adapter.FFanRPM);
end;

if FOverdriveN_PerformanceStatus(FADL2Context, AdapterInfo.iAdapterIndex, PerformanceStats) = ADL_OK then
begin
Adapter.FActivity:=PerformanceStats.iGPUActivityPercent;
Adapter.FVddc:=PerformanceStats.iVddc / 1000;
Adapter.FClock:=PerformanceStats.iCoreClock div 100;
Adapter.FMemory:=PerformanceStats.iMemoryClock div 100;
Adapter.FPerformanceLevel:=PerformanceStats.iCurrentCorePerformanceLevel;
Adapter.FBusSpeed:=PerformanceStats.iCurrentBusSpeed div 1000;
Adapter.FBusLanes:=PerformanceStats.iCurrentBusLanes;
Adapter.FBusLanesMax:=PerformanceStats.iMaximumBusLanes;
end;
end else
begin
AdapterTemp.iSize:=SizeOf(AdapterTemp);
if FOverdrive5_Temperature(AdapterInfo.iAdapterIndex, 0, AdapterTemp) = ADL_OK then
begin
Expand Down Expand Up @@ -506,9 +565,13 @@ procedure TADL.Finalize;
@FOverdrive5_FanSpeedInfo:=nil;
@FOverdrive5_CurrentActivity:=nil;
@FOverdrive5_ODParameters:=nil;
@FOverdrive6_Temperature:=nil;
@FMain_Control_Create2:=nil;
@FMain_Control_Destroy2:=nil;
@FOverdriveN_Capabilities:=nil;
@FOverdriveN_Temperature:=nil;
@FOverdriveN_FanControlGet:=nil;
@FOverdriveN_PerformanceStatus:=nil;
@FOverdrive8_Init_Setting:=nil;
@FOverdrive8_Current_Setting:=nil;
@FNew_QueryPMLogData:=nil;
Expand Down
13 changes: 7 additions & 6 deletions Common/adl_sdk.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
interface

uses
adl_structures;
adl_structures, adl_defines;

///
/// Copyright (c) 2008 - 2013 Advanced Micro Devices, Inc.
Expand Down Expand Up @@ -70,12 +70,13 @@ interface
ADL2_ADAPTER_ACTIVE_GET = function(hContext: Pointer; iNum: Integer; var iActive: Integer): Integer; stdcall;

ADL2_OVERDRIVE_CAPS = function(hContext: Pointer; iAdapterIndex: Integer; var iSupported: Integer; var iEnabled: Integer; var iVersion: Integer): Integer; stdcall;
ADL2_OVERDRIVEN_CAPABILITIES_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpCapabilities: TADLODNCapabilities): Integer; stdcall;
ADL2_OVERDRIVEN_CAPABILITIESX2_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpCapabilities: TADLODNCapabilitiesX2): Integer; stdcall;
ADL2_OVERDRIVEN_PERFORMANCESTATUS_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpStatus: ADLODNPerformanceStatus): Integer; stdcall;
ADL2_OVERDRIVEN_FANCONTROL_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpControl: ADLODNFanControl): Integer; stdcall;
ADL2_OVERDRIVEN_FANCONTROL_SET = function(hContext: Pointer; iAdapterIndex: Integer; var lpControl: ADLODNFanControl): Integer; stdcall;
ADL2_OVERDRIVEN_POWERLIMIT_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLimit: ADLODNPowerLimitSetting): Integer; stdcall;
ADL2_OVERDRIVEN_POWERLIMIT_SET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLimit: ADLODNPowerLimitSetting): Integer; stdcall;
ADL2_OVERDRIVEN_PERFORMANCESTATUS_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpStatus: TADLODNPerformanceStatus): Integer; stdcall;
ADL2_OVERDRIVEN_FANCONTROL_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpControl: TADLODNFanControl): Integer; stdcall;
ADL2_OVERDRIVEN_FANCONTROL_SET = function(hContext: Pointer; iAdapterIndex: Integer; var lpControl: TADLODNFanControl): Integer; stdcall;
ADL2_OVERDRIVEN_POWERLIMIT_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLimit: TADLODNPowerLimitSetting): Integer; stdcall;
ADL2_OVERDRIVEN_POWERLIMIT_SET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLimit: TADLODNPowerLimitSetting): Integer; stdcall;
ADL2_OVERDRIVEN_TEMPERATURE_GET = function(hContext: Pointer; iAdapterIndex: Integer; iTemperatureType: Integer; var lpTemperature: Integer): Integer; stdcall;
ADL2_OVERDRIVEN_SYSTEMCLOCKSX2_GET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLevels: TADLODNPerformanceLevelsX2): Integer; stdcall;
ADL2_OVERDRIVEN_SYSTEMCLOCKSX2_SET = function(hContext: Pointer; iAdapterIndex: Integer; var lpLevels: TADLODNPerformanceLevelsX2): Integer; stdcall;
Expand Down
26 changes: 19 additions & 7 deletions Common/adl_structures.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2655,7 +2655,7 @@ ADLODNParameterRange = record
/// \nosubgrouping
////////////////////////////////////////////////////////////////////////////////////////////
type
_ADLODNCapabilities = record
TADLODNCapabilities = record
/// Number of levels which describe the minimum to maximum clock ranges.
/// The 1st level indicates the minimum clocks, and the 2nd level
/// indicates the maximum clocks.
Expand Down Expand Up @@ -2685,6 +2685,7 @@ _ADLODNCapabilities = record
/// clocks cannot be set outside this range.
minimumPerformanceClock: ADLODNParameterRange;
end;
PADLODNCapabilities = ^TADLODNCapabilities;

/////////////////////////////////////////////////////////////////////////////////////////////
///\brief Structure containing information about Overdrive N capabilities
Expand All @@ -2693,7 +2694,7 @@ _ADLODNCapabilities = record
/// \nosubgrouping
////////////////////////////////////////////////////////////////////////////////////////////
type
_ADLODNCapabilitiesX2 = record
TADLODNCapabilitiesX2 = record
/// Number of levels which describe the minimum to maximum clock ranges.
/// The 1st level indicates the minimum clocks, and the 2nd level
/// indicates the maximum clocks.
Expand Down Expand Up @@ -2730,7 +2731,7 @@ _ADLODNCapabilitiesX2 = record
/// Contains the hard limits of the Auto Systemclock
autoSystemClock: ADLODNParameterRange;
end;
TADLODNCapabilitiesX2 = _ADLODNCapabilitiesX2;
PADLODNCapabilitiesX2 = ^TADLODNCapabilitiesX2;

/////////////////////////////////////////////////////////////////////////////////////////////
///\brief Structure containing information about Overdrive level.
Expand Down Expand Up @@ -2848,7 +2849,7 @@ ADLOD8SingleInitSetting = record
/// \nosubgrouping
////////////////////////////////////////////////////////////////////////////////////////////
type
ADLODNFanControl = record
TADLODNFanControl = record
iMode: integer;
iFanControlMode: integer;
iCurrentFanSpeedMode: integer;
Expand All @@ -2858,7 +2859,7 @@ ADLODNFanControl = record
iMinPerformanceClock: integer;
iMinFanLimit: integer;
end;
PADLODNFanControl = ^ADLODNFanControl;
PADLODNFanControl = ^TADLODNFanControl;

/////////////////////////////////////////////////////////////////////////////////////////////
///\brief Structure containing information about Overdrive N power limit.
Expand All @@ -2868,14 +2869,14 @@ ADLODNFanControl = record
/// \nosubgrouping
////////////////////////////////////////////////////////////////////////////////////////////
type
ADLODNPowerLimitSetting = record
TADLODNPowerLimitSetting = record
iMode: integer;
iTDPLimit: integer;
iMaxOperatingTemperature: integer;
end;

type
ADLODNPerformanceStatus = record
TADLODNPerformanceStatus = record
iCoreClock: integer;
iMemoryClock: integer;
iDCEFClock: integer;
Expand Down Expand Up @@ -2991,6 +2992,17 @@ ADLPMLogDataOutput = record
PADLPMLogDataOutput = ADLPMLogDataOutput;
TADLPMLogDataOutput = ADLPMLogDataOutput;

type
TADLODNTemperatureType = (
CORE = 1,
MEMORY = 2,
VRM_CORE = 3,
VRM_MEMORY = 4,
LIQUID = 5,
PLX = 6,
HOTSPOT = 7
);

implementation

end.
2 changes: 1 addition & 1 deletion Common/d3dkmt.pas
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ procedure TD3DKMTStatistics.Update;
var
I: Integer;
QueryStats: D3DKMT_QUERYSTATISTICS;
CommitLimit, BytesCommitted: UInt64;
BytesCommitted: UInt64;
begin
FMemoryUsage:=0;
FSharedUsage:=0;
Expand Down
Loading

0 comments on commit f43ef85

Please sign in to comment.