diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index 6951c5acc..6a8fd4069 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -31,6 +31,62 @@ DECLARE_TR_CTX(pipe_tr, SOF_UUID(pipe_uuid), LOG_LEVEL_INFO); static SHARED_DATA struct pipeline_posn pipeline_posn; +/** + * \brief Retrieves pipeline position structure. + * \return Pointer to pipeline position structure. + */ +static inline struct pipeline_posn *pipeline_posn_get(void) +{ + return sof_get()->pipeline_posn; +} + +/** + * \brief Retrieves first free pipeline position offset. + * \param[in,out] posn_offset Pipeline position offset to be set. + * \return Error code. + */ +static inline int pipeline_posn_offset_get(uint32_t *posn_offset) +{ + struct pipeline_posn *pipeline_posn = pipeline_posn_get(); + int ret = -EINVAL; + uint32_t i; + + spin_lock(&pipeline_posn->lock); + + for (i = 0; i < PPL_POSN_OFFSETS; ++i) { + if (!pipeline_posn->posn_offset[i]) { + *posn_offset = i * sizeof(struct sof_ipc_stream_posn); + pipeline_posn->posn_offset[i] = true; + ret = 0; + break; + } + } + + platform_shared_commit(pipeline_posn, sizeof(*pipeline_posn)); + + spin_unlock(&pipeline_posn->lock); + + return ret; +} + +/** + * \brief Frees pipeline position offset. + * \param[in] posn_offset Pipeline position offset to be freed. + */ +static inline void pipeline_posn_offset_put(uint32_t posn_offset) +{ + struct pipeline_posn *pipeline_posn = pipeline_posn_get(); + int i = posn_offset / sizeof(struct sof_ipc_stream_posn); + + spin_lock(&pipeline_posn->lock); + + pipeline_posn->posn_offset[i] = false; + + platform_shared_commit(pipeline_posn, sizeof(*pipeline_posn)); + + spin_unlock(&pipeline_posn->lock); +} + void pipeline_posn_init(struct sof *sof) { sof->pipeline_posn = platform_shared_get(&pipeline_posn, diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index 62e76a80e..6162edd19 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -111,68 +111,12 @@ struct pipeline_posn { spinlock_t lock; /**< lock mechanism */ }; -/** - * \brief Retrieves pipeline position structure. - * \return Pointer to pipeline position structure. - */ -static inline struct pipeline_posn *pipeline_posn_get(void) -{ - return sof_get()->pipeline_posn; -} - /** * \brief Initializes pipeline position structure. * \param[in,out] sof Pointer to sof structure. */ void pipeline_posn_init(struct sof *sof); -/** - * \brief Retrieves first free pipeline position offset. - * \param[in,out] posn_offset Pipeline position offset to be set. - * \return Error code. - */ -static inline int pipeline_posn_offset_get(uint32_t *posn_offset) -{ - struct pipeline_posn *pipeline_posn = pipeline_posn_get(); - int ret = -EINVAL; - uint32_t i; - - spin_lock(&pipeline_posn->lock); - - for (i = 0; i < PPL_POSN_OFFSETS; ++i) { - if (!pipeline_posn->posn_offset[i]) { - *posn_offset = i * sizeof(struct sof_ipc_stream_posn); - pipeline_posn->posn_offset[i] = true; - ret = 0; - break; - } - } - - platform_shared_commit(pipeline_posn, sizeof(*pipeline_posn)); - - spin_unlock(&pipeline_posn->lock); - - return ret; -} - -/** - * \brief Frees pipeline position offset. - * \param[in] posn_offset Pipeline position offset to be freed. - */ -static inline void pipeline_posn_offset_put(uint32_t posn_offset) -{ - struct pipeline_posn *pipeline_posn = pipeline_posn_get(); - int i = posn_offset / sizeof(struct sof_ipc_stream_posn); - - spin_lock(&pipeline_posn->lock); - - pipeline_posn->posn_offset[i] = false; - - platform_shared_commit(pipeline_posn, sizeof(*pipeline_posn)); - - spin_unlock(&pipeline_posn->lock); -} - /* checks if two pipelines have the same scheduling component */ static inline bool pipeline_is_same_sched_comp(struct pipeline *current, struct pipeline *previous)