diff --git a/README.md b/README.md index ca00c839..bad189fd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Join the chat at https://gitter.im/Switch-OC-Suite/community](https://badges.gitter.im/Switch-OC-Suite/community.svg)](https://gitter.im/Switch-OC-Suite/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -Overclocking suite for Switch **(Mariko Only)** running on Atmosphere CFW. Support Horizon OS 11.0.0-13.2.0. +Overclocking suite for Switch **(Mariko Only)** running on Atmosphere CFW. Support Horizon OS 13.0.0-13.2.0. This project will not be actively maintained by me and I'm looking for collaborators. Open an issue if you are interested and would like to be added into the maintainer list. @@ -22,8 +22,9 @@ This project will not be actively maintained by me and I'm looking for collabora - **Fan Control Optimization** at high load - **Modded sys-clk and ReverseNX**(-Tools and -RT) - **No need to change clocks manually** after toggling modes in ReverseNX - - Auto-Boost CPU for faster game loading - - Global clock override for all profiles + - **Auto-Boost CPU** for faster game loading + - Permanent global clock override for all profiles + - View charger & battery info, toggle charging/fast-charging in overlay - System Settings - Disable background services, less heat and power consumption in standby mode - Game recording and SysDVR streaming @ 60fps with high video bitrate @@ -39,12 +40,12 @@ This project will not be actively maintained by me and I'm looking for collabora - **Official X1+ CPU/GPU Max clock: 1963.5/1267.2 MHz**. - 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**. - - Only 1331.2 and MAX MHz could be selected in sys-clk. + - **Recommended RAM clock: 1862.4/1996.8 MHz**. + - Only 1600 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 stable for some Micron chips with ~24.8GiB/s throughput without overvolting. (theoretical bandwidth: 31.76GiB/s @ 2131.2 MHz) - - 1862.4 MHz is stable for all. (~23.0 GB/s) + - 2131.2 MHz should be stable for some chips. (theoretical bandwidth: 31.76GiB/s @ 2131.2 MHz) + - 1862.4/1996.8 MHz should be stable for all. - See [issue #5](https://github.com/KazushiMe/Switch-OC-Suite/issues/5) for more info on DRAM OC and timings @@ -55,7 +56,7 @@ This project will not be actively maintained by me and I'm looking for collabora - CPU overvolting: 1220 mV, up from default 1120 mV. Frequencies ≥ 2193 MHz will enable overvolting. - GPU overvolting: 1170 mV, default 1050 mV. Frequencies ≥ 1420 Mhz trigger overvolting. ([issue #4](https://github.com/KazushiMe/Switch-OC-Suite/issues/4)) - - You cannot set ≥ 1344 MHz without official chargers. + - You cannot set > 1267 MHz without official chargers. - RAM [NOT RECOMMENDED] - Only diff patch for hekate bootloader is provided. @@ -70,6 +71,7 @@ This project will not be actively maintained by me and I'm looking for collabora - Higher tolerable temperature and smoother fan curve. Set `holdable_tskin` to 56˚C. Previously it's set to 48˚C, so by default the fan would go crazy (80~100%) easily with a slight degree of OC. - Replace crappy factory thermal paste is preferred. - Place a thermal pad onto Wi-Fi/BT module (shielded, adjacent to antennas) to lower tskin temperature. + - Not tested on Aula, which has lower temperature tolerance. - **Modded sys-clk and ReverseNX**(-Tools and -RT) - **No need to change clocks manually** after toggling modes in ReverseNX @@ -78,7 +80,7 @@ This project will not be actively maintained by me and I'm looking for collabora - **Auto-Boost CPU for faster game loading** - Enable CPU Boost (1963.5 MHz) if CPU Core#3 (System Core) is stressed, especially when the game is loading assets from eMMC/SD card. - Auto-Boost will be enabled only when charger is connected. (>90% w/ PD charger or >95% w/ unsupported charger) - - To **disable this feature**, simply remove `boost.flag` in `/config/sys-clk/ `. + - To **disable this feature**, simply remove `boost.flag` in `/config/sys-clk/`. - Disable background services, less heat and power consumption in standby mode - **Remove** the "Disable Background service" part in `/atmosphere/config/system_settings.ini` if you **use Nintendo Online services**. diff --git a/SdOut/atmosphere/1.2.5_loader_1862.4.kip b/SdOut/atmosphere/1.2.5_loader_1862.4.kip new file mode 100644 index 00000000..65695fb5 Binary files /dev/null and b/SdOut/atmosphere/1.2.5_loader_1862.4.kip differ diff --git a/SdOut/atmosphere/1.2.5_loader_1862.4_timing_adjusted.kip b/SdOut/atmosphere/1.2.5_loader_1862.4_timing_adjusted.kip deleted file mode 100644 index 33183fc0..00000000 Binary files a/SdOut/atmosphere/1.2.5_loader_1862.4_timing_adjusted.kip and /dev/null differ diff --git a/SdOut/atmosphere/1.2.5_loader_1996.8.kip b/SdOut/atmosphere/1.2.5_loader_1996.8.kip new file mode 100644 index 00000000..e646bfa6 Binary files /dev/null and b/SdOut/atmosphere/1.2.5_loader_1996.8.kip differ diff --git a/SdOut/atmosphere/1.2.5_loader_2131.2.kip b/SdOut/atmosphere/1.2.5_loader_2131.2.kip new file mode 100644 index 00000000..2f91b846 Binary files /dev/null and b/SdOut/atmosphere/1.2.5_loader_2131.2.kip differ diff --git a/SdOut/atmosphere/1.2.5_loader_2131.2_timing_adjusted.kip b/SdOut/atmosphere/1.2.5_loader_2131.2_timing_adjusted.kip deleted file mode 100644 index 6b1a33e8..00000000 Binary files a/SdOut/atmosphere/1.2.5_loader_2131.2_timing_adjusted.kip and /dev/null differ diff --git a/SdOut/atmosphere/contents/00FF0000636C6BFF/exefs.nsp b/SdOut/atmosphere/contents/00FF0000636C6BFF/exefs.nsp index b707d506..9f03d495 100644 Binary files a/SdOut/atmosphere/contents/00FF0000636C6BFF/exefs.nsp and b/SdOut/atmosphere/contents/00FF0000636C6BFF/exefs.nsp differ diff --git a/SdOut/atmosphere/old_1.2.5_loader_1795.2_hynix.kip b/SdOut/atmosphere/old_1.2.5_loader_1795.2_hynix.kip deleted file mode 100644 index 0eaa6de2..00000000 Binary files a/SdOut/atmosphere/old_1.2.5_loader_1795.2_hynix.kip and /dev/null differ diff --git a/SdOut/atmosphere/old_1.2.5_loader_1862.4_hynix.kip b/SdOut/atmosphere/old_1.2.5_loader_1862.4_hynix.kip deleted file mode 100644 index bce9f301..00000000 Binary files a/SdOut/atmosphere/old_1.2.5_loader_1862.4_hynix.kip and /dev/null differ diff --git a/SdOut/atmosphere/old_1.2.5_loader_1996.8_micron_samsung.kip b/SdOut/atmosphere/old_1.2.5_loader_1996.8_micron_samsung.kip deleted file mode 100644 index 23bd7eb1..00000000 Binary files a/SdOut/atmosphere/old_1.2.5_loader_1996.8_micron_samsung.kip and /dev/null differ diff --git a/SdOut/atmosphere/old_1.2.5_loader_2064.0_samsung.kip b/SdOut/atmosphere/old_1.2.5_loader_2064.0_samsung.kip deleted file mode 100644 index fe831139..00000000 Binary files a/SdOut/atmosphere/old_1.2.5_loader_2064.0_samsung.kip and /dev/null differ diff --git a/SdOut/switch/.overlays/sys-clk-overlay.ovl b/SdOut/switch/.overlays/sys-clk-overlay.ovl index 62d4457d..fcdcb021 100644 Binary files a/SdOut/switch/.overlays/sys-clk-overlay.ovl and b/SdOut/switch/.overlays/sys-clk-overlay.ovl differ diff --git a/SdOut/switch/sys-clk-manager.nro b/SdOut/switch/sys-clk-manager.nro index 23c1857f..0ded5df5 100644 Binary files a/SdOut/switch/sys-clk-manager.nro and b/SdOut/switch/sys-clk-manager.nro differ diff --git a/Source/Atmosphere/stratosphere/loader/source/ldr_oc_patch.hpp b/Source/Atmosphere/stratosphere/loader/source/ldr_oc_patch.hpp index a14a1161..16fb9221 100644 --- a/Source/Atmosphere/stratosphere/loader/source/ldr_oc_patch.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/ldr_oc_patch.hpp @@ -1,12 +1,12 @@ //#define EXPERIMENTAL constexpr ro::ModuleId PcvModuleId[] = { - ParseModuleId("91D61D59D7002378E35584FC0B38C7693A3ABAB5"), //11.0.0 - ParseModuleId("C503E96550F302E121873136B814A529863D949B"), //12.x + // ParseModuleId("91D61D59D7002378E35584FC0B38C7693A3ABAB5"), //11.0.0 + // ParseModuleId("C503E96550F302E121873136B814A529863D949B"), //12.x ParseModuleId("2058C97C551571506656AA04EC85E2B1B01B155C"), //13.0.0-13.2.0 }; constexpr ro::ModuleId PtmModuleId[] = { - ParseModuleId("A79706954C6C45568B0FFE610627E2E89D8FB0D4"), //12.x + // ParseModuleId("A79706954C6C45568B0FFE610627E2E89D8FB0D4"), //12.x ParseModuleId("2CA78D4066C1C11317CC2705EBADA9A51D3AC981"), //13.0.0-13.2.0 }; @@ -39,24 +39,24 @@ namespace pcv { /* CPU */ constexpr u32 CpuVoltageLimitOffsets[][11] = { - { 0xE1A8C, 0xE1A98, 0xE1AA4, 0xE1AB0, 0xE1AF8, 0xE1B04, 0xE1B10, 0xE1B1C, 0xE1B28, 0xE1B34, 0xE1F4C }, - { 0xF08DC, 0xF08E8, 0xF08F4, 0xF0900, 0xF0948, 0xF0954, 0xF0960, 0xF096C, 0xF0978, 0xF0984, 0xF0D9C }, + // { 0xE1A8C, 0xE1A98, 0xE1AA4, 0xE1AB0, 0xE1AF8, 0xE1B04, 0xE1B10, 0xE1B1C, 0xE1B28, 0xE1B34, 0xE1F4C }, + // { 0xF08DC, 0xF08E8, 0xF08F4, 0xF0900, 0xF0948, 0xF0954, 0xF0960, 0xF096C, 0xF0978, 0xF0984, 0xF0D9C }, { 0xF092C, 0xF0938, 0xF0944, 0xF0950, 0xF0998, 0xF09A4, 0xF09B0, 0xF09BC, 0xF09C8, 0xF09D4, 0xF0DEC }, }; constexpr u32 NewCpuVoltageLimit = 1220; static_assert(NewCpuVoltageLimit <= 1300); //1300mV hangs for me constexpr u32 CpuVoltageOldTableCoeff[][10] = { - { 0xE2140, 0xE2178, 0xE21B0, 0xE21E8, 0xE2220, 0xE2258, 0xE2290, 0xE22C8, 0xE2300, 0xE2338 }, - { 0xF0F90, 0xF0FC8, 0xF1000, 0xF1038, 0xF1070, 0xF10A8, 0xF10E0, 0xF1118, 0xF1150, 0xF1188 }, + // { 0xE2140, 0xE2178, 0xE21B0, 0xE21E8, 0xE2220, 0xE2258, 0xE2290, 0xE22C8, 0xE2300, 0xE2338 }, + // { 0xF0F90, 0xF0FC8, 0xF1000, 0xF1038, 0xF1070, 0xF10A8, 0xF10E0, 0xF1118, 0xF1150, 0xF1188 }, { 0xF0FE0, 0xF1018, 0xF1050, 0xF1088, 0xF10C0, 0xF10F8, 0xF1130, 0xF1168, 0xF11A0, 0xF11D8 }, }; constexpr u32 CpuVoltageScale = 1000; constexpr u32 NewCpuVoltageScaled = NewCpuVoltageLimit * CpuVoltageScale; constexpr u32 CpuTablesFreeSpace[] = { - 0xE2350, - 0xF11A0, + // 0xE2350, + // 0xF11A0, 0xF11F0, }; // TODO: correctly derive c0-c1 dfll coefficients @@ -88,23 +88,23 @@ namespace pcv { static_assert(sizeof(NewCpuTables) <= sizeof(cpu_freq_cvb_table_t)*14); constexpr u32 MaxCpuClockOffset[] = { - 0xE2740, - 0xF1590, + // 0xE2740, + // 0xF1590, 0xF15E0, }; constexpr u32 NewMaxCpuClock = 2397000; /* GPU */ constexpr u32 GpuVoltageLimitOffsets[] = { - 0xE3044, - 0xF1E94, + // 0xE3044, + // 0xF1E94, 0xF1EE4, }; constexpr u32 NewGpuVoltageLimit = 1170; // default max 1050mV constexpr u32 GpuTablesFreeSpace[] = { - 0xE3410, - 0xF2260, + // 0xE3410, + // 0xF2260, 0xF22B0, }; // TODO: correctly derive c0-c5 coefficients @@ -132,8 +132,8 @@ namespace pcv { static_assert(sizeof(NewGpuTables) <= sizeof(gpu_cvb_pll_table_t)*15); constexpr u32 Reg1MaxGpuOffset[] = { - 0x2E0AC, - 0x3F6CC, + // 0x2E0AC, + // 0x3F6CC, 0x3F12C, }; constexpr u8 Reg1NewMaxGpuClock[][0xC] = { @@ -149,14 +149,14 @@ namespace pcv { * MOVK W13,#0x17,LSL #16 * NOP */ - { 0x0D, 0x00, 0x8E, 0x52, 0xED, 0x02, 0xA0, 0x72, 0x1F, 0x20, 0x03, 0xD5 }, - { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, 0x1F, 0x20, 0x03, 0xD5 }, + // { 0x0D, 0x00, 0x8E, 0x52, 0xED, 0x02, 0xA0, 0x72, 0x1F, 0x20, 0x03, 0xD5 }, + // { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, 0x1F, 0x20, 0x03, 0xD5 }, { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, 0x1F, 0x20, 0x03, 0xD5 }, }; constexpr u32 Reg2MaxGpuOffset[] = { - 0x2E110, - 0x3F730, + // 0x2E110, + // 0x3F730, 0x3F190, }; constexpr u8 Reg2NewMaxGpuClock[][0x8] = { @@ -170,8 +170,8 @@ namespace pcv { * MOV W13,#0x7000 * MOVK W13,#0x17,LSL #16 */ - { 0x0D, 0x00, 0x8E, 0x52, 0xED, 0x02, 0xA0, 0x72, }, - { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, }, + // { 0x0D, 0x00, 0x8E, 0x52, 0xED, 0x02, 0xA0, 0x72, }, + // { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, }, { 0x0B, 0x00, 0x8E, 0x52, 0xEB, 0x02, 0xA0, 0x72, }, }; @@ -196,6 +196,10 @@ namespace pcv { // { 1600000, { 675, 650, 637, } }, // }; + constexpr u32 EmcDvb1331[] = { + 0xF0688, + }; + // Sourced from 13.x pcv module // 1st regulator table, 0x142778 - 0x143BB4, if mask = 0b0110101 // 2nd regulator table, 0x143BB8 - 0x144FF4, if mask = 0b1010011 @@ -249,15 +253,15 @@ namespace pcv { // Mariko have 3 mtc tables (204/1331/1600 MHz), only these 3 frequencies could be set. constexpr u32 EmcFreqOffsets[][30] = { - { 0xD7C60, 0xD7C68, 0xD7C70, 0xD7C78, 0xD7C80, 0xD7C88, 0xD7C90, 0xD7C98, 0xD7CA0, 0xD7CA8, 0xE1800, 0xEEFA0, 0xF2478, 0xFE284, 0x10A304, 0x10D7DC, 0x110A40, 0x113CA4, 0x116F08, 0x11A16C, 0x11D3D0, 0x120634, 0x123898, 0x126AFC, 0x129D60, 0x12CFC4, 0x130228, 0x13BFE0, 0x140D00, 0x140D50, }, - { 0xE1810, 0xE6530, 0xE6580, 0xE6AB0, 0xE6AB8, 0xE6AC0, 0xE6AC8, 0xE6AD0, 0xE6AD8, 0xE6AE0, 0xE6AE8, 0xE6AF0, 0xE6AF8, 0xF0650, 0xFDDF0, 0x1012C8, 0x10D0D4, 0x119154, 0x11C62C, 0x11F890, 0x122AF4, 0x125D58, 0x128FBC, 0x12C220, 0x12F484, 0x1326E8, 0x13594C, 0x138BB0, 0x13BE14, 0x13F078, }, + // { 0xD7C60, 0xD7C68, 0xD7C70, 0xD7C78, 0xD7C80, 0xD7C88, 0xD7C90, 0xD7C98, 0xD7CA0, 0xD7CA8, 0xE1800, 0xEEFA0, 0xF2478, 0xFE284, 0x10A304, 0x10D7DC, 0x110A40, 0x113CA4, 0x116F08, 0x11A16C, 0x11D3D0, 0x120634, 0x123898, 0x126AFC, 0x129D60, 0x12CFC4, 0x130228, 0x13BFE0, 0x140D00, 0x140D50, }, + // { 0xE1810, 0xE6530, 0xE6580, 0xE6AB0, 0xE6AB8, 0xE6AC0, 0xE6AC8, 0xE6AD0, 0xE6AD8, 0xE6AE0, 0xE6AE8, 0xE6AF0, 0xE6AF8, 0xF0650, 0xFDDF0, 0x1012C8, 0x10D0D4, 0x119154, 0x11C62C, 0x11F890, 0x122AF4, 0x125D58, 0x128FBC, 0x12C220, 0x12F484, 0x1326E8, 0x13594C, 0x138BB0, 0x13BE14, 0x13F078, }, { 0xE1860, 0xE6580, 0xE65D0, 0xE6B00, 0xE6B08, 0xE6B10, 0xE6B18, 0xE6B20, 0xE6B28, 0xE6B30, 0xE6B38, 0xE6B40, 0xE6B48, 0xF06A0, 0xFDE40, 0x101318, 0x10D124, 0x1191A4, 0x11C67C, 0x11F8E0, 0x122B44, 0x125DA8, 0x12900C, 0x12C270, 0x12F4D4, 0x132738, 0x13599C, 0x138C00, 0x13BE64, 0x13F0C8, }, }; // Mariko mtc tables starting from rev, see mtc_timing_table.hpp for parameters. // All mariko mtc tables will be patched to simplify the procedure. constexpr u32 MtcTable_1600[][13] = { - { 0x1012D8, 0x11C63C, 0x11F8A0, 0x122B04, 0x125D68, 0x128FCC, 0x12C230, 0x12F494, 0x1326F8, 0x13595C, 0x138BC0, 0x13BE24, 0x13F088 }, // 13.x + { 0x1012D8, 0x11C63C, 0x11F8A0, 0x122B04, 0x125D68, 0x128FCC, 0x12C230, 0x12F494, 0x1326F8, 0x13595C, 0x138BC0, 0x13BE24, 0x13F088 }, }; constexpr u32 MtcTableOffset = 0x10CC; @@ -793,7 +797,7 @@ namespace pcv { namespace ptm { constexpr u32 EmcOffsetStart[] = { - 0xC5E24, + // 0xC5E24, 0xA032C, }; diff --git a/Source/Atmosphere/stratosphere/loader/source/ldr_patcher.cpp b/Source/Atmosphere/stratosphere/loader/source/ldr_patcher.cpp index e4ab2dac..d787d1f0 100644 --- a/Source/Atmosphere/stratosphere/loader/source/ldr_patcher.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/ldr_patcher.cpp @@ -68,15 +68,15 @@ namespace ams::ldr { u32 GetEmcClock() { // RAM freqs from Hekate: - // 1600000, 1728000, 1795200, 1862400, 1894400, 1932800, 1996800, 2064000, 2099200, 2131200 + // 1862400, 1894400, 1932800, 1996800, 2064000, 2099200, 2131200 // Other values might work as well // RAM overclock could be UNSTABLE and generate graphical glitches / instabilities / NAND corruption return 1862400; } - u32 GetCpuBoostClock() { - return 1963500; - } + // u32 GetCpuBoostClock() { + // return 1963500; + // } consteval u8 ParseNybble(char c) { AMS_ASSUME(('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f')); @@ -179,42 +179,54 @@ namespace ams::ldr { /* Patch max GPU voltage on Mariko */ std::memcpy(reinterpret_cast(mapped_nso + pcv::GpuVoltageLimitOffsets[i]), &pcv::NewGpuVoltageLimit, sizeof(pcv::NewGpuVoltageLimit)); - if (i >= 2) { - for (u32 j = 0; j < sizeof(pcv::MtcTable_1600[i-2])/sizeof(u32); j++) { - pcv::MarikoMtcTable* mtc_table_new = reinterpret_cast(mapped_nso + pcv::MtcTable_1600[i-2][j]); - pcv::MarikoMtcTable* mtc_table_old = reinterpret_cast(mapped_nso + pcv::MtcTable_1600[i-2][j] - pcv::MtcTableOffset); + for (u32 j = 0; j < sizeof(pcv::MtcTable_1600[i])/sizeof(u32); j++) { + pcv::MarikoMtcTable* mtc_table_new = reinterpret_cast(mapped_nso + pcv::MtcTable_1600[i][j]); + pcv::MarikoMtcTable* mtc_table_old = reinterpret_cast(mapped_nso + pcv::MtcTable_1600[i][j] - pcv::MtcTableOffset); - #ifdef REPLACE_1331 - /* Replace 1331 MHz with 1600 MHz, not possible without proper timings for oc clock */ - std::memcpy(reinterpret_cast(mtc_table_old), reinterpret_cast(mtc_table_new), sizeof(pcv::MarikoMtcTable)); - #endif + /* Replace 1331 MHz with 1600 MHz, not possible without proper timings for oc clock */ + std::memcpy(reinterpret_cast(mtc_table_old), reinterpret_cast(mtc_table_new), sizeof(pcv::MarikoMtcTable)); - /* Generate new table for OC MHz */ - pcv::AdjustMtcTable(mtc_table_new, mtc_table_old); - } + /* Generate new table for OC MHz */ + pcv::AdjustMtcTable(mtc_table_new, mtc_table_old); } /* Patch RAM Clock */ for (u32 j = 0; j < sizeof(pcv::EmcFreqOffsets[i])/sizeof(u32); j++) { std::memcpy(reinterpret_cast(mapped_nso + pcv::EmcFreqOffsets[i][j]), &EmcClock, sizeof(EmcClock)); } + + /* Replace 1331 MHz with 1600 MHz in EmcDvbTable */ + const u32 mem1331 = 1600'000; + std::memcpy(reinterpret_cast(mapped_nso + pcv::EmcDvb1331[i]), &mem1331, sizeof(mem1331)); } } - // u32 PtmEmcClock = GetEmcClock() * 1000; + u32 PtmEmcClk1600 = GetEmcClock() * 1000; + const u32 PtmEmcClk1331 = 1600'000'000; - u32 CpuBoostClock = GetCpuBoostClock() * 1000; + // u32 CpuBoostClock = GetCpuBoostClock() * 1000; + /* Patch Ptm for coexistent of 1600 MHz and OC clock */ 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(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClock, sizeof(PtmEmcClock)); - // std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClock, sizeof(PtmEmcClock)); - // } - for (u32 j = 0; j < 2; j++) { - std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j), &CpuBoostClock, sizeof(CpuBoostClock)); - std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j + 0x4), &CpuBoostClock, sizeof(CpuBoostClock)); + for (u32 j = 0; j < 6; j++) { + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClk1600, sizeof(PtmEmcClk1600)); + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClk1600, sizeof(PtmEmcClk1600)); } + for (u32 j = 6; j < 10; j++) { + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClk1331, sizeof(PtmEmcClk1331)); + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClk1331, sizeof(PtmEmcClk1331)); + } + for (u32 j = 10; j < 16; j+=2) { + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j), &PtmEmcClk1600, sizeof(PtmEmcClk1600)); + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * j + 0x4), &PtmEmcClk1600, sizeof(PtmEmcClk1600)); + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * (j+1)), &PtmEmcClk1331, sizeof(PtmEmcClk1331)); + std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::OffsetInterval * (j+1) + 0x4), &PtmEmcClk1331, sizeof(PtmEmcClk1331)); + } + // for (u32 j = 0; j < 2; j++) { + // std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j), &CpuBoostClock, sizeof(CpuBoostClock)); + // std::memcpy(reinterpret_cast(mapped_nso + ptm::EmcOffsetStart[i] + ptm::CpuBoostOffset + ptm::OffsetInterval * j + 0x4), &CpuBoostClock, sizeof(CpuBoostClock)); + // } } } } diff --git a/Source/sys-clk-OC/common/src/apm_profile_table.c b/Source/sys-clk-OC/common/src/apm_profile_table.c index 669d0e21..2e0ff9be 100644 --- a/Source/sys-clk-OC/common/src/apm_profile_table.c +++ b/Source/sys-clk-OC/common/src/apm_profile_table.c @@ -11,22 +11,22 @@ #include SysClkApmConfiguration sysclk_g_apm_configurations[] = { - {0x00010000, 1020000000, 384000000, 1600000000}, - {0x00010001, 1020000000, 768000000, 1600000000}, - {0x00010002, 1224000000, 691200000, 1600000000}, - {0x00020000, 1020000000, 230400000, 1600000000}, - {0x00020001, 1020000000, 307200000, 1600000000}, - {0x00020002, 1224000000, 230400000, 1600000000}, - {0x00020003, 1020000000, 307200000, 1331200000}, - {0x00020004, 1020000000, 384000000, 1331200000}, - {0x00020005, 1020000000, 307200000, 1065600000}, - {0x00020006, 1020000000, 384000000, 1065600000}, - {0x92220007, 1020000000, 460800000, 1600000000}, - {0x92220008, 1020000000, 460800000, 1331200000}, - {0x92220009, 1963500000, 76800000, 1600000000}, - {0x9222000A, 1963500000, 76800000, 1331200000}, - {0x9222000B, 1020000000, 76800000, 1600000000}, - {0x9222000C, 1020000000, 76800000, 1331200000}, + {0x00010000, 1020000000, 384000000, 1862400000}, + {0x00010001, 1020000000, 768000000, 1862400000}, + {0x00010002, 1224000000, 691200000, 1862400000}, + {0x00020000, 1020000000, 230400000, 1862400000}, + {0x00020001, 1020000000, 307200000, 1862400000}, + {0x00020002, 1224000000, 230400000, 1862400000}, + {0x00020003, 1020000000, 307200000, 1600000000}, + {0x00020004, 1020000000, 384000000, 1600000000}, + {0x00020005, 1020000000, 307200000, 1600000000}, + {0x00020006, 1020000000, 384000000, 1600000000}, + {0x92220007, 1020000000, 460800000, 1862400000}, + {0x92220008, 1020000000, 460800000, 1600000000}, + {0x92220009, 1785000000, 76800000, 1862400000}, + {0x9222000A, 1785000000, 76800000, 1600000000}, + {0x9222000B, 1020000000, 76800000, 1862400000}, + {0x9222000C, 1020000000, 76800000, 1600000000}, {0, 0, 0, 0}, }; diff --git a/Source/sys-clk-OC/common/src/clock_table.c b/Source/sys-clk-OC/common/src/clock_table.c index e3e02c5e..be3962f5 100644 --- a/Source/sys-clk-OC/common/src/clock_table.c +++ b/Source/sys-clk-OC/common/src/clock_table.c @@ -15,11 +15,11 @@ uint32_t sysclk_g_freq_table_mem_hz[] = { // 665600000, // 800000000, // 1065600000, - 1331200000, + // 1331200000, 1600000000, // 1728000000, // 1795200000, - // 1862400000, + 1862400000, // Max Hz // 1894400000, // 1932800000, // 1996800000, diff --git a/Source/sys-clk-OC/manager/src/utils.cpp b/Source/sys-clk-OC/manager/src/utils.cpp index 0f3e66fa..6104c67d 100644 --- a/Source/sys-clk-OC/manager/src/utils.cpp +++ b/Source/sys-clk-OC/manager/src/utils.cpp @@ -110,7 +110,7 @@ brls::SelectListItem* createFreqListItem(SysClkModule module, uint32_t selectedF selected = i + 1; char clock[16]; - if (freq == 1600000000) + if (freq == 1862400000) snprintf(clock, sizeof(clock), "Max MHz"); else snprintf(clock, sizeof(clock), "%d MHz", freq / 1000000); diff --git a/Source/sys-clk-OC/overlay/src/ui/format.h b/Source/sys-clk-OC/overlay/src/ui/format.h index a0f65333..989e1efd 100644 --- a/Source/sys-clk-OC/overlay/src/ui/format.h +++ b/Source/sys-clk-OC/overlay/src/ui/format.h @@ -20,7 +20,7 @@ static inline std::string formatListFreqMhz(std::uint32_t mhz) { return FREQ_DEFAULT_TEXT; } - else if (mhz == 1600) + else if (mhz == 1862) { return "Max MHz"; } diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/base_gui.cpp b/Source/sys-clk-OC/overlay/src/ui/gui/base_gui.cpp index a5c00c86..1c26d1ad 100644 --- a/Source/sys-clk-OC/overlay/src/ui/gui/base_gui.cpp +++ b/Source/sys-clk-OC/overlay/src/ui/gui/base_gui.cpp @@ -13,13 +13,13 @@ #include "../elements/base_frame.h" // #include "logo_rgba_bin.h" -#define LOGO_LABEL_X 18 -#define LOGO_LABEL_Y 26 -#define LOGO_LABEL_FONT_SIZE 23 +#define LOGO_LABEL_X 20 +#define LOGO_LABEL_Y 35 +#define LOGO_LABEL_FONT_SIZE 20 #define VERSION_X 246 #define VERSION_Y LOGO_LABEL_Y -#define VERSION_FONT_SIZE 16 +#define VERSION_FONT_SIZE 15 void BaseGui::preDraw(tsl::gfx::Renderer* renderer) { diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/base_menu_gui.cpp b/Source/sys-clk-OC/overlay/src/ui/gui/base_menu_gui.cpp index ead4ac3e..22a17154 100644 --- a/Source/sys-clk-OC/overlay/src/ui/gui/base_menu_gui.cpp +++ b/Source/sys-clk-OC/overlay/src/ui/gui/base_menu_gui.cpp @@ -34,12 +34,12 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) { char buf[32]; - renderer->drawString("App ID: ", false, 20, 55, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("App ID: ", false, 20, 60, SMALL_TEXT_SIZE, DESC_COLOR); snprintf(buf, sizeof(buf), "%016lX", context->applicationId); - renderer->drawString(buf, false, 81, 55, SMALL_TEXT_SIZE, VALUE_COLOR); + renderer->drawString(buf, false, 81, 60, SMALL_TEXT_SIZE, VALUE_COLOR); - renderer->drawString("Profile: ", false, 246, 55, SMALL_TEXT_SIZE, DESC_COLOR); - renderer->drawString(sysclkFormatProfile(context->profile, true), false, 302, 55, SMALL_TEXT_SIZE, VALUE_COLOR); + renderer->drawString("Profile: ", false, 246, 60, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString(sysclkFormatProfile(context->profile, true), false, 302, 60, SMALL_TEXT_SIZE, VALUE_COLOR); static struct { @@ -55,11 +55,11 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) { std::uint32_t hz = this->context->freqs[freqOffsets[i].m]; snprintf(buf, sizeof(buf), "%u.%u MHz", hz / 1000000, hz / 100000 - hz / 1000000 * 10); - renderer->drawString(buf, false, freqOffsets[i].x, 80, SMALL_TEXT_SIZE, VALUE_COLOR); + renderer->drawString(buf, false, freqOffsets[i].x, 85, SMALL_TEXT_SIZE, VALUE_COLOR); } - renderer->drawString("CPU:", false, 20, 80, SMALL_TEXT_SIZE, DESC_COLOR); - renderer->drawString("GPU:", false, 162, 80, SMALL_TEXT_SIZE, DESC_COLOR); - renderer->drawString("MEM:", false, 295, 80, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("CPU:", false, 20, 85, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("GPU:", false, 162, 85, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("MEM:", false, 295, 85, SMALL_TEXT_SIZE, DESC_COLOR); static struct { @@ -71,14 +71,14 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) { SysClkThermalSensor_Skin, 268 }, }; - renderer->drawString("SOC:", false, 20, 105, SMALL_TEXT_SIZE, DESC_COLOR); - renderer->drawString("PCB:", false, 125, 105, SMALL_TEXT_SIZE, DESC_COLOR); - renderer->drawString("Skin:", false, 230, 105, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("SOC:", false, 20, 110, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("PCB:", false, 125, 110, SMALL_TEXT_SIZE, DESC_COLOR); + renderer->drawString("Skin:", false, 230, 110, SMALL_TEXT_SIZE, DESC_COLOR); for(unsigned int i = 0; i < SysClkModule_EnumMax; i++) { std::uint32_t millis = this->context->temps[tempOffsets[i].s]; snprintf(buf, sizeof(buf), "%u.%u °C", millis / 1000, (millis - millis / 1000 * 1000) / 100); - renderer->drawString(buf, false, tempOffsets[i].x, 105, SMALL_TEXT_SIZE, VALUE_COLOR); + renderer->drawString(buf, false, tempOffsets[i].x, 110, SMALL_TEXT_SIZE, VALUE_COLOR); } } } diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/main_gui.cpp b/Source/sys-clk-OC/overlay/src/ui/gui/main_gui.cpp index 44605e28..734b2f06 100644 --- a/Source/sys-clk-OC/overlay/src/ui/gui/main_gui.cpp +++ b/Source/sys-clk-OC/overlay/src/ui/gui/main_gui.cpp @@ -13,7 +13,7 @@ #include "fatal_gui.h" #include "app_profile_gui.h" #include "global_override_gui.h" -// #include "misc_gui.h" +#include "misc_gui.h" void MainGui::listUI() { @@ -68,17 +68,17 @@ void MainGui::listUI() }); this->listElement->addItem(globalPermanentOverrideItem); - // tsl::elm::ListItem* miscItem = new tsl::elm::ListItem("Miscellaneous"); - // miscItem->setClickListener([this](u64 keys) { - // if((keys & HidNpadButton_A) == HidNpadButton_A && this->context) - // { - // tsl::changeTo(); - // return true; - // } + tsl::elm::ListItem* miscItem = new tsl::elm::ListItem("Miscellaneous"); + miscItem->setClickListener([this](u64 keys) { + if((keys & HidNpadButton_A) == HidNpadButton_A && this->context) + { + tsl::changeTo(); + return true; + } - // return false; - // }); - // this->listElement->addItem(miscItem); + return false; + }); + this->listElement->addItem(miscItem); } void MainGui::refresh() diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp new file mode 100644 index 00000000..bb61fc01 --- /dev/null +++ b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp @@ -0,0 +1,77 @@ +/* + * -------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * , , + * wrote this file. As long as you retain this notice you can do whatever you + * want with this stuff. If you meet any of us some day, and you think this + * stuff is worth it, you can buy us a beer in return. - The sys-clk authors + * -------------------------------------------------------------------------- + */ + +#include "misc_gui.h" + +#include "fatal_gui.h" +#include "../format.h" + +MiscGui::MiscGui() +{ + this->chargeInfo = new ChargeInfo; +} + +MiscGui::~MiscGui() +{ + delete this->chargeInfo; +} + +void MiscGui::preDraw(tsl::gfx::Renderer* render) +{ + BaseMenuGui::preDraw(render); + + render->drawString(this->psmOutput, false, 40, 300, SMALL_TEXT_SIZE, DESC_COLOR); +} + +void MiscGui::listUI() +{ + // Charging + this->chargingToggle = new tsl::elm::ToggleListItem("Charging", false); + chargingToggle->setStateChangedListener([this](bool state) { + if (PsmChargingToggler(state)) + { + this->chargingToggle->setState(state); + this->fastChargingToggle->setState(this->PsmIsFastCharging()); + } + else + { + this->chargingToggle->setState(!state); + } + }); + this->listElement->addItem(this->chargingToggle); + + // FastCharging + this->fastChargingToggle = new tsl::elm::ToggleListItem("Fast Charging", false); + fastChargingToggle->setStateChangedListener([this](bool state) { + if (PsmFastChargingToggler(state)) + { + this->fastChargingToggle->setState(state); + } + else + { + this->fastChargingToggle->setState(!state); + } + }); + this->listElement->addItem(this->fastChargingToggle); +} + +void MiscGui::update() +{ + BaseMenuGui::update(); + + if (++frameCounter >= 60) + { + frameCounter = 0; + PsmUpdate(); + PsmGetInfo(this->psmOutput, sizeof(this->psmOutput)); + this->chargingToggle->setState(this->PsmIsCharging()); + this->fastChargingToggle->setState(this->PsmIsFastCharging()); + } +} diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.h b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.h new file mode 100644 index 00000000..66e5ac97 --- /dev/null +++ b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.h @@ -0,0 +1,201 @@ +/* + * -------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * , , + * wrote this file. As long as you retain this notice you can do whatever you + * want with this stuff. If you meet any of us some day, and you think this + * stuff is worth it, you can buy us a beer in return. - The sys-clk authors + * -------------------------------------------------------------------------- + */ + +#pragma once + +#include "../../ipc.h" +#include "base_menu_gui.h" +#include + +class MiscGui : public BaseMenuGui +{ + public: + MiscGui(); + ~MiscGui(); + void preDraw(tsl::gfx::Renderer* render) override; + void listUI() override; + void update() override; + + protected: + typedef enum { + PDCtrler_NewPDO = 1, //Received new Power Data Object + PDCtrler_NoPD = 2, //No Power Delivery source is detected + PDCtrler_AcceptedRDO = 3 //Received and accepted Request Data Object + } ChargeInfoPDCtrler; //BM92T series + + typedef enum { + PowerRole_Sink = 1, + PowerRole_Source = 2 + } ChargeInfoPowerRole; + + constexpr const char* ChargeInfoPowerRoleToStr(ChargeInfoPowerRole in) + { + switch (in) + { + case PowerRole_Sink: return "Sink"; + case PowerRole_Source: return "Source"; + default: return "Unknown"; + } + }; + + typedef enum { + ChargerType_None = 0, + ChargerType_PD = 1, + ChargerType_TypeC_1500mA = 2, + ChargerType_TypeC_3000mA = 3, + ChargerType_DCP = 4, + ChargerType_CDP = 5, + ChargerType_SDP = 6, + ChargerType_Apple_500mA = 7, + ChargerType_Apple_1000mA = 8, + ChargerType_Apple_2000mA = 9 + } ChargeInfoChargerType; + + constexpr const char* ChargeInfoChargerTypeToStr(ChargeInfoChargerType in) noexcept + { + switch (in) + { + case ChargerType_None: return "None"; + case ChargerType_PD: return "USB-C PD"; + case ChargerType_TypeC_1500mA: + case ChargerType_TypeC_3000mA: return "USB-C"; + case ChargerType_DCP: return "USB DCP"; + case ChargerType_CDP: return "USB CDP"; + case ChargerType_SDP: return "USB SDP"; + case ChargerType_Apple_500mA: + case ChargerType_Apple_1000mA: + case ChargerType_Apple_2000mA: return "Apple"; + default: return "Unknown"; + } + }; + + typedef enum { + Flags_NoHub = BIT(0), //If hub is disconnected + Flags_Rail = BIT(8), //At least one Joy-con is charging from rail + Flags_SPDSRC = BIT(12), //OTG + Flags_ACC = BIT(16) //Accessory + } ChargeInfoFlags; + + typedef struct { + int32_t InputCurrentLimit; //Input (Sink) current limit in mA + int32_t VBUSCurrentLimit; //Output (Source/VBUS/OTG) current limit in mA + int32_t ChargeCurrentLimit; //Battery charging current limit in mA (512mA when Docked, 768mA when BatteryTemperature < 17.0 C) + int32_t ChargeVoltageLimit; //Battery charging voltage limit in mV (3952mV when BatteryTemperature >= 51.0 C) + int32_t unk_x10; //Possibly an emum, getting the same value as PowerRole in all tested cases + int32_t unk_x14; //Possibly flags + ChargeInfoPDCtrler PDCtrlerState; //Power Delivery Controller State + int32_t BatteryTemperature; //Battery temperature in milli C + int32_t RawBatteryCharge; //Raw battery charged capacity per cent-mille (i.e. 100% = 100000 pcm) + int32_t VoltageAvg; //Voltage avg in mV (more in Notes) + int32_t BatteryAge; //Battery age (capacity full / capacity design) per cent-mille (i.e. 100% = 100000 pcm) + ChargeInfoPowerRole PowerRole; + ChargeInfoChargerType ChargerType; + int32_t ChargerVoltageLimit; //Charger and external device voltage limit in mV + int32_t ChargerCurrentLimit; //Charger and external device current limit in mA + ChargeInfoFlags Flags; //Unknown flags + } ChargeInfo; + + void PsmUpdate(uint32_t dispatchId = 0) + { + smInitialize(); + psmInitialize(); + + if (dispatchId) + { + serviceDispatch(psmGetServiceSession(), dispatchId); + svcSleepThread(1000); + } + + serviceDispatchOut(psmGetServiceSession(), 17, *(this->chargeInfo)); + psmIsEnoughPowerSupplied(&(this->isEnoughPowerSupplied)); + + psmExit(); + smExit(); + } + + bool PsmIsChargerConnected() + { + return this->chargeInfo->ChargerType != ChargerType_None; + } + + bool PsmIsCharging() + { + return PsmIsChargerConnected() && ((this->chargeInfo->unk_x14 >> 8) & 1); + } + + bool PsmIsFastCharging() + { + return this->chargeInfo->ChargeCurrentLimit > 768; + } + + bool PsmIsEnoughPowerSupplied() + { + return this->isEnoughPowerSupplied; + } + + void PsmGetInfo(char* out, size_t outsize) + { + float chargerVoltLimit = (float)chargeInfo->ChargerVoltageLimit / 1000; + float chargerCurrLimit = (float)chargeInfo->ChargerCurrentLimit / 1000; + float chargerOutWatts = chargerVoltLimit * chargerCurrLimit; + + char chargeVoltLimit[20] = ""; + if (chargeInfo->ChargeVoltageLimit) + snprintf(chargeVoltLimit, sizeof(chargeVoltLimit), ", %u mV", chargeInfo->ChargeVoltageLimit); + + snprintf(out, outsize, + "Charger: %s %.1fV/%.1fA (%.1fW)" + "\n%s" + "\nBattery: %.3fV %.2f\u00B0C" + "\nCurrent Limit: %u mA IN, %u mA OUT" + "\nCharging Limit: %u mA%s" + "\nRaw Charge: %.2f%%" + "\nBattery Age: %.2f%%" + "\nPower Role: %s" + , + ChargeInfoChargerTypeToStr(chargeInfo->ChargerType), chargerVoltLimit, chargerCurrLimit, chargerOutWatts, + PsmIsEnoughPowerSupplied() ? "Enough Power Supplied" : "", + (float)chargeInfo->VoltageAvg / 1000, + (float)chargeInfo->BatteryTemperature / 1000, + chargeInfo->InputCurrentLimit, chargeInfo->VBUSCurrentLimit, + chargeInfo->ChargeCurrentLimit, chargeVoltLimit, + (float)chargeInfo->RawBatteryCharge / 1000, + (float)chargeInfo->BatteryAge / 1000, + ChargeInfoPowerRoleToStr(chargeInfo->PowerRole) + ); + } + + bool PsmChargingToggler(bool enable) + { + if (!PsmIsChargerConnected()) + return false; + + PsmUpdate(enable ? 2 : 3); + + return PsmIsCharging() == enable; + } + + bool PsmFastChargingToggler(bool enable) + { + if (!PsmIsChargerConnected()) + return false; + + PsmUpdate(enable ? 10 : 11); + + return PsmIsFastCharging() == enable; + } + + tsl::elm::ToggleListItem *chargingToggle, *fastChargingToggle; + + ChargeInfo* chargeInfo; + bool isEnoughPowerSupplied = false; + char psmOutput[800] = ""; + int frameCounter = 60; +}; diff --git a/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp b/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp index f34e54bd..32b7fb63 100644 --- a/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp +++ b/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp @@ -59,11 +59,9 @@ ClockManager::ClockManager() this->oc = new SysClkOcExtra; this->oc->systemCoreBoostCPU = false; - // this->oc->systemCoreCheckStuck = false; - // this->oc->systemCoreStuckCount = 0; this->oc->reverseNXMode = ReverseNX_NotFound; this->oc->tickWaitTimeMs = 0; - this->oc->maxMEMFreq = 1600'000'000; + this->oc->maxMEMFreq = 0; } ClockManager::~ClockManager() @@ -130,9 +128,9 @@ uint32_t ClockManager::GetHz(SysClkModule module) break; case SysClkModule_MEM: if (!IsReverseNXDocked() && this->context->realProfile != SysClkProfile_Docked) - hz = 1331'200'000; + hz = 1600000000; else - hz = 1600'000'000; + hz = MAX_MEM_CLOCK; break; default: break; @@ -144,11 +142,16 @@ uint32_t ClockManager::GetHz(SysClkModule module) /* Considering realProfile frequency limit */ hz = Clocks::GetNearestHz(module, this->context->realProfile, hz); - if (module == SysClkModule_MEM && hz == 1600'000'000) + if (module == SysClkModule_MEM && hz == MAX_MEM_CLOCK) { - /* Return maxMemFreq */ - if (this->context->freqs[module] > this->oc->maxMEMFreq) - this->oc->maxMEMFreq = this->context->freqs[module]; + /* Trigger Max Mem Clock and record it */ + if (!this->oc->maxMEMFreq) + { + uint32_t CurrentHz = Clocks::GetCurrentHz(SysClkModule_MEM); + Clocks::SetHz(SysClkModule_MEM, MAX_MEM_CLOCK); + this->oc->maxMEMFreq = Clocks::GetCurrentHz(SysClkModule_MEM); + Clocks::SetHz(SysClkModule_MEM, CurrentHz); + } return this->oc->maxMEMFreq; } @@ -385,6 +388,29 @@ void ClockManager::CheckReverseNXTool() this->oc->reverseNXMode = getMode; } +bool ClockManager::CheckReverseNXRT() +{ + bool shouldCheckReverseNXRT = FileUtils::IsReverseNXSyncEnabled(); + if (!shouldCheckReverseNXRT) + return false; + + bool shouldAdjustProfile = false; + + ReverseNXMode getMode = ReverseNXFileHandler(false, FILE_REVERSENX_RT_CONF_PATH); + if (getMode) + { + this->oc->reverseNXMode = getMode; + shouldAdjustProfile = true; + } + + if (getMode == ReverseNX_RTResetToDefault) + { + this->oc->reverseNXMode = ReverseNX_SystemDefault; + } + + return shouldAdjustProfile; +} + bool ClockManager::RefreshContext() { bool hasChanged = false; @@ -421,18 +447,9 @@ bool ClockManager::RefreshContext() } /* Check ReverseNX-RT */ + if (CheckReverseNXRT()) { - ReverseNXMode getMode = ReverseNXFileHandler(false, FILE_REVERSENX_RT_CONF_PATH); - if (getMode) - { - this->oc->reverseNXMode = getMode; - shouldAdjustProfile = true; - } - - if (getMode == ReverseNX_RTResetToDefault) - { - this->oc->reverseNXMode = ReverseNX_SystemDefault; - } + shouldAdjustProfile = true; } /* Adjust nominal profile when tid, real profile or -RT profile change */ diff --git a/Source/sys-clk-OC/sysmodule/src/clock_manager.h b/Source/sys-clk-OC/sysmodule/src/clock_manager.h index 7060afec..72433859 100644 --- a/Source/sys-clk-OC/sysmodule/src/clock_manager.h +++ b/Source/sys-clk-OC/sysmodule/src/clock_manager.h @@ -47,7 +47,7 @@ class ClockManager std::uint64_t lastCsvWriteNs; SysClkOcExtra *oc; - const uint32_t CPU_BOOST_FREQ = 1963'500'000; + const uint32_t CPU_BOOST_FREQ = 1785'000'000; bool IsCpuBoostMode(); bool IsReverseNXEnabled(); @@ -58,6 +58,7 @@ class ClockManager ReverseNXMode ReverseNXFileHandler(bool, const char*); void CheckReverseNXTool(); + bool CheckReverseNXRT(); // LockableMutex systemCoreStuckCountMutex; // Thread t_CheckSystemCoreStuck_0, t_CheckSystemCoreStuck_1, t_CheckSystemCoreStuck_2; diff --git a/Source/sys-clk-OC/sysmodule/src/clocks.h b/Source/sys-clk-OC/sysmodule/src/clocks.h index 7da5f8e9..ff9db853 100644 --- a/Source/sys-clk-OC/sysmodule/src/clocks.h +++ b/Source/sys-clk-OC/sysmodule/src/clocks.h @@ -13,6 +13,8 @@ #include #include +#define MAX_MEM_CLOCK 1862'400'000 + class Clocks { public: