comp: add comp_get_status() helper function

This commit adds comp_get_status() helper function, which
takes two arguments: requesting component and component from
which user wants to read status. In case when both components
are on the different cores function additionally invokes
comp_invalidate().

This commit also fixes issue in smart_amp_copy() function, where
we always invoke comp_invalidate(sad->feedback_buf->source) whether
or not both components (smart amp and sad->feedback_buf->source)
are on different cores. In case when both components are on
the same core, we can invalidate data not previously writebacked.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2020-08-28 14:47:41 +02:00 committed by Liam Girdwood
parent 6be9315596
commit b6e31d1185
2 changed files with 18 additions and 2 deletions

View File

@ -432,8 +432,7 @@ static int smart_amp_copy(struct comp_dev *dev)
avail_frames = avail_passthrough_frames;
buffer_lock(sad->feedback_buf, &feedback_flags);
comp_invalidate(sad->feedback_buf->source);
if (sad->feedback_buf->source->state == dev->state) {
if (comp_get_state(dev, sad->feedback_buf->source) == dev->state) {
/* feedback */
avail_feedback_frames = audio_stream_get_avail_frames(&sad->feedback_buf->stream);

View File

@ -755,6 +755,23 @@ static inline void comp_writeback(struct comp_dev *dev)
dcache_writeback_region(dev, sizeof(struct comp_dev));
}
/**
* Get component state.
*
* @param req_dev Requesting component
* @param dev Component from which user wants to read status.
*/
static inline int comp_get_state(struct comp_dev *req_dev, struct comp_dev *dev)
{
/* we should not invalidate data when components are on the same
* core, because we could invalidate data not previously writebacked
*/
if (req_dev->comp.core != dev->comp.core)
comp_invalidate(dev);
return dev->state;
}
/**
* Frees data for large component configurations.
*