Support rx5700 series (#177)

Fixes #134.
This commit is contained in:
Ferenc Boldog
2019-12-17 09:47:39 +01:00
committed by Phyxion
parent d26dcc4189
commit 36a9d0604b
2 changed files with 310 additions and 168 deletions
+258 -168
View File
@@ -14,20 +14,22 @@ namespace LibreHardwareMonitor.Hardware.Gpu
private readonly int _adapterIndex;
private readonly Sensor _controlSensor;
private readonly Sensor _coreClock;
private readonly Sensor _socClock;
private readonly Sensor _coreLoad;
private readonly Sensor _coreVoltage;
private readonly int _currentOverdriveApiLevel;
private readonly Sensor _fan;
private readonly Control _fanControl;
private readonly Sensor _memoryClock;
private readonly Sensor _memoryVoltage;
private readonly Sensor _powerCore;
private readonly Sensor _powerPpt;
private readonly Sensor _powerSocket;
private readonly Sensor _powerTotal;
private readonly Sensor _temperatureCore;
private readonly Sensor _temperatureHbm;
private readonly Sensor _temperatureMemory;
private readonly Sensor _temperatureHotSpot;
private readonly Sensor _temperatureLiquid;
private readonly Sensor _temperatureMvdd;
@@ -44,7 +46,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
DeviceNumber = deviceNumber;
_temperatureCore = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
_temperatureHbm = new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
_temperatureMemory = new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
_temperatureVddc = new Sensor("GPU VR VDDC", 2, SensorType.Temperature, this, settings);
_temperatureMvdd = new Sensor("GPU VR MVDD", 3, SensorType.Temperature, this, settings);
_temperatureLiquid = new Sensor("GPU Liquid", 4, SensorType.Temperature, this, settings);
@@ -52,12 +54,16 @@ namespace LibreHardwareMonitor.Hardware.Gpu
_temperatureHotSpot = new Sensor("GPU Hot Spot", 6, SensorType.Temperature, this, settings);
_coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
_memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
_socClock = new Sensor("GPU SoC", 1, SensorType.Clock, this, settings);
_memoryClock = new Sensor("GPU Memory", 2, SensorType.Clock, this, settings);
_fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
_coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
_memoryVoltage = new Sensor("GPU Memory", 1, SensorType.Voltage, this, settings);
_coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
_controlSensor = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
_powerCore = new Sensor("GPU Core", 0, SensorType.Power, this, settings);
@@ -141,202 +147,286 @@ namespace LibreHardwareMonitor.Hardware.Gpu
public override void Update()
{
if (_currentOverdriveApiLevel >= 6)
if (_currentOverdriveApiLevel < 8)
{
int powerOf8 = 0;
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_TOTAL_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
if (_currentOverdriveApiLevel >= 6)
{
_powerTotal.Value = powerOf8 >> 8;
ActivateSensor(_powerTotal);
}
else
{
_powerTotal.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_PPT_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerPpt.Value = powerOf8 >> 8;
ActivateSensor(_powerPpt);
}
else
{
_powerPpt.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_SOCKET_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerSocket.Value = powerOf8 >> 8;
ActivateSensor(_powerSocket);
}
else
{
_powerSocket.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_CHIP_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerCore.Value = powerOf8 >> 8;
ActivateSensor(_powerCore);
}
else
{
_powerCore.Value = null;
}
}
if (_currentOverdriveApiLevel >= 7)
{
int temp = 0;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureCore.Value = 0.001f * temp;
ActivateSensor(_temperatureCore);
}
else
{
_temperatureCore.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureHbm.Value = temp;
ActivateSensor(_temperatureHbm);
}
else
{
_temperatureHbm.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureVddc.Value = temp;
ActivateSensor(_temperatureVddc);
}
else
{
_temperatureVddc.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureMvdd.Value = temp;
ActivateSensor(_temperatureMvdd);
}
else
{
_temperatureMvdd.Value = null;
}
_temperatureLiquid.Value = null;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK)
{
if (temp > 0)
int powerOf8 = 0;
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_TOTAL_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_temperatureLiquid.Value = temp;
ActivateSensor(_temperatureLiquid);
_powerTotal.Value = powerOf8 >> 8;
ActivateSensor(_powerTotal);
}
else
{
_powerTotal.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_PPT_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerPpt.Value = powerOf8 >> 8;
ActivateSensor(_powerPpt);
}
else
{
_powerPpt.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_SOCKET_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerSocket.Value = powerOf8 >> 8;
ActivateSensor(_powerSocket);
}
else
{
_powerSocket.Value = null;
}
if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_CHIP_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
{
_powerCore.Value = powerOf8 >> 8;
ActivateSensor(_powerCore);
}
else
{
_powerCore.Value = null;
}
}
_temperaturePlx.Value = null;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK)
if (_currentOverdriveApiLevel >= 7)
{
if (temp > 0)
int temp = 0;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK)
{
_temperaturePlx.Value = temp;
ActivateSensor(_temperaturePlx);
_temperatureCore.Value = 0.001f * temp;
ActivateSensor(_temperatureCore);
}
else
{
_temperatureCore.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureMemory.Value = temp;
ActivateSensor(_temperatureMemory);
}
else
{
_temperatureMemory.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureVddc.Value = temp;
ActivateSensor(_temperatureVddc);
}
else
{
_temperatureVddc.Value = null;
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureMvdd.Value = temp;
ActivateSensor(_temperatureMvdd);
}
else
{
_temperatureMvdd.Value = null;
}
_temperatureLiquid.Value = null;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK)
{
if (temp > 0)
{
_temperatureLiquid.Value = temp;
ActivateSensor(_temperatureLiquid);
}
}
_temperaturePlx.Value = null;
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK)
{
if (temp > 0)
{
_temperaturePlx.Value = temp;
ActivateSensor(_temperaturePlx);
}
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK)
{
_temperatureHotSpot.Value = temp;
ActivateSensor(_temperatureHotSpot);
}
else
{
_temperatureHotSpot.Value = null;
}
}
else
{
AtiAdlxx.ADLTemperature temperature = new AtiAdlxx.ADLTemperature();
if (AtiAdlxx.ADL_Overdrive5_Temperature_Get(_adapterIndex, 0, ref temperature) == AtiAdlxx.ADL_OK)
{
_temperatureCore.Value = 0.001f * temperature.Temperature;
ActivateSensor(_temperatureCore);
}
else
{
_temperatureCore.Value = null;
}
}
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK)
AtiAdlxx.ADLFanSpeedValue fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue { SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_RPM };
if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
{
_temperatureHotSpot.Value = temp;
ActivateSensor(_temperatureHotSpot);
_fan.Value = fanSpeedValue.FanSpeed;
ActivateSensor(_fan);
}
else
{
_temperatureHotSpot.Value = null;
_fan.Value = null;
}
}
else
{
AtiAdlxx.ADLTemperature temperature = new AtiAdlxx.ADLTemperature();
if (AtiAdlxx.ADL_Overdrive5_Temperature_Get(_adapterIndex, 0, ref temperature) == AtiAdlxx.ADL_OK)
fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue { SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT };
if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
{
_temperatureCore.Value = 0.001f * temperature.Temperature;
ActivateSensor(_temperatureCore);
_controlSensor.Value = fanSpeedValue.FanSpeed;
ActivateSensor(_controlSensor);
}
else
{
_temperatureCore.Value = null;
_controlSensor.Value = null;
}
}
AtiAdlxx.ADLFanSpeedValue fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue { SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_RPM };
if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
{
_fan.Value = fanSpeedValue.FanSpeed;
ActivateSensor(_fan);
}
else
{
_fan.Value = null;
}
fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue { SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT };
if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
{
_controlSensor.Value = fanSpeedValue.FanSpeed;
ActivateSensor(_controlSensor);
}
else
{
_controlSensor.Value = null;
}
AtiAdlxx.ADLPMActivity adlpmActivity = new AtiAdlxx.ADLPMActivity();
if (AtiAdlxx.ADL_Overdrive5_CurrentActivity_Get(_adapterIndex, ref adlpmActivity) == AtiAdlxx.ADL_OK)
{
if (adlpmActivity.EngineClock > 0)
AtiAdlxx.ADLPMActivity adlpmActivity = new AtiAdlxx.ADLPMActivity();
if (AtiAdlxx.ADL_Overdrive5_CurrentActivity_Get(_adapterIndex, ref adlpmActivity) == AtiAdlxx.ADL_OK)
{
_coreClock.Value = 0.01f * adlpmActivity.EngineClock;
ActivateSensor(_coreClock);
if (adlpmActivity.EngineClock > 0)
{
_coreClock.Value = 0.01f * adlpmActivity.EngineClock;
ActivateSensor(_coreClock);
}
else
{
_coreClock.Value = null;
}
if (adlpmActivity.MemoryClock > 0)
{
_memoryClock.Value = 0.01f * adlpmActivity.MemoryClock;
ActivateSensor(_memoryClock);
}
else
{
_memoryClock.Value = null;
}
if (adlpmActivity.Vddc > 0)
{
_coreVoltage.Value = 0.001f * adlpmActivity.Vddc;
ActivateSensor(_coreVoltage);
}
else
{
_coreVoltage.Value = null;
}
_coreLoad.Value = Math.Min(adlpmActivity.ActivityPercent, 100);
ActivateSensor(_coreLoad);
}
else
{
_coreClock.Value = null;
}
if (adlpmActivity.MemoryClock > 0)
{
_memoryClock.Value = 0.01f * adlpmActivity.MemoryClock;
ActivateSensor(_memoryClock);
}
else
{
_memoryClock.Value = null;
}
if (adlpmActivity.Vddc > 0)
{
_coreVoltage.Value = 0.001f * adlpmActivity.Vddc;
ActivateSensor(_coreVoltage);
}
else
{
_coreVoltage.Value = null;
_coreLoad.Value = null;
}
_coreLoad.Value = Math.Min(adlpmActivity.ActivityPercent, 100);
ActivateSensor(_coreLoad);
}
else
{
_coreClock.Value = null;
_memoryClock.Value = null;
_coreVoltage.Value = null;
_coreLoad.Value = null;
AtiAdlxx.ADLPMLogDataOutput logDataOutput = new AtiAdlxx.ADLPMLogDataOutput();
if (AtiAdlxx.ADL2_New_QueryPMLogData_Get(_context, _adapterIndex, ref logDataOutput) == AtiAdlxx.ADL_OK)
{
_temperatureCore.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_EDGE].value;
ActivateSensor(_temperatureCore);
_temperatureHotSpot.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_HOTSPOT].value;
ActivateSensor(_temperatureHotSpot);
_temperatureVddc.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRVDDC].value;
ActivateSensor(_temperatureVddc);
_temperatureMemory.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_MEM].value;
ActivateSensor(_temperatureMemory);
_temperatureMvdd.Value = null;
if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRMVDD].value > 0)
{
_temperatureMvdd.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRMVDD].value;
ActivateSensor(_temperatureMvdd);
}
_temperatureLiquid.Value = null;
if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_LIQUID].value > 0)
{
_temperatureLiquid.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_LIQUID].value;
ActivateSensor(_temperatureLiquid);
}
_temperaturePlx.Value = null;
if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_PLX].value > 0)
{
_temperaturePlx.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_PLX].value;
ActivateSensor(_temperaturePlx);
}
_coreClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_GFXCLK].value;
ActivateSensor(_coreClock);
_socClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_SOCCLK].value;
ActivateSensor(_socClock);
_memoryClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_MEMCLK].value;
ActivateSensor(_memoryClock);
if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_RPM].value != UInt16.MaxValue)
{
_fan.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_RPM].value;
_controlSensor.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_PERCENTAGE].value;
}
else
{
_fan.Value = null;
_controlSensor.Value = null;
}
ActivateSensor(_fan);
ActivateSensor(_controlSensor);
_coreVoltage.Value = 0.001f * logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_VOLTAGE].value;
ActivateSensor(_coreVoltage);
_memoryVoltage.Value = 0.001f * logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_MEM_VOLTAGE].value;
ActivateSensor(_memoryVoltage);
_coreLoad.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_INFO_ACTIVITY_GFX].value;
ActivateSensor(_coreLoad);
_powerCore.Value = null;
if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_POWER].value > 0)
{
_powerCore.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_POWER].value;
ActivateSensor(_powerCore);
}
_powerSocket.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_ASIC_POWER].value;
ActivateSensor(_powerSocket);
}
}
}
@@ -106,6 +106,9 @@ namespace LibreHardwareMonitor.Interop
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL2_Main_Control_Destroy(IntPtr context);
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
public static extern int ADL2_New_QueryPMLogData_Get(IntPtr context, int adapterIndex, ref ADLPMLogDataOutput aDLPMLogDataOutput);
public static int ADL_Main_Control_Create(int enumConnectedAdapters)
{
try
@@ -255,5 +258,54 @@ namespace LibreHardwareMonitor.Interop
PLX = 6,
HOTSPOT = 7
}
internal const int ADL_PMLOG_MAX_SENSORS = 256;
[StructLayout(LayoutKind.Sequential)]
internal struct ADLSingleSensorData
{
public int supported;
public int value;
}
[StructLayout(LayoutKind.Sequential)]
internal struct ADLPMLogDataOutput
{
public int size;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = ADL_PMLOG_MAX_SENSORS)]
public ADLSingleSensorData[] sensors;
}
internal enum ADLSensorType
{
SENSOR_MAXTYPES = 0,
PMLOG_CLK_GFXCLK = 1,
PMLOG_CLK_MEMCLK = 2,
PMLOG_CLK_SOCCLK = 3,
PMLOG_CLK_UVDCLK1 = 4,
PMLOG_CLK_UVDCLK2 = 5,
PMLOG_CLK_VCECLK = 6,
PMLOG_CLK_VCNCLK = 7,
PMLOG_TEMPERATURE_EDGE = 8,
PMLOG_TEMPERATURE_MEM = 9,
PMLOG_TEMPERATURE_VRVDDC = 10,
PMLOG_TEMPERATURE_VRMVDD = 11,
PMLOG_TEMPERATURE_LIQUID = 12,
PMLOG_TEMPERATURE_PLX = 13,
PMLOG_FAN_RPM = 14,
PMLOG_FAN_PERCENTAGE = 15,
PMLOG_SOC_VOLTAGE = 16,
PMLOG_SOC_POWER = 17,
PMLOG_SOC_CURRENT = 18,
PMLOG_INFO_ACTIVITY_GFX = 19,
PMLOG_INFO_ACTIVITY_MEM = 20,
PMLOG_GFX_VOLTAGE = 21,
PMLOG_MEM_VOLTAGE = 22,
PMLOG_ASIC_POWER = 23,
PMLOG_TEMPERATURE_VRSOC = 24,
PMLOG_TEMPERATURE_VRMVDD0 = 25,
PMLOG_TEMPERATURE_VRMVDD1 = 26,
PMLOG_TEMPERATURE_HOTSPOT = 27
}
}
}