Power Manager
[System]


Data Structures

struct  _AlpPowerBattEventDetails
struct  _AlpPowerOffEventDetails
struct  _AlpPowerWakeStateEventDetails

Power Manager Notifications

The Power Manager informs applications of changes in the device and battery states through notifications. Notifications are generated on each state change, and indicate both the new and previous states. Sleep notifications (transitions from a higher wake state to a lower), and the power-off notification sent when the device is shutting down, are delivered before the new state is entered, allowing applications to prepare for the change (e.g., save data, shut down network connections, etc.); all other notifications are sent after the fact.

As with all notifications, applications should register for the most specific power notifications possible, to minimize the amount of processing the system does during power state transation, which occur frequently. This is especially important for "sleep" notifications, since the device will not enter the lower wake state until processing of the sleep notification has been completed by all apps. In addition, most apps will have no use for power notifications when they are not running, and should therefore use alp_notify_register() to register for power notifications when started, to ensure that the registration is cancelled when the app exits.

#define ALP_NOTIFY_EVENT_POWER_BATT_CHANGE   "/alp/power/batt"
 Power Manager battery state notifications. All battery notifications.
#define ALP_NOTIFY_EVENT_POWER_BATT_STATE_CHANGE   "/alp/power/batt/state"
 Battery state change.
#define ALP_NOTIFY_EVENT_POWER_OFF   "/alp/power/off"
 Power Manager power-off notification. Device is being powered off.
#define ALP_NOTIFY_EVENT_POWER_SLEEP   "/alp/power/wake_state/sleep"
 All sleep notifications.
#define ALP_NOTIFY_EVENT_POWER_SLEEP_TO_SEMI_WAKE   "/alp/power/wake_state/sleep/semi_wake"
 Descending into "semi-wake" state.
#define ALP_NOTIFY_EVENT_POWER_SLEEP_TO_SLEEP   "/alp/power/wake_state/sleep/sleep"
 Descending into "sleep" state.
#define ALP_NOTIFY_EVENT_POWER_WAKE   "/alp/power/wake_state/wake"
 All wake notifications.
#define ALP_NOTIFY_EVENT_POWER_WAKE_STATE_CHANGE   "/alp/power/wake_state"
 Power Manager wake state notifications. All sleep and wake notifications.
#define ALP_NOTIFY_EVENT_POWER_WAKE_TO_FULL_WAKE   "/alp/power/wake_state/wake/full_wake"
 Waking into "full-wake" state.
#define ALP_NOTIFY_EVENT_POWER_WAKE_TO_SEMI_WAKE   "/alp/power/wake_state/wake/semi_wake"
 Waking into "semi-wake" state.
typedef _AlpPowerBattEventDetails AlpPowerBattEventDetails
typedef _AlpPowerOffEventDetails AlpPowerOffEventDetails
typedef _AlpPowerWakeStateEventDetails AlpPowerWakeStateEventDetails

Backlight and Timeout Names

These constants can be used as the name arguments to alp_power_set_default_timeout() and alp_power_set_brightness(), to specify the backlight device(s) to which the new timeout/brightness setting should be applied.

#define ALP_POWER_ALL_PRIMARY   "_all-primary"
 All primary backlights (LCD and keypad).
#define ALP_POWER_ALL_TIMEOUTS   "_all-timeouts"
 Auto-off timer and all primary backlights (timeout only).
#define ALP_POWER_AUTO_OFF   "_auto-off"
 Auto-off timer (timeout only).
#define ALP_POWER_PRIMARY_KEYBOARD   "_primary-key"
 Primary keyboard/keypad backlight.
#define ALP_POWER_PRIMARY_LCD   "_primary-lcd"
 Primary LCD backlight.

DPM Perfomance Levels

These values are used with alp_power_set_performance_request() to specify the minimum level of system performance (i.e., CPU and memory performance) needed by an application.

Performance values range from negative (very slow performance is acceptible) to positive (very high performance is required). The default performance level is appropriate for an interactive UI app.

