POWER_STATE_SLEEP_INDEX,
POWER_STATE_POWEROFF_INDEX,
POWER_STATE_REBOOT_INDEX,
+ POWER_STATE_EXIT_INDEX,
POWER_STATE_MAX_INDEX,
};
#define POWER_STATE_SLEEP (1ULL << POWER_STATE_SLEEP_INDEX)
#define POWER_STATE_POWEROFF (1ULL << POWER_STATE_POWEROFF_INDEX)
#define POWER_STATE_REBOOT (1ULL << POWER_STATE_REBOOT_INDEX)
+#define POWER_STATE_EXIT (1ULL << POWER_STATE_EXIT_INDEX)
#define POWER_STATE_ALL ((1ULL << POWER_STATE_MAX_INDEX) - (1ULL << POWER_STATE_MIN_INDEX))
#define SIGNAME_CHANGE_STATE_TO_START "ChangeStateToStart"
#define SIGNAME_CHANGE_STATE_TO_SLEEP "ChangeStateToSleep"
#define SIGNAME_CHANGE_STATE_TO_POWEROFF "ChangeStateToPowerOff"
#define SIGNAME_CHANGE_STATE_TO_REBOOT "ChangeStateToReboot"
+#define SIGNAME_CHANGE_STATE_TO_EXIT "ChangeStateToExit"
struct device_change_state_info {
- uint64_t prev_state;
- uint64_t next_state;
- uint64_t id;
- int reason;
+ uint64_t prev_state; /* previous state before the state transition, one of POWER_STATE_* */
+ uint64_t next_state; /* current state that has been transitioned, one of POWER_STATE_* */
+ uint64_t id; /* unique id for each transition. it is used for wait-done */
+ int reason; /* integer that signifies what event has triggered the transition */
};
+/**
+ * Callback function that delivers information about a state transition.
+ */
typedef void (*change_state_callback) (const struct device_change_state_info *info, void *user_data);
+/**
+ * Add callback for states to be transitioned.
+ *
+ * uint64_t state_bits: bitwise-ORing of interesting state.
+ * change_state_wait_callback cb: For every state transition to the state_bit, the cb will be invoked.
+ * void *user_data: user data for the callback.
+ */
int device_power_add_change_state_wait_callback(uint64_t state_bits, change_state_callback cb, void *user_data);
+
+/**
+ * Notify the deviced that it is ready to transition state.
+ *
+ * uint64_t id: id of device_change_state_info that has received through callback.
+ */
int device_power_change_state_wait_done(uint64_t id);
+
+/**
+ * Remove callback of state transition.
+ */
void device_power_remove_change_state_wait_callback(uint64_t state_bits);
#ifdef __cplusplus
[POWER_STATE_SLEEP_INDEX] = SIGNAME_CHANGE_STATE_TO_SLEEP,
[POWER_STATE_POWEROFF_INDEX] = SIGNAME_CHANGE_STATE_TO_POWEROFF,
[POWER_STATE_REBOOT_INDEX] = SIGNAME_CHANGE_STATE_TO_REBOOT,
+ [POWER_STATE_EXIT_INDEX] = SIGNAME_CHANGE_STATE_TO_EXIT,
};
static void signal_unsubscribed_callback(void *data)