public bool SetFanSpeed(int gpuIndex, int value, bool isAutoMode) { try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(false); } AdlStatus r; if (isAutoMode) { r = AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set(context, adapterIndex, 0); if (r != AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}"); r = AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset(context, adapterIndex); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset)} {r.ToString()}"); } } return(true); } ADLFanSpeedValue info = new ADLFanSpeedValue { SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT }; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}"); return(false); } info.FanSpeed = value; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set)} {r.ToString()}"); return(false); } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }
public bool SetFanSpeed(int gpuIndex, int value, bool isAutoMode) { try { if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu)) { return(false); } if (gpu.OverdriveVersion < 8) { AdlStatus r; if (isAutoMode) { try { r = AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set(_context, gpu.AdapterIndex, 0); if (r != AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}"); } } catch (Exception e) { r = AdlStatus.ADL_ERR; Logger.ErrorDebugLine(e); } if (r != AdlStatus.ADL_OK) { try { r = AdlNativeMethods.ADL_Overdrive5_FanSpeedToDefault_Set(gpu.AdapterIndex, 0); if (r != AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}"); } } catch (Exception e) { Logger.ErrorDebugLine(e); } } if (r != AdlStatus.ADL_OK) { try { r = AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset(_context, gpu.AdapterIndex); if (r != AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset)} {r.ToString()}"); } } catch (Exception e) { Logger.ErrorDebugLine(e); } } return(true); } ADLFanSpeedValue info = new ADLFanSpeedValue { SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT, Flags = AdlConst.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED }; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(gpu.AdapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}"); return(false); } info.FanSpeed = value; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set(gpu.AdapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set)} {r.ToString()}"); return(false); } } else { if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting)) { SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_FAN_MIN_SPEED, isAutoMode, value); SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_FAN_ACOUSTIC_LIMIT, isAutoMode, value); } } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }