Skip to content

Commit

Permalink
Add workaround for marazmista#151
Browse files Browse the repository at this point in the history
If the PC returns from sleep/hibernation we can enforce restoration of
the correct fan control mode by checking if the correct value is set for
pwm_enable and restore the value f necessary
  • Loading branch information
FMeinicke committed Oct 7, 2020
1 parent 1f98740 commit 9495412
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions radeon-profile/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,24 @@ void gpu::setForcePowerLevel(const QString &newForcePowerLevel) {
}

void gpu::setPwmValue(unsigned int value) {
// If the PC is sent to sleep (or hibernate) it can happen that PWM is
// disabled (by the OS..?) and that we have to re-enable it, if needed,
// after returning from sleep
static QFile pwmEnableFile(getDriverFiles().hwmonAttributes.pwm1_enable);
if (Q_UNLIKELY(pwmEnabled && pwmEnableFile.open(QFile::ReadOnly)
&& !pwmEnableFile.read(1).contains(pwm_manual)))
{
setPwmManualControl(true);
}
pwmEnableFile.close();

value = getGpuConstParams().pwmMaxSpeed * value / 100;
driverHandler->setNewValue(getDriverFiles().hwmonAttributes.pwm1, QString::number(value));
}

void gpu::setPwmManualControl(bool manual) {
driverHandler->setNewValue(getDriverFiles().hwmonAttributes.pwm1_enable, QString(manual ? pwm_manual : pwm_auto));
pwmEnabled = manual;
}

void gpu::getFanSpeed() {
Expand Down
1 change: 1 addition & 0 deletions radeon-profile/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class gpu : public QObject

char currentGpuIndex;
QString currentPowerProfile, currentPowerLevel;
bool pwmEnabled = false;

QList<QTreeWidgetItem *> getCardConnectors() const;
QStringList getGLXInfo(QString gpuName) const;
Expand Down

0 comments on commit 9495412

Please sign in to comment.