ipc4: Expose ipc4_update_buffer_format()

It will be needed by other modules as well.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2023-07-06 20:11:16 -07:00 committed by Liam Girdwood
parent a25cdbb90b
commit 4779aa7397
5 changed files with 33 additions and 30 deletions

View File

@ -25,6 +25,7 @@
#include <sof/ut.h>
#include <sof/trace/trace.h>
#include <ipc4/alh.h>
#include <ipc4/base-config.h>
#include <ipc4/copier.h>
#include <ipc4/module.h>
#include <ipc4/error_status.h>
@ -499,7 +500,7 @@ static int copier_module_copy(struct processing_module *mod,
return -EINVAL;
/* update corresponding sink format in case it isn't updated */
update_buffer_format(sink_c, &cd->out_fmt[sink_queue_id]);
ipc4_update_buffer_format(sink_c, &cd->out_fmt[sink_queue_id]);
comp_get_copy_limits(src_c, sink_c, &processed_data);
@ -688,7 +689,7 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data,
sink_id = IPC4_SINK_QUEUE_ID(sink_c->id);
if (sink_id == sink_fmt->sink_id) {
update_buffer_format(sink_c, &sink_fmt->sink_fmt);
ipc4_update_buffer_format(sink_c, &sink_fmt->sink_fmt);
buffer_release(sink_c);
break;
}

View File

@ -4,6 +4,7 @@
//
// Author: Andrula Song <xiaoyuan.song@intel.com>
#include <ipc4/base-config.h>
#include <ipc4/copier.h>
#include <sof/audio/component_ext.h>
@ -57,29 +58,6 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
}
#endif
void update_buffer_format(struct comp_buffer __sparse_cache *buf_c,
const struct ipc4_audio_format *fmt)
{
enum sof_ipc_frame valid_fmt, frame_fmt;
int i;
audio_stream_set_channels(&buf_c->stream, fmt->channels_count);
audio_stream_set_rate(&buf_c->stream, fmt->sampling_frequency);
audio_stream_fmt_conversion(fmt->depth,
fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
fmt->s_type);
audio_stream_set_frm_fmt(&buf_c->stream, frame_fmt);
audio_stream_set_valid_fmt(&buf_c->stream, valid_fmt);
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;
buf_c->hw_params_configured = true;
}
void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
@ -111,7 +89,7 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
j = IPC4_SINK_QUEUE_ID(sink_c->id);
update_buffer_format(sink_c, &cd->out_fmt[j]);
ipc4_update_buffer_format(sink_c, &cd->out_fmt[j]);
buffer_release(sink_c);
}
@ -127,7 +105,7 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
source_c = buffer_acquire(source);
in_fmt = &cd->config.base.audio_fmt;
update_buffer_format(source_c, in_fmt);
ipc4_update_buffer_format(source_c, in_fmt);
buffer_release(source_c);
}

View File

@ -25,6 +25,7 @@
#define __SOF_IPC4_BASE_CONFIG_H__
#include <stdint.h>
#include <sof/compiler_attributes.h>
enum ipc4_sampling_frequency {
IPC4_FS_8000HZ = 8000,
@ -240,5 +241,8 @@ union ipc4_cfg_param_id_data {
struct sof_ipc_stream_params;
void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg,
struct sof_ipc_stream_params *params);
struct comp_buffer;
void ipc4_update_buffer_format(struct comp_buffer __sparse_cache *buf_c,
const struct ipc4_audio_format *fmt);
#endif

View File

@ -283,9 +283,6 @@ int create_endpoint_buffer(struct comp_dev *parent_dev,
enum sof_ipc_stream_direction
get_gateway_direction(enum ipc4_connector_node_id_type node_id_type);
void update_buffer_format(struct comp_buffer __sparse_cache *buf_c,
const struct ipc4_audio_format *fmt);
void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
struct sof_ipc_stream_params *params);
#endif

View File

@ -826,3 +826,26 @@ void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *ba
for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)
params->chmap[i] = (base_cfg->audio_fmt.ch_map >> i * 4) & 0xf;
}
void ipc4_update_buffer_format(struct comp_buffer __sparse_cache *buf_c,
const struct ipc4_audio_format *fmt)
{
enum sof_ipc_frame valid_fmt, frame_fmt;
int i;
audio_stream_set_channels(&buf_c->stream, fmt->channels_count);
audio_stream_set_rate(&buf_c->stream, fmt->sampling_frequency);
audio_stream_fmt_conversion(fmt->depth,
fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
fmt->s_type);
audio_stream_set_frm_fmt(&buf_c->stream, frame_fmt);
audio_stream_set_valid_fmt(&buf_c->stream, valid_fmt);
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;
buf_c->hw_params_configured = true;
}