Sys-clk-OC: Option to regard Power Delivery chargers supplying >=18W (typically, 9V/2A) as official chargers

This commit is contained in:
KazushiM
2021-09-15 12:23:54 +08:00
parent 584e8d8665
commit a45b767a80
6 changed files with 98 additions and 29 deletions

View File

@@ -19,9 +19,11 @@ Overclocking suite for Switch **(Mariko Only)** running on Atmosphere CFW. Suppo
- **CPU/GPU/RAM Overclock** up to **2397.0/1344.0/2131.2 MHz**
- **Auto-Boost CPU for faster game loading**
- **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
- **Modded sys-clk and ReverseNX**(-Tools and -RT)
- Option to regard Power Delivery chargers supplying >=18W (typically, 9V/2A) as official chargers
- **No need to change clocks manually** after toggling modes in ReverseNX
- Profile-aware clock override for all games
- Disable background services, less heat and power consumption in standby mode
- Profile-aware clock override for all games
- Game recording and SysDVR streaming @ 60fps with high video bitrate
- Remove copyright watermark in screenshots/recordings, courtesy of [HookedBehemoth](https://github.com/HookedBehemoth/exefs_patches)
- **TinyMemBenchNX**: DRAM throughput and latency test based on [tinymembench](https://github.com/ssvb/tinymembench)
@@ -43,27 +45,29 @@ Overclocking suite for Switch **(Mariko Only)** running on Atmosphere CFW. Suppo
- To **disable this feature**, simply remove `boost_start.flag` and `boost.flag` in `/config/sys-clk/ `.
- **Fan Control Optimization** at high load
- 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.
- **Modded sys-clk and ReverseNX**(-Tools and -RT), **no need to change clocks manually** after toggling modes in ReverseNX
- Add `/config/sys-clk/downclock_dock.flag` to use handheld clocks in Docked mode when Handheld mode is set in ReverseNX.
- To **disable this feature**, use original version of ReverseNX and delete `/config/sys-clk/ReverseNX_sync.flag`.
- **Modded sys-clk and ReverseNX**(-Tools and -RT)
- Option to regard Power Delivery chargers that could supply >=18W (typically, 9V/2A) as official chargers.
- To **disable this feature**, remove `/config/sys-clk/pd18w_official.flag `.
- **No need to change clocks manually** after toggling modes in ReverseNX
- Add `/config/sys-clk/downclock_dock.flag` to use handheld clocks in Docked mode when Handheld mode is set in ReverseNX.
- To **disable this feature**, use original version of ReverseNX-RT and delete `/config/sys-clk/ReverseNX_sync.flag`.
- Profile-aware clock override for all games
- Add `[A111111111111111]` title config in `/config/sys-clk/config.ini` to set frequency override globally:
```ini
[A111111111111111]
docked_cpu=
docked_gpu=
handheld_charging_cpu=
handheld_charging_gpu=
handheld_charging_usb_cpu=
handheld_charging_usb_gpu=
handheld_charging_official_cpu=
handheld_charging_official_gpu=
handheld_cpu=
handheld_gpu=
```
- 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**.
- Profile-aware clock override for all games
- Add `[A111111111111111]` title config in `/config/sys-clk/config.ini` to set frequency override globally:
```ini
[A111111111111111]
docked_cpu=
docked_gpu=
handheld_charging_cpu=
handheld_charging_gpu=
handheld_charging_usb_cpu=
handheld_charging_usb_gpu=
handheld_charging_official_cpu=
handheld_charging_official_gpu=
handheld_cpu=
handheld_gpu=
```
- Game recording and SysDVR streaming @ 60fps with high video bitrate (7.5Mbps)
- (Recommended)[dvr-patches](https://github.com/exelix11/dvr-patches): Allow recording in any games.
- For optimal streaming experience, SysDVR via USB interface is recommended.

View File

View File

@@ -11,9 +11,42 @@
#include <nxExt.h>
#include "clocks.h"
#include "errors.h"
#include "file_utils.h"
bool Clocks::isMariko = false;
typedef enum {
None = 0,
PD = 1,
TypeC_1500mA = 2,
TypeC_3000mA = 3,
DCP = 4,
CDP = 5,
SDP = 6,
Apple_500mA = 7,
Apple_1000mA = 8,
Apple_2000mA = 9
} BatteryChargeInfoFieldsChargerType;
typedef struct {
uint32_t InputCurrentLimit; //Input (Sink) current limit in mA
uint32_t VBUSCurrentLimit; //Output (Source/VBUS/OTG) current limit in mA
uint32_t ChargeCurrentLimit; //Battery charging current limit in mA (512mA when Docked, 768mA when BatteryTemperature < 17.0 C)
uint32_t ChargeVoltageLimit; //Battery charging voltage limit in mV (3952mV when BatteryTemperature >= 51.0 C)
uint32_t unk_x10; //Possibly an emum, getting the same value as PowerRole in all tested cases
uint32_t unk_x14; //Possibly flags
uint16_t PDControllerState; //Power Delivery Controller State
uint32_t BatteryTemperature; //Battery temperature in milli C
uint32_t RawBatteryCharge; //Raw battery charged capacity per cent-mille (i.e. 100% = 100000 pcm)
uint32_t VoltageAvg; //Voltage avg in mV (more in Notes)
uint32_t BatteryAge; //Battery age (capacity full / capacity design) per cent-mille (i.e. 100% = 100000 pcm)
uint16_t PowerRole; //Sink or Source
BatteryChargeInfoFieldsChargerType ChargerType;
uint32_t ChargerVoltageLimit; //Charger and external device voltage limit in mV
uint32_t ChargerCurrentLimit; //Charger and external device current limit in mA
uint16_t Flags; //Unknown flags
} BatteryChargeInfoFields;
void Clocks::GetList(SysClkModule module, std::uint32_t **outClocks)
{
switch(module)
@@ -193,6 +226,10 @@ void Clocks::ResetToStock(unsigned int module)
}
}
Result psmGetBatteryChargeInfoFields(Service* psmService, BatteryChargeInfoFields *out) {
return serviceDispatchOut(psmService, 17, *out);
}
SysClkProfile Clocks::GetCurrentProfile()
{
std::uint32_t mode = 0;
@@ -204,21 +241,34 @@ SysClkProfile Clocks::GetCurrentProfile()
return SysClkProfile_Docked;
}
if(FileUtils::IsPd18wAsOfficialChargerEnabled())
{
static Service* psmService = psmGetServiceSession();
static BatteryChargeInfoFields* _Fields = new BatteryChargeInfoFields;
psmGetBatteryChargeInfoFields(psmService, _Fields);
if(_Fields->ChargerType == PD)
{
uint8_t ChargerWatts = (_Fields->ChargerVoltageLimit * _Fields->ChargerCurrentLimit)/1000000.0;
if(ChargerWatts >= 17)
return SysClkProfile_HandheldChargingOfficial;
}
}
PsmChargerType chargerType;
rc = psmGetChargerType(&chargerType);
ASSERT_RESULT_OK(rc, "psmGetChargerType");
if(chargerType == PsmChargerType_EnoughPower)
switch(chargerType)
{
return SysClkProfile_HandheldChargingOfficial;
case PsmChargerType_EnoughPower:
return SysClkProfile_HandheldChargingOfficial;
case PsmChargerType_LowPower:
case PsmChargerType_NotSupported:
return SysClkProfile_HandheldChargingUSB;
default:
return SysClkProfile_Handheld;
}
else if(chargerType == PsmChargerType_LowPower || chargerType == PsmChargerType_NotSupported)
{
return SysClkProfile_HandheldChargingUSB;
}
return SysClkProfile_Handheld;
}
void Clocks::SetHz(SysClkModule module, std::uint32_t hz)

View File

@@ -21,6 +21,7 @@ static bool g_log_enabled = false;
static bool g_boost_enabled = false;
static bool g_boost_start_enabled = false;
static bool g_downclock_dock_enabled = false;
static bool g_pd18w_as_official_charger_enabled = false;
static bool g_reversenx_tool_exist = false;
static bool g_reversenx_sync_enabled = false;
static std::uint64_t g_last_flag_check = 0;
@@ -183,6 +184,13 @@ void FileUtils::InitCheckFlags()
fclose(file);
}
file = fopen(FILE_PD18W_AS_OFFICIAL_CHARGER_FLAG_PATH, "r");
if (file)
{
g_pd18w_as_official_charger_enabled = true;
fclose(file);
}
file = fopen(FILE_REVERSENX_SYNC_FLAG_PATH, "r");
if (file)
{
@@ -213,6 +221,11 @@ bool FileUtils::IsDownclockDockEnabled()
return g_downclock_dock_enabled;
}
bool FileUtils::IsPd18wAsOfficialChargerEnabled()
{
return g_pd18w_as_official_charger_enabled;
}
bool FileUtils::IsReverseNXToolExist()
{
return g_reversenx_tool_exist;

View File

@@ -25,6 +25,7 @@
#define FILE_BOOST_FLAG_PATH FILE_CONFIG_DIR "/boost.flag"
#define FILE_BOOST_START_FLAG_PATH FILE_CONFIG_DIR "/boost_start.flag"
#define FILE_DOWNCLOCK_DOCK_FLAG_PATH FILE_CONFIG_DIR "/downclock_dock.flag"
#define FILE_PD18W_AS_OFFICIAL_CHARGER_FLAG_PATH FILE_CONFIG_DIR "/pd18w_official.flag"
#define FILE_SALTYNX_PATH "/atmosphere/contents/0000000000534C56/flags/boot2.flag" // Just check for SaltyNX boot flag
#define FILE_REVERSENX_SYNC_FLAG_PATH FILE_CONFIG_DIR "/ReverseNX_sync.flag"
#define FILE_REVERSENX_RT_CONF_PATH FILE_CONFIG_DIR "/ReverseNX-RT.conf"
@@ -39,6 +40,7 @@ class FileUtils
static bool IsBoostEnabled();
static bool IsBoostStartEnabled();
static bool IsDownclockDockEnabled();
static bool IsPd18wAsOfficialChargerEnabled();
static bool IsReverseNXSyncEnabled();
static bool IsReverseNXToolExist();
static void InitializeAsync();