Fix index in pstate editor when loading settings

This commit is contained in:
jussi 2019-05-20 15:50:14 +03:00
parent 360f387755
commit 41a769c674
3 changed files with 14 additions and 9 deletions

14
amd.cpp
View File

@ -233,7 +233,7 @@ QString amd::applySettings(int GPUIndex)
//QString errStr = "Failed to apply these settings: ";
QString errStr = "Failed to apply settings ";
bool hadErrors = false;
bool hadChanges = false;
QProcess proc;
QString cmd = "pkexec /bin/sh -c \"";
@ -245,6 +245,7 @@ QString amd::applySettings(int GPUIndex)
// On custom mode, the mode needs to be set again to load the new points
if (fanModeComboBox->currentIndex() == 2 || fanModeComboBox->currentIndex() != GPUList[GPUIndex].fanControlMode) {
hadChanges = true;
switch (fanModeComboBox->currentIndex()) {
case 0:
cmd.append("echo '0' > "+GPUList[GPUIndex].hwmonpath+"/pwm1_enable & ");
@ -293,6 +294,7 @@ QString amd::applySettings(int GPUIndex)
}
// Apply fan speed
if (fanModeComboBox->currentIndex() == 1 && (latestFanSlider != fanSlider->value())) {
hadChanges = true;
int targetValue = fanSlider->value();
cmdval = static_cast<int>(ceil(targetValue*2.55));
cmd.append("echo '"+QString::number(cmdval)+"' > "+GPUList[GPUIndex].hwmonpath+"/pwm1 & ");
@ -301,12 +303,14 @@ QString amd::applySettings(int GPUIndex)
// Apply power limit
if (GPUList[GPUIndex].powerLimitAvailable) {
if (powerLimSlider->value() != latestpowerLimSlider) {
hadChanges = true;
cmd.append("echo '" + QString::number(powerLimSlider->value() * 1000000) +"' > " + GPUList[GPUIndex].hwmonpath + "/power1_cap & ");
}
}
// Apply voltage/core clock (highest pstate)
if (GPUList[GPUIndex].overClockAvailable) {
if ((coreClockSlider->value() != GPUList[GPUIndex].coreclocks.last()) || (voltageSlider->value() != GPUList[GPUIndex].corevolts.last())) {
hadChanges = true;
QString volt = QString::number(voltageSlider->value());
QString freq = QString::number(coreClockSlider->value());
cmd.append("echo 'm "+ QString::number(GPUList[GPUIndex].corevolts.size()-1) + " "+ freq +" "+ volt +"' "+"> /sys/class/drm/card"+QString::number(GPUList[GPUIndex].fsindex)+"/device/pp_od_clk_voltage & ");
@ -315,9 +319,11 @@ QString amd::applySettings(int GPUIndex)
cmd.append("\"");
qDebug() << "running cmd " << cmd;
proc.start(cmd);
proc.waitForFinished(-1);
QThread::msleep(200);
if (hadChanges) {
proc.start(cmd);
proc.waitForFinished(-1);
QThread::msleep(200);
} else return "Nothing to apply.";
// If fan mode was changed, check if it was successful
/*if (fanModeComboBox->currentIndex() != GPUList[GPUIndex].fanControlMode) {

View File

@ -121,8 +121,8 @@ void amdPstateEditor::generateUI(gputypes *newtypes, int GPUIndex)
// Set the appropriate slider values for the pstate
int frequency = settings.value("frequency").toInt();
int voltage = settings.value("voltage").toInt();
memPstates[memPstateIndices[i].toInt()].freqspinbox->setValue(frequency);
memPstates[memPstateIndices[i].toInt()].voltspinbox->setValue(voltage);
memPstates[memPstateIndices[i].toInt() - 1].freqspinbox->setValue(frequency);
memPstates[memPstateIndices[i].toInt() - 1].voltspinbox->setValue(voltage);
settings.endGroup();
}
settings.endGroup();
@ -134,8 +134,8 @@ void amdPstateEditor::generateUI(gputypes *newtypes, int GPUIndex)
settings.beginGroup(corePstateIndices[i]);
int frequency = settings.value("frequency").toInt();
int voltage = settings.value("voltage").toInt();
corePstates[corePstateIndices[i].toInt()].freqspinbox->setValue(frequency);
corePstates[corePstateIndices[i].toInt()].voltspinbox->setValue(voltage);
corePstates[corePstateIndices[i].toInt() - 1].freqspinbox->setValue(frequency);
corePstates[corePstateIndices[i].toInt() - 1].voltspinbox->setValue(voltage);
settings.endGroup();
}
settings.endGroup();

View File

@ -90,7 +90,6 @@ editProfile::editProfile(QWidget *parent, int GPUIndex, gputypes *types) :
}
settings.endArray();
ui->curvePlot->graph(0)->setData(qv_x, qv_y);
drawFillerLines();