Add sensors for Astral GPUs (#2168)

* Add sensors for Astral GPUs

* Clean up imports

* Code clean-up

---------

Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
Timotej
2026-01-22 10:00:23 +01:00
committed by GitHub
co-authored by PhyxionNL
parent 24218b0703
commit 6f9ac5aece
2 changed files with 171 additions and 0 deletions
+35
View File
@@ -23,6 +23,8 @@ internal static class NvApi
public const int THERMAL_SENSOR_RESERVED_COUNT = 8;
public const int THERMAL_SENSOR_TEMPERATURE_COUNT = 32;
public const uint NVAPI_I2C_SPEED_DEPRECATED = 0xFFFF;
private const string DllName = "nvapi.dll";
private const string DllName64 = "nvapi64.dll";
@@ -46,6 +48,7 @@ internal static class NvApi
public static NvAPI_GPU_GetUsagesDelegate NvAPI_GPU_GetUsages { get; internal set; }
public static NvAPI_GPU_SetCoolerLevelsDelegate NvAPI_GPU_SetCoolerLevels { get; internal set; }
public static NvAPI_GPU_GetThermalSensorsDelegate NvAPI_GPU_GetThermalSensors { get; internal set; }
public static NvAPI_I2CReadExDelegate NvAPI_I2CReadEx { get; internal set; }
public static NvAPI_GPU_ClientVoltRailsGetStatusDelegate NvAPI_GPU_ClientVoltRailsGetStatus { get; internal set; }
private static NvAPI_GetInterfaceVersionStringDelegate _nvAPI_GetInterfaceVersionString;
@@ -91,6 +94,7 @@ internal static class NvApi
NvAPI_GPU_ClientFanCoolersSetControl = GetDelegate<NvAPI_GPU_ClientFanCoolersSetControlDelegate>(0xA58971A5);
NvAPI_GPU_ClientPowerTopologyGetStatus = GetDelegate<NvAPI_GPU_ClientPowerTopologyGetStatusDelegate>(0x0EDCF624E);
NvAPI_GPU_GetThermalSensors = GetDelegate<NvAPI_GPU_GetThermalSensorsDelegate>(0x65FE3AAD);
NvAPI_I2CReadEx = GetDelegate<NvAPI_I2CReadExDelegate>(0x4D7B0709);
NvAPI_GPU_ClientVoltRailsGetStatus = GetDelegate<NvAPI_GPU_ClientVoltRailsGetStatusDelegate>(0x465F9BCF);
IsAvailable = true;
@@ -160,6 +164,9 @@ internal static class NvApi
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_SetCoolerLevelsDelegate(NvPhysicalGpuHandle gpuHandle, int coolerIndex, ref NvCoolerLevels NvCoolerLevels);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_I2CReadExDelegate(NvPhysicalGpuHandle gpuHandle, ref NvI2CInfo i2cInfo, ref uint readData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_ClientVoltRailsGetStatusDelegate(NvPhysicalGpuHandle gpuHandle, ref NvGpuClientVoltRailsStatus status);
@@ -194,6 +201,17 @@ internal static class NvApi
BusInterface // Bus
}
public enum NvI2CSpeed : uint
{
Default = 0,
Speed3Khz = 1,
Speed10Khz = 2,
Speed33Khz = 3,
Speed100Khz = 4,
Speed200Khz = 5,
Speed400Khz = 6
}
public static bool IsAvailable { get; private set; }
[DllImport(DllName, EntryPoint = "nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
@@ -628,6 +646,23 @@ internal static class NvApi
public bool IsPresent => (_isPresent & 1) != 0;
}
[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal struct NvI2CInfo
{
public uint Version;
public uint DisplayMask;
public byte IsDDCPort;
public byte I2CDevAddress;
public IntPtr I2CRegAddress;
public uint RegAddrSize;
public IntPtr Data;
public uint Size;
public uint I2CSpeed;
public NvI2CSpeed I2CSpeedKhz;
public byte PortId;
public uint IsPortIdSet;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate NvStatus NvAPI_InitializeDelegate();