|
|
@ -136,10 +136,10 @@ PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} { |
|
|
{9, nullptr, "DisableEnoughPowerChargeEmulation"}, |
|
|
{9, nullptr, "DisableEnoughPowerChargeEmulation"}, |
|
|
{10, nullptr, "EnableFastBatteryCharging"}, |
|
|
{10, nullptr, "EnableFastBatteryCharging"}, |
|
|
{11, nullptr, "DisableFastBatteryCharging"}, |
|
|
{11, nullptr, "DisableFastBatteryCharging"}, |
|
|
{12, nullptr, "GetBatteryVoltageState"}, |
|
|
|
|
|
|
|
|
{12, &PSM::GetBatteryVoltageState, "GetBatteryVoltageState"}, |
|
|
{13, nullptr, "GetRawBatteryChargePercentage"}, |
|
|
{13, nullptr, "GetRawBatteryChargePercentage"}, |
|
|
{14, nullptr, "IsEnoughPowerSupplied"}, |
|
|
{14, nullptr, "IsEnoughPowerSupplied"}, |
|
|
{15, nullptr, "GetBatteryAgePercentage"}, |
|
|
|
|
|
|
|
|
{15, &PSM::GetBatteryAgePercentage, "GetBatteryAgePercentage"}, |
|
|
{16, nullptr, "GetBatteryChargeInfoEvent"}, |
|
|
{16, nullptr, "GetBatteryChargeInfoEvent"}, |
|
|
{17, &PSM::GetBatteryChargeInfoFields, "GetBatteryChargeInfoFields"}, |
|
|
{17, &PSM::GetBatteryChargeInfoFields, "GetBatteryChargeInfoFields"}, |
|
|
{18, nullptr, "GetBatteryChargeCalibratedEvent"}, |
|
|
{18, nullptr, "GetBatteryChargeCalibratedEvent"}, |
|
|
@ -189,6 +189,20 @@ void PSM::OpenSession(HLERequestContext& ctx) { |
|
|
rb.PushIpcInterface<IPsmSession>(system); |
|
|
rb.PushIpcInterface<IPsmSession>(system); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PSM::GetBatteryVoltageState(HLERequestContext& ctx) { |
|
|
|
|
|
LOG_DEBUG(Service_PTM, "(stubbed)"); |
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
|
|
rb.Push(ResultSuccess); |
|
|
|
|
|
rb.PushRaw<u32>(0); //
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PSM::GetBatteryAgePercentage(HLERequestContext& ctx) { |
|
|
|
|
|
LOG_DEBUG(Service_PTM, "(stubbed)"); |
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
|
|
rb.Push(ResultSuccess); |
|
|
|
|
|
rb.PushRaw<f64>(1.f); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
struct BatteryChargeInfoFields { |
|
|
struct BatteryChargeInfoFields { |
|
|
u32 input_current_limit; //mA
|
|
|
u32 input_current_limit; //mA
|
|
|
u32 boost_mode_current_limit; |
|
|
u32 boost_mode_current_limit; |
|
|
@ -200,9 +214,9 @@ struct BatteryChargeInfoFields { |
|
|
INSERT_PADDING_BYTES_NOINIT(2); |
|
|
INSERT_PADDING_BYTES_NOINIT(2); |
|
|
u32 vdd50_state; |
|
|
u32 vdd50_state; |
|
|
u32 temperature_celcius; |
|
|
u32 temperature_celcius; |
|
|
u32 battery_charge_percentage; |
|
|
|
|
|
|
|
|
f32 battery_charge_percentage; |
|
|
u32 battery_charge_milli_voltage; |
|
|
u32 battery_charge_milli_voltage; |
|
|
u32 battery_age_percentage; |
|
|
|
|
|
|
|
|
f32 battery_age_percentage; |
|
|
u32 usb_power_role; |
|
|
u32 usb_power_role; |
|
|
u32 usb_charger_type; |
|
|
u32 usb_charger_type; |
|
|
u32 charger_input_voltage_limit; |
|
|
u32 charger_input_voltage_limit; |
|
|
@ -214,17 +228,21 @@ struct BatteryChargeInfoFields { |
|
|
INSERT_PADDING_BYTES_NOINIT(0x14); //[+17.0.0]
|
|
|
INSERT_PADDING_BYTES_NOINIT(0x14); //[+17.0.0]
|
|
|
}; |
|
|
}; |
|
|
static_assert(sizeof(struct BatteryChargeInfoFields) == 0x54); |
|
|
static_assert(sizeof(struct BatteryChargeInfoFields) == 0x54); |
|
|
|
|
|
|
|
|
void PSM::GetBatteryChargeInfoFields(HLERequestContext& ctx) { |
|
|
void PSM::GetBatteryChargeInfoFields(HLERequestContext& ctx) { |
|
|
LOG_DEBUG(Service_PTM, "called"); |
|
|
LOG_DEBUG(Service_PTM, "called"); |
|
|
Common::PowerStatus power_status = Common::GetPowerStatus(); |
|
|
Common::PowerStatus power_status = Common::GetPowerStatus(); |
|
|
|
|
|
|
|
|
BatteryChargeInfoFields r{}; |
|
|
BatteryChargeInfoFields r{}; |
|
|
r.battery_charge_percentage = power_status.percentage; //100%
|
|
|
|
|
|
r.battery_age_percentage = power_status.percentage; //100%
|
|
|
|
|
|
|
|
|
r.battery_charge_percentage = f32(power_status.percentage); //100%
|
|
|
|
|
|
r.battery_age_percentage = f32(power_status.percentage); //100%
|
|
|
r.battery_charging = power_status.charging ? 1 : 0; |
|
|
r.battery_charging = power_status.charging ? 1 : 0; |
|
|
r.charger_type = u32(power_status.has_battery && power_status.charging |
|
|
r.charger_type = u32(power_status.has_battery && power_status.charging |
|
|
? ChargerType::RegularCharger : ChargerType::Unplugged); |
|
|
? ChargerType::RegularCharger : ChargerType::Unplugged); |
|
|
|
|
|
r.charger_input_voltage_limit = 100; |
|
|
|
|
|
r.charger_input_voltage_limit = 100; |
|
|
|
|
|
r.input_current_limit = 100; |
|
|
|
|
|
r.boost_mode_current_limit = 100; |
|
|
|
|
|
r.fast_charge_current_limit = 100; |
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
rb.Push(ResultSuccess); |
|
|
rb.Push(ResultSuccess); |
|
|
|