diff --git a/amd.cpp b/amd.cpp index be16536..1f6184b 100644 --- a/amd.cpp +++ b/amd.cpp @@ -36,16 +36,39 @@ bool amd::setupGPU() GPU gpu; gpu.fsindex = i; gpu.gputype = Type::AMDGPU; + // Get the hwmon folder name + QString monpath = "/sys/class/drm/card0/device/hwmon"; + QDir mondir(monpath); + qDebug() << mondir.entryList() << "mondir"; + QStringList list = mondir.entryList(); + for (int i=0; i(percspeed); + qDebug() << GPUList[GPUIndex].fanSpeed << "fanspeed"; + } + else qDebug("Failed to query fan speed"); +} void amd::queryGPUUsedVRAM(int GPUIndex){} void amd::queryGPUFreqOffset(int GPUIndex){} void amd::queryGPUMemClkOffset(int GPUIndex){} @@ -116,8 +150,35 @@ void amd::queryGPUPowerDraw(int GPUIndex) &GPUList[GPUIndex].powerDraw); if (ret < 0) qDebug("failed to query GPU power draw"); } -void amd::queryGPUPowerLimit(int GPUIndex){} -void amd::queryGPUPowerLimitLimits(int GPUIndex){} +void amd::queryGPUPowerLimit(int GPUIndex) +{ + QFile pcapfile(GPUList[GPUIndex].hwmonpath+"/power1_cap"); + bool ret = pcapfile.open(QFile::ReadOnly | QFile::Text); + if (ret) { + QString pcap = pcapfile.readLine(); + GPUList[GPUIndex].powerLim = static_cast(pcap.toInt()/1000000); + qDebug() << GPUList[GPUIndex].powerLim << "current power limit"; + } + else qDebug("Failed to query power limit"); +} +void amd::queryGPUPowerLimitLimits(int GPUIndex) +{ + QFile maxpcapfile(GPUList[GPUIndex].hwmonpath+"/power1_cap_max"); + bool ret = maxpcapfile.open(QFile::ReadOnly | QFile::Text); + if (ret) { + QString maxpcap = maxpcapfile.readLine(); + GPUList[GPUIndex].maxPowerLim = static_cast(maxpcap.toInt()/1000000); + qDebug() << GPUList[GPUIndex].maxPowerLim << "max power limit"; + } + + QFile mincapfile(GPUList[GPUIndex].hwmonpath+"/power1_cap_min"); + ret = mincapfile.open(QFile::ReadOnly | QFile::Text); + if (ret) { + QString minpcap = mincapfile.readLine(); + GPUList[GPUIndex].minPowerLim = static_cast(minpcap.toInt()/1000000); + qDebug() << GPUList[GPUIndex].minPowerLim << "min power limit"; + } +} void amd::queryGPUCurrentMaxClocks(int GPUIndex) { amdgpu_gpu_info info; @@ -134,7 +195,10 @@ void amd::queryGPUCurrentMaxClocks(int GPUIndex) void amd::queryGPUPowerLimitAvailability(int GPUIndex){} bool amd::assignGPUFanSpeed(int GPUIndex, int targetValue){} -bool amd::assignGPUFanCtlMode(int GPUIndex, bool manual){} +bool amd::assignGPUFanCtlMode(int GPUIndex, bool manual) +{ + +} bool amd::assignGPUFreqOffset(int GPUIndex, int targetValue){} bool amd::assignGPUMemClockOffset(int GPUIndex, int targetValue){} bool amd::assignGPUVoltageOffset(int GPUIndex, int targetValue){} diff --git a/gputypes.h b/gputypes.h index 8b9c7a2..d09e850 100644 --- a/gputypes.h +++ b/gputypes.h @@ -70,6 +70,8 @@ public: // AMD only: // GPU index in the filesystem eg. card0 int fsindex; + // name of the folder in /sys/class/drm/card(n)/device/hwmon + QString hwmonpath; }; QVector GPUList;