Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ void comp_unregister(struct comp_driver_info *drv)
irq_local_enable(flags);
}

/* NOTE: Keep the component state diagram up to date:
* sof-docs/developer_guides/firmware/components/images/comp-dev-states.pu
*/

int comp_set_state(struct comp_dev *dev, int cmd)
{
int requested_state = comp_get_requested_state(cmd);
Expand Down
56 changes: 19 additions & 37 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,16 @@ struct dai_hw_params;
* @{
*/

/** \name Audio Component States
* @{
/* NOTE: Keep the component state diagram up to date:
* sof-docs/developer_guides/firmware/components/images/comp-dev-states.pu
*/

/**
* States may transform as below:-
* \verbatim
* +---------------------------------------+
* | |
* ------------- |
* pause | | stop |
* +-------------| ACTIVITY |---------------+ |
* | | | | prepare |
* | ------------- | +---------+ |
* | ^ ^ | | | |
* | | | | | | |
* v | | v | | |
* ------------- | | ------------- | |
* | | release | | start | | | |
* | PAUSED |-----------+ +-------------| PREPARE |<-----+ |
* | | | | |
* ------------- ------------- |
* | ^ ^ |
* | stop | | |
* +--------------------------------------+ | |
* | prepare |
* ------------- | |
* | | | |
* ----------->| READY |------------------+ |
* reset | | |
* ------------- |
* ^ |
* | xrun |
* +---------------------------------------+
*
* \endverbatim
/** \name Audio Component States
* @{
*/

#define COMP_STATE_INIT 0 /**< Component being initialised */
#define COMP_STATE_READY 1 /**< Component inactive, but ready */
#define COMP_STATE_SUSPEND 2 /**< Component suspended */
#define COMP_STATE_READY 1 /**< Component inactive, but ready */
#define COMP_STATE_SUSPEND 2 /**< Component suspended */
#define COMP_STATE_PREPARE 3 /**< Component prepared */
#define COMP_STATE_PAUSED 4 /**< Component paused */
#define COMP_STATE_ACTIVE 5 /**< Component active */
Expand Down Expand Up @@ -551,6 +520,19 @@ static inline void comp_shared_commit(struct comp_dev *dev)
* @param dev Component device.
* @param cmd Command, one of <i>COMP_TRIGGER_...</i>.
* @return 0 if succeeded, error code otherwise.
*
* This function should be called by a component implementation at the beginning
* of its state transition to verify whether the trigger is valid in the
* current state and abort the transition otherwise.
*
* Typically the COMP_STATE_READY as the initial state is set directly
* by the component's implementation of _new().
*
* COMP_TRIGGER_PREPARE is called from the component's prepare().
*
* COMP_TRIGGER_START/STOP is called from trigger().
*
* COMP_TRIGGER_RESET is called from reset().
*/
int comp_set_state(struct comp_dev *dev, int cmd);

Expand Down