mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-22 09:57:20 +00:00
Added partial support for ADL (AMD Display Library) OverDrive6 and OverDrive Next APIs.
This commit is contained in:
parent
dc15084ed5
commit
d2c60279a0
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -77,6 +77,23 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
public int MaxRPM;
|
public int MaxRPM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum ADLODNCurrentPowerType {
|
||||||
|
TOTAL_POWER = 0,
|
||||||
|
PPT_POWER,
|
||||||
|
SOCKET_POWER,
|
||||||
|
CHIP_POWER,
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum ADLODNTemperatureType {
|
||||||
|
CORE = 1,
|
||||||
|
MEMORY = 2,
|
||||||
|
VRM_CORE = 3,
|
||||||
|
VRM_MEMORY = 4,
|
||||||
|
LIQUID = 5,
|
||||||
|
PLX = 6,
|
||||||
|
HOTSPOT = 7,
|
||||||
|
}
|
||||||
|
|
||||||
internal class ADL {
|
internal class ADL {
|
||||||
public const int ADL_MAX_PATH = 256;
|
public const int ADL_MAX_PATH = 256;
|
||||||
public const int ADL_MAX_ADAPTERS = 40;
|
public const int ADL_MAX_ADAPTERS = 40;
|
||||||
@ -127,6 +144,18 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
int adapterIndex, int thermalControllerIndex);
|
int adapterIndex, int thermalControllerIndex);
|
||||||
public delegate int ADL_Overdrive5_FanSpeed_SetDelegate(int adapterIndex,
|
public delegate int ADL_Overdrive5_FanSpeed_SetDelegate(int adapterIndex,
|
||||||
int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
||||||
|
public delegate int ADL_Overdrive_CapsDelegate(int adapterIndex,
|
||||||
|
out int supported, out int enabled, out int version);
|
||||||
|
private delegate int ADL2_Main_Control_CreateDelegate(
|
||||||
|
ADL_Main_Memory_AllocDelegate callback, int enumConnectedAdapters,
|
||||||
|
out IntPtr context);
|
||||||
|
public delegate int ADL2_Main_Control_DestroyDelegate(IntPtr context);
|
||||||
|
public delegate int ADL2_OverdriveN_Temperature_GetDelegate(IntPtr context,
|
||||||
|
int adapterIndex, ADLODNTemperatureType temperatureType,
|
||||||
|
out int temperature);
|
||||||
|
public delegate int ADL2_Overdrive6_CurrentPower_GetDelegate(IntPtr context,
|
||||||
|
int adapterIndex, ADLODNCurrentPowerType powerType,
|
||||||
|
out int currentValue);
|
||||||
|
|
||||||
private static ADL_Main_Control_CreateDelegate
|
private static ADL_Main_Control_CreateDelegate
|
||||||
_ADL_Main_Control_Create;
|
_ADL_Main_Control_Create;
|
||||||
@ -155,6 +184,16 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
ADL_Overdrive5_FanSpeedToDefault_Set;
|
ADL_Overdrive5_FanSpeedToDefault_Set;
|
||||||
public static ADL_Overdrive5_FanSpeed_SetDelegate
|
public static ADL_Overdrive5_FanSpeed_SetDelegate
|
||||||
ADL_Overdrive5_FanSpeed_Set;
|
ADL_Overdrive5_FanSpeed_Set;
|
||||||
|
public static ADL_Overdrive_CapsDelegate
|
||||||
|
ADL_Overdrive_Caps;
|
||||||
|
private static ADL2_Main_Control_CreateDelegate
|
||||||
|
_ADL2_Main_Control_Create;
|
||||||
|
public static ADL2_Main_Control_DestroyDelegate
|
||||||
|
ADL2_Main_Control_Destroy;
|
||||||
|
public static ADL2_OverdriveN_Temperature_GetDelegate
|
||||||
|
ADL2_OverdriveN_Temperature_Get;
|
||||||
|
public static ADL2_Overdrive6_CurrentPower_GetDelegate
|
||||||
|
ADL2_Overdrive6_CurrentPower_Get;
|
||||||
|
|
||||||
private static string dllName;
|
private static string dllName;
|
||||||
|
|
||||||
@ -201,7 +240,17 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
out ADL_Overdrive5_FanSpeedToDefault_Set);
|
out ADL_Overdrive5_FanSpeedToDefault_Set);
|
||||||
GetDelegate("ADL_Overdrive5_FanSpeed_Set",
|
GetDelegate("ADL_Overdrive5_FanSpeed_Set",
|
||||||
out ADL_Overdrive5_FanSpeed_Set);
|
out ADL_Overdrive5_FanSpeed_Set);
|
||||||
}
|
GetDelegate("ADL_Overdrive_Caps",
|
||||||
|
out ADL_Overdrive_Caps);
|
||||||
|
GetDelegate("ADL2_Main_Control_Create",
|
||||||
|
out _ADL2_Main_Control_Create);
|
||||||
|
GetDelegate("ADL2_Main_Control_Destroy",
|
||||||
|
out ADL2_Main_Control_Destroy);
|
||||||
|
GetDelegate("ADL2_OverdriveN_Temperature_Get",
|
||||||
|
out ADL2_OverdriveN_Temperature_Get);
|
||||||
|
GetDelegate("ADL2_Overdrive6_CurrentPower_Get",
|
||||||
|
out ADL2_Overdrive6_CurrentPower_Get);
|
||||||
|
}
|
||||||
|
|
||||||
static ADL() {
|
static ADL() {
|
||||||
CreateDelegates("atiadlxx");
|
CreateDelegates("atiadlxx");
|
||||||
@ -224,6 +273,21 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int ADL2_Main_Control_Create(int enumConnectedAdapters,
|
||||||
|
out IntPtr context)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
var result = _ADL2_Main_Control_Create(Main_Memory_Alloc,
|
||||||
|
enumConnectedAdapters, out context);
|
||||||
|
if (result != ADL.ADL_OK)
|
||||||
|
context = IntPtr.Zero;
|
||||||
|
return result;
|
||||||
|
} catch {
|
||||||
|
context = IntPtr.Zero;
|
||||||
|
return ADL_ERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int ADL_Adapter_AdapterInfo_Get(ADLAdapterInfo[] info) {
|
public static int ADL_Adapter_AdapterInfo_Get(ADLAdapterInfo[] info) {
|
||||||
int elementSize = Marshal.SizeOf(typeof(ADLAdapterInfo));
|
int elementSize = Marshal.SizeOf(typeof(ADLAdapterInfo));
|
||||||
int size = info.Length * elementSize;
|
int size = info.Length * elementSize;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,17 +17,30 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
private readonly int adapterIndex;
|
private readonly int adapterIndex;
|
||||||
private readonly int busNumber;
|
private readonly int busNumber;
|
||||||
private readonly int deviceNumber;
|
private readonly int deviceNumber;
|
||||||
private readonly Sensor temperature;
|
private readonly Sensor temperatureCore;
|
||||||
|
private readonly Sensor temperatureMemory;
|
||||||
|
private readonly Sensor temperatureVrmCore;
|
||||||
|
private readonly Sensor temperatureVrmMemory;
|
||||||
|
private readonly Sensor temperatureLiquid;
|
||||||
|
private readonly Sensor temperaturePlx;
|
||||||
|
private readonly Sensor temperatureHotSpot;
|
||||||
|
private readonly Sensor powerCore;
|
||||||
|
private readonly Sensor powerPpt;
|
||||||
|
private readonly Sensor powerSocket;
|
||||||
|
private readonly Sensor powerTotal;
|
||||||
private readonly Sensor fan;
|
private readonly Sensor fan;
|
||||||
private readonly Sensor coreClock;
|
private readonly Sensor coreClock;
|
||||||
private readonly Sensor memoryClock;
|
private readonly Sensor memoryClock;
|
||||||
private readonly Sensor coreVoltage;
|
private readonly Sensor coreVoltage;
|
||||||
private readonly Sensor coreLoad;
|
private readonly Sensor coreLoad;
|
||||||
private readonly Sensor controlSensor;
|
private readonly Sensor controlSensor;
|
||||||
private readonly Control fanControl;
|
private readonly Control fanControl;
|
||||||
|
|
||||||
|
private IntPtr context;
|
||||||
|
private readonly int overdriveVersion;
|
||||||
|
|
||||||
public ATIGPU(string name, int adapterIndex, int busNumber,
|
public ATIGPU(string name, int adapterIndex, int busNumber,
|
||||||
int deviceNumber, ISettings settings)
|
int deviceNumber, IntPtr context, ISettings settings)
|
||||||
: base(name, new Identifier("atigpu",
|
: base(name, new Identifier("atigpu",
|
||||||
adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
|
adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
|
||||||
{
|
{
|
||||||
@ -35,7 +48,35 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
this.busNumber = busNumber;
|
this.busNumber = busNumber;
|
||||||
this.deviceNumber = deviceNumber;
|
this.deviceNumber = deviceNumber;
|
||||||
|
|
||||||
this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
|
this.context = context;
|
||||||
|
|
||||||
|
if (ADL.ADL_Overdrive_Caps(adapterIndex, out _, out _,
|
||||||
|
out overdriveVersion) != ADL.ADL_OK)
|
||||||
|
{
|
||||||
|
overdriveVersion = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.temperatureCore =
|
||||||
|
new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
|
||||||
|
this.temperatureMemory =
|
||||||
|
new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
|
||||||
|
this.temperatureVrmCore =
|
||||||
|
new Sensor("GPU VRM Core", 2, SensorType.Temperature, this, settings);
|
||||||
|
this.temperatureVrmMemory =
|
||||||
|
new Sensor("GPU VRM Memory", 3, SensorType.Temperature, this, settings);
|
||||||
|
this.temperatureLiquid =
|
||||||
|
new Sensor("GPU Liquid", 4, SensorType.Temperature, this, settings);
|
||||||
|
this.temperaturePlx =
|
||||||
|
new Sensor("GPU PLX", 5, SensorType.Temperature, this, settings);
|
||||||
|
this.temperatureHotSpot =
|
||||||
|
new Sensor("GPU Hot Spot", 6, SensorType.Temperature, this, settings);
|
||||||
|
|
||||||
|
this.powerTotal = new Sensor("GPU Total", 0, SensorType.Power, this, settings);
|
||||||
|
this.powerCore = new Sensor("GPU Core", 1, SensorType.Power, this, settings);
|
||||||
|
this.powerPpt = new Sensor("GPU PPT", 2, SensorType.Power, this, settings);
|
||||||
|
this.powerSocket = new Sensor("GPU Socket", 3, SensorType.Power, this, settings);
|
||||||
|
|
||||||
|
|
||||||
this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
|
this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
|
||||||
this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
|
this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
|
||||||
this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
|
this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
|
||||||
@ -99,17 +140,59 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
get { return HardwareType.GpuAti; }
|
get { return HardwareType.GpuAti; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update() {
|
private void GetODNTemperature(ADLODNTemperatureType type,
|
||||||
ADLTemperature adlt = new ADLTemperature();
|
Sensor sensor)
|
||||||
if (ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt)
|
{
|
||||||
== ADL.ADL_OK)
|
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex,
|
||||||
|
type, out int temperature) == ADL.ADL_OK)
|
||||||
{
|
{
|
||||||
temperature.Value = 0.001f * adlt.Temperature;
|
sensor.Value = 0.001f * temperature;
|
||||||
ActivateSensor(temperature);
|
ActivateSensor(sensor);
|
||||||
} else {
|
} else {
|
||||||
temperature.Value = null;
|
sensor.Value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetOD6Power(ADLODNCurrentPowerType type, Sensor sensor)
|
||||||
|
{
|
||||||
|
if (ADL.ADL2_Overdrive6_CurrentPower_Get(context, adapterIndex, type,
|
||||||
|
out int power) == ADL.ADL_OK)
|
||||||
|
{
|
||||||
|
sensor.Value = power * (1.0f / 0xFF);
|
||||||
|
ActivateSensor(sensor);
|
||||||
|
} else {
|
||||||
|
sensor.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update() {
|
||||||
|
if (context != IntPtr.Zero && overdriveVersion >= 7) {
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.CORE, temperatureCore);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.MEMORY, temperatureMemory);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.VRM_CORE, temperatureVrmCore);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.VRM_MEMORY, temperatureVrmMemory);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.LIQUID, temperatureLiquid);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.PLX, temperaturePlx);
|
||||||
|
GetODNTemperature(ADLODNTemperatureType.HOTSPOT, temperatureHotSpot);
|
||||||
|
} else {
|
||||||
|
ADLTemperature adlt = new ADLTemperature();
|
||||||
|
if (ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt)
|
||||||
|
== ADL.ADL_OK) {
|
||||||
|
temperatureCore.Value = 0.001f * adlt.Temperature;
|
||||||
|
ActivateSensor(temperatureCore);
|
||||||
|
} else {
|
||||||
|
temperatureCore.Value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context != IntPtr.Zero && overdriveVersion >= 6) {
|
||||||
|
GetOD6Power(ADLODNCurrentPowerType.TOTAL_POWER, powerTotal);
|
||||||
|
GetOD6Power(ADLODNCurrentPowerType.CHIP_POWER, powerCore);
|
||||||
|
GetOD6Power(ADLODNCurrentPowerType.PPT_POWER, powerPpt);
|
||||||
|
GetOD6Power(ADLODNCurrentPowerType.SOCKET_POWER, powerSocket);
|
||||||
|
}
|
||||||
|
|
||||||
ADLFanSpeedValue adlf = new ADLFanSpeedValue();
|
ADLFanSpeedValue adlf = new ADLFanSpeedValue();
|
||||||
adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_RPM;
|
adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_RPM;
|
||||||
if (ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref adlf)
|
if (ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref adlf)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,18 +19,24 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
private readonly List<ATIGPU> hardware = new List<ATIGPU>();
|
private readonly List<ATIGPU> hardware = new List<ATIGPU>();
|
||||||
private readonly StringBuilder report = new StringBuilder();
|
private readonly StringBuilder report = new StringBuilder();
|
||||||
|
|
||||||
|
private IntPtr context = IntPtr.Zero;
|
||||||
|
|
||||||
public ATIGroup(ISettings settings) {
|
public ATIGroup(ISettings settings) {
|
||||||
try {
|
try {
|
||||||
int status = ADL.ADL_Main_Control_Create(1);
|
int adlStatus = ADL.ADL_Main_Control_Create(1);
|
||||||
|
int adl2Status = ADL.ADL2_Main_Control_Create(1, out context);
|
||||||
|
|
||||||
report.AppendLine("AMD Display Library");
|
report.AppendLine("AMD Display Library");
|
||||||
report.AppendLine();
|
report.AppendLine();
|
||||||
report.Append("Status: ");
|
report.Append("ADL Status: ");
|
||||||
report.AppendLine(status == ADL.ADL_OK ? "OK" :
|
report.AppendLine(adlStatus == ADL.ADL_OK ? "OK" :
|
||||||
status.ToString(CultureInfo.InvariantCulture));
|
adlStatus.ToString(CultureInfo.InvariantCulture));
|
||||||
|
report.Append("ADL2 Status: ");
|
||||||
|
report.AppendLine(adl2Status == ADL.ADL_OK ? "OK" :
|
||||||
|
adl2Status.ToString(CultureInfo.InvariantCulture));
|
||||||
report.AppendLine();
|
report.AppendLine();
|
||||||
|
|
||||||
if (status == ADL.ADL_OK) {
|
if (adlStatus == ADL.ADL_OK) {
|
||||||
int numberOfAdapters = 0;
|
int numberOfAdapters = 0;
|
||||||
ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
|
ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
|
||||||
|
|
||||||
@ -91,7 +97,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
adapterInfo[i].AdapterName.Trim(),
|
adapterInfo[i].AdapterName.Trim(),
|
||||||
adapterInfo[i].AdapterIndex,
|
adapterInfo[i].AdapterIndex,
|
||||||
adapterInfo[i].BusNumber,
|
adapterInfo[i].BusNumber,
|
||||||
adapterInfo[i].DeviceNumber, settings));
|
adapterInfo[i].DeviceNumber, context, settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
report.AppendLine();
|
report.AppendLine();
|
||||||
@ -120,6 +126,12 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
try {
|
try {
|
||||||
foreach (ATIGPU gpu in hardware)
|
foreach (ATIGPU gpu in hardware)
|
||||||
gpu.Close();
|
gpu.Close();
|
||||||
|
|
||||||
|
if (context != IntPtr.Zero) {
|
||||||
|
ADL.ADL2_Main_Control_Destroy(context);
|
||||||
|
context = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
ADL.ADL_Main_Control_Destroy();
|
ADL.ADL_Main_Control_Destroy();
|
||||||
} catch (Exception) { }
|
} catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user