If the user defined flag is not set on fanspeed, set the fanspeed with it first.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/adl.c b/adl.c
index 804c3d4..f937e9c 100644
--- a/adl.c
+++ b/adl.c
@@ -299,15 +299,9 @@ void init_adl(int nDevs)
/* Save the fanspeed values as defaults in case we reset later */
ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
- if (gpus[gpu].gpu_fan) {
- ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
- ga->targetfan = ga->lpFanSpeedValue.iFanSpeed = gpus[gpu].gpu_fan;
- ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
- ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
- applog(LOG_INFO, "Setting GPU %d fan speed to %d%%", gpu, gpus[gpu].gpu_fan);
- ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
- ga->managed = true;
- } else
+ if (gpus[gpu].gpu_fan)
+ set_fanspeed(gpu, gpus[gpu].gpu_fan);
+ else
gpus[gpu].gpu_fan = 85; /* Set a nominal upper limit of 85% */
/* Not fatal if powercontrol get fails */
@@ -331,7 +325,6 @@ void init_adl(int nDevs)
ga->autofan = true;
/* Set a safe starting default if we're automanaging fan speeds */
set_fanspeed(gpu, gpus[gpu].gpu_fan);
- ga->managed = true;
}
if (opt_autoengine) {
ga->autoengine = true;
@@ -771,13 +764,17 @@ static int set_fanspeed(int gpu, int iFanSpeed)
/* Store what fanspeed we're actually aiming for for re-entrant changes
* in case this device does not support fine setting changes */
ga->targetfan = iFanSpeed;
- ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) {
/* Must convert speed to an RPM */
iFanSpeed = ga->lpFanSpeedInfo.iMaxRPM * iFanSpeed / 100;
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
} else
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
+ if (!(ga->lpFanSpeedValue.iFlags & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED)) {
+ /* If user defined is not already specified, set it first */
+ ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
+ ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
+ }
ga->lpFanSpeedValue.iFanSpeed = iFanSpeed;
if (ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) == ADL_OK)
ret = 0;