Skip to content

Commit

Permalink
buf: move chmap to stream_params structure
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marcinszkudlinski authored and kv2019i committed Sep 27, 2024
1 parent e331b9c commit 64cb133
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/pipeline/pipeline-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 0 additions & 3 deletions src/include/ipc/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
/*
* Stream configuration.
*/

#define SOF_IPC_MAX_CHANNELS 8

/* common sample rates for use in masks */
#define SOF_RATE_8000 (1 << 0) /**< 8000Hz */
#define SOF_RATE_11025 (1 << 1) /**< 11025Hz */
Expand Down
2 changes: 2 additions & 0 deletions src/include/module/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

Expand Down
2 changes: 2 additions & 0 deletions src/include/module/ipc/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef __MODULE_IPC_STREAM_H__
#define __MODULE_IPC_STREAM_H__

#define SOF_IPC_MAX_CHANNELS 8

/* stream PCM frame format */
enum sof_ipc_frame {
SOF_IPC_FRAME_S16_LE = 0,
Expand Down
11 changes: 11 additions & 0 deletions src/include/sof/audio/audio_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 0 additions & 3 deletions src/include/sof/audio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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! */
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 64cb133

Please sign in to comment.