mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 07:39:49 -04:00
boot: update for 13.0.0/aula parameter changes (closes #1477)
This commit is contained in:
parent
990daec3a2
commit
d1bc1a5c57
10 changed files with 96 additions and 68 deletions
|
@ -114,7 +114,6 @@ namespace ams::gpio {
|
|||
GpioPadName_NfcEn = 92,
|
||||
};
|
||||
|
||||
/* TODO: Better place for this? */
|
||||
constexpr inline const DeviceCode DeviceCode_CodecLdoEnTemp = 0x33000002;
|
||||
constexpr inline const DeviceCode DeviceCode_PowSdEn = 0x3C000001;
|
||||
constexpr inline const DeviceCode DeviceCode_BtRst = 0x37000002;
|
||||
|
@ -128,7 +127,7 @@ namespace ams::gpio {
|
|||
constexpr inline const DeviceCode DeviceCode_FanTach = 0x3D000002;
|
||||
constexpr inline const DeviceCode DeviceCode_ExtconDetS = 0x3500040B;
|
||||
constexpr inline const DeviceCode DeviceCode_Vdd50AEn = 0x39000401;
|
||||
constexpr inline const DeviceCode DeviceCode_SdevCoaxSel1 = 0xCA000402;
|
||||
constexpr inline const DeviceCode DeviceCode_SdevCoaxSel1 = 0xCA000406;
|
||||
constexpr inline const DeviceCode DeviceCode_GameCardCd = 0x3C000403;
|
||||
constexpr inline const DeviceCode DeviceCode_ProdType0 = 0xC900040B;
|
||||
constexpr inline const DeviceCode DeviceCode_ProdType1 = 0xC900040C;
|
||||
|
@ -148,7 +147,7 @@ namespace ams::gpio {
|
|||
constexpr inline const DeviceCode DeviceCode_PdVconnEn = 0x040000CC;
|
||||
constexpr inline const DeviceCode DeviceCode_PdRstN = 0x040000CA;
|
||||
constexpr inline const DeviceCode DeviceCode_Bq24190Irq = 0x39000002;
|
||||
constexpr inline const DeviceCode DeviceCode_SdevCoaxSel0 = 0xCA000401;
|
||||
constexpr inline const DeviceCode DeviceCode_SdevCoaxSel0 = 0xCA000405;
|
||||
constexpr inline const DeviceCode DeviceCode_SdWp = 0x3C000003;
|
||||
constexpr inline const DeviceCode DeviceCode_TpReset = 0x35000035;
|
||||
constexpr inline const DeviceCode DeviceCode_BtGpio2 = 0x37000401;
|
||||
|
@ -216,6 +215,7 @@ namespace ams::gpio {
|
|||
constexpr inline const DeviceCode DeviceCode_GpioPortY7 = 0x35000065;
|
||||
constexpr inline const DeviceCode DeviceCode_GpioPortF1 = 0x04000409;
|
||||
constexpr inline const DeviceCode DeviceCode_GpioPortH0 = 0x34000401;
|
||||
constexpr inline const DeviceCode DeviceCode_GpioPortI6 = 0x37000405;
|
||||
|
||||
constexpr inline GpioPadName ConvertToGpioPadName(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::powctl::driver::impl {
|
|||
int m_charge_voltage_limit;
|
||||
BatteryTemperatureLevel m_temperature_level;
|
||||
int m_avg_v_cell;
|
||||
int m_open_circuit_voltage;
|
||||
float m_voltage_fuel_gauge_percentage;
|
||||
bool m_has_battery_done_current;
|
||||
int m_battery_done_current;
|
||||
PowerState m_power_state;
|
||||
|
@ -45,6 +45,17 @@ namespace ams::powctl::driver::impl {
|
|||
return value < max;
|
||||
}
|
||||
}
|
||||
static constexpr bool IsInRangeFloat(float value, float min, float max) {
|
||||
if (!(min <= value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (max == std::numeric_limits<float>::max()) {
|
||||
return value <= max;
|
||||
} else {
|
||||
return value < max;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsAcceptablePowerState(const PowerState *acceptable, size_t num_acceptable) const {
|
||||
for (size_t i = 0; i < num_acceptable; ++i) {
|
||||
|
@ -57,7 +68,7 @@ namespace ams::powctl::driver::impl {
|
|||
public:
|
||||
ChargeArbiter(const ChargeParametersRule *r, size_t nr, int cvl)
|
||||
: m_rules(r), m_num_rules(nr), m_charge_voltage_limit(cvl), m_temperature_level(BatteryTemperatureLevel::Medium),
|
||||
m_avg_v_cell(4080), m_open_circuit_voltage(4001), m_has_battery_done_current(false), m_battery_done_current(0),
|
||||
m_avg_v_cell(4080), m_voltage_fuel_gauge_percentage(25.0), m_has_battery_done_current(false), m_battery_done_current(0),
|
||||
m_power_state(PowerState::FullAwake), m_selected_rule(nullptr), m_check_battery_done_current(false)
|
||||
{
|
||||
this->UpdateSelectedRule();
|
||||
|
@ -73,8 +84,8 @@ namespace ams::powctl::driver::impl {
|
|||
this->UpdateSelectedRule();
|
||||
}
|
||||
|
||||
void SetBatteryOpenCircuitVoltage(int ocv) {
|
||||
m_open_circuit_voltage = ocv;
|
||||
void SetBatteryVoltageFuelGaugePercentage(float pct) {
|
||||
m_voltage_fuel_gauge_percentage = pct;
|
||||
this->UpdateSelectedRule();
|
||||
}
|
||||
|
||||
|
@ -121,8 +132,8 @@ namespace ams::powctl::driver::impl {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Check that open circuit voltage is in range. */
|
||||
if (!IsInRange(m_open_circuit_voltage, cur_rule.min_open_circuit_voltage, cur_rule.max_open_circuit_voltage)) {
|
||||
/* Check that voltage fuel gauge percentage is in range. */
|
||||
if (!IsInRangeFloat(m_voltage_fuel_gauge_percentage, cur_rule.min_voltage_fuel_gauge_percentage, cur_rule.max_voltage_fuel_gauge_percentage)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -138,9 +149,25 @@ namespace ams::powctl::driver::impl {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Determine whether we should check battery done current. */
|
||||
bool check_battery_done_current;
|
||||
|
||||
if (m_selected_rule != nullptr && m_selected_rule->check_battery_current) {
|
||||
if (m_selected_rule->temperature_level == m_temperature_level &&
|
||||
IsInRange(m_avg_v_cell, m_selected_rule->min_avg_v_cell, m_selected_rule->max_avg_v_cell) &&
|
||||
IsInRangeFloat(m_voltage_fuel_gauge_percentage, m_selected_rule->min_voltage_fuel_gauge_percentage, m_selected_rule->max_voltage_fuel_gauge_percentage))
|
||||
{
|
||||
check_battery_done_current = m_has_battery_done_current && !IsInRange(m_battery_done_current, m_selected_rule->min_battery_done_current, m_selected_rule->max_battery_done_current);
|
||||
} else {
|
||||
check_battery_done_current = true;
|
||||
}
|
||||
} else {
|
||||
check_battery_done_current = false;
|
||||
}
|
||||
|
||||
/* Set whether we need to check the battery done current. */
|
||||
m_has_battery_done_current = false;
|
||||
m_check_battery_done_current |= cur_rule.check_battery_current;
|
||||
m_check_battery_done_current |= check_battery_done_current;
|
||||
} else {
|
||||
/* We're selecting the currently selected rule. Make sure the battery done current is acceptable if we have one. */
|
||||
if (m_has_battery_done_current && !IsInRange(m_battery_done_current, cur_rule.min_battery_done_current, cur_rule.max_battery_done_current)) {
|
||||
|
|
|
@ -23,10 +23,12 @@ namespace ams::powctl::driver::impl {
|
|||
BatteryTemperatureLevel temperature_level;
|
||||
int min_avg_v_cell;
|
||||
int max_avg_v_cell;
|
||||
int min_open_circuit_voltage;
|
||||
int max_open_circuit_voltage;
|
||||
int min_battery_done_current;
|
||||
int max_battery_done_current;
|
||||
float min_unknown_14;
|
||||
float max_unknown_18;
|
||||
float min_voltage_fuel_gauge_percentage;
|
||||
float max_voltage_fuel_gauge_percentage;
|
||||
const PowerState *acceptable_power_states;
|
||||
size_t num_acceptable_power_states;
|
||||
bool check_battery_current;
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace ams::powctl::impl {
|
|||
constexpr inline int GetDisplayPercentage(double raw_percentage, double min, double max) {
|
||||
/* Calculate the display percentage. */
|
||||
constexpr const double BaseDisplayPercentage = 2.0;
|
||||
const auto display_percentage = BaseDisplayPercentage + ((static_cast<double>(MaxDisplayPercentage - MinDisplayPercentage) * (raw_percentage - min)) / (max - min));
|
||||
const auto display_percentage = BaseDisplayPercentage + ((static_cast<double>(MaxDisplayPercentage - BaseDisplayPercentage) * (raw_percentage - min)) / (max - min));
|
||||
|
||||
/* Clamp the display percentage within bounds. */
|
||||
return std::max(std::min(static_cast<int>(display_percentage), MaxDisplayPercentage), MinDisplayPercentage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue