[Sys-clk-OC] Add RAM freq selection

This commit is contained in:
KazushiM
2021-12-11 20:21:20 +08:00
parent 46c0cb88c3
commit 314b769708
14 changed files with 47 additions and 28 deletions

View File

@@ -38,7 +38,7 @@ This project will not be actively maintained by me and I'm looking for collabora
- Anything above that are not in the table of official module. ([issue #4](https://github.com/KazushiMe/Switch-OC-Suite/issues/4))
- **Recommended RAM clock: 1862.4 MHz**.
- **RAM clock is set permanently** via patching ptm module, rather than sys-clk.
- Only 1331.2 and MAX MHz could be selected in sys-clk.
- Apply thermal paste on RAM chips and test with emuNAND before long-term usage.
- DRAM Timing Table Adjustment:
- 2131.2 MHz should be usable and stable for all, with throughput reached about 24.7GiB/s. (theoretical bandwidth: 31.76GiB/s @ 2131.2 MHz)
@@ -82,14 +82,19 @@ This project will not be actively maintained by me and I'm looking for collabora
[A111111111111111]
docked_cpu=
docked_gpu=
docked_mem=
handheld_charging_cpu=
handheld_charging_gpu=
handheld_charging_mem=
handheld_charging_usb_cpu=
handheld_charging_usb_gpu=
handheld_charging_usb_mem=
handheld_charging_official_cpu=
handheld_charging_official_gpu=
handheld_charging_official_mem=
handheld_cpu=
handheld_gpu=
handheld_mem=
```
- Disable background services, less heat and power consumption in standby mode

Binary file not shown.

View File

@@ -279,16 +279,16 @@ namespace ams::ldr {
}
}
u32 PtmEmcClock = GetEmcClock() * 1000;
// u32 PtmEmcClock = GetEmcClock() * 1000;
u32 CpuBoostClock = GetCpuBoostClock() * 1000;
for (u32 i = 0; i < sizeof(PtmModuleId)/sizeof(ro::ModuleId); i++) {
if (std::memcmp(std::addressof(PtmModuleId[i]), std::addressof(module_id), sizeof(module_id)) == 0) {
for (u32 j = 0; j < 16; j++) {
std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClock, sizeof(PtmEmcClock));
std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClock, sizeof(PtmEmcClock));
}
// for (u32 j = 0; j < 16; j++) {
// std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClock, sizeof(PtmEmcClock));
// std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClock, sizeof(PtmEmcClock));
// }
for (u32 j = 0; j < 2; j++) {
std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j), &CpuBoostClock, sizeof(CpuBoostClock));
std::memcpy(reinterpret_cast<void *>(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j + 0x4), &CpuBoostClock, sizeof(CpuBoostClock));

View File

@@ -131,14 +131,19 @@ Presets can be customized by adding them to the ini config file located at `/con
[Application Title ID]
docked_cpu=
docked_gpu=
docked_mem=
handheld_charging_cpu=
handheld_charging_gpu=
handheld_charging_mem=
handheld_charging_usb_cpu=
handheld_charging_usb_gpu=
handheld_charging_usb_mem=
handheld_charging_official_cpu=
handheld_charging_official_gpu=
handheld_charging_official_mem=
handheld_cpu=
handheld_gpu=
handheld_mem=
```
* Replace `Application Title ID` with the title id of the game/application you're interested in customizing.
@@ -160,6 +165,7 @@ Leads to a smoother framerate overall (ex: in the korok forest)
[01007EF00011E000]
docked_cpu=1224
handheld_charging_cpu=1224
handheld_mem=1600
```
### Example 2: Picross

View File

@@ -77,7 +77,7 @@ AdvancedSettingsTab::AdvancedSettingsTab()
});
// MEM
/*brls::SelectListItem *memFreqListItem = createFreqListItem(SysClkModule_MEM, context.overrideFreqs[SysClkModule_MEM] / 1000000);
brls::SelectListItem *memFreqListItem = createFreqListItem(SysClkModule_MEM, context.overrideFreqs[SysClkModule_MEM] / 1000000);
memFreqListItem->getValueSelectedEvent()->subscribe([](int result)
{
Result rc = result == 0 ?
@@ -90,7 +90,7 @@ AdvancedSettingsTab::AdvancedSettingsTab()
errorResult(result == 0 ? "sysclkIpcRemoveOverride" : "sysclkIpcSetOverride", rc);
// TODO: Reset selected value
}
});*/
});
this->addView(cpuFreqListItem);
this->addView(gpuFreqListItem);

View File

@@ -116,7 +116,7 @@ void AppProfileFrame::addFreqs(brls::List* list, SysClkProfile profile)
list->addView(gpuListItem);
// MEM
/*brls::SelectListItem* memListItem = createFreqListItem(SysClkModule_MEM, this->profiles.mhzMap[profile][SysClkModule_MEM]);
brls::SelectListItem* memListItem = createFreqListItem(SysClkModule_MEM, this->profiles.mhzMap[profile][SysClkModule_MEM]);
this->profiles.mhzMap[profile][SysClkModule_MEM] *= 1000000;
@@ -126,7 +126,7 @@ void AppProfileFrame::addFreqs(brls::List* list, SysClkProfile profile)
brls::Logger::debug("Caching freq for module %d and profile %d to %" PRIu32, SysClkModule_MEM, profile, this->profiles.mhzMap[profile][SysClkModule_MEM]);
});
list->addView(memListItem);*/
list->addView(memListItem);
}
void AppProfileFrame::onProfileChanged()

View File

@@ -110,7 +110,10 @@ brls::SelectListItem* createFreqListItem(SysClkModule module, uint32_t selectedF
selected = i + 1;
char clock[16];
snprintf(clock, sizeof(clock), "%d MHz", freq / 1000000);
if (freq == 1600000000)
snprintf(clock, sizeof(clock), "Max MHz");
else
snprintf(clock, sizeof(clock), "%d MHz", freq / 1000000);
clocks.push_back(std::string(clock));

View File

@@ -20,6 +20,10 @@ static inline std::string formatListFreqMhz(std::uint32_t mhz)
{
return FREQ_DEFAULT_TEXT;
}
else if (mhz == 1600)
{
return "Max MHz";
}
char buf[10];
return std::string(buf, snprintf(buf, sizeof(buf), "%u MHz", mhz));

View File

@@ -62,7 +62,7 @@ void AppProfileGui::addProfileUI(SysClkProfile profile)
this->listElement->addItem(new tsl::elm::CategoryHeader(sysclkFormatProfile(profile, true)));
this->addModuleListItem(profile, SysClkModule_CPU, &sysclk_g_freq_table_cpu_hz[0]);
this->addModuleListItem(profile, SysClkModule_GPU, &sysclk_g_freq_table_gpu_hz[0]);
//this->addModuleListItem(profile, SysClkModule_MEM, &sysclk_g_freq_table_mem_hz[0]);
this->addModuleListItem(profile, SysClkModule_MEM, &sysclk_g_freq_table_mem_hz[0]);
}
void AppProfileGui::listUI()

View File

@@ -62,7 +62,7 @@ void GlobalOverrideGui::listUI()
{
this->addModuleListItem(SysClkModule_CPU, &sysclk_g_freq_table_cpu_hz[0]);
this->addModuleListItem(SysClkModule_GPU, &sysclk_g_freq_table_gpu_hz[0]);
//this->addModuleListItem(SysClkModule_MEM, &sysclk_g_freq_table_mem_hz[0]);
this->addModuleListItem(SysClkModule_MEM, &sysclk_g_freq_table_mem_hz[0]);
}
void GlobalOverrideGui::refresh()

View File

@@ -214,7 +214,7 @@ void ClockManager::Tick()
{
std::uint32_t hz = 0;
std::uint32_t hzForceOverride = 0;
for (unsigned int module = 0; module < SysClkModule_EnumMax - 1; module++)
for (unsigned int module = 0; module < SysClkModule_EnumMax; module++)
{
hz = this->context->overrideFreqs[module];
@@ -239,6 +239,13 @@ void ClockManager::Tick()
else
hz = 768'000'000;
break;
case SysClkModule_MEM:
if (!isDockedReverseNX && ((FileUtils::IsDownclockDockEnabled() && RealProfile == SysClkProfile_Docked)
|| RealProfile != SysClkProfile_Docked))
hz = 1331'200'000;
else
hz = 1600'000'000;
break;
}
}
@@ -247,6 +254,10 @@ void ClockManager::Tick()
if (hz)
{
hz = Clocks::GetNearestHz((SysClkModule)module, isEnabledReverseNX ? RealProfile : this->context->profile, hz);
if (module == SysClkModule_MEM && hz == 1600'000'000 && this->context->freqs[module] >= hz)
{
continue;
}
if (hz != this->context->freqs[module] && this->context->enabled)
{
@@ -442,13 +453,6 @@ bool ClockManager::RefreshContext()
{
hz = Clocks::GetCurrentHz((SysClkModule)module);
// Skip MEM freq check
if (module == SysClkModule_MEM)
{
this->context->freqs[module] = hz;
break;
}
// Round to MHz
uint32_t cur_mhz = hz/1000'000;
uint32_t be4_mhz = this->context->freqs[module]/1000'000;

View File

@@ -179,10 +179,10 @@ void Clocks::ResetToStock(unsigned int module)
{
Clocks::SetHz(SysClkModule_GPU, apmConfiguration->gpu_hz);
}
// if (module == SysClkModule_EnumMax || module == SysClkModule_MEM)
// {
// Clocks::SetHz(SysClkModule_MEM, apmConfiguration->mem_hz);
// }
if (module == SysClkModule_EnumMax || module == SysClkModule_MEM)
{
Clocks::SetHz(SysClkModule_MEM, apmConfiguration->mem_hz);
}
}
else
{
@@ -225,9 +225,6 @@ SysClkProfile Clocks::GetCurrentProfile()
void Clocks::SetHz(SysClkModule module, std::uint32_t hz)
{
if (module == SysClkModule_MEM)
return;
Result rc = 0;
if(hosversionAtLeast(8,0,0))