Hook up individual set state functions

This commit is contained in:
Marc Di Luzio 2019-02-03 18:47:18 +00:00
parent 53428356a5
commit bd5baccc67

View File

@ -42,17 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
// Intel? // Intel?
// Gather GPU type and information automatically if possible // Gather GPU type and information automatically if possible
// NVIDIA
// Running these commands:
// nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=1400'
// nvidia-settings -a '[gpu:0]/GPUGraphicsClockOffset[3]=50'
// AMD
// We'll want to set both the following:
// core: device/pp_sclk_od (0%+ additional)
// mem: device/pp_mclk_od (0%+ additional)
// Guide from https://www.maketecheasier.com/overclock-amd-gpu-linux/
/* Helper to quit with usage */ /* Helper to quit with usage */
static const char *usage_text = static const char *usage_text =
"usage: gpuclockctl PCI_ID DEVICE [get] [set CORE MEM [PERF_LEVEL]]]"; "usage: gpuclockctl PCI_ID DEVICE [get] [set CORE MEM [PERF_LEVEL]]]";
@ -69,26 +58,39 @@ static void print_usage_and_exit(void)
int get_gpu_state(struct GameModeGPUInfo *info) int get_gpu_state(struct GameModeGPUInfo *info)
{ {
fprintf(stderr, "Fetching GPU state is currently unimplemented!\n"); fprintf(stderr, "Fetching GPU state is currently unimplemented!\n");
return -1; return info != NULL;
} }
/** /**
* Set the gpu state based on input parameters * Set the gpu state based on input parameters on Nvidia
* Only works when run as root
*/ */
int set_gpu_state(struct GameModeGPUInfo *info) int set_gpu_state_nv(struct GameModeGPUInfo *info)
{ {
if (!info) if(info->vendor != Vendor_NVIDIA )
return -1; return -1;
switch (info->vendor) { // Running these commands:
case Vendor_NVIDIA: // nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=1400'
break; // nvidia-settings -a '[gpu:0]/GPUGraphicsClockOffset[3]=50'
case Vendor_Intel:
break; fprintf(stderr, "Setting GPU parameters on NVIDIA is currently unimplemented!\n");
default: return 0;
break; }
}
/**
* Set the gpu state based on input parameters on amd
*/
int set_gpu_state_amd(struct GameModeGPUInfo *info)
{
if(info->vendor != Vendor_AMD)
return -1;
// We'll want to set both the following:
// core: device/pp_sclk_od (0%+ additional)
// mem: device/pp_mclk_od (0%+ additional)
// Guide from https://www.maketecheasier.com/overclock-amd-gpu-linux/
fprintf(stderr, "Setting GPU parameters on AMD is currently unimplemented!\n");
return 0; return 0;
} }
@ -171,7 +173,15 @@ int main(int argc, char *argv[])
if (info.vendor == Vendor_NVIDIA) if (info.vendor == Vendor_NVIDIA)
printf("on Performance Level %ld\n", info.nv_perf_level); printf("on Performance Level %ld\n", info.nv_perf_level);
return set_gpu_state(&info); switch (info.vendor) {
case Vendor_NVIDIA:
return set_gpu_state_nv(&info);
case Vendor_AMD:
return set_gpu_state_amd(&info);
default:
printf("Currently unsupported GPU vendor 0x%04x, doing nothing!\n", (short)info.vendor);
break;
}
} else { } else {
print_usage_and_exit(); print_usage_and_exit();
} }