diff --git a/README.md b/README.md index d90260c..cee41fc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ ### Changelog: +- **v0.7** - [NvApiOc v0.7](https://github.com/Demion/nvapioc/releases/download/v0.7/NvApiOc_v0.7.zip) + * Add NVIDIA NvAPI switch option. + * Add AMD ATI ADL switch option. + * Add log file switch option. - **v0.6** - [NvApiOc v0.6](https://github.com/Demion/nvapioc/releases/download/v0.6/NvApiOc_v0.6.zip) * Add curve (voltage:frequency) option. - **v0.5** - [NvApiOc v0.5](https://github.com/Demion/nvapioc/releases/download/v0.5/NvApiOc_v0.5.zip) @@ -35,6 +39,9 @@ NvApiOc Open Source NVIDIA NvAPI & AMD ATI ADL Overdrive GPU Overclock - **-led** gpuBusId type brightness *(type: 0 = logo; 1 = sliBridge)* - **-curve** gpuBusId count voltageUV frequencyKHz vUV2 fKHz2 vUV3 fKHz3
*(count: 0 = reset; -1 = save; frequencyKHz: 0 = default; NVIDIA offset)* +- **-nvidia** enable *(enable: 0 = false; 1 = true = default)* +- **-amd** enable *(enable: 0 = false; 1 = true = default)* +- **-log** enable *(enable: 0 = false; 1 = true = default)* - **-restart** ### Donation: diff --git a/Source/main.cpp b/Source/main.cpp index fc83401..56b6ec8 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -300,6 +300,9 @@ enum class PStateLimitType All = 3 }; +bool NvApi = true, Adl = true; +bool LogFileEnable = true; + void *NvApiGpuHandles[128] = {0}; unsigned int AdlGpuIndexes[128] = {0}; @@ -1285,16 +1288,72 @@ void PrintUsage() "-led gpuBusId type brightness (type: 0 = logo; 1 = sliBridge)\n" "-curve gpuBusId count voltageUV frequencyKHz vUV2 fKHz2 vUV3 fKHz3\n" "(count: 0 = reset; -1 = save; frequencyKHz: 0 = default; NVIDIA offset)\n" + "-nvidia enable (enable: 0 = false; 1 = true = default)\n" + "-amd enable (enable: 0 = false; 1 = true = default)\n" + "-log enable (enable: 0 = false; 1 = true = default)\n" "-restart\n"); } +void ParseInitArgs(int argc, char *argv[]) +{ + int arg = 1; + + while (arg < argc) + { + if (strcmp(strupr(argv[arg]), "-NVIDIA") == 0) + { + if (arg + 1 < argc) + { + NvApi = (atoi(argv[++arg]) != 0); + } + } + else if (strcmp(strupr(argv[arg]), "-AMD") == 0) + { + if (arg + 1 < argc) + { + Adl = (atoi(argv[++arg]) != 0); + } + } + else if (strcmp(strupr(argv[arg]), "-LOG") == 0) + { + if (arg + 1 < argc) + { + LogFileEnable = (atoi(argv[++arg]) != 0); + } + } + + ++arg; + } +} + void ParseArgs(int argc, char *argv[]) { int arg = 1; while (arg < argc) { - if (strcmp(strupr(argv[arg]), "-CORE") == 0) + if (strcmp(strupr(argv[arg]), "-NVIDIA") == 0) + { + if (arg + 1 < argc) + { + NvApi = (atoi(argv[++arg]) != 0); + } + } + else if (strcmp(strupr(argv[arg]), "-AMD") == 0) + { + if (arg + 1 < argc) + { + Adl = (atoi(argv[++arg]) != 0); + } + } + else if (strcmp(strupr(argv[arg]), "-LOG") == 0) + { + if (arg + 1 < argc) + { + LogFileEnable = (atoi(argv[++arg]) != 0); + } + } + else if (strcmp(strupr(argv[arg]), "-CORE") == 0) { if (arg + 3 < argc) { @@ -1476,49 +1535,60 @@ void ParseArgs(int argc, char *argv[]) int main(int argc, char *argv[]) { - LogFile = fopen("log.txt", "a"); - if (argc > 1) { - bool nvapi = false, adl = false; + ParseInitArgs(argc, argv); + + if (LogFileEnable) + LogFile = fopen("log.txt", "a"); - if (NvApiLoad() == 0) + if (NvApi) { - if (NvApiInit() == 0) + NvApi = false; + + if (NvApiLoad() == 0) { - nvapi = true; + if (NvApiInit() == 0) + { + NvApiEnumGpus(); + NvApiEnumTccGpus(); - NvApiEnumGpus(); - NvApiEnumTccGpus(); + NvApi = true; + } } } - if (AdlLoad() == 0) + if (Adl) { - if (AdlInit() == 0) + Adl = false; + + if (AdlLoad() == 0) { - adl = true; + if (AdlInit() == 0) + { + AdlEnumGpus(); - AdlEnumGpus(); + Adl = true; + } } } - if ((nvapi) || (adl)) + if ((NvApi) || (Adl)) ParseArgs(argc, argv); - if (nvapi) + if (NvApi) NvApiFree(); - if (adl) + if (Adl) AdlFree(); + + if (LogFile) + fclose(LogFile); } else { PrintUsage(); } - if (LogFile) - fclose(LogFile); - return EXIT_SUCCESS; } \ No newline at end of file