diff --git a/src/ext_xnvctrl.c b/src/ext_xnvctrl.c index 582b86ff6..78ffab64e 100644 --- a/src/ext_xnvctrl.c +++ b/src/ext_xnvctrl.c @@ -114,14 +114,18 @@ int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val) { if (xnvctrl->dpy == NULL) return -1; - xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); - int cur; int rc = get_fan_control (xnvctrl, gpu, &cur); if (rc == -1) return -1; + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); + + rc = get_fan_control (xnvctrl, gpu, &cur); + + if (rc == -1) return -1; + if (cur != val) return -1; return 0; @@ -140,6 +144,8 @@ int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val) int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val) { + if (xnvctrl->dpy == NULL) return -1; + int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val); if (!rc) return -1; @@ -162,14 +168,18 @@ int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val) { if (xnvctrl->dpy == NULL) return -1; - xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); - int cur; int rc = get_fan_speed_target (xnvctrl, gpu, &cur); if (rc == -1) return -1; + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); + + rc = get_fan_speed_target (xnvctrl, gpu, &cur); + + if (rc == -1) return -1; + if (cur != val) return -1; return 0;