#define ALP_POWER_PERF_LEVEL_DEFAULT   0
#define ALP_POWER_PERF_LEVEL_LAUNCH   ALP_POWER_PERF_LEVEL_MAX
 level used for launching apps
#define ALP_POWER_PERF_LEVEL_MAX   5
#define ALP_POWER_PERF_LEVEL_MIN   -5

Power Manager Error Codes

#define ALP_STATUS_POWER_INVALID_PARAM   (ALP_CLASS_POWER | 0x00010000)
 Invalid parameter value.
#define ALP_STATUS_POWER_NO_DEVICE   (ALP_CLASS_POWER | 0x00070000)
 Specified device doesn't exist.
#define ALP_STATUS_POWER_NO_FREE_RAM   (ALP_CLASS_POWER | 0x00020000)
 Memory allocation failed.
#define ALP_STATUS_POWER_NO_MISER   (ALP_CLASS_POWER | 0x00030000)
 Can't connect to Power Miser daeomon.
#define ALP_STATUS_POWER_NO_WAKEUP   (ALP_CLASS_POWER | 0x00060000)
 Specified wake-up is not active.
#define ALP_STATUS_POWER_NOT_ALLOWED   (ALP_CLASS_POWER | 0x00040000)
 Operation not allowed.
#define ALP_STATUS_POWER_TIME_PASSED   (ALP_CLASS_POWER | 0x00050000)
 Requested wake-up time is in the past.

Battery States

These values are returned through the
stateOut parameter to alp_power_get_battery_state(), to indicate the system's current battery charge state.

enum  AlpPowerBatteryState { ALP_POWER_NORMAL_BATTERY_STATE, ALP_POWER_LOW_BATTERY_STATE, ALP_POWER_CRITICAL_BATTERY_STATE }

Wake State Names

These values describe the device's current "wake state": fully on, partially on, or asleep.

enum  AlpPowerWakeState { ALP_POWER_FULL_WAKE_STATE, ALP_POWER_SEMI_WAKE_STATE, ALP_POWER_SLEEP_STATE }

Typedefs

typedef gboolean(* AlpPowerWakeupCallback )(gpointer data)
 Prototype for functions which handle Power Manager wake-up events.

Functions

alp_status_t alp_power_acquire_wake_ref (AlpPowerWakeState state)
 Request device enter/remain in the specified "wake state".
alp_status_t alp_power_cancel_wakeup (guint wakeupID)
 Cancel a wake-up event.
alp_status_t alp_power_clear_performance_request (void)
 Cancel DPM performance request for the current process.
alp_status_t alp_power_force_full_wake ()
 Force device into full-wake.
alp_status_t alp_power_get_battery_state (guint *percentOut, AlpPowerBatteryState *stateOut, gboolean *chargingOut)
 Retrieve current battery state.
alp_status_t alp_power_get_battery_thresholds (guint *lowBatteryThresholdOut, guint *criticalBatteryThresholdOut)
 Retrieve thresholds for transitions between battery states, in percentage charge remaining.
alp_status_t alp_power_get_wake_state (AlpPowerWakeState *stateOut)
 Retrieve device's current "wake state".
alp_status_t alp_power_release_wake_ref (AlpPowerWakeState state)
 Cancel previous request for specified "wake state".
alp_status_t alp_power_request_wakeup (time_t when, AlpPowerWakeState state, AlpPowerWakeupCallback callback, gpointer data, guint *wakeupIDOut)
 Schedule wake-up at specified time.
alp_status_t alp_power_set_performance_request (int level)
 Set DPM performance request for current process.
alp_status_t alp_power_set_timeout (struct _GtkWindow *win, const char *name, uint32_t timeout)
 Set task-specific backlight/auto-off timeout, effective while the window is shown.
alp_status_t alp_power_wakeup_handled ()
 Signal asynchronous completion of wake-up event.


Define Documentation

#define ALP_NOTIFY_EVENT_POWER_BATT_CHANGE   "/alp/power/batt"
 

Power Manager battery state notifications. All battery notifications.

#define ALP_NOTIFY_EVENT_POWER_BATT_STATE_CHANGE   "/alp/power/batt/state"
 

Battery state change.

