From ccae5e5561e5380dc7a086d02c6bec6785486bc5 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Fri, 20 Sep 2024 12:26:48 +0200 Subject: [PATCH] buf: move chmap to stream_params structure chmap is a parameter common for all types of buffers, should be accessible through sink/src api, so it needs to be kept in sof_audio_stream_params an API inroduced for accessing the parameter Signed-off-by: Marcin Szkudlinski --- src/audio/buffers/comp_buffer.c | 2 +- src/audio/copier/copier_dai.c | 3 ++- src/audio/copier/copier_generic.c | 2 +- src/audio/dai-zephyr.c | 3 ++- src/audio/pipeline/pipeline-params.c | 2 +- src/include/module/audio/audio_stream.h | 4 +++- src/include/sof/audio/audio_buffer.h | 11 +++++++++++ src/include/sof/audio/buffer.h | 3 --- src/ipc/ipc4/helper.c | 2 +- 9 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/audio/buffers/comp_buffer.c b/src/audio/buffers/comp_buffer.c index be26ef5479b6..7aa6c158124c 100644 --- a/src/audio/buffers/comp_buffer.c +++ b/src/audio/buffers/comp_buffer.c @@ -440,7 +440,7 @@ int buffer_set_params(struct comp_buffer *buffer, audio_stream_set_buffer_fmt(&buffer->stream, params->buffer_fmt); for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) - buffer->chmap[i] = params->chmap[i]; + audio_buffer_set_chmap(&buffer->audio_buffer, i, params->chmap[i]); audio_buffer_set_hw_params_configured(&buffer->audio_buffer); diff --git a/src/audio/copier/copier_dai.c b/src/audio/copier/copier_dai.c index 80866f6933c1..741bbad9db3b 100644 --- a/src/audio/copier/copier_dai.c +++ b/src/audio/copier/copier_dai.c @@ -540,7 +540,8 @@ int copier_dai_params(struct copier_data *cd, struct comp_dev *dev, return ret; for (j = 0; j < SOF_IPC_MAX_CHANNELS; j++) - cd->dd[dai_index]->dma_buffer->chmap[j] = (cd->chan_map[dai_index] >> j * 4) & 0xf; + audio_buffer_set_chmap(&cd->dd[dai_index]->dma_buffer->audio_buffer, + j, (cd->chan_map[dai_index] >> j * 4) & 0xf); /* set channel copy func */ container_size = audio_stream_sample_bytes(&cd->multi_endpoint_buffer->stream); diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index 0fe271d76c12..a0502d6376df 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -192,7 +192,7 @@ int create_endpoint_buffer(struct comp_dev *dev, copier_cfg->base.audio_fmt.interleaving_style); for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) - buffer->chmap[i] = (chan_map >> i * 4) & 0xf; + audio_buffer_set_chmap(&buffer->audio_buffer, i, (chan_map >> i * 4) & 0xf); audio_buffer_set_hw_params_configured(&buffer->audio_buffer); diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 783207c45b64..5e6708437992 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -426,7 +426,8 @@ dai_dma_multi_endpoint_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t fr /* copy all channels one by one */ for (i = 0; i < audio_stream_get_channels(&dd->dma_buffer->stream); i++) { - uint32_t multi_buf_channel = dd->dma_buffer->chmap[i]; + uint32_t multi_buf_channel = audio_buffer_get_chmap(&dd->dma_buffer->audio_buffer, + i); if (dev->direction == SOF_IPC_STREAM_PLAYBACK) dd->channel_copy(&multi_endpoint_buffer->stream, multi_buf_channel, diff --git a/src/audio/pipeline/pipeline-params.c b/src/audio/pipeline/pipeline-params.c index 8c9de7969bb8..6bd07e35e883 100644 --- a/src/audio/pipeline/pipeline-params.c +++ b/src/audio/pipeline/pipeline-params.c @@ -121,7 +121,7 @@ static void pipeline_update_buffer_pcm_params(struct comp_buffer *buffer, params->rate = audio_stream_get_rate(&buffer->stream); params->channels = audio_stream_get_channels(&buffer->stream); for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) - params->chmap[i] = buffer->chmap[i]; + params->chmap[i] = audio_buffer_get_chmap(&buffer->audio_buffer, i); } /* fetch hardware stream parameters from DAI */ diff --git a/src/include/module/audio/audio_stream.h b/src/include/module/audio/audio_stream.h index 301d74861a74..8c9fc7923849 100644 --- a/src/include/module/audio/audio_stream.h +++ b/src/include/module/audio/audio_stream.h @@ -11,7 +11,7 @@ #include #include -#include "../ipc/stream.h" +#include /** * set of parameters describing audio stream @@ -51,6 +51,8 @@ struct sof_audio_stream_params { uint32_t buffer_fmt; /**< enum sof_ipc_buffer_format */ + uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */ + bool hw_params_configured; /**< indicates whether hw params were set */ }; diff --git a/src/include/sof/audio/audio_buffer.h b/src/include/sof/audio/audio_buffer.h index 0e161c5a4df0..3b8aedd30fb4 100644 --- a/src/include/sof/audio/audio_buffer.h +++ b/src/include/sof/audio/audio_buffer.h @@ -194,6 +194,17 @@ static inline void audio_buffer_reset_params(struct sof_audio_buffer *buffer) buffer->audio_stream_params->hw_params_configured = false; } +static inline uint16_t audio_buffer_get_chmap(struct sof_audio_buffer *buffer, size_t index) +{ + return buffer->audio_stream_params->chmap[index]; +} + +static inline void audio_buffer_set_chmap(struct sof_audio_buffer *buffer, size_t index, + uint16_t value) +{ + buffer->audio_stream_params->chmap[index] = value; +} + /** * @brief return a handler to stream params structure */ diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 05543d70fa6d..5805fe0f420d 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -141,9 +141,6 @@ struct comp_buffer { /* lists */ struct list_item source_list; /* list in comp buffers */ struct list_item sink_list; /* list in comp buffers */ - - /* runtime stream params */ - uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */ }; /* Only to be used for synchronous same-core notifications! */ diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 619be15a8030..8ef06f8e93b8 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -1194,7 +1194,7 @@ void ipc4_update_buffer_format(struct comp_buffer *buf_c, audio_stream_set_buffer_fmt(&buf_c->stream, fmt->interleaving_style); for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) - buf_c->chmap[i] = (fmt->ch_map >> i * 4) & 0xf; + audio_buffer_set_chmap(&buf_c->audio_buffer, i, (fmt->ch_map >> i * 4) & 0xf); audio_buffer_set_hw_params_configured(&buf_c->audio_buffer); }