Пример #1
0
 private static bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = NvCoolerSettings.Create();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Пример #2
0
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Пример #3
0
        private bool SetCooler(int busId, uint value, bool isAutoMode)
        {
            #region GTX
            if (NvapiNativeMethods.NvSetCoolerLevels != null)
            {
                try {
                    NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
                    NvCoolerLevel  info        = new NvCoolerLevel()
                    {
                        version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerLevel)))),
                        coolers = new NvCoolerLevelItem[NvapiConst.NVAPI_MAX_COOLERS_PER_GPU]
                    };
                    info.coolers[0].currentLevel  = isAutoMode ? 0 : value;
                    info.coolers[0].currentPolicy = isAutoMode ? NvCoolerPolicy.NVAPI_COOLER_POLICY_AUTO : NvCoolerPolicy.NVAPI_COOLER_POLICY_MANUAL;
                    var r = NvapiNativeMethods.NvSetCoolerLevels(HandlesByBusId[busId], coolerIndex, ref info);
                    if (r != NvStatus.OK)
                    {
                        Write.DevError($"{nameof(NvapiNativeMethods.NvSetCoolerLevels)} {r}");
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch {
                }
            }
            #endregion

            #region RTX
            if (NvapiNativeMethods.NvFanCoolersSetControl == null)
            {
                return(false);
            }
            try {
                if (NvFanCoolersGetControl(busId, out PrivateFanCoolersControlV1 info))
                {
                    for (int i = 0; i < info.FanCoolersControlCount; i++)
                    {
                        info.FanCoolersControlEntries[i].ControlMode = isAutoMode ? FanCoolersControlMode.Auto : FanCoolersControlMode.Manual;
                        info.FanCoolersControlEntries[i].Level       = isAutoMode ? 0u : (uint)value;
                    }
                    var r = NvapiNativeMethods.NvFanCoolersSetControl(HandlesByBusId[busId], ref info);
                    if (r != NvStatus.OK)
                    {
                        Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersSetControl)} {r}");
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
            #endregion
        }
Пример #4
0
        private bool SetCooler(int busId, uint value, bool isAutoMode)
        {
            if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
            {
                return(false);
            }
            #region GTX
            if (NvapiNativeMethods.NvSetCoolerLevels != null)
            {
                try {
                    NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
                    NvCoolerLevel  info        = NvCoolerLevel.Create();
                    info.coolers[0].currentLevel  = isAutoMode ? 0 : value;
                    info.coolers[0].currentPolicy = isAutoMode ? NvCoolerPolicy.NVAPI_COOLER_POLICY_AUTO : NvCoolerPolicy.NVAPI_COOLER_POLICY_MANUAL;
                    var r = NvapiNativeMethods.NvSetCoolerLevels(handle, coolerIndex, ref info);
                    if (r != NvStatus.NVAPI_OK)
                    {
                        NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetCoolerLevels)} {r.ToString()}");
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch {
                }
            }
            #endregion

            #region RTX
            if (NvapiNativeMethods.NvFanCoolersSetControl == null)
            {
                return(false);
            }
            try {
                if (NvFanCoolersGetControl(busId, out PrivateFanCoolersControlV1 info))
                {
                    for (int i = 0; i < info.FanCoolersControlCount; i++)
                    {
                        info.FanCoolersControlEntries[i].ControlMode = isAutoMode ? FanCoolersControlMode.Auto : FanCoolersControlMode.Manual;
                        info.FanCoolersControlEntries[i].Level       = isAutoMode ? 0u : (uint)value;
                    }
                    var r = NvapiNativeMethods.NvFanCoolersSetControl(handle, ref info);
                    if (r != NvStatus.NVAPI_OK)
                    {
                        NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvFanCoolersSetControl)} {r.ToString()}");
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
            #endregion
        }
Пример #5
0
 // 20卡不支持该方法,所以尝试两次返回值不正确不再尝试
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(HandlesByBusId[busId], coolerIndex, ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }