Add missing ATI GPU temperatures (#123)

Thanks to @fboldog
This commit is contained in:
Ferenc Boldog
2019-09-12 10:29:31 +02:00
committed by Phyxion
parent 9b29f4e071
commit c745d888df
2 changed files with 72 additions and 10 deletions
+4
View File
@@ -123,6 +123,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL_Overdrive5_Temperature_Get(int adapterIndex, int thermalControllerIndex, ref ADLTemperature temperature);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL2_OverdriveN_Temperature_Get(IntPtr context, int adapterIndex, int thermalControllerIndex, ref int temp);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL_Overdrive5_FanSpeed_Get(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL_Overdrive5_FanSpeedInfo_Get(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedInfo fanSpeedInfo);
@@ -130,6 +132,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
public static extern int ADL_Overdrive5_FanSpeedToDefault_Set(int adapterIndex, int thermalControllerIndex);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL_Overdrive5_FanSpeed_Set(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL_Overdrive_Caps(int adapterIndex, ref int supported, ref int enabled, ref int version);
public static int ADL_Main_Control_Create(int enumConnectedAdapters) {
try {
+68 -10
View File
@@ -10,6 +10,7 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.ATI {
internal sealed class ATIGPU : Hardware {
@@ -17,14 +18,19 @@ namespace OpenHardwareMonitor.Hardware.ATI {
private readonly int adapterIndex;
private readonly int busNumber;
private readonly int deviceNumber;
private readonly Sensor temperature;
private readonly Sensor temperatureCore;
private readonly Sensor temperatureHBM;
private readonly Sensor temperatureVDDC;
private readonly Sensor temperatureMVDD;
private readonly Sensor temperatureHotSpot;
private readonly Sensor fan;
private readonly Sensor coreClock;
private readonly Sensor memoryClock;
private readonly Sensor coreVoltage;
private readonly Sensor coreLoad;
private readonly Sensor controlSensor;
private readonly Control fanControl;
private readonly Control fanControl;
private readonly bool isOverdriveNSupported;
public ATIGPU(string name, int adapterIndex, int busNumber,
int deviceNumber, ISettings settings)
@@ -35,7 +41,11 @@ namespace OpenHardwareMonitor.Hardware.ATI {
this.busNumber = busNumber;
this.deviceNumber = deviceNumber;
this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
this.temperatureCore = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
this.temperatureHBM = new Sensor("GPU HBM", 1, SensorType.Temperature, this, settings);
this.temperatureVDDC = new Sensor("GPU VDDC", 2, SensorType.Temperature, this, settings);
this.temperatureMVDD = new Sensor("GPU MVDD", 3, SensorType.Temperature, this, settings);
this.temperatureHotSpot = new Sensor("GPU Hot Spot", 4, SensorType.Temperature, 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.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
@@ -43,6 +53,11 @@ namespace OpenHardwareMonitor.Hardware.ATI {
this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
this.controlSensor = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
int supported = 0;
int enabled = 0;
int version = 0;
isOverdriveNSupported = ADL.ADL_Overdrive_Caps(1, ref supported, ref enabled, ref version) == ADL.ADL_OK && version >= 7;
ADLFanSpeedInfo afsi = new ADLFanSpeedInfo();
if (ADL.ADL_Overdrive5_FanSpeedInfo_Get(adapterIndex, 0, ref afsi)
!= ADL.ADL_OK)
@@ -100,14 +115,57 @@ namespace OpenHardwareMonitor.Hardware.ATI {
}
public override void Update() {
ADLTemperature adlt = new ADLTemperature();
if (ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt)
== ADL.ADL_OK)
{
temperature.Value = 0.001f * adlt.Temperature;
ActivateSensor(temperature);
if (isOverdriveNSupported) {
int temp = 0;
IntPtr context = IntPtr.Zero;
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex, 1, ref temp) == ADL.ADL_OK) {
temperatureCore.Value = 0.001f * temp;
ActivateSensor(temperatureCore);
} else {
temperatureCore.Value = null;
}
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex, 2, ref temp) == ADL.ADL_OK) {
temperatureHBM.Value = temp;
ActivateSensor(temperatureHBM);
} else {
temperatureHBM.Value = null;
}
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex, 3, ref temp) == ADL.ADL_OK) {
temperatureVDDC.Value = temp;
ActivateSensor(temperatureVDDC);
} else {
temperatureVDDC.Value = null;
}
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex, 4, ref temp) == ADL.ADL_OK) {
temperatureMVDD.Value = temp;
ActivateSensor(temperatureMVDD);
} else {
temperatureMVDD.Value = null;
}
if (ADL.ADL2_OverdriveN_Temperature_Get(context, adapterIndex, 7, ref temp) == ADL.ADL_OK) {
temperatureHotSpot.Value = temp;
ActivateSensor(temperatureHotSpot);
} else {
temperatureHotSpot.Value = null;
}
if (context != IntPtr.Zero) {
Marshal.FreeHGlobal(context);
}
} else {
temperature.Value = null;
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;
}
}
ADLFanSpeedValue adlf = new ADLFanSpeedValue();