#define ALP_NOTIFY_EVENT_POWER_OFF   "/alp/power/off"
 

Power Manager power-off notification. Device is being powered off.

#define ALP_NOTIFY_EVENT_POWER_SLEEP   "/alp/power/wake_state/sleep"
 

All sleep notifications.

#define ALP_NOTIFY_EVENT_POWER_SLEEP_TO_SEMI_WAKE   "/alp/power/wake_state/sleep/semi_wake"
 

Descending into "semi-wake" state.

#define ALP_NOTIFY_EVENT_POWER_SLEEP_TO_SLEEP   "/alp/power/wake_state/sleep/sleep"
 

Descending into "sleep" state.

#define ALP_NOTIFY_EVENT_POWER_WAKE   "/alp/power/wake_state/wake"
 

All wake notifications.

#define ALP_NOTIFY_EVENT_POWER_WAKE_STATE_CHANGE   "/alp/power/wake_state"
 

Power Manager wake state notifications. All sleep and wake notifications.

#define ALP_NOTIFY_EVENT_POWER_WAKE_TO_FULL_WAKE   "/alp/power/wake_state/wake/full_wake"
 

Waking into "full-wake" state.

#define ALP_NOTIFY_EVENT_POWER_WAKE_TO_SEMI_WAKE   "/alp/power/wake_state/wake/semi_wake"
 

Waking into "semi-wake" state.

#define ALP_POWER_ALL_PRIMARY   "_all-primary"
 

All primary backlights (LCD and keypad).

#define ALP_POWER_ALL_TIMEOUTS   "_all-timeouts"
 

Auto-off timer and all primary backlights (timeout only).

#define ALP_POWER_AUTO_OFF   "_auto-off"
 

Auto-off timer (timeout only).

#define ALP_POWER_PERF_LEVEL_DEFAULT   0
 

#define ALP_POWER_PERF_LEVEL_LAUNCH   ALP_POWER_PERF_LEVEL_MAX
 

level used for launching apps

#define ALP_POWER_PERF_LEVEL_MAX   5
 

#define ALP_POWER_PERF_LEVEL_MIN   -5
 

#define ALP_POWER_PRIMARY_KEYBOARD   "_primary-key"
 

Primary keyboard/keypad backlight.

#define ALP_POWER_PRIMARY_LCD   "_primary-lcd"
 

Primary LCD backlight.

#define ALP_STATUS_POWER_INVALID_PARAM   (ALP_CLASS_POWER | 0x00010000)
 

Invalid parameter value.

#define ALP_STATUS_POWER_NO_DEVICE   (ALP_CLASS_POWER | 0x00070000)
 

Specified device doesn't exist.

#define ALP_STATUS_POWER_NO_FREE_RAM   (ALP_CLASS_POWER | 0x00020000)
 

Memory allocation failed.

#define ALP_STATUS_POWER_NO_MISER   (ALP_CLASS_POWER | 0x00030000)
 

Can't connect to Power Miser daeomon.

#define ALP_STATUS_POWER_NO_WAKEUP   (ALP_CLASS_POWER | 0x00060000)
 

Specified wake-up is not active.

#define ALP_STATUS_POWER_NOT_ALLOWED   (ALP_CLASS_POWER | 0x00040000)
 

Operation not allowed.

#define ALP_STATUS_POWER_TIME_PASSED   (ALP_CLASS_POWER | 0x00050000)
 

Requested wake-up time is in the past.


Typedef Documentation

typedef struct _AlpPowerBattEventDetails AlpPowerBattEventDetails
 

typedef struct _AlpPowerOffEventDetails AlpPowerOffEventDetails
 

typedef struct _AlpPowerWakeStateEventDetails AlpPowerWakeStateEventDetails
 

typedef gboolean(* AlpPowerWakeupCallback)(gpointer data)
 

Prototype for functions which handle Power Manager wake-up events.


Enumeration Type Documentation

enum AlpPowerBatteryState
 

