Improved the saving and restoring of default fan control settings for ATI GPUs.
1.1 --- a/GUI/MainForm.cs Thu Jan 20 21:31:54 2011 +0000
1.2 +++ b/GUI/MainForm.cs Thu Jan 20 21:48:26 2011 +0000
1.3 @@ -462,6 +462,7 @@
1.4 sensorContextMenu.MenuItems.Add(item);
1.5 }
1.6 if (node.Sensor.Control != null) {
1.7 + sensorContextMenu.MenuItems.Add(new MenuItem("-"));
1.8 IControl control = node.Sensor.Control;
1.9 MenuItem controlItem = new MenuItem("Control");
1.10 MenuItem defaultItem = new MenuItem("Default");
2.1 --- a/Hardware/ATI/ATIGPU.cs Thu Jan 20 21:31:54 2011 +0000
2.2 +++ b/Hardware/ATI/ATIGPU.cs Thu Jan 20 21:48:26 2011 +0000
2.3 @@ -54,7 +54,8 @@
2.4 private readonly Sensor controlSensor;
2.5 private readonly Control fanControl;
2.6
2.7 - private ADLFanSpeedValue initialFanSpeedValue;
2.8 + private bool restoreDefaultFanSpeedRequired = false;
2.9 + private ADLFanSpeedValue initialFanSpeedValue;
2.10
2.11 public ATIGPU(string name, int adapterIndex, int busNumber,
2.12 int deviceNumber, ISettings settings)
2.13 @@ -64,12 +65,6 @@
2.14 this.busNumber = busNumber;
2.15 this.deviceNumber = deviceNumber;
2.16
2.17 - this.initialFanSpeedValue = new ADLFanSpeedValue();
2.18 - this.initialFanSpeedValue.SpeedType =
2.19 - ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
2.20 - ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0,
2.21 - ref this.initialFanSpeedValue);
2.22 -
2.23 this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
2.24 this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
2.25 this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
2.26 @@ -96,8 +91,28 @@
2.27 Update();
2.28 }
2.29
2.30 + private void SaveDefaultFanSpeed() {
2.31 + if (!restoreDefaultFanSpeedRequired) {
2.32 + initialFanSpeedValue = new ADLFanSpeedValue();
2.33 + initialFanSpeedValue.SpeedType =
2.34 + ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
2.35 + restoreDefaultFanSpeedRequired =
2.36 + ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0,
2.37 + ref initialFanSpeedValue) == ADL.ADL_OK;
2.38 + }
2.39 + }
2.40 +
2.41 + private void RestoreDefaultFanSpeed() {
2.42 + if (restoreDefaultFanSpeedRequired) {
2.43 + ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0,
2.44 + ref this.initialFanSpeedValue);
2.45 + restoreDefaultFanSpeedRequired = false;
2.46 + }
2.47 + }
2.48 +
2.49 private void SoftwareControlValueChanged(IControl control) {
2.50 if (control.ControlMode == ControlMode.Software) {
2.51 + SaveDefaultFanSpeed();
2.52 ADLFanSpeedValue adlf = new ADLFanSpeedValue();
2.53 adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
2.54 adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
2.55 @@ -108,14 +123,9 @@
2.56
2.57 private void ControlModeChanged(IControl control) {
2.58 if (control.ControlMode == ControlMode.Default) {
2.59 - ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0,
2.60 - ref this.initialFanSpeedValue);
2.61 + RestoreDefaultFanSpeed();
2.62 } else {
2.63 - ADLFanSpeedValue adlf = new ADLFanSpeedValue();
2.64 - adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
2.65 - adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
2.66 - adlf.FanSpeed = (int)control.SoftwareValue;
2.67 - ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0, ref adlf);
2.68 + SoftwareControlValueChanged(control);
2.69 }
2.70 }
2.71
2.72 @@ -204,8 +214,7 @@
2.73 this.fanControl.SoftwareControlValueChanged -=
2.74 SoftwareControlValueChanged;
2.75
2.76 - ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0,
2.77 - ref this.initialFanSpeedValue);
2.78 + RestoreDefaultFanSpeed();
2.79 }
2.80 }
2.81 }