sysclk: rename to hocclk
idc about compatability when the programs are structured very differently, work very differently, and send/get data in very different ways
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <nxExt.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
#include <pwm.h>
|
||||
#include <registers.h>
|
||||
@@ -44,9 +44,9 @@
|
||||
#include "../file_utils.hpp"
|
||||
namespace board {
|
||||
|
||||
SysClkSocType gSocType;
|
||||
HocClkSocType gSocType;
|
||||
u8 gDramID;
|
||||
HorizonOCConsoleType gConsoleType = HorizonOCConsoleType_Iowa;
|
||||
HocClkConsoleType gConsoleType = HocClkConsoleType_Iowa;
|
||||
FuseData fuseData;
|
||||
u8 speedoBracket;
|
||||
PwmChannelSession iCon;
|
||||
@@ -71,17 +71,17 @@ namespace board {
|
||||
|
||||
switch(sku) {
|
||||
case 2 ... 5:
|
||||
gSocType = SysClkSocType_Mariko;
|
||||
gSocType = HocClkSocType_Mariko;
|
||||
break;
|
||||
default:
|
||||
gSocType = SysClkSocType_Erista;
|
||||
gSocType = HocClkSocType_Erista;
|
||||
}
|
||||
|
||||
if (gSocType == SysClkSocType_Mariko) {
|
||||
if (gSocType == HocClkSocType_Mariko) {
|
||||
CacheGpuVoltTable();
|
||||
}
|
||||
|
||||
gConsoleType = static_cast<HorizonOCConsoleType>(sku);
|
||||
gConsoleType = static_cast<HocClkConsoleType>(sku);
|
||||
}
|
||||
|
||||
/* TODO: Check for config */
|
||||
@@ -153,7 +153,7 @@ namespace board {
|
||||
rc = svcQueryMemoryMapping(&dsiVirtAddr, &outsize, 0x54300000, 0x40000);
|
||||
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (dsi)");
|
||||
|
||||
display::DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr, .isLite = (GetConsoleType() == HorizonOCConsoleType_Hoag), .isRetroSUPER = integrations::GetRETROSuperStatus()};
|
||||
display::DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr, .isLite = (GetConsoleType() == HocClkConsoleType_Hoag), .isRetroSUPER = integrations::GetRETROSuperStatus()};
|
||||
display::Initialize(&cfg);
|
||||
|
||||
CacheDfllData();
|
||||
@@ -189,11 +189,11 @@ namespace board {
|
||||
nvExit();
|
||||
}
|
||||
|
||||
SysClkSocType GetSocType() {
|
||||
HocClkSocType GetSocType() {
|
||||
return gSocType;
|
||||
}
|
||||
|
||||
HorizonOCConsoleType GetConsoleType() {
|
||||
HocClkConsoleType GetConsoleType() {
|
||||
return gConsoleType;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace board {
|
||||
|
||||
/* TODO: Put this into a different file. */
|
||||
void SetDisplayRefreshDockedState(bool docked) {
|
||||
if (GetConsoleType() != HorizonOCConsoleType_Hoag) {
|
||||
if (GetConsoleType() != HocClkConsoleType_Hoag) {
|
||||
display::SetDockedState(docked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include "board_fuse.hpp"
|
||||
#include "board_load.hpp"
|
||||
#include "board_name.hpp"
|
||||
@@ -43,8 +43,8 @@ namespace board {
|
||||
|
||||
void Initialize();
|
||||
void Exit();
|
||||
SysClkSocType GetSocType();
|
||||
HorizonOCConsoleType GetConsoleType();
|
||||
HocClkSocType GetSocType();
|
||||
HocClkConsoleType GetConsoleType();
|
||||
u8 GetDramID();
|
||||
u8 GetGpuSpeedoBracket();
|
||||
bool IsDram8GB();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <nxExt.h>
|
||||
#include "display_refresh_rate.hpp"
|
||||
#include "board.hpp"
|
||||
@@ -34,24 +34,24 @@
|
||||
|
||||
namespace board {
|
||||
|
||||
PcvModule GetPcvModule(SysClkModule sysclkModule) {
|
||||
switch (sysclkModule) {
|
||||
case SysClkModule_CPU:
|
||||
PcvModule GetPcvModule(HocClkModule hocclkModule) {
|
||||
switch (hocclkModule) {
|
||||
case HocClkModule_CPU:
|
||||
return PcvModule_CpuBus;
|
||||
case SysClkModule_GPU:
|
||||
case HocClkModule_GPU:
|
||||
return PcvModule_GPU;
|
||||
case SysClkModule_MEM:
|
||||
case HocClkModule_MEM:
|
||||
return PcvModule_EMC;
|
||||
default:
|
||||
ASSERT_ENUM_VALID(SysClkModule, sysclkModule);
|
||||
ASSERT_ENUM_VALID(HocClkModule, hocclkModule);
|
||||
}
|
||||
|
||||
return static_cast<PcvModule>(0);
|
||||
}
|
||||
|
||||
PcvModuleId GetPcvModuleId(SysClkModule sysclkModule) {
|
||||
PcvModuleId GetPcvModuleId(HocClkModule hocclkModule) {
|
||||
PcvModuleId pcvModuleId;
|
||||
Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(sysclkModule));
|
||||
Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(hocclkModule));
|
||||
ASSERT_RESULT_OK(rc, "pcvGetModuleId");
|
||||
|
||||
return pcvModuleId;
|
||||
@@ -65,12 +65,12 @@ namespace board {
|
||||
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
|
||||
}
|
||||
|
||||
void SetHz(SysClkModule module, u32 hz) {
|
||||
void SetHz(HocClkModule module, u32 hz) {
|
||||
Result rc = 0;
|
||||
bool usesGovenor = module > SysClkModule_MEM;
|
||||
bool usesGovenor = module > HocClkModule_MEM;
|
||||
|
||||
|
||||
if (module == HorizonOCModule_Display) {
|
||||
if (module == HocClkModule_Display) {
|
||||
display::SetRate(hz);
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace board {
|
||||
ClkrstSetHz(session, hz);
|
||||
|
||||
/* Voltage bug workaround. */
|
||||
if (module == SysClkModule_CPU) {
|
||||
if (module == HocClkModule_CPU) {
|
||||
svcSleepThread(250'000);
|
||||
ClkrstSetHz(session, hz);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace board {
|
||||
} else {
|
||||
PcvSetHz(GetPcvModule(module), hz);
|
||||
|
||||
if (module == SysClkModule_CPU) {
|
||||
if (module == HocClkModule_CPU) {
|
||||
svcSleepThread(250'000);
|
||||
PcvSetHz(GetPcvModule(module), hz);
|
||||
}
|
||||
@@ -107,11 +107,11 @@ namespace board {
|
||||
return hz;
|
||||
}
|
||||
|
||||
u32 GetHz(SysClkModule module) {
|
||||
u32 GetHz(HocClkModule module) {
|
||||
Result rc = 0;
|
||||
u32 hz = 0;
|
||||
|
||||
if (module == HorizonOCModule_Display) {
|
||||
if (module == HocClkModule_Display) {
|
||||
return GetDisplayRate(hz);
|
||||
}
|
||||
|
||||
@@ -133,26 +133,26 @@ namespace board {
|
||||
return hz;
|
||||
}
|
||||
|
||||
u32 GetRealHz(SysClkModule module) {
|
||||
u32 GetRealHz(HocClkModule module) {
|
||||
u32 hz = 0;
|
||||
switch (module) {
|
||||
case SysClkModule_CPU:
|
||||
case HocClkModule_CPU:
|
||||
return t210ClkCpuFreq();
|
||||
case SysClkModule_GPU:
|
||||
case HocClkModule_GPU:
|
||||
return t210ClkGpuFreq();
|
||||
case SysClkModule_MEM:
|
||||
case HocClkModule_MEM:
|
||||
return t210ClkMemFreq();
|
||||
case HorizonOCModule_Display:
|
||||
case HocClkModule_Display:
|
||||
return GetDisplayRate(hz);
|
||||
return hz;
|
||||
default:
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetFreqList(SysClkModule module, u32 *outList, u32 maxCount, u32 *outCount) {
|
||||
void GetFreqList(HocClkModule module, u32 *outList, u32 maxCount, u32 *outCount) {
|
||||
Result rc = 0;
|
||||
PcvClockRatesListType type;
|
||||
s32 tmpInMaxCount = maxCount;
|
||||
@@ -182,7 +182,7 @@ namespace board {
|
||||
}
|
||||
|
||||
u32 GetHighestDockedDisplayRate() {
|
||||
if (GetConsoleType() != HorizonOCConsoleType_Hoag) {
|
||||
if (GetConsoleType() != HocClkConsoleType_Hoag) {
|
||||
return display::GetDockedHighestAllowed();
|
||||
}
|
||||
|
||||
@@ -196,10 +196,10 @@ namespace board {
|
||||
rc = apmExtGetCurrentPerformanceConfiguration(&confId);
|
||||
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
|
||||
|
||||
SysClkApmConfiguration* apmConfiguration = nullptr;
|
||||
for (size_t i = 0; sysclk_g_apm_configurations[i].id; ++i) {
|
||||
if(sysclk_g_apm_configurations[i].id == confId) {
|
||||
apmConfiguration = &sysclk_g_apm_configurations[i];
|
||||
HocClkApmConfiguration* apmConfiguration = nullptr;
|
||||
for (size_t i = 0; hocclk_g_apm_configurations[i].id; ++i) {
|
||||
if(hocclk_g_apm_configurations[i].id == confId) {
|
||||
apmConfiguration = &hocclk_g_apm_configurations[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -208,9 +208,9 @@ namespace board {
|
||||
ERROR_THROW("Unknown apm configuration: %x", confId);
|
||||
}
|
||||
|
||||
SetHz(SysClkModule_CPU, apmConfiguration->cpu_hz);
|
||||
SetHz(SysClkModule_GPU, apmConfiguration->gpu_hz);
|
||||
SetHz(SysClkModule_MEM, apmConfiguration->mem_hz);
|
||||
SetHz(HocClkModule_CPU, apmConfiguration->cpu_hz);
|
||||
SetHz(HocClkModule_GPU, apmConfiguration->gpu_hz);
|
||||
SetHz(HocClkModule_MEM, apmConfiguration->mem_hz);
|
||||
} else {
|
||||
u32 mode = 0;
|
||||
rc = apmExtGetPerformanceMode(&mode);
|
||||
@@ -222,7 +222,7 @@ namespace board {
|
||||
}
|
||||
|
||||
void ResetToStockDisplay() {
|
||||
if (GetConsoleType() != HorizonOCConsoleType_Hoag) {
|
||||
if (GetConsoleType() != HocClkConsoleType_Hoag) {
|
||||
display::SetRate(60);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,24 +26,24 @@
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <nxExt.h>
|
||||
#include "../errors.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
void SetHz(SysClkModule module, u32 hz);
|
||||
void SetHz(HocClkModule module, u32 hz);
|
||||
|
||||
u32 GetHz(SysClkModule module);
|
||||
u32 GetRealHz(SysClkModule module);
|
||||
void GetFreqList(SysClkModule module, u32 *outList, u32 maxCount, u32 *outCount);
|
||||
u32 GetHz(HocClkModule module);
|
||||
u32 GetRealHz(HocClkModule module);
|
||||
void GetFreqList(HocClkModule module, u32 *outList, u32 maxCount, u32 *outCount);
|
||||
u32 GetHighestDockedDisplayRate();
|
||||
|
||||
void ResetToStock();
|
||||
void ResetToStockDisplay();
|
||||
|
||||
template <typename Getter>
|
||||
void ResetToStockModule(Getter getHzFunc, SysClkModule module) {
|
||||
void ResetToStockModule(Getter getHzFunc, HocClkModule module) {
|
||||
Result rc = 0;
|
||||
|
||||
if (hosversionAtLeast(9, 0, 0)) {
|
||||
@@ -51,11 +51,11 @@ namespace board {
|
||||
rc = apmExtGetCurrentPerformanceConfiguration(&confId);
|
||||
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
|
||||
|
||||
SysClkApmConfiguration* apmConfiguration = nullptr;
|
||||
for (size_t i = 0; sysclk_g_apm_configurations[i].id; ++i) {
|
||||
HocClkApmConfiguration* apmConfiguration = nullptr;
|
||||
for (size_t i = 0; hocclk_g_apm_configurations[i].id; ++i) {
|
||||
|
||||
if (sysclk_g_apm_configurations[i].id == confId) {
|
||||
apmConfiguration = &sysclk_g_apm_configurations[i];
|
||||
if (hocclk_g_apm_configurations[i].id == confId) {
|
||||
apmConfiguration = &hocclk_g_apm_configurations[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -76,15 +76,15 @@ namespace board {
|
||||
}
|
||||
|
||||
inline void ResetToStockCpu() {
|
||||
ResetToStockModule([](const SysClkApmConfiguration& cfg) {return cfg.cpu_hz; }, SysClkModule_CPU);
|
||||
ResetToStockModule([](const HocClkApmConfiguration& cfg) {return cfg.cpu_hz; }, HocClkModule_CPU);
|
||||
}
|
||||
|
||||
inline void ResetToStockGpu() {
|
||||
ResetToStockModule([](const SysClkApmConfiguration& cfg){ return cfg.gpu_hz; }, SysClkModule_GPU);
|
||||
ResetToStockModule([](const HocClkApmConfiguration& cfg){ return cfg.gpu_hz; }, HocClkModule_GPU);
|
||||
}
|
||||
|
||||
inline void ResetToStockMem() {
|
||||
ResetToStockModule([](const SysClkApmConfiguration& cfg){ return cfg.mem_hz; }, SysClkModule_MEM);
|
||||
ResetToStockModule([](const HocClkApmConfiguration& cfg){ return cfg.mem_hz; }, HocClkModule_MEM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <nxExt.h>
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
@@ -104,11 +104,11 @@ namespace board {
|
||||
return std::round(std::max({cpuUsage0, cpuUsage1, cpuUsage2}));
|
||||
}
|
||||
|
||||
u32 GetPartLoad(SysClkPartLoad loadSource) {
|
||||
u32 GetPartLoad(HocClkPartLoad loadSource) {
|
||||
switch(loadSource) {
|
||||
case SysClkPartLoad_EMC:
|
||||
case HocClkPartLoad_EMC:
|
||||
return t210EmcLoadAll();
|
||||
case SysClkPartLoad_EMCCpu:
|
||||
case HocClkPartLoad_EMCCpu:
|
||||
return t210EmcLoadCpu();
|
||||
case HocClkPartLoad_GPU:
|
||||
return gpuLoad;
|
||||
@@ -121,7 +121,7 @@ namespace board {
|
||||
case HocClkPartLoad_FAN:
|
||||
return GetFanLevel();
|
||||
default:
|
||||
ASSERT_ENUM_VALID(SysClkPartLoad, loadSource);
|
||||
ASSERT_ENUM_VALID(HocClkPartLoad, loadSource);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
void StartLoad(Result nvCheck, u32 fd);
|
||||
void ExitLoad();
|
||||
u32 GetPartLoad(SysClkPartLoad loadSource);
|
||||
u32 GetPartLoad(HocClkPartLoad loadSource);
|
||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method);
|
||||
void SchedSetFD2(u32 fd2);
|
||||
void NvSchedSucceed(Result nvSched);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <pwm.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
@@ -25,29 +25,29 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
const char *GetModuleName(SysClkModule module, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
return sysclkFormatModule(module, pretty);
|
||||
const char *GetModuleName(HocClkModule module, bool pretty) {
|
||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||
return hocclkFormatModule(module, pretty);
|
||||
}
|
||||
|
||||
const char *GetProfileName(SysClkProfile profile, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkProfile, profile);
|
||||
return sysclkFormatProfile(profile, pretty);
|
||||
const char *GetProfileName(HocClkProfile profile, bool pretty) {
|
||||
ASSERT_ENUM_VALID(HocClkProfile, profile);
|
||||
return hocclkFormatProfile(profile, pretty);
|
||||
}
|
||||
|
||||
const char *GetThermalSensorName(SysClkThermalSensor sensor, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkThermalSensor, sensor);
|
||||
return sysclkFormatThermalSensor(sensor, pretty);
|
||||
const char *GetThermalSensorName(HocClkThermalSensor sensor, bool pretty) {
|
||||
ASSERT_ENUM_VALID(HocClkThermalSensor, sensor);
|
||||
return hocclkFormatThermalSensor(sensor, pretty);
|
||||
}
|
||||
|
||||
const char *GetPowerSensorName(SysClkPowerSensor sensor, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkPowerSensor, sensor);
|
||||
return sysclkFormatPowerSensor(sensor, pretty);
|
||||
const char *GetPowerSensorName(HocClkPowerSensor sensor, bool pretty) {
|
||||
ASSERT_ENUM_VALID(HocClkPowerSensor, sensor);
|
||||
return hocclkFormatPowerSensor(sensor, pretty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
const char *GetModuleName(SysClkModule module, bool pretty);
|
||||
const char *GetProfileName(SysClkProfile profile, bool pretty);
|
||||
const char *GetThermalSensorName(SysClkThermalSensor sensor, bool pretty);
|
||||
const char *GetPowerSensorName(SysClkPowerSensor sensor, bool pretty);
|
||||
const char *GetModuleName(HocClkModule module, bool pretty);
|
||||
const char *GetProfileName(HocClkProfile profile, bool pretty);
|
||||
const char *GetThermalSensorName(HocClkThermalSensor sensor, bool pretty);
|
||||
const char *GetPowerSensorName(HocClkPowerSensor sensor, bool pretty);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <nxExt.h>
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
SysClkProfile GetProfile() {
|
||||
HocClkProfile GetProfile() {
|
||||
u32 mode = 0;
|
||||
Result rc = apmExtGetPerformanceMode(&mode);
|
||||
ASSERT_RESULT_OK(rc, "apmExtGetPerformanceMode");
|
||||
|
||||
if (mode) {
|
||||
return SysClkProfile_Docked;
|
||||
return HocClkProfile_Docked;
|
||||
}
|
||||
|
||||
PsmChargerType chargerType;
|
||||
@@ -46,12 +46,12 @@ namespace board {
|
||||
ASSERT_RESULT_OK(rc, "psmGetChargerType");
|
||||
|
||||
if (chargerType == PsmChargerType_EnoughPower) {
|
||||
return SysClkProfile_HandheldChargingOfficial;
|
||||
return HocClkProfile_HandheldChargingOfficial;
|
||||
} else if (chargerType == PsmChargerType_LowPower) {
|
||||
return SysClkProfile_HandheldChargingUSB;
|
||||
return HocClkProfile_HandheldChargingUSB;
|
||||
}
|
||||
|
||||
return SysClkProfile_Handheld;
|
||||
return HocClkProfile_Handheld;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
SysClkProfile GetProfile();
|
||||
HocClkProfile GetProfile();
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
#include <nxExt.h>
|
||||
#include <cmath>
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace board {
|
||||
|
||||
s32 GetTemperatureMilli(SysClkThermalSensor sensor) {
|
||||
s32 GetTemperatureMilli(HocClkThermalSensor sensor) {
|
||||
s32 millis = 0;
|
||||
BatteryChargeInfo info;
|
||||
|
||||
@@ -43,15 +43,15 @@ namespace board {
|
||||
soctherm::ReadSensors(temps);
|
||||
|
||||
switch(sensor) {
|
||||
case SysClkThermalSensor_SOC: {
|
||||
case HocClkThermalSensor_SOC: {
|
||||
millis = tmp451TempSoc();
|
||||
break;
|
||||
}
|
||||
case SysClkThermalSensor_PCB: {
|
||||
case HocClkThermalSensor_PCB: {
|
||||
millis = tmp451TempPcb();
|
||||
break;
|
||||
}
|
||||
case SysClkThermalSensor_Skin: {
|
||||
case HocClkThermalSensor_Skin: {
|
||||
if (HOSSVC_HAS_TC) {
|
||||
Result rc;
|
||||
rc = tcGetSkinTemperatureMilliC(&millis);
|
||||
@@ -59,46 +59,46 @@ namespace board {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_Battery: {
|
||||
case HocClkThermalSensor_Battery: {
|
||||
batteryInfoGetChargeInfo(&info);
|
||||
millis = batteryInfoGetTemperatureMiliCelsius(&info);
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_PMIC: {
|
||||
case HocClkThermalSensor_PMIC: {
|
||||
millis = 50000;
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_CPU: {
|
||||
case HocClkThermalSensor_CPU: {
|
||||
millis = temps.cpu;
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_GPU: {
|
||||
case HocClkThermalSensor_GPU: {
|
||||
millis = temps.gpu;
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_MEM: {
|
||||
millis = board::GetSocType() == SysClkSocType_Mariko ? temps.pllx : temps.mem;
|
||||
case HocClkThermalSensor_MEM: {
|
||||
millis = board::GetSocType() == HocClkSocType_Mariko ? temps.pllx : temps.mem;
|
||||
break;
|
||||
}
|
||||
case HorizonOCThermalSensor_PLLX: {
|
||||
case HocClkThermalSensor_PLLX: {
|
||||
millis = temps.pllx;
|
||||
}
|
||||
default: {
|
||||
ASSERT_ENUM_VALID(SysClkThermalSensor, sensor);
|
||||
ASSERT_ENUM_VALID(HocClkThermalSensor, sensor);
|
||||
}
|
||||
}
|
||||
|
||||
return std::max(0, millis);
|
||||
}
|
||||
|
||||
s32 GetPowerMw(SysClkPowerSensor sensor) {
|
||||
s32 GetPowerMw(HocClkPowerSensor sensor) {
|
||||
switch (sensor) {
|
||||
case SysClkPowerSensor_Now:
|
||||
case HocClkPowerSensor_Now:
|
||||
return max17050PowerNow();
|
||||
case SysClkPowerSensor_Avg:
|
||||
case HocClkPowerSensor_Avg:
|
||||
return max17050PowerAvg();
|
||||
default:
|
||||
ASSERT_ENUM_VALID(SysClkPowerSensor, sensor);
|
||||
ASSERT_ENUM_VALID(HocClkPowerSensor, sensor);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
s32 GetTemperatureMilli(SysClkThermalSensor sensor);
|
||||
s32 GetPowerMw(SysClkPowerSensor sensor);
|
||||
s32 GetTemperatureMilli(HocClkThermalSensor sensor);
|
||||
s32 GetPowerMw(HocClkPowerSensor sensor);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <memmem.h>
|
||||
#include <registers.h>
|
||||
#include <cstring>
|
||||
@@ -100,11 +100,11 @@ namespace board {
|
||||
Result rc = svcQueryMemoryMapping(&cldvfs, &temp, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
|
||||
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (cldvfs)");
|
||||
|
||||
if (GetSocType() == SysClkSocType_Erista) {
|
||||
if (GetSocType() == HocClkSocType_Erista) {
|
||||
cachedTune.tune0Low = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
cachedTune.tune1Low = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
} else {
|
||||
SetHz(SysClkModule_CPU, 1785000000);
|
||||
SetHz(HocClkModule_CPU, 1785000000);
|
||||
cachedTune.tune0High = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
ResetToStockCpu();
|
||||
}
|
||||
@@ -114,8 +114,8 @@ namespace board {
|
||||
void SetDfllTunings(u32 levelLow, u32 levelHigh, u32 tbreakPoint) {
|
||||
u32* tune0_ptr = reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
u32* tune1_ptr = reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
if (GetHz(SysClkModule_CPU) < tbreakPoint && (levelLow || levelHigh)) {
|
||||
if (GetSocType() == HocClkSocType_Mariko) {
|
||||
if (GetHz(HocClkModule_CPU) < tbreakPoint && (levelLow || levelHigh)) {
|
||||
if (levelLow) {
|
||||
*tune0_ptr = marikoCpuUvLow[levelLow-1].tune0_low;
|
||||
*tune1_ptr = marikoCpuUvLow[levelLow-1].tune1_low;
|
||||
@@ -132,17 +132,17 @@ namespace board {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (GetHz(SysClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
if (GetHz(HocClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
*tune0_ptr = 0xCFFF;
|
||||
*tune1_ptr = 0xFF072201;
|
||||
return;
|
||||
} else if (GetHz(SysClkModule_CPU) >= tbreakPoint || (!levelHigh)) {
|
||||
} else if (GetHz(HocClkModule_CPU) >= tbreakPoint || (!levelHigh)) {
|
||||
*tune0_ptr = cachedTune.tune0High; // per console?
|
||||
*tune1_ptr = 0xFFF7FF3F;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (GetHz(SysClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
if (GetHz(HocClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
*tune0_ptr = cachedTune.tune0Low; // I think each erista has a different tune0/tune1?
|
||||
*tune1_ptr = cachedTune.tune1Low;
|
||||
return;
|
||||
@@ -167,7 +167,7 @@ namespace board {
|
||||
};
|
||||
*/
|
||||
u32 CalculateTbreak(u32 table) {
|
||||
if (GetSocType() == SysClkSocType_Erista) {
|
||||
if (GetSocType() == HocClkSocType_Erista) {
|
||||
return 1581000000;
|
||||
} else {
|
||||
switch (table) {
|
||||
@@ -241,7 +241,7 @@ namespace board {
|
||||
rgltrCloseSession(&session);
|
||||
break;
|
||||
case HocClkVoltage_CPU:
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
if (GetSocType() == HocClkSocType_Mariko) {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77621_Cpu);
|
||||
} else {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77812_Cpu);
|
||||
@@ -251,7 +251,7 @@ namespace board {
|
||||
rgltrCloseSession(&session);
|
||||
break;
|
||||
case HocClkVoltage_GPU:
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
if (GetSocType() == HocClkSocType_Mariko) {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77621_Gpu);
|
||||
} else {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77812_Gpu);
|
||||
@@ -261,7 +261,7 @@ namespace board {
|
||||
rgltrCloseSession(&session);
|
||||
break;
|
||||
case HocClkVoltage_EMCVDDQ:
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
if (GetSocType() == HocClkSocType_Mariko) {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77812_Dram);
|
||||
ASSERT_RESULT_OK(rc, "rgltrOpenSession")
|
||||
rgltrGetVoltage(&session, &out);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
|
||||
@@ -49,36 +49,36 @@ namespace clockManager {
|
||||
|
||||
bool gRunning = false;
|
||||
LockableMutex gContextMutex;
|
||||
SysClkContext gContext = {};
|
||||
FreqTable gFreqTable[SysClkModule_EnumMax];
|
||||
HocClkContext gContext = {};
|
||||
FreqTable gFreqTable[HocClkModule_EnumMax];
|
||||
std::uint64_t gLastTempLogNs = 0;
|
||||
std::uint64_t gLastFreqLogNs = 0;
|
||||
std::uint64_t gLastPowerLogNs = 0;
|
||||
std::uint64_t gLastCsvWriteNs = 0;
|
||||
|
||||
bool IsAssignableHz(SysClkModule module, std::uint32_t hz)
|
||||
bool IsAssignableHz(HocClkModule module, std::uint32_t hz)
|
||||
{
|
||||
switch (module) {
|
||||
case SysClkModule_CPU:
|
||||
case HocClkModule_CPU:
|
||||
return hz >= 500000000;
|
||||
case SysClkModule_MEM:
|
||||
case HocClkModule_MEM:
|
||||
return hz >= 665600000;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t GetMaxAllowedHz(SysClkModule module, SysClkProfile profile)
|
||||
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile)
|
||||
{
|
||||
if (config::GetConfigValue(HocClkConfigValue_UncappedClocks)) {
|
||||
return ~0; // Integer limit, uncapped clocks ON
|
||||
} else {
|
||||
if (module == SysClkModule_GPU) {
|
||||
if (profile < SysClkProfile_HandheldCharging) {
|
||||
if (module == HocClkModule_GPU) {
|
||||
if (profile < HocClkProfile_HandheldCharging) {
|
||||
switch (board::GetSocType()) {
|
||||
case SysClkSocType_Erista:
|
||||
case HocClkSocType_Erista:
|
||||
return 460800000;
|
||||
case SysClkSocType_Mariko:
|
||||
case HocClkSocType_Mariko:
|
||||
switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
||||
case 0:
|
||||
return 614400000;
|
||||
@@ -92,11 +92,11 @@ namespace clockManager {
|
||||
default:
|
||||
return 460800000;
|
||||
}
|
||||
} else if (profile <= SysClkProfile_HandheldChargingUSB) {
|
||||
} else if (profile <= HocClkProfile_HandheldChargingUSB) {
|
||||
switch (board::GetSocType()) {
|
||||
case SysClkSocType_Erista:
|
||||
case HocClkSocType_Erista:
|
||||
return 768000000;
|
||||
case SysClkSocType_Mariko:
|
||||
case HocClkSocType_Mariko:
|
||||
switch (config::GetConfigValue(KipConfigValue_marikoGpuUV)) {
|
||||
case 0:
|
||||
return 844800000;
|
||||
@@ -111,8 +111,8 @@ namespace clockManager {
|
||||
return 768000000;
|
||||
}
|
||||
}
|
||||
} else if (module == SysClkModule_CPU) {
|
||||
if (profile < SysClkProfile_HandheldCharging && board::GetSocType() == SysClkSocType_Erista) {
|
||||
} else if (module == HocClkModule_CPU) {
|
||||
if (profile < HocClkProfile_HandheldCharging && board::GetSocType() == HocClkSocType_Erista) {
|
||||
return 1581000000;
|
||||
} else {
|
||||
return ~0;
|
||||
@@ -122,7 +122,7 @@ namespace clockManager {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t GetNearestHz(SysClkModule module, std::uint32_t inHz, std::uint32_t maxHz)
|
||||
std::uint32_t GetNearestHz(HocClkModule module, std::uint32_t inHz, std::uint32_t maxHz)
|
||||
{
|
||||
std::uint32_t *freqs = &gFreqTable[module].list[0];
|
||||
size_t count = gFreqTable[module].count - 1;
|
||||
@@ -144,8 +144,8 @@ namespace clockManager {
|
||||
void ResetToStockClocks()
|
||||
{
|
||||
board::ResetToStockCpu();
|
||||
if (config::GetConfigValue(HorizonOCConfigValue_LiveCpuUv)) {
|
||||
if (board::GetSocType() == SysClkSocType_Erista)
|
||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||
if (board::GetSocType() == HocClkSocType_Erista)
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||
else
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||
@@ -154,7 +154,7 @@ namespace clockManager {
|
||||
board::ResetToStockGpu();
|
||||
}
|
||||
|
||||
bool ConfigIntervalTimeout(SysClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs)
|
||||
bool ConfigIntervalTimeout(HocClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs)
|
||||
{
|
||||
std::uint64_t logInterval = config::GetConfigValue(intervalMsConfigValue) * 1000000ULL;
|
||||
bool shouldLog = logInterval && ((ns - *lastLogNs) > logInterval);
|
||||
@@ -166,15 +166,15 @@ namespace clockManager {
|
||||
return shouldLog;
|
||||
}
|
||||
|
||||
void RefreshFreqTableRow(SysClkModule module)
|
||||
void RefreshFreqTableRow(HocClkModule module)
|
||||
{
|
||||
std::scoped_lock lock{gContextMutex};
|
||||
|
||||
std::uint32_t freqs[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t count;
|
||||
|
||||
fileUtils::LogLine("[mgr] %s freq list refresh", board::GetModuleName(module, true));
|
||||
board::GetFreqList(module, &freqs[0], SYSCLK_FREQ_LIST_MAX, &count);
|
||||
board::GetFreqList(module, &freqs[0], HOCCLK_FREQ_LIST_MAX, &count);
|
||||
|
||||
std::uint32_t *hz = &gFreqTable[module].list[0];
|
||||
gFreqTable[module].count = 0;
|
||||
@@ -195,14 +195,14 @@ namespace clockManager {
|
||||
|
||||
void HandleSafetyFeatures()
|
||||
{
|
||||
if (config::GetConfigValue(HocClkConfigValue_HandheldTDP) && (gContext.profile != SysClkProfile_Docked)) {
|
||||
if (board::GetConsoleType() == HorizonOCConsoleType_Hoag) {
|
||||
if (board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
|
||||
if (config::GetConfigValue(HocClkConfigValue_HandheldTDP) && (gContext.profile != HocClkProfile_Docked)) {
|
||||
if (board::GetConsoleType() == HocClkConsoleType_Hoag) {
|
||||
if (board::GetPowerMw(HocClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
|
||||
ResetToStockClocks();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
|
||||
if (board::GetPowerMw(HocClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
|
||||
ResetToStockClocks();
|
||||
return;
|
||||
}
|
||||
@@ -217,14 +217,14 @@ namespace clockManager {
|
||||
|
||||
void HandleMiscFeatures()
|
||||
{
|
||||
if (config::GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent)) {
|
||||
I2c_Bq24193_SetFastChargeCurrentLimit(config::GetConfigValue(HorizonOCConfigValue_BatteryChargeCurrent));
|
||||
if (config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent)) {
|
||||
I2c_Bq24193_SetFastChargeCurrentLimit(config::GetConfigValue(HocClkConfigValue_BatteryChargeCurrent));
|
||||
}
|
||||
}
|
||||
|
||||
void DVFSBeforeSet(u32 targetHz)
|
||||
{
|
||||
s32 dvfsOffset = config::GetConfigValue(HorizonOCConfigValue_DVFSOffset);
|
||||
s32 dvfsOffset = config::GetConfigValue(HocClkConfigValue_DVFSOffset);
|
||||
u32 vmin = board::GetMinimumGpuVmin(targetHz / 1000000, board::GetGpuSpeedoBracket()) + dvfsOffset;
|
||||
|
||||
board::PcvHijackGpuVolts(vmin);
|
||||
@@ -239,7 +239,7 @@ namespace clockManager {
|
||||
|
||||
void DVFSAfterSet(u32 targetHz)
|
||||
{
|
||||
s32 dvfsOffset = config::GetConfigValue(HorizonOCConfigValue_DVFSOffset);
|
||||
s32 dvfsOffset = config::GetConfigValue(HocClkConfigValue_DVFSOffset);
|
||||
dvfsOffset = std::max(dvfsOffset, -80);
|
||||
u32 vmin = board::GetMinimumGpuVmin(targetHz / 1000000, board::GetGpuSpeedoBracket());
|
||||
|
||||
@@ -247,22 +247,22 @@ namespace clockManager {
|
||||
vmin += dvfsOffset;
|
||||
}
|
||||
|
||||
u32 maxHz = GetMaxAllowedHz(SysClkModule_GPU, gContext.profile);
|
||||
u32 nearestHz = GetNearestHz(SysClkModule_GPU, targetHz, maxHz);
|
||||
u32 maxHz = GetMaxAllowedHz(HocClkModule_GPU, gContext.profile);
|
||||
u32 nearestHz = GetNearestHz(HocClkModule_GPU, targetHz, maxHz);
|
||||
board::PcvHijackGpuVolts(vmin);
|
||||
|
||||
if (targetHz) {
|
||||
board::SetHz(SysClkModule_GPU, ~0);
|
||||
board::SetHz(SysClkModule_GPU, nearestHz);
|
||||
board::SetHz(HocClkModule_GPU, ~0);
|
||||
board::SetHz(HocClkModule_GPU, nearestHz);
|
||||
} else {
|
||||
board::SetHz(SysClkModule_GPU, ~0);
|
||||
board::SetHz(HocClkModule_GPU, ~0);
|
||||
board::ResetToStockGpu();
|
||||
}
|
||||
}
|
||||
|
||||
void HandleCpuUv()
|
||||
{
|
||||
if (board::GetSocType() == SysClkSocType_Erista)
|
||||
if (board::GetSocType() == HocClkSocType_Erista)
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||
else
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||
@@ -270,50 +270,50 @@ namespace clockManager {
|
||||
|
||||
void DVFSReset()
|
||||
{
|
||||
if (board::GetSocType() == SysClkSocType_Mariko && config::GetConfigValue(HorizonOCConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
if (board::GetSocType() == HocClkSocType_Mariko && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
board::PcvHijackGpuVolts(0);
|
||||
|
||||
u32 targetHz = gContext.overrideFreqs[SysClkModule_GPU];
|
||||
u32 targetHz = gContext.overrideFreqs[HocClkModule_GPU];
|
||||
if (!targetHz) {
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, SysClkModule_GPU, gContext.profile, false);
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, HocClkModule_GPU, gContext.profile, false);
|
||||
if (!targetHz) {
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, SysClkModule_GPU, gContext.profile, false);
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HocClkModule_GPU, gContext.profile, false);
|
||||
}
|
||||
}
|
||||
u32 maxHz = GetMaxAllowedHz(SysClkModule_GPU, gContext.profile);
|
||||
u32 nearestHz = GetNearestHz(SysClkModule_GPU, targetHz, maxHz);
|
||||
u32 maxHz = GetMaxAllowedHz(HocClkModule_GPU, gContext.profile);
|
||||
u32 nearestHz = GetNearestHz(HocClkModule_GPU, targetHz, maxHz);
|
||||
|
||||
board::SetHz(SysClkModule_GPU, ~0);
|
||||
board::SetHz(HocClkModule_GPU, ~0);
|
||||
if (targetHz) {
|
||||
board::SetHz(SysClkModule_GPU, nearestHz);
|
||||
board::SetHz(HocClkModule_GPU, nearestHz);
|
||||
} else {
|
||||
board::ResetToStockGpu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleFreqReset(SysClkModule module, bool isBoost)
|
||||
void HandleFreqReset(HocClkModule module, bool isBoost)
|
||||
{
|
||||
switch (module) {
|
||||
case SysClkModule_CPU:
|
||||
case HocClkModule_CPU:
|
||||
if (!(isBoost || (config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost)))
|
||||
board::ResetToStockCpu();
|
||||
if (config::GetConfigValue(HorizonOCConfigValue_LiveCpuUv)) {
|
||||
if (board::GetSocType() == SysClkSocType_Erista)
|
||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||
if (board::GetSocType() == HocClkSocType_Erista)
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||
else
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||
}
|
||||
break;
|
||||
case SysClkModule_GPU:
|
||||
case HocClkModule_GPU:
|
||||
board::ResetToStockGpu();
|
||||
break;
|
||||
case SysClkModule_MEM:
|
||||
case HocClkModule_MEM:
|
||||
board::ResetToStockMem();
|
||||
DVFSReset();
|
||||
break;
|
||||
case HorizonOCModule_Display:
|
||||
if (config::GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate)) {
|
||||
case HocClkModule_Display:
|
||||
if (config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate)) {
|
||||
board::ResetToStockDisplay();
|
||||
}
|
||||
break;
|
||||
@@ -329,87 +329,87 @@ namespace clockManager {
|
||||
std::uint32_t nearestHz = 0;
|
||||
|
||||
if (isBoost && !config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode)) {
|
||||
u32 boostFreq = board::GetHz(SysClkModule_CPU);
|
||||
u32 boostFreq = board::GetHz(HocClkModule_CPU);
|
||||
if (boostFreq / 1000000 > 1785) {
|
||||
board::SetHz(SysClkModule_CPU, boostFreq);
|
||||
board::SetHz(HocClkModule_CPU, boostFreq);
|
||||
}
|
||||
return; // Return if we aren't overwriting boost mode
|
||||
}
|
||||
|
||||
bool returnRaw = false; // Return a value scaled to MHz instead of raw value
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
u32 oldHz = board::GetHz((SysClkModule)module); // Get Old hz (used primarily for DVFS Logic)
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
u32 oldHz = board::GetHz((HocClkModule)module); // Get Old hz (used primarily for DVFS Logic)
|
||||
|
||||
if (module > SysClkModule_MEM)
|
||||
if (module > HocClkModule_MEM)
|
||||
returnRaw = true;
|
||||
else
|
||||
returnRaw = false;
|
||||
targetHz = gContext.overrideFreqs[module];
|
||||
if (!targetHz) {
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, (SysClkModule)module, gContext.profile, returnRaw);
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, (HocClkModule)module, gContext.profile, returnRaw);
|
||||
if (!targetHz)
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, (SysClkModule)module, gContext.profile, returnRaw);
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, (HocClkModule)module, gContext.profile, returnRaw);
|
||||
}
|
||||
|
||||
if (module == HorizonOCModule_Governor) {
|
||||
if (module == HocClkModule_Governor) {
|
||||
governor::HandleGovernor(targetHz);
|
||||
}
|
||||
|
||||
bool noCPU = governor::isCpuGovernorEnabled;
|
||||
bool noGPU = governor::isGpuGovernorEnabled;
|
||||
bool noDisp = governor::isVRREnabled;
|
||||
if (noDisp && module == HorizonOCModule_Display)
|
||||
if (noDisp && module == HocClkModule_Display)
|
||||
continue;
|
||||
|
||||
if (module == HorizonOCModule_Display && config::GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate) && !noDisp) {
|
||||
if (module == HocClkModule_Display && config::GetConfigValue(HocClkConfigValue_OverwriteRefreshRate) && !noDisp) {
|
||||
if (targetHz) {
|
||||
board::SetHz(HorizonOCModule_Display, targetHz);
|
||||
gContext.freqs[HorizonOCModule_Display] = targetHz;
|
||||
gContext.realFreqs[HorizonOCModule_Display] = targetHz;
|
||||
board::SetHz(HocClkModule_Display, targetHz);
|
||||
gContext.freqs[HocClkModule_Display] = targetHz;
|
||||
gContext.realFreqs[HocClkModule_Display] = targetHz;
|
||||
} else {
|
||||
HandleFreqReset(HorizonOCModule_Display, isBoost);
|
||||
HandleFreqReset(HocClkModule_Display, isBoost);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip GPU and CPU if governors handle them
|
||||
if (module > SysClkModule_MEM) {
|
||||
if (module > HocClkModule_MEM) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (noCPU && module == SysClkModule_CPU)
|
||||
if (noCPU && module == HocClkModule_CPU)
|
||||
continue;
|
||||
if (noGPU && module == SysClkModule_GPU)
|
||||
if (noGPU && module == HocClkModule_GPU)
|
||||
continue;
|
||||
|
||||
if (targetHz) {
|
||||
maxHz = GetMaxAllowedHz((SysClkModule)module, gContext.profile);
|
||||
nearestHz = GetNearestHz((SysClkModule)module, targetHz, maxHz);
|
||||
maxHz = GetMaxAllowedHz((HocClkModule)module, gContext.profile);
|
||||
nearestHz = GetNearestHz((HocClkModule)module, targetHz, maxHz);
|
||||
|
||||
if (nearestHz != gContext.freqs[module]) {
|
||||
fileUtils::LogLine(
|
||||
"[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)",
|
||||
board::GetModuleName((SysClkModule)module, true),
|
||||
board::GetModuleName((HocClkModule)module, true),
|
||||
nearestHz / 1000000, nearestHz / 100000 - nearestHz / 1000000 * 10,
|
||||
targetHz / 1000000, targetHz / 100000 - targetHz / 1000000 * 10
|
||||
);
|
||||
|
||||
if (module == SysClkModule_MEM && board::GetSocType() == SysClkSocType_Mariko && targetHz > oldHz && config::GetConfigValue(HorizonOCConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko && targetHz > oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
DVFSBeforeSet(targetHz);
|
||||
}
|
||||
|
||||
board::SetHz((SysClkModule)module, nearestHz);
|
||||
board::SetHz((HocClkModule)module, nearestHz);
|
||||
gContext.freqs[module] = nearestHz;
|
||||
|
||||
if (module == SysClkModule_CPU && config::GetConfigValue(HorizonOCConfigValue_LiveCpuUv)) {
|
||||
if (module == HocClkModule_CPU && config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||
HandleCpuUv();
|
||||
}
|
||||
|
||||
if (module == SysClkModule_MEM && board::GetSocType() == SysClkSocType_Mariko && targetHz < oldHz && config::GetConfigValue(HorizonOCConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko && targetHz < oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
DVFSAfterSet(targetHz);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HandleFreqReset((SysClkModule)module, isBoost);
|
||||
HandleFreqReset((HocClkModule)module, isBoost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,7 @@ namespace clockManager {
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
SysClkProfile profile = board::GetProfile();
|
||||
HocClkProfile profile = board::GetProfile();
|
||||
if (profile != gContext.profile) {
|
||||
fileUtils::LogLine("[mgr] Profile change: %s", board::GetProfileName(profile, true));
|
||||
gContext.profile = profile;
|
||||
@@ -439,27 +439,27 @@ namespace clockManager {
|
||||
// restore clocks to stock values on app or profile change
|
||||
if (hasChanged) {
|
||||
board::ResetToStock();
|
||||
if (board::GetSocType() == SysClkSocType_Mariko && config::GetConfigValue(HorizonOCConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
if (board::GetSocType() == HocClkSocType_Mariko && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
board::PcvHijackGpuVolts(0);
|
||||
board::SetHz(SysClkModule_GPU, ~0);
|
||||
board::SetHz(HocClkModule_GPU, ~0);
|
||||
board::ResetToStockGpu();
|
||||
}
|
||||
WaitForNextTick();
|
||||
}
|
||||
|
||||
std::uint32_t hz = 0;
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
hz = board::GetHz((SysClkModule)module);
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
hz = board::GetHz((HocClkModule)module);
|
||||
if (hz != 0 && hz != gContext.freqs[module]) {
|
||||
fileUtils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((SysClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
||||
fileUtils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
||||
gContext.freqs[module] = hz;
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
hz = config::GetOverrideHz((SysClkModule)module);
|
||||
hz = config::GetOverrideHz((HocClkModule)module);
|
||||
if (hz != gContext.overrideFreqs[module]) {
|
||||
if (hz) {
|
||||
fileUtils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((SysClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
||||
fileUtils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
||||
}
|
||||
gContext.overrideFreqs[module] = hz;
|
||||
hasChanged = true;
|
||||
@@ -470,60 +470,60 @@ namespace clockManager {
|
||||
|
||||
// temperatures do not and should not force a refresh, hasChanged untouched
|
||||
std::uint32_t millis = 0;
|
||||
bool shouldLogTemp = ConfigIntervalTimeout(SysClkConfigValue_TempLogIntervalMs, ns, &gLastTempLogNs);
|
||||
for (unsigned int sensor = 0; sensor < SysClkThermalSensor_EnumMax; sensor++) {
|
||||
millis = board::GetTemperatureMilli((SysClkThermalSensor)sensor);
|
||||
bool shouldLogTemp = ConfigIntervalTimeout(HocClkConfigValue_TempLogIntervalMs, ns, &gLastTempLogNs);
|
||||
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
||||
millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor);
|
||||
if (shouldLogTemp) {
|
||||
fileUtils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((SysClkThermalSensor)sensor, true), millis / 1000, (millis - millis / 1000 * 1000) / 100);
|
||||
fileUtils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((HocClkThermalSensor)sensor, true), millis / 1000, (millis - millis / 1000 * 1000) / 100);
|
||||
}
|
||||
gContext.temps[sensor] = millis;
|
||||
}
|
||||
|
||||
// power stats do not and should not force a refresh, hasChanged untouched
|
||||
std::int32_t mw = 0;
|
||||
bool shouldLogPower = ConfigIntervalTimeout(SysClkConfigValue_PowerLogIntervalMs, ns, &gLastPowerLogNs);
|
||||
for (unsigned int sensor = 0; sensor < SysClkPowerSensor_EnumMax; sensor++) {
|
||||
mw = board::GetPowerMw((SysClkPowerSensor)sensor);
|
||||
bool shouldLogPower = ConfigIntervalTimeout(HocClkConfigValue_PowerLogIntervalMs, ns, &gLastPowerLogNs);
|
||||
for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) {
|
||||
mw = board::GetPowerMw((HocClkPowerSensor)sensor);
|
||||
if (shouldLogPower) {
|
||||
fileUtils::LogLine("[mgr] Power %s: %d mW", board::GetPowerSensorName((SysClkPowerSensor)sensor, false), mw);
|
||||
fileUtils::LogLine("[mgr] Power %s: %d mW", board::GetPowerSensorName((HocClkPowerSensor)sensor, false), mw);
|
||||
}
|
||||
gContext.power[sensor] = mw;
|
||||
}
|
||||
|
||||
// real freqs do not and should not force a refresh, hasChanged untouched
|
||||
std::uint32_t realHz = 0;
|
||||
bool shouldLogFreq = ConfigIntervalTimeout(SysClkConfigValue_FreqLogIntervalMs, ns, &gLastFreqLogNs);
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
realHz = board::GetRealHz((SysClkModule)module);
|
||||
bool shouldLogFreq = ConfigIntervalTimeout(HocClkConfigValue_FreqLogIntervalMs, ns, &gLastFreqLogNs);
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
realHz = board::GetRealHz((HocClkModule)module);
|
||||
if (shouldLogFreq) {
|
||||
fileUtils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((SysClkModule)module, true), realHz / 1000000, realHz / 100000 - realHz / 1000000 * 10);
|
||||
fileUtils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), realHz / 1000000, realHz / 100000 - realHz / 1000000 * 10);
|
||||
}
|
||||
gContext.realFreqs[module] = realHz;
|
||||
}
|
||||
|
||||
// ram load do not and should not force a refresh, hasChanged untouched
|
||||
for (unsigned int loadSource = 0; loadSource < SysClkPartLoad_EnumMax; loadSource++) {
|
||||
gContext.partLoad[loadSource] = board::GetPartLoad((SysClkPartLoad)loadSource);
|
||||
for (unsigned int loadSource = 0; loadSource < HocClkPartLoad_EnumMax; loadSource++) {
|
||||
gContext.partLoad[loadSource] = board::GetPartLoad((HocClkPartLoad)loadSource);
|
||||
}
|
||||
|
||||
for (unsigned int voltageSource = 0; voltageSource < HocClkVoltage_EnumMax; voltageSource++) {
|
||||
gContext.voltages[voltageSource] = board::GetVoltage((HocClkVoltage)voltageSource);
|
||||
}
|
||||
|
||||
if (ConfigIntervalTimeout(SysClkConfigValue_CsvWriteIntervalMs, ns, &gLastCsvWriteNs)) {
|
||||
if (ConfigIntervalTimeout(HocClkConfigValue_CsvWriteIntervalMs, ns, &gLastCsvWriteNs)) {
|
||||
fileUtils::WriteContextToCsv(&gContext);
|
||||
}
|
||||
|
||||
// this->context->maxDisplayFreq = board::GetHighestDockedDisplayRate();
|
||||
u32 targetHz = gContext.overrideFreqs[HorizonOCModule_Display];
|
||||
u32 targetHz = gContext.overrideFreqs[HocClkModule_Display];
|
||||
if (!targetHz) {
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, HorizonOCModule_Display, gContext.profile, true);
|
||||
targetHz = config::GetAutoClockHz(gContext.applicationId, HocClkModule_Display, gContext.profile, true);
|
||||
if (!targetHz)
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HorizonOCModule_Display, gContext.profile, true);
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HocClkModule_Display, gContext.profile, true);
|
||||
}
|
||||
|
||||
if (board::GetConsoleType() != HorizonOCConsoleType_Hoag)
|
||||
board::SetDisplayRefreshDockedState(gContext.profile == SysClkProfile_Docked);
|
||||
if (board::GetConsoleType() != HocClkConsoleType_Hoag)
|
||||
board::SetDisplayRefreshDockedState(gContext.profile == HocClkProfile_Docked);
|
||||
|
||||
if (gContext.isSaltyNXInstalled)
|
||||
gContext.fps = integrations::GetSaltyNXFPS();
|
||||
@@ -544,12 +544,12 @@ namespace clockManager {
|
||||
|
||||
gContext = {};
|
||||
gContext.applicationId = 0;
|
||||
gContext.profile = SysClkProfile_Handheld;
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
gContext.profile = HocClkProfile_Handheld;
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
gContext.freqs[module] = 0;
|
||||
gContext.realFreqs[module] = 0;
|
||||
gContext.overrideFreqs[module] = 0;
|
||||
RefreshFreqTableRow((SysClkModule)module);
|
||||
RefreshFreqTableRow((HocClkModule)module);
|
||||
}
|
||||
|
||||
gRunning = false;
|
||||
@@ -571,8 +571,8 @@ namespace clockManager {
|
||||
|
||||
gContext.dramID = board::GetDramID();
|
||||
gContext.isDram8GB = board::IsDram8GB();
|
||||
board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HorizonOCConfigValue_GPUScheduling), (GpuSchedulingOverrideMethod)config::GetConfigValue(HorizonOCConfigValue_GPUSchedulingMethod));
|
||||
gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HorizonOCConfigValue_GPUScheduling);
|
||||
board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling), (GpuSchedulingOverrideMethod)config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod));
|
||||
gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling);
|
||||
|
||||
gContext.isSysDockInstalled = integrations::GetSysDockState();
|
||||
gContext.isSaltyNXInstalled = integrations::GetSaltyNXState();
|
||||
@@ -590,7 +590,7 @@ namespace clockManager {
|
||||
config::Exit();
|
||||
}
|
||||
|
||||
SysClkContext GetCurrentContext()
|
||||
HocClkContext GetCurrentContext()
|
||||
{
|
||||
std::scoped_lock lock{gContextMutex};
|
||||
return gContext;
|
||||
@@ -606,9 +606,9 @@ namespace clockManager {
|
||||
return gRunning;
|
||||
}
|
||||
|
||||
void GetFreqList(SysClkModule module, std::uint32_t *list, std::uint32_t maxCount, std::uint32_t *outCount)
|
||||
void GetFreqList(HocClkModule module, std::uint32_t *list, std::uint32_t maxCount, std::uint32_t *outCount)
|
||||
{
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||
|
||||
*outCount = std::min(maxCount, gFreqTable[module].count);
|
||||
memcpy(list, &gFreqTable[module].list[0], *outCount * sizeof(gFreqTable[0].list[0]));
|
||||
@@ -616,7 +616,7 @@ namespace clockManager {
|
||||
|
||||
void Tick()
|
||||
{
|
||||
fileUtils::LogLine("CPU Temp: %d", board::GetTemperatureMilli(HorizonOCThermalSensor_CPU));
|
||||
fileUtils::LogLine("CPU Temp: %d", board::GetTemperatureMilli(HocClkThermalSensor_CPU));
|
||||
std::scoped_lock lock{gContextMutex};
|
||||
std::uint32_t mode = 0;
|
||||
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
||||
@@ -634,8 +634,8 @@ namespace clockManager {
|
||||
|
||||
void WaitForNextTick()
|
||||
{
|
||||
if (board::GetHz(SysClkModule_MEM) > 665000000)
|
||||
svcSleepThread(config::GetConfigValue(SysClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||
if (board::GetHz(HocClkModule_MEM) > 665000000)
|
||||
svcSleepThread(config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||
else
|
||||
svcSleepThread(5000 * 1000000ULL); // 5 seconds in sleep mode
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
#include <nxExt/cpp/lockable_mutex.h>
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace clockManager {
|
||||
|
||||
struct FreqTable {
|
||||
std::uint32_t count;
|
||||
std::uint32_t list[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t list[HOCCLK_FREQ_LIST_MAX];
|
||||
};
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace clockManager {
|
||||
// instance variables
|
||||
extern bool gRunning;
|
||||
extern LockableMutex gContextMutex;
|
||||
extern SysClkContext gContext;
|
||||
extern FreqTable gFreqTable[SysClkModule_EnumMax];
|
||||
extern HocClkContext gContext;
|
||||
extern FreqTable gFreqTable[HocClkModule_EnumMax];
|
||||
extern std::uint64_t gLastTempLogNs;
|
||||
extern std::uint64_t gLastFreqLogNs;
|
||||
extern std::uint64_t gLastPowerLogNs;
|
||||
@@ -54,15 +54,15 @@ namespace clockManager {
|
||||
void Initialize();
|
||||
void Exit();
|
||||
|
||||
SysClkContext GetCurrentContext();
|
||||
HocClkContext GetCurrentContext();
|
||||
|
||||
void SetRunning(bool running);
|
||||
bool Running();
|
||||
|
||||
std::uint32_t GetMaxAllowedHz(SysClkModule module, SysClkProfile profile);
|
||||
bool IsAssignableHz(SysClkModule module, std::uint32_t hz);
|
||||
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile);
|
||||
bool IsAssignableHz(HocClkModule module, std::uint32_t hz);
|
||||
|
||||
void GetFreqList(SysClkModule module, std::uint32_t* list, std::uint32_t maxCount, std::uint32_t* outCount);
|
||||
void GetFreqList(HocClkModule module, std::uint32_t* list, std::uint32_t maxCount, std::uint32_t* outCount);
|
||||
|
||||
void Tick();
|
||||
void WaitForNextTick();
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
namespace config {
|
||||
|
||||
uint64_t configValues[SysClkConfigValue_EnumMax];
|
||||
uint64_t configValues[HocClkConfigValue_EnumMax];
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace config {
|
||||
std::string gPath;
|
||||
time_t gMtime = 0;
|
||||
std::atomic_bool gEnabled{false};
|
||||
std::uint32_t gOverrideFreqs[SysClkModule_EnumMax];
|
||||
std::map<std::tuple<std::uint64_t, SysClkProfile, SysClkModule>, std::uint32_t> gProfileMHzMap;
|
||||
std::uint32_t gOverrideFreqs[HocClkModule_EnumMax];
|
||||
std::map<std::tuple<std::uint64_t, HocClkProfile, HocClkModule>, std::uint32_t> gProfileMHzMap;
|
||||
std::map<std::uint64_t, std::uint8_t> gProfileCountMap;
|
||||
LockableMutex gConfigMutex;
|
||||
LockableMutex gOverrideMutex;
|
||||
@@ -67,7 +67,7 @@ namespace config {
|
||||
return mtime;
|
||||
}
|
||||
|
||||
std::uint32_t FindClockMHz(std::uint64_t tid, SysClkModule module, SysClkProfile profile) {
|
||||
std::uint32_t FindClockMHz(std::uint64_t tid, HocClkModule module, HocClkProfile profile) {
|
||||
if (gLoaded) {
|
||||
auto it = gProfileMHzMap.find(std::make_tuple(tid, profile, module));
|
||||
if (it != gProfileMHzMap.end()) {
|
||||
@@ -77,7 +77,7 @@ namespace config {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t FindClockHzFromProfiles(std::uint64_t tid, SysClkModule module, std::initializer_list<SysClkProfile> profiles, u32 mhzMultiplier = 1000000) {
|
||||
std::uint32_t FindClockHzFromProfiles(std::uint64_t tid, HocClkModule module, std::initializer_list<HocClkProfile> profiles, u32 mhzMultiplier = 1000000) {
|
||||
std::uint32_t mhz = 0;
|
||||
|
||||
if (gLoaded) {
|
||||
@@ -96,11 +96,11 @@ namespace config {
|
||||
(void)userdata;
|
||||
std::uint64_t input;
|
||||
if (!strcmp(section, CONFIG_VAL_SECTION)) {
|
||||
for (unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++) {
|
||||
if (!strcmp(key, sysclkFormatConfigValue((SysClkConfigValue)kval, false))) {
|
||||
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
||||
if (!strcmp(key, hocclkFormatConfigValue((HocClkConfigValue)kval, false))) {
|
||||
input = strtoul(value, NULL, 0);
|
||||
if (!sysclkValidConfigValue((SysClkConfigValue)kval, input)) {
|
||||
input = sysclkDefaultConfigValue((SysClkConfigValue)kval);
|
||||
if (!hocclkValidConfigValue((HocClkConfigValue)kval, input)) {
|
||||
input = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
||||
fileUtils::LogLine("[cfg] Invalid value for key '%s' in section '%s': using default %d", key, section, input);
|
||||
}
|
||||
configValues[kval] = input;
|
||||
@@ -119,28 +119,28 @@ namespace config {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SysClkProfile parsedProfile = SysClkProfile_EnumMax;
|
||||
SysClkModule parsedModule = SysClkModule_EnumMax;
|
||||
HocClkProfile parsedProfile = HocClkProfile_EnumMax;
|
||||
HocClkModule parsedModule = HocClkModule_EnumMax;
|
||||
|
||||
for (unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++) {
|
||||
const char* profileCode = board::GetProfileName((SysClkProfile)profile, false);
|
||||
for (unsigned int profile = 0; profile < HocClkProfile_EnumMax; profile++) {
|
||||
const char* profileCode = board::GetProfileName((HocClkProfile)profile, false);
|
||||
size_t profileCodeLen = strlen(profileCode);
|
||||
|
||||
if (!strncmp(key, profileCode, profileCodeLen) && key[profileCodeLen] == '_') {
|
||||
const char* subkey = key + profileCodeLen + 1;
|
||||
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
const char* moduleCode = board::GetModuleName((SysClkModule)module, false);
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
const char* moduleCode = board::GetModuleName((HocClkModule)module, false);
|
||||
size_t moduleCodeLen = strlen(moduleCode);
|
||||
if (!strncmp(subkey, moduleCode, moduleCodeLen) && subkey[moduleCodeLen] == '\0') {
|
||||
parsedProfile = (SysClkProfile)profile;
|
||||
parsedModule = (SysClkModule)module;
|
||||
parsedProfile = (HocClkProfile)profile;
|
||||
parsedModule = (HocClkModule)module;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parsedModule == SysClkModule_EnumMax || parsedProfile == SysClkProfile_EnumMax) {
|
||||
if (parsedModule == HocClkModule_EnumMax || parsedProfile == HocClkProfile_EnumMax) {
|
||||
fileUtils::LogLine("[cfg] Skipping key '%s' in section '%s': Unrecognized key", key, section);
|
||||
return 1;
|
||||
}
|
||||
@@ -166,8 +166,8 @@ namespace config {
|
||||
gLoaded = false;
|
||||
gProfileMHzMap.clear();
|
||||
gProfileCountMap.clear();
|
||||
for (unsigned int i = 0; i < SysClkConfigValue_EnumMax; i++) {
|
||||
configValues[i] = sysclkDefaultConfigValue((SysClkConfigValue)i);
|
||||
for (unsigned int i = 0; i < HocClkConfigValue_EnumMax; i++) {
|
||||
configValues[i] = hocclkDefaultConfigValue((HocClkConfigValue)i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,11 +194,11 @@ namespace config {
|
||||
gProfileCountMap.clear();
|
||||
gMtime = 0;
|
||||
gEnabled = false;
|
||||
for (unsigned int i = 0; i < SysClkModule_EnumMax; i++) {
|
||||
for (unsigned int i = 0; i < HocClkModule_EnumMax; i++) {
|
||||
gOverrideFreqs[i] = 0;
|
||||
}
|
||||
for (unsigned int i = 0; i < SysClkConfigValue_EnumMax; i++) {
|
||||
configValues[i] = sysclkDefaultConfigValue((SysClkConfigValue)i);
|
||||
for (unsigned int i = 0; i < HocClkConfigValue_EnumMax; i++) {
|
||||
configValues[i] = hocclkDefaultConfigValue((HocClkConfigValue)i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,34 +221,34 @@ namespace config {
|
||||
return gLoaded;
|
||||
}
|
||||
|
||||
std::uint32_t GetAutoClockHz(std::uint64_t tid, SysClkModule module, SysClkProfile profile, bool returnRaw) {
|
||||
std::uint32_t GetAutoClockHz(std::uint64_t tid, HocClkModule module, HocClkProfile profile, bool returnRaw) {
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
switch (profile) {
|
||||
case SysClkProfile_Handheld:
|
||||
return FindClockHzFromProfiles(tid, module, {SysClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case SysClkProfile_HandheldCharging:
|
||||
case SysClkProfile_HandheldChargingUSB:
|
||||
return FindClockHzFromProfiles(tid, module, {SysClkProfile_HandheldChargingUSB, SysClkProfile_HandheldCharging, SysClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case SysClkProfile_HandheldChargingOfficial:
|
||||
return FindClockHzFromProfiles(tid, module, {SysClkProfile_HandheldChargingOfficial, SysClkProfile_HandheldCharging, SysClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case SysClkProfile_Docked:
|
||||
return FindClockHzFromProfiles(tid, module, {SysClkProfile_Docked}, returnRaw ? 1 : 1000000);
|
||||
case HocClkProfile_Handheld:
|
||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case HocClkProfile_HandheldCharging:
|
||||
case HocClkProfile_HandheldChargingUSB:
|
||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_HandheldChargingUSB, HocClkProfile_HandheldCharging, HocClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case HocClkProfile_HandheldChargingOfficial:
|
||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_HandheldChargingOfficial, HocClkProfile_HandheldCharging, HocClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
||||
case HocClkProfile_Docked:
|
||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_Docked}, returnRaw ? 1 : 1000000);
|
||||
default:
|
||||
ERROR_THROW("Unhandled SysClkProfile: %u", profile);
|
||||
ERROR_THROW("Unhandled HocClkProfile: %u", profile);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetProfiles(std::uint64_t tid, SysClkTitleProfileList* out_profiles) {
|
||||
void GetProfiles(std::uint64_t tid, HocClkTitleProfileList* out_profiles) {
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
for (unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
out_profiles->mhzMap[profile][module] = FindClockMHz(tid, (SysClkModule)module, (SysClkProfile)profile);
|
||||
for (unsigned int profile = 0; profile < HocClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
out_profiles->mhzMap[profile][module] = FindClockMHz(tid, (HocClkModule)module, (HocClkProfile)profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bool immediate) {
|
||||
bool SetProfiles(std::uint64_t tid, HocClkTitleProfileList* profiles, bool immediate) {
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
uint8_t numProfiles = 0;
|
||||
|
||||
@@ -257,19 +257,19 @@ namespace config {
|
||||
|
||||
std::vector<std::string> keys;
|
||||
std::vector<std::string> values;
|
||||
keys.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||
values.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||
keys.reserve(HocClkProfile_EnumMax * HocClkModule_EnumMax);
|
||||
values.reserve(HocClkProfile_EnumMax * HocClkModule_EnumMax);
|
||||
|
||||
std::uint32_t* mhz = &profiles->mhz[0];
|
||||
|
||||
for (unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
for (unsigned int profile = 0; profile < HocClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
if (*mhz) {
|
||||
numProfiles++;
|
||||
|
||||
std::string key = std::string(board::GetProfileName((SysClkProfile)profile, false)) +
|
||||
std::string key = std::string(board::GetProfileName((HocClkProfile)profile, false)) +
|
||||
"_" +
|
||||
board::GetModuleName((SysClkModule)module, false);
|
||||
board::GetModuleName((HocClkModule)module, false);
|
||||
std::string value = std::to_string(*mhz);
|
||||
|
||||
keys.push_back(key);
|
||||
@@ -298,12 +298,12 @@ namespace config {
|
||||
if (immediate) {
|
||||
mhz = &profiles->mhz[0];
|
||||
gProfileCountMap[tid] = numProfiles;
|
||||
for (unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
for (unsigned int profile = 0; profile < HocClkProfile_EnumMax; profile++) {
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
if (*mhz) {
|
||||
gProfileMHzMap[std::make_tuple(tid, (SysClkProfile)profile, (SysClkModule)module)] = *mhz;
|
||||
gProfileMHzMap[std::make_tuple(tid, (HocClkProfile)profile, (HocClkModule)module)] = *mhz;
|
||||
} else {
|
||||
gProfileMHzMap.erase(std::make_tuple(tid, (SysClkProfile)profile, (SysClkModule)module));
|
||||
gProfileMHzMap.erase(std::make_tuple(tid, (HocClkProfile)profile, (HocClkModule)module));
|
||||
}
|
||||
mhz++;
|
||||
}
|
||||
@@ -329,51 +329,51 @@ namespace config {
|
||||
return gEnabled;
|
||||
}
|
||||
|
||||
void SetOverrideHz(SysClkModule module, std::uint32_t hz) {
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
void SetOverrideHz(HocClkModule module, std::uint32_t hz) {
|
||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||
std::scoped_lock lock{gOverrideMutex};
|
||||
gOverrideFreqs[module] = hz;
|
||||
}
|
||||
|
||||
std::uint32_t GetOverrideHz(SysClkModule module) {
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
std::uint32_t GetOverrideHz(HocClkModule module) {
|
||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||
std::scoped_lock lock{gOverrideMutex};
|
||||
return gOverrideFreqs[module];
|
||||
}
|
||||
|
||||
std::uint64_t GetConfigValue(SysClkConfigValue kval) {
|
||||
ASSERT_ENUM_VALID(SysClkConfigValue, kval);
|
||||
std::uint64_t GetConfigValue(HocClkConfigValue kval) {
|
||||
ASSERT_ENUM_VALID(HocClkConfigValue, kval);
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
return configValues[kval];
|
||||
}
|
||||
|
||||
const char* GetConfigValueName(SysClkConfigValue kval, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkConfigValue, kval);
|
||||
return sysclkFormatConfigValue(kval, pretty);
|
||||
const char* GetConfigValueName(HocClkConfigValue kval, bool pretty) {
|
||||
ASSERT_ENUM_VALID(HocClkConfigValue, kval);
|
||||
return hocclkFormatConfigValue(kval, pretty);
|
||||
}
|
||||
|
||||
void GetConfigValues(SysClkConfigValueList* out_configValues) {
|
||||
void GetConfigValues(HocClkConfigValueList* out_configValues) {
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
for (unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++) {
|
||||
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
||||
out_configValues->values[kval] = configValues[kval];
|
||||
}
|
||||
}
|
||||
|
||||
bool SetConfigValues(SysClkConfigValueList* configValues, bool immediate) {
|
||||
bool SetConfigValues(HocClkConfigValueList* configValues, bool immediate) {
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
|
||||
std::vector<const char*> iniKeys;
|
||||
std::vector<std::string> iniValues;
|
||||
iniKeys.reserve(SysClkConfigValue_EnumMax + 1);
|
||||
iniValues.reserve(SysClkConfigValue_EnumMax);
|
||||
iniKeys.reserve(HocClkConfigValue_EnumMax + 1);
|
||||
iniValues.reserve(HocClkConfigValue_EnumMax);
|
||||
|
||||
for (unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++) {
|
||||
if (!sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval]) ||
|
||||
configValues->values[kval] == sysclkDefaultConfigValue((SysClkConfigValue)kval)) {
|
||||
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
||||
if (!hocclkValidConfigValue((HocClkConfigValue)kval, configValues->values[kval]) ||
|
||||
configValues->values[kval] == hocclkDefaultConfigValue((HocClkConfigValue)kval)) {
|
||||
continue;
|
||||
}
|
||||
iniValues.push_back(std::to_string(configValues->values[kval]));
|
||||
iniKeys.push_back(sysclkFormatConfigValue((SysClkConfigValue)kval, false));
|
||||
iniKeys.push_back(hocclkFormatConfigValue((HocClkConfigValue)kval, false));
|
||||
}
|
||||
|
||||
iniKeys.push_back(NULL);
|
||||
@@ -390,11 +390,11 @@ namespace config {
|
||||
}
|
||||
|
||||
if (immediate) {
|
||||
for (unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++) {
|
||||
if (sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval])) {
|
||||
for (unsigned int kval = 0; kval < HocClkConfigValue_EnumMax; kval++) {
|
||||
if (hocclkValidConfigValue((HocClkConfigValue)kval, configValues->values[kval])) {
|
||||
config::configValues[kval] = configValues->values[kval];
|
||||
} else {
|
||||
config::configValues[kval] = sysclkDefaultConfigValue((SysClkConfigValue)kval);
|
||||
config::configValues[kval] = hocclkDefaultConfigValue((HocClkConfigValue)kval);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -402,22 +402,22 @@ namespace config {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResetConfigValue(SysClkConfigValue kval) {
|
||||
if (!SYSCLK_ENUM_VALID(SysClkConfigValue, kval)) {
|
||||
fileUtils::LogLine("[cfg] Invalid SysClkConfigValue: %u", kval);
|
||||
bool ResetConfigValue(HocClkConfigValue kval) {
|
||||
if (!HOCCLK_ENUM_VALID(HocClkConfigValue, kval)) {
|
||||
fileUtils::LogLine("[cfg] Invalid HocClkConfigValue: %u", kval);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::scoped_lock lock{gConfigMutex};
|
||||
|
||||
std::uint64_t defaultValue = sysclkDefaultConfigValue(kval);
|
||||
std::uint64_t defaultValue = hocclkDefaultConfigValue(kval);
|
||||
|
||||
std::vector<const char*> iniKeys;
|
||||
std::vector<std::string> iniValues;
|
||||
iniKeys.reserve(2);
|
||||
iniValues.reserve(1);
|
||||
|
||||
iniKeys.push_back(sysclkFormatConfigValue(kval, false));
|
||||
iniKeys.push_back(hocclkFormatConfigValue(kval, false));
|
||||
iniValues.push_back("");
|
||||
iniKeys.push_back(NULL);
|
||||
|
||||
@@ -439,11 +439,11 @@ namespace config {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetConfigValue(SysClkConfigValue kval, std::uint64_t value, bool immediate) {
|
||||
if (!SYSCLK_ENUM_VALID(SysClkConfigValue, kval)) {
|
||||
bool SetConfigValue(HocClkConfigValue kval, std::uint64_t value, bool immediate) {
|
||||
if (!HOCCLK_ENUM_VALID(HocClkConfigValue, kval)) {
|
||||
return false;
|
||||
}
|
||||
if (!sysclkValidConfigValue(kval, value)) {
|
||||
if (!hocclkValidConfigValue(kval, value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace config {
|
||||
iniKeys.reserve(2);
|
||||
iniValues.reserve(1);
|
||||
|
||||
iniKeys.push_back(sysclkFormatConfigValue(kval, false));
|
||||
iniKeys.push_back(hocclkFormatConfigValue(kval, false));
|
||||
iniValues.push_back(std::to_string(value));
|
||||
iniKeys.push_back(NULL);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
|
||||
#define CONFIG_VAL_SECTION "values"
|
||||
@@ -40,22 +40,22 @@ namespace config {
|
||||
bool HasProfilesLoaded();
|
||||
|
||||
std::uint8_t GetProfileCount(std::uint64_t tid);
|
||||
void GetProfiles(std::uint64_t tid, SysClkTitleProfileList* out_profiles);
|
||||
bool SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bool immediate);
|
||||
std::uint32_t GetAutoClockHz(std::uint64_t tid, SysClkModule module, SysClkProfile profile, bool returnRaw);
|
||||
void GetProfiles(std::uint64_t tid, HocClkTitleProfileList* out_profiles);
|
||||
bool SetProfiles(std::uint64_t tid, HocClkTitleProfileList* profiles, bool immediate);
|
||||
std::uint32_t GetAutoClockHz(std::uint64_t tid, HocClkModule module, HocClkProfile profile, bool returnRaw);
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
bool Enabled();
|
||||
void SetOverrideHz(SysClkModule module, std::uint32_t hz);
|
||||
std::uint32_t GetOverrideHz(SysClkModule module);
|
||||
void SetOverrideHz(HocClkModule module, std::uint32_t hz);
|
||||
std::uint32_t GetOverrideHz(HocClkModule module);
|
||||
|
||||
std::uint64_t GetConfigValue(SysClkConfigValue val);
|
||||
const char* GetConfigValueName(SysClkConfigValue val, bool pretty);
|
||||
void GetConfigValues(SysClkConfigValueList* out_configValues);
|
||||
bool SetConfigValues(SysClkConfigValueList* configValues, bool immediate);
|
||||
bool ResetConfigValue(SysClkConfigValue kval);
|
||||
bool SetConfigValue(SysClkConfigValue kval, std::uint64_t value, bool immediate = true);
|
||||
std::uint64_t GetConfigValue(HocClkConfigValue val);
|
||||
const char* GetConfigValueName(HocClkConfigValue val, bool pretty);
|
||||
void GetConfigValues(HocClkConfigValueList* out_configValues);
|
||||
bool SetConfigValues(HocClkConfigValueList* configValues, bool immediate);
|
||||
bool ResetConfigValue(HocClkConfigValue kval);
|
||||
bool SetConfigValue(HocClkConfigValue kval, std::uint64_t value, bool immediate = true);
|
||||
|
||||
extern uint64_t configValues[SysClkConfigValue_EnumMax];
|
||||
extern uint64_t configValues[HocClkConfigValue_EnumMax];
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
ERROR_RESULT_THROW(rc, "ASSERT_RESULT_OK: " format, ##__VA_ARGS__); \
|
||||
}
|
||||
#define ASSERT_ENUM_VALID(n, v) \
|
||||
if (!SYSCLK_ENUM_VALID(n, v)) { \
|
||||
if (!HOCCLK_ENUM_VALID(n, v)) { \
|
||||
ERROR_THROW("No such %s: %u", #n, v); \
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace fileUtils {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void WriteContextToCsv(const SysClkContext* context) {
|
||||
void WriteContextToCsv(const HocClkContext* context) {
|
||||
std::scoped_lock lock{g_csv_mutex};
|
||||
|
||||
FILE* file = fopen(FILE_CONTEXT_CSV_PATH, "a");
|
||||
@@ -106,20 +106,20 @@ namespace fileUtils {
|
||||
if (!ftell(file)) {
|
||||
fprintf(file, "timestamp,profile,app_tid");
|
||||
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%s_hz", sysclkFormatModule((SysClkModule)module, false));
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%s_hz", hocclkFormatModule((HocClkModule)module, false));
|
||||
}
|
||||
|
||||
for (unsigned int sensor = 0; sensor < SysClkThermalSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%s_milliC", sysclkFormatThermalSensor((SysClkThermalSensor)sensor, false));
|
||||
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%s_milliC", hocclkFormatThermalSensor((HocClkThermalSensor)sensor, false));
|
||||
}
|
||||
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%s_real_hz", sysclkFormatModule((SysClkModule)module, false));
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%s_real_hz", hocclkFormatModule((HocClkModule)module, false));
|
||||
}
|
||||
|
||||
for (unsigned int sensor = 0; sensor < SysClkPowerSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%s_mw", sysclkFormatPowerSensor((SysClkPowerSensor)sensor, false));
|
||||
for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%s_mw", hocclkFormatPowerSensor((HocClkPowerSensor)sensor, false));
|
||||
}
|
||||
|
||||
fprintf(file, "\n");
|
||||
@@ -128,21 +128,21 @@ namespace fileUtils {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
|
||||
fprintf(file, "%ld%03ld,%s,%016lx", now.tv_sec, now.tv_nsec / 1000000UL, sysclkFormatProfile(context->profile, false), context->applicationId);
|
||||
fprintf(file, "%ld%03ld,%s,%016lx", now.tv_sec, now.tv_nsec / 1000000UL, hocclkFormatProfile(context->profile, false), context->applicationId);
|
||||
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%d", context->freqs[module]);
|
||||
}
|
||||
|
||||
for (unsigned int sensor = 0; sensor < SysClkThermalSensor_EnumMax; sensor++) {
|
||||
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%d", context->temps[sensor]);
|
||||
}
|
||||
|
||||
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++) {
|
||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||
fprintf(file, ",%d", context->realFreqs[module]);
|
||||
}
|
||||
|
||||
for (unsigned int sensor = 0; sensor < SysClkPowerSensor_EnumMax; sensor++) {
|
||||
for (unsigned int sensor = 0; sensor < HocClkPowerSensor_EnumMax; sensor++) {
|
||||
fprintf(file, ",%d", context->power[sensor]);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <cstdarg>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
#define FILE_CONFIG_DIR "/config/" TARGET
|
||||
#define FILE_FLAG_CHECK_INTERVAL_NS (10000ULL * 1000000000ULL)
|
||||
@@ -48,6 +48,6 @@ namespace fileUtils {
|
||||
bool IsLogEnabled();
|
||||
void InitializeAsync();
|
||||
void LogLine(const char* format, ...);
|
||||
void WriteContextToCsv(const SysClkContext* context);
|
||||
void WriteContextToCsv(const HocClkContext* context);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace governor {
|
||||
|
||||
void HandleGovernor(uint32_t targetHz)
|
||||
{
|
||||
u32 tempTargetHz = clockManager::gContext.overrideFreqs[HorizonOCModule_Governor];
|
||||
u32 tempTargetHz = clockManager::gContext.overrideFreqs[HocClkModule_Governor];
|
||||
if (!tempTargetHz) {
|
||||
tempTargetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HorizonOCModule_Governor, clockManager::gContext.profile, true);
|
||||
tempTargetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Governor, clockManager::gContext.profile, true);
|
||||
if (!tempTargetHz)
|
||||
tempTargetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HorizonOCModule_Governor, clockManager::gContext.profile, true);
|
||||
tempTargetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HocClkModule_Governor, clockManager::gContext.profile, true);
|
||||
}
|
||||
|
||||
auto resolve = [](u8 app, u8 temp) -> u8 {
|
||||
@@ -81,7 +81,7 @@ namespace governor {
|
||||
return table.count - 1;
|
||||
}
|
||||
|
||||
u32 ResolveTargetHz(SysClkModule module)
|
||||
u32 ResolveTargetHz(HocClkModule module)
|
||||
{
|
||||
u32 hz = clockManager::gContext.overrideFreqs[module];
|
||||
if (!hz)
|
||||
@@ -123,7 +123,7 @@ namespace governor {
|
||||
isCpuGovernorInBoostMode = false;
|
||||
}
|
||||
|
||||
auto& table = clockManager::gFreqTable[SysClkModule_CPU];
|
||||
auto& table = clockManager::gFreqTable[HocClkModule_CPU];
|
||||
|
||||
if (table.count == 0)
|
||||
continue;
|
||||
@@ -134,8 +134,8 @@ namespace governor {
|
||||
|
||||
u32 tableMaxHz = table.list[table.count - 1];
|
||||
u32 desiredHz = SchedutilTargetHz(cpuLoad, tableMaxHz);
|
||||
u32 targetHz = ResolveTargetHz(SysClkModule_CPU);
|
||||
u32 maxHz = clockManager::GetMaxAllowedHz(SysClkModule_CPU, clockManager::gContext.profile);
|
||||
u32 targetHz = ResolveTargetHz(HocClkModule_CPU);
|
||||
u32 maxHz = clockManager::GetMaxAllowedHz(HocClkModule_CPU, clockManager::gContext.profile);
|
||||
|
||||
if (targetHz && desiredHz > targetHz)
|
||||
desiredHz = targetHz;
|
||||
@@ -157,16 +157,16 @@ namespace governor {
|
||||
downHoldRemaining--;
|
||||
|
||||
if (++tick > 50) {
|
||||
minHz = config::GetConfigValue(HorizonOCConfigValue_CpuGovernorMinimumFreq);
|
||||
minHz = config::GetConfigValue(HocClkConfigValue_CpuGovernorMinimumFreq);
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
if (newHz < minHz)
|
||||
newHz = minHz;
|
||||
|
||||
if ((!goingDown || (downHoldRemaining == 0)) && clockManager::IsAssignableHz(SysClkModule_CPU, newHz)) {
|
||||
board::SetHz(SysClkModule_CPU, newHz);
|
||||
clockManager::gContext.freqs[SysClkModule_CPU] = newHz;
|
||||
if ((!goingDown || (downHoldRemaining == 0)) && clockManager::IsAssignableHz(HocClkModule_CPU, newHz)) {
|
||||
board::SetHz(HocClkModule_CPU, newHz);
|
||||
clockManager::gContext.freqs[HocClkModule_CPU] = newHz;
|
||||
lastHz = newHz;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace governor {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto& table = clockManager::gFreqTable[SysClkModule_GPU];
|
||||
auto& table = clockManager::gFreqTable[HocClkModule_GPU];
|
||||
if (table.count == 0)
|
||||
continue;
|
||||
|
||||
@@ -198,8 +198,8 @@ namespace governor {
|
||||
u32 gpuLoad = board::GetPartLoad(HocClkPartLoad_GPU);
|
||||
u32 tableMaxHz = table.list[table.count - 1];
|
||||
u32 desiredHz = SchedutilTargetHz(gpuLoad, tableMaxHz);
|
||||
u32 targetHz = ResolveTargetHz(SysClkModule_GPU);
|
||||
u32 maxHz = clockManager::GetMaxAllowedHz(SysClkModule_GPU, clockManager::gContext.profile);
|
||||
u32 targetHz = ResolveTargetHz(HocClkModule_GPU);
|
||||
u32 maxHz = clockManager::GetMaxAllowedHz(HocClkModule_GPU, clockManager::gContext.profile);
|
||||
|
||||
if (targetHz && desiredHz > targetHz)
|
||||
desiredHz = targetHz;
|
||||
@@ -218,9 +218,9 @@ namespace governor {
|
||||
if (downHoldRemaining > 0)
|
||||
downHoldRemaining--;
|
||||
|
||||
if ((!goingDown || (downHoldRemaining == 0)) && clockManager::IsAssignableHz(SysClkModule_GPU, newHz)) {
|
||||
board::SetHz(SysClkModule_GPU, newHz);
|
||||
clockManager::gContext.freqs[SysClkModule_GPU] = newHz;
|
||||
if ((!goingDown || (downHoldRemaining == 0)) && clockManager::IsAssignableHz(HocClkModule_GPU, newHz)) {
|
||||
board::SetHz(HocClkModule_GPU, newHz);
|
||||
clockManager::gContext.freqs[HocClkModule_GPU] = newHz;
|
||||
lastHz = newHz;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace governor {
|
||||
|
||||
u8 tick = 0;
|
||||
for (;;) {
|
||||
if (!clockManager::gRunning || clockManager::gContext.profile == SysClkProfile_Docked || !isVRREnabled) {
|
||||
if (!clockManager::gRunning || clockManager::gContext.profile == HocClkProfile_Docked || !isVRREnabled) {
|
||||
svcSleepThread(POLL_NS);
|
||||
continue;
|
||||
}
|
||||
@@ -259,11 +259,11 @@ namespace governor {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
u32 targetHz = clockManager::gContext.overrideFreqs[HorizonOCModule_Display];
|
||||
u32 targetHz = clockManager::gContext.overrideFreqs[HocClkModule_Display];
|
||||
if (!targetHz) {
|
||||
targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HorizonOCModule_Display, clockManager::gContext.profile, false);
|
||||
targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Display, clockManager::gContext.profile, false);
|
||||
if (!targetHz)
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HorizonOCModule_Display, clockManager::gContext.profile, false);
|
||||
targetHz = config::GetAutoClockHz(GLOBAL_PROFILE_ID, HocClkModule_Display, clockManager::gContext.profile, false);
|
||||
}
|
||||
|
||||
u8 maxDisplay;
|
||||
@@ -273,28 +273,28 @@ namespace governor {
|
||||
maxDisplay = 60; // don't assume display stuff!
|
||||
}
|
||||
|
||||
u8 minDisplay = board::GetConsoleType() == HorizonOCConsoleType_Aula ? 45 : 40;
|
||||
u8 minDisplay = board::GetConsoleType() == HocClkConsoleType_Aula ? 45 : 40;
|
||||
if (maxDisplay == minDisplay)
|
||||
continue;
|
||||
|
||||
if (fps >= minDisplay && fps <= maxDisplay) {
|
||||
board::SetHz(HorizonOCModule_Display, fps);
|
||||
clockManager::gContext.freqs[HorizonOCModule_Display] = fps;
|
||||
clockManager::gContext.realFreqs[HorizonOCModule_Display] = fps;
|
||||
board::SetHz(HocClkModule_Display, fps);
|
||||
clockManager::gContext.freqs[HocClkModule_Display] = fps;
|
||||
clockManager::gContext.realFreqs[HocClkModule_Display] = fps;
|
||||
} else {
|
||||
for (u32 i = 0; i < 10; i++) {
|
||||
u32 compareHz = fps * i;
|
||||
if (compareHz >= minDisplay && compareHz <= maxDisplay) {
|
||||
board::SetHz(HorizonOCModule_Display, compareHz);
|
||||
clockManager::gContext.freqs[HorizonOCModule_Display] = compareHz;
|
||||
clockManager::gContext.realFreqs[HorizonOCModule_Display] = compareHz;
|
||||
board::SetHz(HocClkModule_Display, compareHz);
|
||||
clockManager::gContext.freqs[HocClkModule_Display] = compareHz;
|
||||
clockManager::gContext.realFreqs[HocClkModule_Display] = compareHz;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (++tick > 50) {
|
||||
board::SetHz(HorizonOCModule_Display, maxDisplay);
|
||||
board::SetHz(HocClkModule_Display, maxDisplay);
|
||||
tick = 0;
|
||||
svcSleepThread(50'000'000);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include "board/board.hpp"
|
||||
#include "clock_manager.hpp"
|
||||
#include <cstring>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace integrations {
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace ipcService {
|
||||
IpcServer gServer;
|
||||
|
||||
Result GetApiVersion(u32* out_version) {
|
||||
*out_version = SYSCLK_IPC_API_VERSION;
|
||||
*out_version = HOCCLK_IPC_API_VERSION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace ipcService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result GetCurrentContext(SysClkContext* out_ctx) {
|
||||
Result GetCurrentContext(HocClkContext* out_ctx) {
|
||||
*out_ctx = clockManager::GetCurrentContext();
|
||||
return 0;
|
||||
}
|
||||
@@ -66,27 +66,27 @@ namespace ipcService {
|
||||
|
||||
Result GetProfileCount(std::uint64_t* tid, std::uint8_t* out_count) {
|
||||
if (!config::HasProfilesLoaded()) {
|
||||
return SYSCLK_ERROR(ConfigNotLoaded);
|
||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||
}
|
||||
*out_count = config::GetProfileCount(*tid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result GetProfiles(std::uint64_t* tid, SysClkTitleProfileList* out_profiles) {
|
||||
Result GetProfiles(std::uint64_t* tid, HocClkTitleProfileList* out_profiles) {
|
||||
if (!config::HasProfilesLoaded()) {
|
||||
return SYSCLK_ERROR(ConfigNotLoaded);
|
||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||
}
|
||||
config::GetProfiles(*tid, out_profiles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result SetProfiles(SysClkIpc_SetProfiles_Args* args) {
|
||||
Result SetProfiles(HocClkIpc_SetProfiles_Args* args) {
|
||||
if (!config::HasProfilesLoaded()) {
|
||||
return SYSCLK_ERROR(ConfigNotLoaded);
|
||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||
}
|
||||
SysClkTitleProfileList profiles = args->profiles;
|
||||
HocClkTitleProfileList profiles = args->profiles;
|
||||
if (!config::SetProfiles(args->tid, &profiles, true)) {
|
||||
return SYSCLK_ERROR(ConfigSaveFailed);
|
||||
return HOCCLK_ERROR(ConfigSaveFailed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -96,39 +96,39 @@ namespace ipcService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result SetOverride(SysClkIpc_SetOverride_Args* args) {
|
||||
if (!SYSCLK_ENUM_VALID(SysClkModule, args->module)) {
|
||||
return SYSCLK_ERROR(Generic);
|
||||
Result SetOverride(HocClkIpc_SetOverride_Args* args) {
|
||||
if (!HOCCLK_ENUM_VALID(HocClkModule, args->module)) {
|
||||
return HOCCLK_ERROR(Generic);
|
||||
}
|
||||
config::SetOverrideHz(args->module, args->hz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result GetConfigValuesHandler(SysClkConfigValueList* out_configValues) {
|
||||
Result GetConfigValuesHandler(HocClkConfigValueList* out_configValues) {
|
||||
if (!config::HasProfilesLoaded()) {
|
||||
return SYSCLK_ERROR(ConfigNotLoaded);
|
||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||
}
|
||||
config::GetConfigValues(out_configValues);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result SetConfigValuesHandler(SysClkConfigValueList* configValues) {
|
||||
Result SetConfigValuesHandler(HocClkConfigValueList* configValues) {
|
||||
if (!config::HasProfilesLoaded()) {
|
||||
return SYSCLK_ERROR(ConfigNotLoaded);
|
||||
return HOCCLK_ERROR(ConfigNotLoaded);
|
||||
}
|
||||
SysClkConfigValueList copy = *configValues;
|
||||
HocClkConfigValueList copy = *configValues;
|
||||
if (!config::SetConfigValues(©, true)) {
|
||||
return SYSCLK_ERROR(ConfigSaveFailed);
|
||||
return HOCCLK_ERROR(ConfigSaveFailed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result GetFreqList(SysClkIpc_GetFreqList_Args* args, std::uint32_t* out_list, std::size_t size, std::uint32_t* out_count) {
|
||||
if (!SYSCLK_ENUM_VALID(SysClkModule, args->module)) {
|
||||
return SYSCLK_ERROR(Generic);
|
||||
Result GetFreqList(HocClkIpc_GetFreqList_Args* args, std::uint32_t* out_list, std::size_t size, std::uint32_t* out_count) {
|
||||
if (!HOCCLK_ENUM_VALID(HocClkModule, args->module)) {
|
||||
return HOCCLK_ERROR(Generic);
|
||||
}
|
||||
if (args->maxCount != size/sizeof(*out_list)) {
|
||||
return SYSCLK_ERROR(Generic);
|
||||
return HOCCLK_ERROR(Generic);
|
||||
}
|
||||
clockManager::GetFreqList(args->module, out_list, args->maxCount, out_count);
|
||||
return 0;
|
||||
@@ -137,11 +137,11 @@ namespace ipcService {
|
||||
Result ServiceHandlerFunc(void* arg, const IpcServerRequest* r, u8* out_data, size_t* out_dataSize) {
|
||||
(void)arg;
|
||||
switch (r->data.cmdId) {
|
||||
case SysClkIpcCmd_GetApiVersion:
|
||||
case HocClkIpcCmd_GetApiVersion:
|
||||
*out_dataSize = sizeof(u32);
|
||||
return GetApiVersion((u32*)out_data);
|
||||
|
||||
case SysClkIpcCmd_GetVersionString:
|
||||
case HocClkIpcCmd_GetVersionString:
|
||||
if (r->hipc.meta.num_recv_buffers >= 1) {
|
||||
return GetVersionString(
|
||||
(char*)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
||||
@@ -150,75 +150,75 @@ namespace ipcService {
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_GetCurrentContext:
|
||||
case HocClkIpcCmd_GetCurrentContext:
|
||||
if (r->data.size >= sizeof(std::uint64_t) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
||||
if (bufSize >= sizeof(SysClkContext)) {
|
||||
return GetCurrentContext((SysClkContext*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
if (bufSize >= sizeof(HocClkContext)) {
|
||||
return GetCurrentContext((HocClkContext*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_Exit:
|
||||
case HocClkIpcCmd_Exit:
|
||||
return ExitHandler();
|
||||
|
||||
case SysClkIpcCmd_GetProfileCount:
|
||||
case HocClkIpcCmd_GetProfileCount:
|
||||
if (r->data.size >= sizeof(std::uint64_t)) {
|
||||
*out_dataSize = sizeof(std::uint8_t);
|
||||
return GetProfileCount((std::uint64_t*)r->data.ptr, (std::uint8_t*)out_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_GetProfiles:
|
||||
case HocClkIpcCmd_GetProfiles:
|
||||
if (r->data.size >= sizeof(std::uint64_t) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
||||
if (bufSize >= sizeof(SysClkTitleProfileList)) {
|
||||
return GetProfiles((std::uint64_t*)r->data.ptr, (SysClkTitleProfileList*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
if (bufSize >= sizeof(HocClkTitleProfileList)) {
|
||||
return GetProfiles((std::uint64_t*)r->data.ptr, (HocClkTitleProfileList*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_SetProfiles:
|
||||
if (r->data.size >= sizeof(SysClkIpc_SetProfiles_Args)) {
|
||||
return SetProfiles((SysClkIpc_SetProfiles_Args*)r->data.ptr);
|
||||
case HocClkIpcCmd_SetProfiles:
|
||||
if (r->data.size >= sizeof(HocClkIpc_SetProfiles_Args)) {
|
||||
return SetProfiles((HocClkIpc_SetProfiles_Args*)r->data.ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_SetEnabled:
|
||||
case HocClkIpcCmd_SetEnabled:
|
||||
if (r->data.size >= sizeof(std::uint8_t)) {
|
||||
return SetEnabled((std::uint8_t*)r->data.ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_SetOverride:
|
||||
if (r->data.size >= sizeof(SysClkIpc_SetOverride_Args)) {
|
||||
return SetOverride((SysClkIpc_SetOverride_Args*)r->data.ptr);
|
||||
case HocClkIpcCmd_SetOverride:
|
||||
if (r->data.size >= sizeof(HocClkIpc_SetOverride_Args)) {
|
||||
return SetOverride((HocClkIpc_SetOverride_Args*)r->data.ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_GetConfigValues:
|
||||
case HocClkIpcCmd_GetConfigValues:
|
||||
if (r->hipc.meta.num_recv_buffers >= 1) {
|
||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
||||
if (bufSize >= sizeof(SysClkConfigValueList)) {
|
||||
return GetConfigValuesHandler((SysClkConfigValueList*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
if (bufSize >= sizeof(HocClkConfigValueList)) {
|
||||
return GetConfigValuesHandler((HocClkConfigValueList*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_SetConfigValues:
|
||||
case HocClkIpcCmd_SetConfigValues:
|
||||
if (r->hipc.meta.num_send_buffers >= 1) {
|
||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.send_buffers);
|
||||
if (bufSize >= sizeof(SysClkConfigValueList)) {
|
||||
return SetConfigValuesHandler((SysClkConfigValueList*)hipcGetBufferAddress(r->hipc.data.send_buffers));
|
||||
if (bufSize >= sizeof(HocClkConfigValueList)) {
|
||||
return SetConfigValuesHandler((HocClkConfigValueList*)hipcGetBufferAddress(r->hipc.data.send_buffers));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SysClkIpcCmd_GetFreqList:
|
||||
if (r->data.size >= sizeof(SysClkIpc_GetFreqList_Args) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||
case HocClkIpcCmd_GetFreqList:
|
||||
if (r->data.size >= sizeof(HocClkIpc_GetFreqList_Args) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||
*out_dataSize = sizeof(std::uint32_t);
|
||||
return GetFreqList(
|
||||
(SysClkIpc_GetFreqList_Args*)r->data.ptr,
|
||||
(HocClkIpc_GetFreqList_Args*)r->data.ptr,
|
||||
(std::uint32_t*)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
||||
hipcGetBufferSize(r->hipc.data.recv_buffers),
|
||||
(std::uint32_t*)out_data
|
||||
@@ -234,7 +234,7 @@ namespace ipcService {
|
||||
break;
|
||||
}
|
||||
|
||||
return SYSCLK_ERROR(Generic);
|
||||
return HOCCLK_ERROR(Generic);
|
||||
}
|
||||
|
||||
void ProcessThreadFunc(void* arg) {
|
||||
@@ -259,7 +259,7 @@ namespace ipcService {
|
||||
std::int32_t priority;
|
||||
Result rc = svcGetThreadPriority(&priority, CUR_THREAD_HANDLE);
|
||||
ASSERT_RESULT_OK(rc, "svcGetThreadPriority");
|
||||
rc = ipcServerInit(&gServer, SYSCLK_IPC_SERVICE_NAME, 42);
|
||||
rc = ipcServerInit(&gServer, HOCCLK_IPC_SERVICE_NAME, 42);
|
||||
ASSERT_RESULT_OK(rc, "ipcServerInit");
|
||||
rc = threadCreate(&gThread, &ProcessThreadFunc, nullptr, NULL, 0x2000, priority, -2);
|
||||
ASSERT_RESULT_OK(rc, "threadCreate");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include <switch.h>
|
||||
|
||||
namespace ipcService {
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace kip {
|
||||
void SetKipData()
|
||||
{
|
||||
// TODO: figure out if this REALLY causes issues (i doubt it)
|
||||
// if(board::GetSocType() == SysClkSocType_Mariko) {
|
||||
// if(board::GetSocType() == HocClkSocType_Mariko) {
|
||||
// if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) {
|
||||
// fileUtils::LogLine("[clock_manager] Failed set i2c vddq");
|
||||
// notification::writeNotification("Horizon OC\nFailed to write I2C\nwhile setting vddq");
|
||||
@@ -108,11 +108,11 @@ namespace kip {
|
||||
CUST_WRITE_FIELD_BATCH(&table, gpuSpeedo, config::GetConfigValue(KipConfigValue_gpuSpeedo));
|
||||
|
||||
for (int i = 0; i < 24; i++) {
|
||||
table.marikoGpuVoltArray[i] = config::GetConfigValue((SysClkConfigValue)(KipConfigValue_g_volt_76800 + i));
|
||||
table.marikoGpuVoltArray[i] = config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_76800 + i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 27; i++) {
|
||||
table.eristaGpuVoltArray[i] = config::GetConfigValue((SysClkConfigValue)(KipConfigValue_g_volt_e_76800 + i));
|
||||
table.eristaGpuVoltArray[i] = config::GetConfigValue((HocClkConfigValue)(KipConfigValue_g_volt_e_76800 + i));
|
||||
}
|
||||
|
||||
CUST_WRITE_FIELD_BATCH(&table, t6_tRTW_fine_tune, config::GetConfigValue(KipConfigValue_t6_tRTW_fine_tune));
|
||||
@@ -123,7 +123,7 @@ namespace kip {
|
||||
notification::writeNotification("Horizon OC\nKip write failed");
|
||||
}
|
||||
|
||||
SysClkConfigValueList configValues;
|
||||
HocClkConfigValueList configValues;
|
||||
config::GetConfigValues(&configValues);
|
||||
|
||||
configValues.values[KipCrc32] = (u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
||||
@@ -153,7 +153,7 @@ namespace kip {
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
SysClkConfigValueList configValues;
|
||||
HocClkConfigValueList configValues;
|
||||
config::GetConfigValues(&configValues);
|
||||
|
||||
CustomizeTable table;
|
||||
@@ -236,7 +236,7 @@ namespace kip {
|
||||
// if(cust_get_cust_rev(&table) == KIP_CUST_REV)
|
||||
// return;
|
||||
|
||||
if (sizeof(SysClkConfigValueList) <= sizeof(configValues)) {
|
||||
if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) {
|
||||
if (config::SetConfigValues(&configValues, false)) {
|
||||
fileUtils::LogLine("[clock_manager] Successfully loaded KIP data into config");
|
||||
} else {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
#include "soctherm.hpp"
|
||||
#include "board/board.hpp"
|
||||
#include "file_utils.hpp"
|
||||
@@ -551,7 +551,7 @@ namespace soctherm {
|
||||
temps.gpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) & SENSOR_TEMP1_GPU_TEMP_MASK);
|
||||
temps.pllx = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP2) & SENSOR_TEMP2_PLLX_TEMP_MASK);
|
||||
|
||||
if (board::GetSocType() == SysClkSocType_Erista) {
|
||||
if (board::GetSocType() == HocClkSocType_Erista) {
|
||||
temps.mem = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP2) >> 16);
|
||||
} else {
|
||||
temps.mem = -1;
|
||||
@@ -617,7 +617,7 @@ namespace soctherm {
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
isMariko = board::GetSocType() == SysClkSocType_Mariko;
|
||||
isMariko = board::GetSocType() == HocClkSocType_Mariko;
|
||||
|
||||
constexpr u64 SocthermPa = 0x700E2000, FusePa = 0x7000F000, CarPa = 0x60006000;
|
||||
R_UNLESS(MapAddress(socthermVa, SocthermPa, "soctherm"));
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
namespace soctherm {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user