diff --git a/amd.cpp b/amd.cpp index 6c9f449..14eb5aa 100644 --- a/amd.cpp +++ b/amd.cpp @@ -1,6 +1,7 @@ #ifdef AMD #include "gputypes.h" #include +#include amd::amd() {} bool amd::setupGPU() @@ -244,10 +245,12 @@ QString amd::applySettings(int GPUIndex) cmd.append("\""); proc.start(cmd); proc.waitForFinished(-1); + QThread::msleep(200); // If fan mode was changed, check if it was successful if (fanModeComboBox->currentIndex() != GPUList[GPUIndex].fanControlMode) { queryGPUFanCtlMode(GPUIndex); + qDebug() << "checking combo box" << fanModeComboBox->currentIndex() << GPUList[GPUIndex].fanControlMode; if (fanModeComboBox->currentIndex() != GPUList[GPUIndex].fanControlMode) { hadErrors = true; errStr.append("Fan mode, "); @@ -255,6 +258,15 @@ QString amd::applySettings(int GPUIndex) } } // Power limit + if (powerLimSlider->value() != latestpowerLimSlider) { + queryGPUPowerLimit(GPUIndex); + if (powerLimSlider->value() * 1000000 != static_cast(GPUList[GPUIndex].powerLim)) { + hadErrors = true; + errStr.append("Power Limit, "); + } else { + latestpowerLimSlider = powerLimSlider->value(); + } + } if (hadErrors) { errStr.chop(2); diff --git a/amdpstateeditor.cpp b/amdpstateeditor.cpp index 5981b73..e0276de 100644 --- a/amdpstateeditor.cpp +++ b/amdpstateeditor.cpp @@ -120,13 +120,23 @@ void amdPstateEditor::generateUI(gputypes *newtypes, int GPUIndex) buttonwidget->setLayout(buttonlo); llo->addWidget(buttonwidget); + QStatusBar *statusbar = new QStatusBar; + statusBar = statusbar; + QWidget *barwdg = new QWidget; + QVBoxLayout *barlo = new QVBoxLayout; + barlo->addWidget(statusbar); + barwdg->setLayout(barlo); + lower->setLayout(llo); upper->setLayout(ulo); QVBoxLayout *mainlo = new QVBoxLayout; mainlo->addWidget(upper); mainlo->addWidget(lower); + mainlo->addWidget(barwdg); ui->centralWidget->setLayout(mainlo); + + //statusbar->showMessage("test"); } bool amdPstateEditor::applyValues() { @@ -135,11 +145,12 @@ bool amdPstateEditor::applyValues() QString volt; QString freq; QString cmd = "pkexec /bin/sh -c \""; - bool changedState = false; + // Vector for saving what got applied + QVector changedMemPstates, changedCorePstates; // Apply core pstates for (int i=0; ivalue() != types->GPUList[gpuidx].coreclocks[i]) || (corePstates[i].voltspinbox->value() != types->GPUList[gpuidx].corevolts[i])) { - changedState = true; + changedCorePstates.append(i); volt = QString::number(corePstates[i].voltspinbox->value()); freq = QString::number(corePstates[i].freqspinbox->value()); cmd.append("echo 's "+ QString::number(i) + " "+ freq +" "+ volt +"' "+"> /sys/class/drm/card"+QString::number(types->GPUList[gpuidx].fsindex)+"/device/pp_od_clk_voltage & "); @@ -149,20 +160,34 @@ bool amdPstateEditor::applyValues() // Apply memory pstates for (int i=0; ivalue() != types->GPUList[gpuidx].memclocks[i]) || (memPstates[i].voltspinbox->value() != types->GPUList[gpuidx].memvolts[i])) { - changedState = true; + changedMemPstates.append(i); volt = QString::number(memPstates[i].voltspinbox->value()); freq = QString::number(memPstates[i].freqspinbox->value()); cmd.append("echo 'm "+ QString::number(i) + " "+ freq +" "+ volt +"' "+"> /sys/class/drm/card"+QString::number(types->GPUList[gpuidx].fsindex)+"/device/pp_od_clk_voltage & "); qDebug() << cmd; } } - if (changedState) { + if (!changedMemPstates.isEmpty() || !changedCorePstates.isEmpty()) { cmd.append("\""); proc.start(cmd); proc.waitForFinished(-1); - if (proc.exitCode() != 0) return false; + if (proc.exitCode() != 0) { + statusBar->showMessage("Failed to apply changes."); + return false; + } + } + // Save the values if it was successful + for (int i=0; iGPUList[gpuidx].memclocks[changedMemPstates[i]] = memPstates[changedMemPstates[i]].freqspinbox->value(); + types->GPUList[gpuidx].memvolts[changedMemPstates[i]] = memPstates[changedMemPstates[i]].voltspinbox->value(); } + for (int i=0; iGPUList[gpuidx].coreclocks[changedCorePstates[i]] = corePstates[changedCorePstates[i]].freqspinbox->value(); + types->GPUList[gpuidx].corevolts[changedCorePstates[i]] = corePstates[changedCorePstates[i]].voltspinbox->value(); + } + + statusBar->showMessage("Changes applied."); return true; } bool amdPstateEditor::resetPstates() diff --git a/amdpstateeditor.h b/amdpstateeditor.h index 25d08a5..1592958 100644 --- a/amdpstateeditor.h +++ b/amdpstateeditor.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "gputypes.h" namespace Ui { @@ -39,6 +40,7 @@ private: }; QVector corePstates; QVector memPstates; + QStatusBar *statusBar; gputypes *types; int gpuidx; private slots: diff --git a/amdpstateeditor.ui b/amdpstateeditor.ui index b1bb933..504bf13 100644 --- a/amdpstateeditor.ui +++ b/amdpstateeditor.ui @@ -6,10 +6,8 @@ 0 0 - 713 - 550 - 600 - 428 + 617 + 458 diff --git a/gputypes.h b/gputypes.h index 9b8ee3e..d30b659 100644 --- a/gputypes.h +++ b/gputypes.h @@ -65,12 +65,14 @@ public: bool overClockAvailable = false; bool memOverClockAvailable = false; bool powerLimitAvailable = false; + bool voltageReadable = false; bool coreClkReadable = false; bool memClkReadable = false; bool powerDrawReadable = false; bool coreUtilReadable = false; bool manualFanCtrlAvailable = false; + int fanControlMode; int maxVoltageOffset; int minVoltageOffset; diff --git a/mainwindow.cpp b/mainwindow.cpp index acde70c..c6ed692 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -231,6 +231,39 @@ void MainWindow::setupMonitorTab() } void MainWindow::setupGraphMonitorTab() { + // Check what is readable and make monitoring structs + if (types->GPUList[currentGPUIndex].voltageReadable) { + monitorCmds monstruct; + monstruct.queryFunc = &gputypes::queryGPUVoltage; + monstruct.displayValue = types->GPUList[currentGPUIndex].displayVoltage; + monitorCmdsList.append(monstruct); + } + if (types->GPUList[currentGPUIndex].powerDrawReadable) { + monitorCmds monstruct; + monstruct.queryFunc = &gputypes::queryGPUPowerDraw; + monstruct.displayValue = types->GPUList[currentGPUIndex].displayPowerDraw; + monitorCmdsList.append(monstruct); + } + if (types->GPUList[currentGPUIndex].coreUtilReadable) { + monitorCmds monstruct; + monstruct.queryFunc = &gputypes::queryGPUUtils; + monstruct.displayValue = types->GPUList[currentGPUIndex].displayCoreUtil; + monitorCmdsList.append(monstruct); + } + + if (types->GPUList[currentGPUIndex].coreClkReadable) { + monitorCmds monstruct; + monstruct.queryFunc = &gputypes::queryGPUFrequencies; + monstruct.displayValue = types->GPUList[currentGPUIndex].displayCoreFreq; + monitorCmdsList.append(monstruct); + } + monitorCmds monstruct; + monstruct.queryFunc = &gputypes::queryGPUFanSpeed; + monstruct.displayValue = types->GPUList[currentGPUIndex].displayFanSpeed; + monitorCmdsList.append(monstruct); + + + types->queryGPUTemp(currentGPUIndex); types->queryGPUPowerDraw(currentGPUIndex); types->queryGPUFrequencies(currentGPUIndex); @@ -422,13 +455,17 @@ void MainWindow::updateMonitor() { // Update the values for plots types->queryGPUTemp(currentGPUIndex); - types->queryGPUPowerDraw(currentGPUIndex); - types->queryGPUFrequencies(currentGPUIndex); - types->queryGPUUtils(currentGPUIndex); + //types->queryGPUPowerDraw(currentGPUIndex); + //types->queryGPUFrequencies(currentGPUIndex); + //types->queryGPUUtils(currentGPUIndex); types->queryGPUVoltage(currentGPUIndex); - types->queryGPUFanSpeed(currentGPUIndex); + //types->queryGPUFanSpeed(currentGPUIndex); types->queryGPUUsedVRAM(currentGPUIndex); + for (int i=0; iGPUList[currentGPUIndex].powerDraw; pwrdraw = pwrdraw/10; @@ -1064,6 +1101,7 @@ void MainWindow::enableFanUpdater() } void MainWindow::on_applyButton_clicked() { + resettimer->stop(); QSettings settings("tuxclocker"); settings.beginGroup("General"); QString prevProfile = settings.value("currentProfile").toString(); diff --git a/mainwindow.h b/mainwindow.h index 46b9e37..b73692d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -213,6 +213,11 @@ private: double latestPointerXcoord; int plotIndex = 0; + struct monitorCmds { + void (gputypes::*queryFunc)(int); + int displayValue; + }; + QVector monitorCmdsList; struct plotCmds { QVector vector;