- sys-clk-OC: force disable charging, a temporary toggle that will be reset once power state changes (#57)

This commit is contained in:
KazushiM
2023-01-04 14:25:33 +08:00
parent 277f8d48e5
commit 012cd40a68
13 changed files with 95 additions and 14 deletions

View File

@@ -58,6 +58,7 @@ ClockManager::ClockManager()
this->oc = new SysClkOcExtra;
this->oc->systemCoreBoostCPU = false;
this->oc->batteryChargingDisabledOverride = false;
this->oc->governor = false;
this->oc->realProfile = SysClkProfile_Handheld;
@@ -209,9 +210,7 @@ void ClockManager::WaitForNextTick()
bool ClockManager::RefreshContext()
{
uint32_t chargingCurrent = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingCurrentLimit);
uint32_t chargingLimit = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingLimitPercentage);
PsmExt::ChargingHandler(chargingCurrent, chargingLimit);
PsmExt::ChargingHandler(this->GetInstance());
bool hasChanged = this->config->Refresh();
if (hasChanged) {
@@ -259,11 +258,13 @@ bool ClockManager::RefreshContext()
this->governor->Stop();
}
SysClkProfile profile = Clocks::GetCurrentProfile();
if (profile != this->oc->realProfile)
SysClkProfile realProfile = Clocks::GetCurrentProfile();
if (realProfile != this->oc->realProfile)
{
FileUtils::LogLine("[mgr] Profile change: %s", Clocks::GetProfileName(profile, true));
this->oc->realProfile = profile;
FileUtils::LogLine("[mgr] Profile change: %s", Clocks::GetProfileName(realProfile, true));
this->oc->realProfile = realProfile;
// Signal that power state has been changed, reset the override
this->SetBatteryChargingDisabledOverride(false);
hasChanged = true;
}
@@ -371,3 +372,12 @@ Config* ClockManager::GetConfig()
{
return this->config;
}
bool ClockManager::GetBatteryChargingDisabledOverride() {
return this->oc->batteryChargingDisabledOverride;
}
Result ClockManager::SetBatteryChargingDisabledOverride(bool toggle_true) {
this->oc->batteryChargingDisabledOverride = toggle_true;
return 0;
}