Quellcode durchsuchen

Set up overclocking calls on NVidia

	These require the coolbits plugin to be activated on nvidia-xsettings
Marc Di Luzio vor 6 Jahren
Ursprung
Commit
f5e7fa3222
3 geänderte Dateien mit 32 neuen und 7 gelöschten Zeilen
  1. 0 1
      daemon/external-helper.c
  2. 31 5
      daemon/gpuclockctl.c
  3. 1 1
      daemon/meson.build

+ 0 - 1
daemon/external-helper.c

@@ -31,7 +31,6 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #define _GNU_SOURCE
 
-#include "config.h"
 #include "logging.h"
 
 #include <linux/limits.h>

+ 31 - 5
daemon/gpuclockctl.c

@@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #include "logging.h"
 
+#include "external-helper.h"
 #include "gpu-control.h"
 
 // TODO
@@ -66,14 +67,39 @@ int get_gpu_state(struct GameModeGPUInfo *info)
  */
 int set_gpu_state_nv(struct GameModeGPUInfo *info)
 {
-	if(info->vendor != Vendor_NVIDIA )
+	if (info->vendor != Vendor_NVIDIA)
 		return -1;
 
-	// Running these commands:
-	// nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=1400'
-	// nvidia-settings -a '[gpu:0]/GPUGraphicsClockOffset[3]=50'
+	// These commands don't technically even need root
+
+	/* Set the GPUGraphicsClockOffset parameter */
+	char core_arg[64];
+	snprintf(core_arg,
+	         64,
+	         "[gpu:%ld]/GPUGraphicsClockOffset[%ld]=%ld",
+	         info->device,
+	         info->nv_perf_level,
+	         info->core);
+	const char *exec_args_core[] = { "/usr/bin/nvidia-settings", "-a", core_arg, NULL };
+	if (run_external_process(exec_args_core) != 0) {
+		LOG_ERROR("ERROR: Failed to set %s!\n", core_arg);
+		return -1;
+	}
+
+	/* Set the GPUMemoryTransferRateOffset parameter */
+	char mem_arg[64];
+	snprintf(mem_arg,
+	         64,
+	         "[gpu:%ld]/GPUMemoryTransferRateOffset[%ld]=%ld",
+	         info->device,
+	         info->nv_perf_level,
+	         info->mem);
+	const char *exec_args_mem[] = { "/usr/bin/nvidia-settings", "-a", mem_arg, NULL };
+	if (run_external_process(exec_args_mem) != 0) {
+		LOG_ERROR("ERROR: Failed to set %s!\n", mem_arg);
+		return -1;
+	}
 
-	fprintf(stderr, "Setting GPU parameters on NVIDIA is currently unimplemented!\n");
 	return 0;
 }
 

+ 1 - 1
daemon/meson.build

@@ -2,6 +2,7 @@
 common_sources = [
     'logging.c',
     'governors-query.c',
+    'external-helper.c',
 ]
 
 daemon_common = static_library(
@@ -27,7 +28,6 @@ daemon_sources = [
     'gamemode-gpu.c',
     'daemonize.c',
     'dbus_messaging.c',
-    'external-helper.c',
     'daemon_config.c',
 ]