Enumerator:
ALP_POWER_NORMAL_BATTERY_STATE  Battery has enough charge for normal device functioning.
ALP_POWER_LOW_BATTERY_STATE  Battery is low; some device functionality may be unavailable.
ALP_POWER_CRITICAL_BATTERY_STATE  Battery if very low; forced device shutdown is imminent.

enum AlpPowerWakeState
 

Enumerator:
ALP_POWER_FULL_WAKE_STATE  Device fully awake, screen on.
ALP_POWER_SEMI_WAKE_STATE  Device partially awake, screen off.
ALP_POWER_SLEEP_STATE  Device asleep, can be re-awakened by hardware or software events.


Function Documentation

alp_status_t alp_power_acquire_wake_ref AlpPowerWakeState  state  ) 
 

Request device enter/remain in the specified "wake state".

Applications may prevent the device from moving to a lower wake state by acquring a "wake reference" on that state. As long as the wake reference is held, the Power Manager will prevent the device from leaving the specified state.

Parameters:
[in] state Wake state to remain in
Returns:
ALP_STATUS_OK if the wake reference was acquired successfully
Remarks:
Should the device's battery become critically low, the Power Manager may force the device to sleep, regardless of any outstanding wake references.

alp_status_t alp_power_cancel_wakeup guint  wakeupID  ) 
 

Cancel a wake-up event.

Cancel a wake-up request scheduled through a previous call to alp_power_request_wakeup().

Parameters:
[in] wakeupID Identifier returned by alp_power_request_wakeup() when the event was scheduled
Returns:
ALP_STATUS_OK if the wake-up event was cancelled successfully

ALP_STATUS_NO_WAKEUP if the identifier does not correspond to a pending wake-up event

alp_status_t alp_power_clear_performance_request void   ) 
 

Cancel DPM performance request for the current process.

Cancels a performance request previously issued via a call to alp_power_set_performance_request().

Remarks:
When an application no longer requires a particular level of system performance, it should call alp_power_clear_performance_request() instead of alp_power_set_performance_request(ALP_POWER_PERF_LEVEL_DEFAULT), as doing so will give the system greater latitude to adjust system performance levels (e.g., it may be able to scale down the clocks to a very low level when system load is very light, etc.).

alp_status_t alp_power_force_full_wake  ) 
 

Force device into full-wake.

Forces the device into the Full-Wake state. This call resets the Power Manager's inactivity timer, and therefore all backlight timers and the auto-off timer.

Returns:
ALP_STATUS_OK if the transition into Full-Wake was successful.

ALP_STATUS_NOT_ALLOWED if the transition into Full-Wake was prevented, probably due to a critically low battery

alp_status_t alp_power_get_battery_state guint *  percentOut,
AlpPowerBatteryState stateOut,
gboolean *  chargingOut
 

Retrieve current battery state.

Retrieves the device's current battery charge level, in percent full, the current device battery state (normal, low, critically low), and whether or not the device is currently plugged-in to an external power source.

Parameters:
[out] percentOut Current battery charge level, in percent full
[out] stateOut Current device battery state
[out] chargingOut Indicates whether device is currently plugged-in

alp_status_t alp_power_get_battery_thresholds guint *  lowBatteryThresholdOut,
guint *  criticalBatteryThresholdOut
 

Retrieve thresholds for transitions between battery states, in percentage charge remaining.

alp_status_t alp_power_get_wake_state AlpPowerWakeState stateOut  ) 
 

Retrieve device's current "wake state".

Retrieves the device's current "wake state".

Parameters:
[out] stateOut Devices current wake state
Returns:
ALP_STATUS_OK if the wake state was retrieved successfully

alp_status_t alp_power_release_wake_ref AlpPowerWakeState  state  ) 
 

Cancel previous request for specified "wake state".

Releases a wake reference on the specified state acquired through a previous call to alp_power_acquire_wake_ref().

Parameters:
[in] state Wake state against which the reference is released
Returns:
ALP_STATUS_OK if the wake reference was released successfully

ALP_STATUS_NOT_ALLOWED if the application is not currently holding a reference on the specified wake state

alp_status_t alp_power_request_wakeup time_t  when,
AlpPowerWakeState  state,
AlpPowerWakeupCallback  callback,
gpointer  data,
guint *  wakeupIDOut
 

