libnx  v4.2.0
Data Structures | Enumerations | Functions
psm.h File Reference

PSM service IPC wrapper. More...

#include "../types.h"
#include "../sf/service.h"
#include "../kernel/event.h"

Go to the source code of this file.

Data Structures

struct  PsmSession
 IPsmSession. More...
 

Enumerations

enum  PsmChargerType {
  PsmChargerType_Unconnected = 0,
  PsmChargerType_EnoughPower = 1,
  PsmChargerType_LowPower = 2,
  PsmChargerType_NotSupported = 3
}
 
enum  PsmBatteryVoltageState {
  PsmBatteryVoltageState_NeedsShutdown = 0,
  PsmBatteryVoltageState_NeedsSleep = 1,
  PsmBatteryVoltageState_NoPerformanceBoost = 2,
  PsmBatteryVoltageState_Normal = 3
}
 

Functions

Result psmInitialize (void)
 Initialize psm.
 
void psmExit (void)
 Exit psm.
 
ServicepsmGetServiceSession (void)
 Gets the Service object for the actual psm service session.
 
Result psmGetBatteryChargePercentage (u32 *out)
 
Result psmGetChargerType (PsmChargerType *out)
 
Result psmGetBatteryVoltageState (PsmBatteryVoltageState *out)
 
Result psmGetRawBatteryChargePercentage (double *out)
 
Result psmIsEnoughPowerSupplied (bool *out)
 
Result psmGetBatteryAgePercentage (double *out)
 
Result psmBindStateChangeEvent (PsmSession *s, bool ChargerType, bool PowerSupply, bool BatteryVoltage)
 Wrapper func which opens a PsmSession and handles event setup. More...
 
Result psmWaitStateChangeEvent (PsmSession *s, u64 timeout)
 Wait on the Event setup by psmBindStateChangeEvent.
 
Result psmUnbindStateChangeEvent (PsmSession *s)
 Cleanup version of psmBindStateChangeEvent. Must be called by the user once the PsmSession is done being used.
 

Detailed Description

PSM service IPC wrapper.

Author
XorTroll, endrift, and yellows8

Enumeration Type Documentation

◆ PsmBatteryVoltageState

Enumerator
PsmBatteryVoltageState_NeedsShutdown 

Power state should transition to shutdown.

PsmBatteryVoltageState_NeedsSleep 

Power state should transition to sleep.

PsmBatteryVoltageState_NoPerformanceBoost 

Performance boost modes cannot be entered.

PsmBatteryVoltageState_Normal 

Everything is normal.

◆ PsmChargerType

Enumerator
PsmChargerType_Unconnected 

No charger.

PsmChargerType_EnoughPower 

Full supported power.

PsmChargerType_LowPower 

Lower power supported USB-PD mode.

PsmChargerType_NotSupported 

No common supported USB-PD modes.

Function Documentation

◆ psmBindStateChangeEvent()

Result psmBindStateChangeEvent ( PsmSession s,
bool  ChargerType,
bool  PowerSupply,
bool  BatteryVoltage 
)

Wrapper func which opens a PsmSession and handles event setup.

Note
Uses the actual BindStateChangeEvent cmd internally.
The event is not signalled on BatteryChargePercentage changes.
Parameters
[out]sPsmSession object.
[in]ChargerTypePassed to SetChargerTypeChangeEventEnabled.
[in]PowerSupplyPassed to SetPowerSupplyChangeEventEnabled.
[in]BatteryVoltagePassed to SetBatteryVoltageStateChangeEventEnabled.