sysclk: fix refresh rate on lite

also increase heap size due to larger ipc packets
This commit is contained in:
souldbminersmwc
2026-03-20 20:03:36 -04:00
parent 2454afd58f
commit 95e68bd27e
8 changed files with 62 additions and 77 deletions

View File

@@ -24,8 +24,6 @@
* --------------------------------------------------------------------------
*/
// Note: Hoag crashes on display refresh rate init while in sleep mode
#include <nxExt.h>
#include "board.h"
#include "errors.h"
@@ -282,17 +280,15 @@ void Board::Initialize()
pwmCheck = pwmOpenSession2(&g_ICon, 0x3D000001);
}
if(!IsHoag()) {
u64 clkVirtAddr, dsiVirtAddr, outsize;
rc = svcQueryMemoryMapping(&clkVirtAddr, &outsize, 0x60006000, 0x1000);
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (clk)");
rc = svcQueryMemoryMapping(&dsiVirtAddr, &outsize, 0x54300000, 0x40000);
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (dsi)");
u64 clkVirtAddr, dsiVirtAddr, outsize;
rc = svcQueryMemoryMapping(&clkVirtAddr, &outsize, 0x60006000, 0x1000);
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (clk)");
rc = svcQueryMemoryMapping(&dsiVirtAddr, &outsize, 0x54300000, 0x40000);
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (dsi)");
DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr};
DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr, .isLite = IsHoag()};
DisplayRefresh_Initialize(&cfg);
}
DisplayRefresh_Initialize(&cfg);
rc = svcQueryMemoryMapping(&cldvfs, &cldvfs_temp, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (cldvfs)");
@@ -420,14 +416,15 @@ void Board::Exit()
// threadClose(&cpuCore3Thread);
threadClose(&miscThread);
DisplayRefresh_Shutdown();
pwmChannelSessionClose(&g_ICon);
pwmExit();
rgltrExit();
batteryInfoExit();
pmdmntExit();
nvExit();
if(!IsHoag())
DisplayRefresh_Shutdown();
}
SysClkProfile Board::GetProfile()
@@ -462,8 +459,7 @@ void Board::SetHz(SysClkModule module, std::uint32_t hz)
{
Result rc = 0;
if(module == HorizonOCModule_Display) {
if(!IsHoag())
DisplayRefresh_SetRate(hz);
DisplayRefresh_SetRate(hz);
return;
}
if(module > SysClkModule_MEM)
@@ -501,10 +497,7 @@ std::uint32_t Board::GetHz(SysClkModule module)
std::uint32_t hz = 0;
if(module == HorizonOCModule_Display) {
if(!IsHoag())
DisplayRefresh_GetRate(&hz, false);
else
hz = 60;
DisplayRefresh_GetRate(&hz, false);
return hz;
}
@@ -541,10 +534,7 @@ std::uint32_t Board::GetRealHz(SysClkModule module)
case SysClkModule_MEM:
return t210ClkMemFreq();
case HorizonOCModule_Display:
if(!IsHoag())
DisplayRefresh_GetRate(&hz, false);
else
hz = 60;
DisplayRefresh_GetRate(&hz, false);
return hz;
default:
ASSERT_ENUM_VALID(SysClkModule, module);
@@ -739,8 +729,7 @@ void Board::ResetToStockGpu()
}
void Board::ResetToStockDisplay() {
if(!IsHoag())
DisplayRefresh_SetRate(60);
DisplayRefresh_SetRate(60);
}
u8 Board::GetHighestDockedDisplayRate() {

View File

@@ -495,11 +495,6 @@ void ClockManager::VRRThread(void* arg) {
continue;
}
if(Board::IsHoag()) { // don't do anything on lite
svcSleepThread(~0ULL);
continue;
}
std::scoped_lock lock{mgr->contextMutex};
u8 fps;
@@ -566,7 +561,7 @@ void ClockManager::VRRThread(void* arg) {
}
u8 cached_RR = 60;
void ClockManager::HandleSafetyFeatures() {
AppletOperationMode opMode = appletGetOperationMode();
if(this->config->GetConfigValue(HocClkConfigValue_HandheldTDP) && opMode == AppletOperationMode_Handheld) {
@@ -730,7 +725,7 @@ void ClockManager::HandleFreqReset(SysClkModule module, bool isBoost) {
DVFSReset();
break;
case HorizonOCModule_Display:
if(this->config->GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate) && !Board::IsHoag()) {
if(this->config->GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate)) {
Board::ResetToStockDisplay();
}
break;
@@ -776,17 +771,15 @@ void ClockManager::SetClocks(bool isBoost) {
bool noCPU = isCpuGovernorEnabled;
bool noGPU = isGpuGovernorEnabled;
if(!Board::IsHoag()) {
bool noDisp = isVRREnabled;
if(noDisp && module == HorizonOCModule_Display)
continue;
bool noDisp = isVRREnabled;
if(noDisp && module == HorizonOCModule_Display)
continue;
if(module == HorizonOCModule_Display && this->config->GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate)) {
if(targetHz)
Board::SetHz(HorizonOCModule_Display, targetHz);
else
Board::ResetToStockDisplay();
}
if(module == HorizonOCModule_Display && this->config->GetConfigValue(HorizonOCConfigValue_OverwriteRefreshRate)) {
if(targetHz)
Board::SetHz(HorizonOCModule_Display, targetHz);
else
Board::ResetToStockDisplay();
}
// Skip GPU and CPU if governors handle them
@@ -991,20 +984,19 @@ bool ClockManager::RefreshContext()
}
// this->context->maxDisplayFreq = Board::GetHighestDockedDisplayRate();
if(!Board::IsHoag()) {
u32 targetHz = this->context->overrideFreqs[HorizonOCModule_Display];
if (!targetHz)
{
targetHz = this->config->GetAutoClockHz(this->context->applicationId, HorizonOCModule_Display, this->context->profile, true);
if(!targetHz)
targetHz = this->config->GetAutoClockHz(GLOBAL_PROFILE_ID, HorizonOCModule_Display, this->context->profile, true);
}
if(targetHz && this->context->realFreqs[HorizonOCModule_Display] > targetHz && this->context->profile != SysClkProfile_Docked)
this->context->realFreqs[HorizonOCModule_Display] = targetHz; // clean up display real freqs, should probably be moved to the real freqs loop?
Board::SetDisplayRefreshDockedState(this->context->profile == SysClkProfile_Docked);
u32 targetHz = this->context->overrideFreqs[HorizonOCModule_Display];
if (!targetHz)
{
targetHz = this->config->GetAutoClockHz(this->context->applicationId, HorizonOCModule_Display, this->context->profile, true);
if(!targetHz)
targetHz = this->config->GetAutoClockHz(GLOBAL_PROFILE_ID, HorizonOCModule_Display, this->context->profile, true);
}
if(targetHz && this->context->realFreqs[HorizonOCModule_Display] > targetHz && this->context->profile != SysClkProfile_Docked)
this->context->realFreqs[HorizonOCModule_Display] = targetHz; // clean up display real freqs, should probably be moved to the real freqs loop?
if(!Board::IsHoag())
Board::SetDisplayRefreshDockedState(this->context->profile == SysClkProfile_Docked);
if(this->context->isSaltyNXInstalled)
this->context->fps = saltyNXIntegration->GetFPS();
else

View File

@@ -36,7 +36,7 @@
#include "process_management.h"
#include "clock_manager.h"
#include "ipc_service.h"
#define INNER_HEAP_SIZE 0x40000
#define INNER_HEAP_SIZE 0x45000
extern "C"