Schedule wake-up at specified time.

Applications can request that the device be in a particular wake state at a particular time. If the system is in a lower wake state at the specified time, the Power Manager will wake the device into the specified state, and will keep it in that state until the application has finished handling the wake-up event.

Parameters:
[in] when Time, in seconds since the epoch UTC, for the wake-up to occur
[in] state Minimum wake state required for the wake-up event
[in] callback Optional function to be called back at the time of the wake-up event
[in] data Optional data to be passed to the callback
[out] wakeupIDOut Identifier which can be used to cancel the wake-up request
Returns:
ALP_STATUS_OK if the wake-up was scheduled successfully

ALP_STATUS_TIME_PASSED if the specified time is in the past

ALP_STATUS_NOT_ALLOWED if too many wake-ups are already scheduled by the application

Remarks:
If a NULL callback is specified, the Power Manager will simply ensure that the device is in the desired wake state at the event time. This is primarily useful for returning the device to Full-Wake, since the auto-off timer will prevent it from immediately returning to sleep (the auto-off timer does not run in Semi-Wake, so the device may go back to sleep right away after waking).
If a callback is specified, the Power Manager will acquire a wake reference against the specified wake state on the application's behalf before invoking the callback. That reference will remain in effect until the callback return TRUE, or the application calls alp_power_wakeup_handled(). The reference cannot be released through alp_power_release_wake_ref().

alp_status_t alp_power_set_performance_request int  level  ) 
 

Set DPM performance request for current process.

Requests that the system provide the specified level of performance for the calling process, until alp_power_clear_performance_request() is next called.

Parameters:
[in] level Required performance level
Returns:
ALP_STATUS_OK if performance request was granted

ALP_STATUS_NOT_ALLOWED if performance request could not be granted

Remarks:
A call to alp_power_set_performance_request() overrides any performance request previously issued by the process.

An application which has no special performance needs should not call alp_power_set_performance_request(ALP_POWER_PERF_LEVEL_DEFAULT); the system will ensure that applications receives the default level of performance automatically.

alp_status_t alp_power_set_timeout struct _GtkWindow *  win,
const char *  name,
uint32_t  timeout
 

Set task-specific backlight/auto-off timeout, effective while the window is shown.

Registers a task-specific inactivity timeout for the specified device(s). The timeout will be honored whenever the specified window is visible; while the window is hidden, or when it is destroyed, this timeout request will cease to have an effect on the system.

Parameters:
[in] win Window with which this task-specific timeout will be associated
[in] name Backlight/timeout name, specifying the timeout to affect
[in] timeout New timeout, in seconds
Returns:
ALP_STATUS_OK if the timeout was registered successfully

ALP_STATUS_POWER_INVALID_PARAM if the name is not a backlight or timeout name

ALP_STATUS_POWER_NO_DEVICE if the name is valid, but does not match any devices

ALP_STATUS_POWER_NOT_ALLOWED if the application has already registered too many timeouts

Remarks:
Multiple timeouts for different devices may be associated with the same window. If multiple timeouts for the same device are associated with the same window, the timeout value passed to the most recent invocation of alp_power_set_timeout() is used.
A timeout of -1 will cause the specified timeout to be disabled (infinite). A timeout of 0 will cancel a previously-specified timeout.

alp_status_t alp_power_wakeup_handled  ) 
 

Signal asynchronous completion of wake-up event.

If a callback is provided to alp_power_request_wakeup() when a wake-up request is scheduled, and that callback returns FALSE when called by the Power Manager, the application must call alp_power_wakeup_handled() to signal to the Power Manager that processing of the wake-up is complete. Only then will the Power Manager release the wake state reference it acquired for the application before invoking the callback, potentially allowing the device to return to sleep.

Returns:
ALP_STATUS_OK if event completion was signaled to the Power Manager successfully

ALP_STATUS_NO_WAKEUP if the application is not currently handling a wake-up event


Generated on Wed Jul 30 07:06:43 2008 by Doxygen 1.4.6 for ALP SDK + Hiker Documentation

Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.