hoc-sys: add multiple new options
This commit is contained in:
@@ -36,3 +36,5 @@ typedef struct
|
|||||||
} SysClkTitleProfileList;
|
} SysClkTitleProfileList;
|
||||||
|
|
||||||
#define SYSCLK_FREQ_LIST_MAX 32
|
#define SYSCLK_FREQ_LIST_MAX 32
|
||||||
|
#define SYSCLK_GPU_BOOST_HZ 76800000
|
||||||
|
#define SYSCLK_CPU_BOOST_HZ 1785000000
|
||||||
@@ -15,15 +15,23 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SysClkConfigValue_PollingIntervalMs = 0,
|
SysClkConfigValue_PollingIntervalMs = 0,
|
||||||
SysClkConfigValue_TempLogIntervalMs = 1,
|
SysClkConfigValue_TempLogIntervalMs,
|
||||||
SysClkConfigValue_FreqLogIntervalMs = 2,
|
SysClkConfigValue_FreqLogIntervalMs,
|
||||||
SysClkConfigValue_PowerLogIntervalMs = 3,
|
SysClkConfigValue_PowerLogIntervalMs,
|
||||||
SysClkConfigValue_CsvWriteIntervalMs = 4,
|
SysClkConfigValue_CsvWriteIntervalMs,
|
||||||
HocClkConfigValue_UncappedClocks = 5,
|
HocClkConfigValue_UncappedClocks,
|
||||||
HocClkConfigValue_OverwriteBoostMode = 6,
|
HocClkConfigValue_OverwriteBoostMode,
|
||||||
HocClkConfigValue_MaxCpuClock = 7,
|
HocClkConfigValue_EristaMaxCpuClock,
|
||||||
HocClkConfigValue_MaxGpuClock = 8,
|
HocClkConfigValue_EristaMaxGpuClock,
|
||||||
SysClkConfigValue_EnumMax = 9,
|
HocClkConfigValue_EristaMaxMemClock,
|
||||||
|
HocClkConfigValue_MarikoMaxCpuClock,
|
||||||
|
HocClkConfigValue_MarikoMaxGpuClock,
|
||||||
|
HocClkConfigValue_MarikoMaxMemClock,
|
||||||
|
HocClkConfigValue_ThermalThrottle,
|
||||||
|
HocClkConfigValue_ThermalThrottleThreshold,
|
||||||
|
HocClkConfigValue_HandheldGovernor,
|
||||||
|
HocClkConfigValue_DockedGovernor,
|
||||||
|
SysClkConfigValue_EnumMax,
|
||||||
} SysClkConfigValue;
|
} SysClkConfigValue;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -48,10 +56,32 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
|
|||||||
return pretty ? "Uncapped Clocks" : "uncapped_clocks";
|
return pretty ? "Uncapped Clocks" : "uncapped_clocks";
|
||||||
case HocClkConfigValue_OverwriteBoostMode:
|
case HocClkConfigValue_OverwriteBoostMode:
|
||||||
return pretty ? "Overwrite Boost Mode" : "ow_boost";
|
return pretty ? "Overwrite Boost Mode" : "ow_boost";
|
||||||
case HocClkConfigValue_MaxCpuClock:
|
|
||||||
return pretty ? "Max CPU Clock" : "cpu_max";
|
case HocClkConfigValue_EristaMaxCpuClock:
|
||||||
case HocClkConfigValue_MaxGpuClock:
|
return pretty ? "Max CPU Clock" : "cpu_max_e";
|
||||||
return pretty ? "Max GPU Clock" : "gpu_max";
|
case HocClkConfigValue_EristaMaxGpuClock:
|
||||||
|
return pretty ? "Max GPU Clock" : "gpu_max_e";
|
||||||
|
case HocClkConfigValue_EristaMaxMemClock:
|
||||||
|
return pretty ? "Max MEM Clock" : "mem_max_e";
|
||||||
|
|
||||||
|
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||||
|
return pretty ? "Max CPU Clock" : "cpu_max_m";
|
||||||
|
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||||
|
return pretty ? "Max GPU Clock" : "gpu_max_m";
|
||||||
|
case HocClkConfigValue_MarikoMaxMemClock:
|
||||||
|
return pretty ? "Max MEM Clock" : "mem_max_m";
|
||||||
|
|
||||||
|
case HocClkConfigValue_ThermalThrottle:
|
||||||
|
return pretty ? "Thermal Throttle" : "thermal_throttle";
|
||||||
|
|
||||||
|
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||||
|
return pretty ? "Thermal Throttle Threshold" : "thermal_throttle_threshold";
|
||||||
|
|
||||||
|
case HocClkConfigValue_DockedGovernor:
|
||||||
|
return pretty ? "Docked Governor" : "governor_docked";
|
||||||
|
case HocClkConfigValue_HandheldGovernor:
|
||||||
|
return pretty ? "Handheld Governor" : "governor_handheld";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return pretty ? "Null" : "null";
|
return pretty ? "Null" : "null";
|
||||||
}
|
}
|
||||||
@@ -70,10 +100,26 @@ static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
|
|||||||
case HocClkConfigValue_UncappedClocks:
|
case HocClkConfigValue_UncappedClocks:
|
||||||
case HocClkConfigValue_OverwriteBoostMode:
|
case HocClkConfigValue_OverwriteBoostMode:
|
||||||
return 0ULL;
|
return 0ULL;
|
||||||
case HocClkConfigValue_MaxCpuClock:
|
case HocClkConfigValue_EristaMaxCpuClock:
|
||||||
return 1785ULL;
|
return 1785ULL;
|
||||||
case HocClkConfigValue_MaxGpuClock:
|
case HocClkConfigValue_EristaMaxGpuClock:
|
||||||
return 921ULL;
|
return 921ULL;
|
||||||
|
case HocClkConfigValue_EristaMaxMemClock:
|
||||||
|
return 1600ULL;
|
||||||
|
|
||||||
|
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||||
|
return 1963ULL;
|
||||||
|
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||||
|
return 1075ULL;
|
||||||
|
case HocClkConfigValue_MarikoMaxMemClock:
|
||||||
|
return 1862ULL;
|
||||||
|
|
||||||
|
case HocClkConfigValue_ThermalThrottle:
|
||||||
|
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||||
|
case HocClkConfigValue_DockedGovernor:
|
||||||
|
case HocClkConfigValue_HandheldGovernor:
|
||||||
|
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||||
|
return 1ULL;
|
||||||
default:
|
default:
|
||||||
return 0ULL;
|
return 0ULL;
|
||||||
}
|
}
|
||||||
@@ -83,6 +129,13 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
|||||||
{
|
{
|
||||||
switch(val)
|
switch(val)
|
||||||
{
|
{
|
||||||
|
case HocClkConfigValue_EristaMaxCpuClock:
|
||||||
|
case HocClkConfigValue_EristaMaxGpuClock:
|
||||||
|
case HocClkConfigValue_EristaMaxMemClock:
|
||||||
|
case HocClkConfigValue_MarikoMaxCpuClock:
|
||||||
|
case HocClkConfigValue_MarikoMaxGpuClock:
|
||||||
|
case HocClkConfigValue_MarikoMaxMemClock:
|
||||||
|
case HocClkConfigValue_ThermalThrottleThreshold:
|
||||||
case SysClkConfigValue_PollingIntervalMs:
|
case SysClkConfigValue_PollingIntervalMs:
|
||||||
return input > 0;
|
return input > 0;
|
||||||
case SysClkConfigValue_TempLogIntervalMs:
|
case SysClkConfigValue_TempLogIntervalMs:
|
||||||
@@ -92,10 +145,10 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
|
|||||||
return input >= 0;
|
return input >= 0;
|
||||||
case HocClkConfigValue_UncappedClocks:
|
case HocClkConfigValue_UncappedClocks:
|
||||||
case HocClkConfigValue_OverwriteBoostMode:
|
case HocClkConfigValue_OverwriteBoostMode:
|
||||||
|
case HocClkConfigValue_ThermalThrottle:
|
||||||
|
case HocClkConfigValue_DockedGovernor:
|
||||||
|
case HocClkConfigValue_HandheldGovernor:
|
||||||
return (input & 0x1) == input;
|
return (input & 0x1) == input;
|
||||||
case HocClkConfigValue_MaxCpuClock:
|
|
||||||
case HocClkConfigValue_MaxGpuClock:
|
|
||||||
return input > 0;
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,15 +79,28 @@ FreqChoiceGui::~FreqChoiceGui()
|
|||||||
hz = this->hzList[i];
|
hz = this->hzList[i];
|
||||||
uint32_t mhz = hz / 1000000;
|
uint32_t mhz = hz / 1000000;
|
||||||
// Skip 204 MHz exactly
|
// Skip 204 MHz exactly
|
||||||
if(checkMax) {
|
if(checkMax && IsMariko()) {
|
||||||
if (this->configList->values[HocClkConfigValue_MaxCpuClock] < mhz && moduleName == "cpu") {
|
if (this->configList->values[HocClkConfigValue_MarikoMaxCpuClock] < mhz && moduleName == "cpu") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->configList->values[HocClkConfigValue_MaxGpuClock] < mhz&& moduleName == "gpu") {
|
if (this->configList->values[HocClkConfigValue_MarikoMaxGpuClock] < mhz && moduleName == "gpu") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (this->configList->values[HocClkConfigValue_MarikoMaxMemClock] < mhz && moduleName == "mem") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (checkMax && IsErista()) {
|
||||||
|
if (this->configList->values[HocClkConfigValue_EristaMaxCpuClock] < mhz && moduleName == "cpu") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->configList->values[HocClkConfigValue_EristaMaxGpuClock] < mhz && moduleName == "gpu") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (this->configList->values[HocClkConfigValue_EristaMaxMemClock] < mhz && moduleName == "mem") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (moduleName == "mem" && mhz <= 600)
|
if (moduleName == "mem" && mhz <= 600)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,12 +102,28 @@ void MiscGui::updateConfigToggles() {
|
|||||||
|
|
||||||
void MiscGui::listUI()
|
void MiscGui::listUI()
|
||||||
{
|
{
|
||||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Config"));
|
this->listElement->addItem(new tsl::elm::CategoryHeader("Settings"));
|
||||||
addConfigToggle(HocClkConfigValue_UncappedClocks, nullptr);
|
addConfigToggle(HocClkConfigValue_UncappedClocks, nullptr);
|
||||||
addConfigToggle(HocClkConfigValue_OverwriteBoostMode, nullptr);
|
addConfigToggle(HocClkConfigValue_OverwriteBoostMode, nullptr);
|
||||||
|
|
||||||
addConfigButton(HocClkConfigValue_MaxCpuClock, nullptr, SysClkModule_CPU);
|
this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental"));
|
||||||
addConfigButton(HocClkConfigValue_MaxGpuClock, nullptr, SysClkModule_GPU);
|
addConfigToggle(HocClkConfigValue_ThermalThrottle, nullptr);
|
||||||
|
addConfigToggle(HocClkConfigValue_DockedGovernor, nullptr);
|
||||||
|
addConfigToggle(HocClkConfigValue_HandheldGovernor, nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
this->listElement->addItem(new tsl::elm::CategoryHeader("Max Clocks"));
|
||||||
|
if(IsMariko()) {
|
||||||
|
addConfigButton(HocClkConfigValue_MarikoMaxCpuClock, nullptr, SysClkModule_CPU);
|
||||||
|
addConfigButton(HocClkConfigValue_MarikoMaxGpuClock, nullptr, SysClkModule_GPU);
|
||||||
|
addConfigButton(HocClkConfigValue_MarikoMaxMemClock, nullptr, SysClkModule_MEM);
|
||||||
|
} else {
|
||||||
|
addConfigButton(HocClkConfigValue_EristaMaxCpuClock, nullptr, SysClkModule_CPU);
|
||||||
|
addConfigButton(HocClkConfigValue_EristaMaxGpuClock, nullptr, SysClkModule_GPU);
|
||||||
|
addConfigButton(HocClkConfigValue_EristaMaxMemClock, nullptr, SysClkModule_MEM);
|
||||||
|
}
|
||||||
|
// this->listElement->addItem(new tsl::elm::CategoryHeader("Voltages"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiscGui::refresh() {
|
void MiscGui::refresh() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"title_id_range_min": "0x00FF0000636C6BFF",
|
"title_id_range_min": "0x00FF0000636C6BFF",
|
||||||
"title_id_range_max": "0x00FF0000636C6BFF",
|
"title_id_range_max": "0x00FF0000636C6BFF",
|
||||||
"main_thread_stack_size": "0x00008000",
|
"main_thread_stack_size": "0x00008000",
|
||||||
"main_thread_priority": 49,
|
"main_thread_priority": 63,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 0,
|
"process_category": 0,
|
||||||
"is_retail": true,
|
"is_retail": true,
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"type": "kernel_flags",
|
"type": "kernel_flags",
|
||||||
"value": {
|
"value": {
|
||||||
"highest_thread_priority": 63,
|
"highest_thread_priority": 63,
|
||||||
"lowest_thread_priority": 24,
|
"lowest_thread_priority": 63,
|
||||||
"lowest_cpu_id": 3,
|
"lowest_cpu_id": 0,
|
||||||
"highest_cpu_id": 3
|
"highest_cpu_id": 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "ipc_service.h"
|
#include "ipc_service.h"
|
||||||
|
|
||||||
|
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7,0,0))
|
||||||
|
|
||||||
ClockManager *ClockManager::instance = NULL;
|
ClockManager *ClockManager::instance = NULL;
|
||||||
|
|
||||||
ClockManager *ClockManager::GetInstance()
|
ClockManager *ClockManager::GetInstance()
|
||||||
@@ -207,11 +209,20 @@ void ClockManager::Tick()
|
|||||||
std::uint32_t targetHz = 0;
|
std::uint32_t targetHz = 0;
|
||||||
std::uint32_t maxHz = 0;
|
std::uint32_t maxHz = 0;
|
||||||
std::uint32_t nearestHz = 0;
|
std::uint32_t nearestHz = 0;
|
||||||
|
std::uint32_t mode = 0;
|
||||||
|
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
||||||
|
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
|
||||||
|
|
||||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++)
|
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++)
|
||||||
{
|
{
|
||||||
targetHz = this->context->overrideFreqs[module];
|
targetHz = this->context->overrideFreqs[module];
|
||||||
// if (!this->config->GetConfigValue(HocClkConfigValue_DockedGovernor) || !this->config->GetConfigValue(HocClkConfigValue_HandheldGovernor))
|
// if (!this->config->GetConfigValue(HocClkConfigValue_DockedGovernor) || !this->config->GetConfigValue(HocClkConfigValue_HandheldGovernor))
|
||||||
// {
|
// {
|
||||||
|
if((apmExtIsBoostMode(mode) && !this->config->GetConfigValue(HocClkConfigValue_OverwriteBoostMode)) || ((tmp451TempSoc() / 1000) > (int)this->config->GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold) && this->config->GetConfigValue(HocClkConfigValue_ThermalThrottle)) ) { // WHY?!?!??!?!?
|
||||||
|
Board::ResetToStockCpu();
|
||||||
|
Board::ResetToStockGpu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!targetHz)
|
if (!targetHz)
|
||||||
{
|
{
|
||||||
targetHz = this->config->GetAutoClockHz(this->context->applicationId, (SysClkModule)module, this->context->profile);
|
targetHz = this->config->GetAutoClockHz(this->context->applicationId, (SysClkModule)module, this->context->profile);
|
||||||
@@ -221,9 +232,7 @@ void ClockManager::Tick()
|
|||||||
{
|
{
|
||||||
maxHz = this->GetMaxAllowedHz((SysClkModule)module, this->context->profile);
|
maxHz = this->GetMaxAllowedHz((SysClkModule)module, this->context->profile);
|
||||||
nearestHz = this->GetNearestHz((SysClkModule)module, targetHz, maxHz);
|
nearestHz = this->GetNearestHz((SysClkModule)module, targetHz, maxHz);
|
||||||
|
if (nearestHz != this->context->freqs[module] && this->context->enabled) {
|
||||||
if (nearestHz != this->context->freqs[module] && this->context->enabled/* && !apmExtIsBoostMode(this->context->perfConfId) && !this->config->GetConfigValue(HocClkConfigValue_OverwriteBoostMode)*/)
|
|
||||||
{
|
|
||||||
FileUtils::LogLine(
|
FileUtils::LogLine(
|
||||||
"[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)",
|
"[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)",
|
||||||
Board::GetModuleName((SysClkModule)module, true),
|
Board::GetModuleName((SysClkModule)module, true),
|
||||||
@@ -232,12 +241,10 @@ void ClockManager::Tick()
|
|||||||
|
|
||||||
Board::SetHz((SysClkModule)module, nearestHz);
|
Board::SetHz((SysClkModule)module, nearestHz);
|
||||||
this->context->freqs[module] = nearestHz;
|
this->context->freqs[module] = nearestHz;
|
||||||
}
|
} else {
|
||||||
// else
|
Board::ResetToStockCpu();
|
||||||
// {
|
Board::ResetToStockGpu();
|
||||||
// Board::ResetToStockCpu();
|
}
|
||||||
// Board::ResetToStockGpu();
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// #define GOVERNOR_LOAD_THRESHOLD 80
|
// #define GOVERNOR_LOAD_THRESHOLD 80
|
||||||
|
|||||||
@@ -180,24 +180,17 @@ bool Config::SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bo
|
|||||||
std::scoped_lock lock{this->configMutex};
|
std::scoped_lock lock{this->configMutex};
|
||||||
uint8_t numProfiles = 0;
|
uint8_t numProfiles = 0;
|
||||||
|
|
||||||
// String pointer array passed to ini
|
|
||||||
char* iniKeys[SysClkProfile_EnumMax * SysClkModule_EnumMax + 1];
|
|
||||||
char* iniValues[SysClkProfile_EnumMax * SysClkModule_EnumMax + 1];
|
|
||||||
|
|
||||||
// Char arrays to build strings
|
|
||||||
char keysStr[SysClkProfile_EnumMax * SysClkModule_EnumMax * 0x40];
|
|
||||||
char valuesStr[SysClkProfile_EnumMax * SysClkModule_EnumMax * 0x10];
|
|
||||||
char section[17] = {0};
|
char section[17] = {0};
|
||||||
|
|
||||||
// Iteration pointers
|
|
||||||
char** ik = &iniKeys[0];
|
|
||||||
char** iv = &iniValues[0];
|
|
||||||
char* sk = &keysStr[0];
|
|
||||||
char* sv = &valuesStr[0];
|
|
||||||
std::uint32_t* mhz = &profiles->mhz[0];
|
|
||||||
|
|
||||||
snprintf(section, sizeof(section), "%016lX", tid);
|
snprintf(section, sizeof(section), "%016lX", tid);
|
||||||
|
|
||||||
|
// Use dynamic allocation
|
||||||
|
std::vector<std::string> keys;
|
||||||
|
std::vector<std::string> values;
|
||||||
|
keys.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||||
|
values.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||||
|
|
||||||
|
std::uint32_t* mhz = &profiles->mhz[0];
|
||||||
|
|
||||||
for(unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++)
|
for(unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++)
|
||||||
{
|
{
|
||||||
for(unsigned int module = 0; module < SysClkModule_EnumMax; module++)
|
for(unsigned int module = 0; module < SysClkModule_EnumMax; module++)
|
||||||
@@ -206,34 +199,38 @@ bool Config::SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bo
|
|||||||
{
|
{
|
||||||
numProfiles++;
|
numProfiles++;
|
||||||
|
|
||||||
// Put key and value as string
|
// Build key and value strings
|
||||||
snprintf(sk, 0x40, "%s_%s", Board::GetProfileName((SysClkProfile)profile, false), Board::GetModuleName((SysClkModule)module, false));
|
std::string key = std::string(Board::GetProfileName((SysClkProfile)profile, false)) +
|
||||||
snprintf(sv, 0x10, "%d", *mhz);
|
"_" +
|
||||||
|
Board::GetModuleName((SysClkModule)module, false);
|
||||||
|
std::string value = std::to_string(*mhz);
|
||||||
|
|
||||||
// Add them to the ini key/value str arrays
|
keys.push_back(key);
|
||||||
*ik = sk;
|
values.push_back(value);
|
||||||
*iv = sv;
|
|
||||||
ik++;
|
|
||||||
iv++;
|
|
||||||
|
|
||||||
// We used those chars, get to the next ones
|
|
||||||
sk += 0x40;
|
|
||||||
sv += 0x10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mhz++;
|
mhz++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ik = NULL;
|
// Build pointer arrays
|
||||||
*iv = NULL;
|
std::vector<const char*> keyPointers;
|
||||||
|
std::vector<const char*> valuePointers;
|
||||||
|
keyPointers.reserve(keys.size() + 1);
|
||||||
|
valuePointers.reserve(values.size() + 1);
|
||||||
|
|
||||||
if(!ini_putsection(section, (const char**)iniKeys, (const char**)iniValues, this->path.c_str()))
|
for(size_t i = 0; i < keys.size(); i++) {
|
||||||
|
keyPointers.push_back(keys[i].c_str());
|
||||||
|
valuePointers.push_back(values[i].c_str());
|
||||||
|
}
|
||||||
|
keyPointers.push_back(NULL);
|
||||||
|
valuePointers.push_back(NULL);
|
||||||
|
|
||||||
|
if(!ini_putsection(section, keyPointers.data(), valuePointers.data(), this->path.c_str()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only actually apply changes in memory after a succesful save
|
// Only actually apply changes in memory after a successful save
|
||||||
if(immediate)
|
if(immediate)
|
||||||
{
|
{
|
||||||
mhz = &profiles->mhz[0];
|
mhz = &profiles->mhz[0];
|
||||||
@@ -414,46 +411,43 @@ bool Config::SetConfigValues(SysClkConfigValueList* configValues, bool immediate
|
|||||||
{
|
{
|
||||||
std::scoped_lock lock{this->configMutex};
|
std::scoped_lock lock{this->configMutex};
|
||||||
|
|
||||||
// String pointer array passed to ini
|
// Use dynamic allocation instead of fixed stack buffers
|
||||||
const char* iniKeys[SysClkConfigValue_EnumMax + 1];
|
std::vector<const char*> iniKeys;
|
||||||
char* iniValues[SysClkConfigValue_EnumMax + 1];
|
std::vector<std::string> iniValues;
|
||||||
|
|
||||||
// char arrays to build strings
|
iniKeys.reserve(SysClkConfigValue_EnumMax + 1);
|
||||||
char valuesStr[SysClkConfigValue_EnumMax * 0x80];
|
iniValues.reserve(SysClkConfigValue_EnumMax);
|
||||||
|
|
||||||
// Iteration pointers
|
|
||||||
char* sv = &valuesStr[0];
|
|
||||||
const char** ik = &iniKeys[0];
|
|
||||||
char** iv = &iniValues[0];
|
|
||||||
|
|
||||||
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
||||||
{
|
{
|
||||||
if(!sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval]) || configValues->values[kval] == sysclkDefaultConfigValue((SysClkConfigValue)kval))
|
if(!sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval]) ||
|
||||||
|
configValues->values[kval] == sysclkDefaultConfigValue((SysClkConfigValue)kval))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put key and value as string
|
// Store as string in vector (automatically managed memory)
|
||||||
// And add them to the ini key/value str arrays
|
iniValues.push_back(std::to_string(configValues->values[kval]));
|
||||||
snprintf(sv, 0x20, "%ld", configValues->values[kval]);
|
iniKeys.push_back(sysclkFormatConfigValue((SysClkConfigValue)kval, false));
|
||||||
*ik = sysclkFormatConfigValue((SysClkConfigValue)kval, false);
|
|
||||||
*iv = sv;
|
|
||||||
|
|
||||||
// We used those chars, get to the next ones
|
|
||||||
sv += 0x20;
|
|
||||||
ik++;
|
|
||||||
iv++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*ik = NULL;
|
// Null terminate
|
||||||
*iv = NULL;
|
iniKeys.push_back(NULL);
|
||||||
|
|
||||||
if(!ini_putsection(CONFIG_VAL_SECTION, (const char**)iniKeys, (const char**)iniValues, this->path.c_str()))
|
// Build pointer array for ini function
|
||||||
|
std::vector<const char*> valuePointers;
|
||||||
|
valuePointers.reserve(iniValues.size() + 1);
|
||||||
|
for(const auto& val : iniValues) {
|
||||||
|
valuePointers.push_back(val.c_str());
|
||||||
|
}
|
||||||
|
valuePointers.push_back(NULL);
|
||||||
|
|
||||||
|
if(!ini_putsection(CONFIG_VAL_SECTION, iniKeys.data(), valuePointers.data(), this->path.c_str()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only actually apply changes in memory after a succesful save
|
// Only actually apply changes in memory after a successful save
|
||||||
if(immediate)
|
if(immediate)
|
||||||
{
|
{
|
||||||
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
||||||
@@ -470,4 +464,4 @@ bool Config::SetConfigValues(SysClkConfigValueList* configValues, bool immediate
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4,15 +4,15 @@
|
|||||||
//Fan curve table
|
//Fan curve table
|
||||||
const TemperaturePoint defaultTable[] =
|
const TemperaturePoint defaultTable[] =
|
||||||
{
|
{
|
||||||
{ .temperature_c = 25.0, .fanLevel_f = 0.10 },
|
{ .temperature_c = 25.0, .fanLevel_f = 0.00 },
|
||||||
{ .temperature_c = 30.0, .fanLevel_f = 0.20 },
|
{ .temperature_c = 30.0, .fanLevel_f = 0.00 },
|
||||||
{ .temperature_c = 35.0, .fanLevel_f = 0.30 },
|
{ .temperature_c = 35.0, .fanLevel_f = 0.00 },
|
||||||
{ .temperature_c = 40.0, .fanLevel_f = 0.40 },
|
{ .temperature_c = 40.0, .fanLevel_f = 0.00 },
|
||||||
{ .temperature_c = 45.0, .fanLevel_f = 0.50 },
|
{ .temperature_c = 45.0, .fanLevel_f = 0.30 },
|
||||||
{ .temperature_c = 50.0, .fanLevel_f = 0.60 },
|
{ .temperature_c = 50.0, .fanLevel_f = 0.50 },
|
||||||
{ .temperature_c = 55.0, .fanLevel_f = 0.70 },
|
{ .temperature_c = 55.0, .fanLevel_f = 0.60 },
|
||||||
{ .temperature_c = 60.0, .fanLevel_f = 0.80 },
|
{ .temperature_c = 60.0, .fanLevel_f = 0.85 },
|
||||||
{ .temperature_c = 65.0, .fanLevel_f = 0.90 },
|
{ .temperature_c = 65.0, .fanLevel_f = 0.95 },
|
||||||
{ .temperature_c = 70.0, .fanLevel_f = 1.00 }
|
{ .temperature_c = 70.0, .fanLevel_f = 1.00 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ void FanControllerThreadFunction(void*)
|
|||||||
float fanLevelSet_f = 0;
|
float fanLevelSet_f = 0;
|
||||||
float temperatureC_f = 0;
|
float temperatureC_f = 0;
|
||||||
u64 awakeSleepTime = 250000000ULL; // 0.25 second when awake (250ms - responsive)
|
u64 awakeSleepTime = 250000000ULL; // 0.25 second when awake (250ms - responsive)
|
||||||
u64 sleepSleepTime = 5000000000ULL; // 5 seconds when in sleep
|
u64 sleepSleepTime = 10000000000ULL; // 10 seconds when in sleep
|
||||||
int sleepCheckCounter = 0;
|
int sleepCheckCounter = 0;
|
||||||
|
|
||||||
Result rs = fanOpenController(&fc, 0x3D000001);
|
Result rs = fanOpenController(&fc, 0x3D000001);
|
||||||
@@ -148,9 +148,9 @@ void FanControllerThreadFunction(void*)
|
|||||||
|
|
||||||
while(!fanControllerThreadExit)
|
while(!fanControllerThreadExit)
|
||||||
{
|
{
|
||||||
// Check if system is awake every 20 iterations (~5 seconds) to reduce overhead
|
// Check if system is awake every 40 iterations (~10 seconds) to reduce overhead
|
||||||
sleepCheckCounter++;
|
sleepCheckCounter++;
|
||||||
if(sleepCheckCounter >= 20)
|
if(sleepCheckCounter >= 40)
|
||||||
{
|
{
|
||||||
bool isAwake = IsSystemAwake();
|
bool isAwake = IsSystemAwake();
|
||||||
sleepCheckCounter = 0;
|
sleepCheckCounter = 0;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ Result IpcService::ServiceHandlerFunc(void* arg, const IpcServerRequest* r, u8*
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SysClkIpcCmd_GetConfigValues:
|
case SysClkIpcCmd_GetConfigValues:
|
||||||
*out_dataSize = sizeof(SysClkTitleProfileList);
|
*out_dataSize = sizeof(SysClkConfigValueList); // bug in stock sys-clk. really stupid bug :skull:
|
||||||
return ipcSrv->GetConfigValues((SysClkConfigValueList*)out_data);
|
return ipcSrv->GetConfigValues((SysClkConfigValueList*)out_data);
|
||||||
|
|
||||||
case SysClkIpcCmd_SetConfigValues:
|
case SysClkIpcCmd_SetConfigValues:
|
||||||
|
|||||||
Reference in New Issue
Block a user