mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
Save pstates after applying
This commit is contained in:
parent
fd1fab275b
commit
cbdfe7a6a9
12
amd.cpp
12
amd.cpp
@ -1,6 +1,7 @@
|
||||
#ifdef AMD
|
||||
#include "gputypes.h"
|
||||
#include <tgmath.h>
|
||||
#include <QThread>
|
||||
|
||||
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<int>(GPUList[GPUIndex].powerLim)) {
|
||||
hadErrors = true;
|
||||
errStr.append("Power Limit, ");
|
||||
} else {
|
||||
latestpowerLimSlider = powerLimSlider->value();
|
||||
}
|
||||
}
|
||||
|
||||
if (hadErrors) {
|
||||
errStr.chop(2);
|
||||
|
@ -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 <int> changedMemPstates, changedCorePstates;
|
||||
// Apply core pstates
|
||||
for (int i=0; i<corePstates.size(); i++) {
|
||||
if ((corePstates[i].freqspinbox->value() != 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; i<memPstates.size(); i++) {
|
||||
if ((memPstates[i].freqspinbox->value() != 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; i<changedMemPstates.size(); i++) {
|
||||
types->GPUList[gpuidx].memclocks[changedMemPstates[i]] = memPstates[changedMemPstates[i]].freqspinbox->value();
|
||||
types->GPUList[gpuidx].memvolts[changedMemPstates[i]] = memPstates[changedMemPstates[i]].voltspinbox->value();
|
||||
}
|
||||
|
||||
for (int i=0; i<changedCorePstates.size(); i++) {
|
||||
types->GPUList[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()
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QProcess>
|
||||
#include <QStatusBar>
|
||||
#include "gputypes.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -39,6 +40,7 @@ private:
|
||||
};
|
||||
QVector <corePstate> corePstates;
|
||||
QVector <memPstate> memPstates;
|
||||
QStatusBar *statusBar;
|
||||
gputypes *types;
|
||||
int gpuidx;
|
||||
private slots:
|
||||
|
@ -6,10 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>713</width>
|
||||
<height>550</height>
|
||||
<width>600</width>
|
||||
<height>428</height>
|
||||
<width>617</width>
|
||||
<height>458</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -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;
|
||||
|
@ -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; i<monitorCmdsList.size(); i++) {
|
||||
(*types.*monitorCmdsList[i].queryFunc)(currentGPUIndex);
|
||||
}
|
||||
|
||||
// Remove the last decimal point from power draw to make it take less space on the plot
|
||||
/*double pwrdraw = types->GPUList[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();
|
||||
|
@ -213,6 +213,11 @@ private:
|
||||
double latestPointerXcoord;
|
||||
int plotIndex = 0;
|
||||
|
||||
struct monitorCmds {
|
||||
void (gputypes::*queryFunc)(int);
|
||||
int displayValue;
|
||||
};
|
||||
QVector <monitorCmds> monitorCmdsList;
|
||||
struct plotCmds
|
||||
{
|
||||
QVector <double> vector;
|
||||
|
Loading…
Reference in New Issue
Block a user