Set up overclocking calls on NVidia

These require the coolbits plugin to be activated on nvidia-xsettings
This commit is contained in:
Marc Di Luzio 2019-02-03 19:20:16 +00:00
parent bd5baccc67
commit f5e7fa3222
3 changed files with 32 additions and 7 deletions

View File

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

View File

@ -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;
}

View File

@ -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',
]