Skip to content

Commit

Permalink
ipc4: Expose ipc4_update_buffer_format()
Browse files Browse the repository at this point in the history
It will be needed by other modules as well.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 authored and lgirdwood committed Jul 13, 2023
1 parent a25cdbb commit 4779aa7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
5 changes: 3 additions & 2 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 3 additions & 25 deletions src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/include/ipc4/base-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
3 changes: 0 additions & 3 deletions src/include/ipc4/copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4779aa7

Please sign in to comment.