From 3fc03fdc3efd8b3d9a617562934136383b0d704a Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Wed, 18 Nov 2020 09:00:25 +0100 Subject: [PATCH 1/3] audio_stream: add function writing zeros This will allow to write zeros to the buffer without reference to a source buffer Signed-off-by: Adrian Bonislawski --- src/include/sof/audio/audio_stream.h | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index ed1c57717101..beb71652bfd5 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -587,6 +587,36 @@ static inline int audio_stream_copy(const struct audio_stream *source, return samples; } +/** + * Writes zeros in range [w_ptr, w_ptr+bytes], with rollover if necessary. + * @param buffer Buffer. + * @param bytes Size of the fragment to write zero. + * @return 0 if there is enough free space in buffer. + * @return 1 if there is not enough free space in buffer. + */ +static inline int audio_stream_set_zero(struct audio_stream *buffer, + uint32_t bytes) +{ + uint32_t head_size = bytes; + uint32_t tail_size = 0; + + /* check for overrun */ + if (audio_stream_get_free_bytes(buffer) < bytes) + return 1; + + /* check for potential wrap */ + if ((char *)buffer->w_ptr + bytes > (char *)buffer->end_addr) { + head_size = (char *)buffer->end_addr - (char *)buffer->w_ptr; + tail_size = bytes - head_size; + } + + memset(buffer->w_ptr, 0, head_size); + if (tail_size) + memset(buffer->addr, 0, tail_size); + + return 0; +} + /** @}*/ #endif /* __SOF_AUDIO_AUDIO_STREAM_H__ */ From 4ea9c929afabac658a8b85e7d24b0690eef4efd5 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Wed, 18 Nov 2020 09:05:17 +0100 Subject: [PATCH 2/3] mixer: dont stop mixer on pause Dont stop mixer on pause and write zeros if all sources are inactive Signed-off-by: Adrian Bonislawski --- src/audio/mixer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/audio/mixer.c b/src/audio/mixer.c index d0751ef2b5fe..685b693b00e4 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -243,16 +243,13 @@ static int mixer_trigger(struct comp_dev *dev, int cmd) if (dir == SOF_IPC_STREAM_CAPTURE) return ret; - /* don't stop mixer if at least one source is active */ - if (mixer_source_status_count(dev, COMP_STATE_ACTIVE) && - (cmd == COMP_TRIGGER_PAUSE || cmd == COMP_TRIGGER_STOP)) { + /* don't stop mixer on pause or if at least one source is active/paused */ + if (cmd == COMP_TRIGGER_PAUSE || + (cmd == COMP_TRIGGER_STOP && + (mixer_source_status_count(dev, COMP_STATE_ACTIVE) || + mixer_source_status_count(dev, COMP_STATE_PAUSED)))) { dev->state = COMP_STATE_ACTIVE; ret = PPL_STATUS_PATH_STOP; - /* don't stop mixer if at least one source is paused */ - } else if (mixer_source_status_count(dev, COMP_STATE_PAUSED) && - cmd == COMP_TRIGGER_STOP) { - dev->state = COMP_STATE_PAUSED; - ret = PPL_STATUS_PATH_STOP; } return ret; @@ -299,9 +296,20 @@ static int mixer_copy(struct comp_dev *dev) return 0; } - /* don't have any work if all sources are inactive */ - if (num_mix_sources == 0) + /* write zeros if all sources are inactive */ + if (num_mix_sources == 0) { + buffer_lock(sink, &flags); + frames = MIN(frames, audio_stream_get_free_frames(&sink->stream)); + sink_bytes = frames * audio_stream_frame_bytes(&sink->stream); + buffer_unlock(sink, flags); + + if (!audio_stream_set_zero(&sink->stream, sink_bytes)) { + buffer_writeback(sink, sink_bytes); + comp_update_buffer_produce(sink, sink_bytes); + } + return 0; + } buffer_lock(sink, &flags); From 4312f97ccd3f68d6ec974ecccff5a308b79cfedc Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Fri, 15 Jan 2021 12:24:17 +0100 Subject: [PATCH 3/3] config: byt: remove tone comp Remove tone from the byt defconfig to reduxe code size. Signed-off-by: Adrian Bonislawski --- src/arch/xtensa/configs/baytrail_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arch/xtensa/configs/baytrail_defconfig b/src/arch/xtensa/configs/baytrail_defconfig index 3068f1ccc8ff..8b5264e21649 100644 --- a/src/arch/xtensa/configs/baytrail_defconfig +++ b/src/arch/xtensa/configs/baytrail_defconfig @@ -9,6 +9,7 @@ CONFIG_COMP_DCBLOCK=n CONFIG_COMP_SRC=n CONFIG_COMP_ASRC=n CONFIG_COMP_TDFB=n +CONFIG_COMP_TONE=n CONFIG_OPTIMIZE_FOR_SIZE=y CONFIG_HAVE_AGENT=n CONFIG_DEBUG_MEMORY_USAGE_SCAN=n