Skip to content

Commit 2d91c87

Browse files
sink_src: add ipc4 update format functions
sink/src API must grow to provide similar functionality to comp_buffers. This commit adds 2 helpers for IPC4 format set Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 3bd9991 commit 2d91c87

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

src/audio/source_api_helper.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ bool source_get_underrun(struct sof_source *source)
9696
return source->audio_stream_params->underrun_permitted;
9797
}
9898

99+
int source_set_frm_fmt(struct sof_source *source, enum sof_ipc_frame frm_fmt)
100+
{
101+
source->audio_stream_params->frame_fmt = frm_fmt;
102+
if (source->ops->on_audio_format_set)
103+
return source->ops->on_audio_format_set(source);
104+
return 0;
105+
}
106+
99107
int source_set_valid_fmt(struct sof_source *source,
100108
enum sof_ipc_frame valid_sample_fmt)
101109
{

src/include/ipc4/base-config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,11 @@ void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *ba
244244
struct comp_buffer;
245245
void ipc4_update_buffer_format(struct comp_buffer *buf_c,
246246
const struct ipc4_audio_format *fmt);
247+
struct sof_source;
248+
void ipc4_update_source_format(struct sof_source *source,
249+
const struct ipc4_audio_format *fmt);
250+
struct sof_sink;
251+
void ipc4_update_sink_format(struct sof_sink *sink,
252+
const struct ipc4_audio_format *fmt);
247253

248254
#endif

src/include/sof/audio/source_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ uint32_t source_get_buffer_fmt(struct sof_source *source);
134134
bool source_get_underrun(struct sof_source *source);
135135

136136
/** set of functions for setting audio parameters */
137+
int source_set_frm_fmt(struct sof_source *source, enum sof_ipc_frame frm_fmt);
137138
int source_set_valid_fmt(struct sof_source *source,
138139
enum sof_ipc_frame valid_sample_fmt);
139140
int source_set_rate(struct sof_source *source, unsigned int rate);

src/ipc/ipc4/helper.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,3 +1053,37 @@ void ipc4_update_buffer_format(struct comp_buffer *buf_c,
10531053

10541054
buf_c->hw_params_configured = true;
10551055
}
1056+
1057+
void ipc4_update_source_format(struct sof_source *source,
1058+
const struct ipc4_audio_format *fmt)
1059+
{
1060+
enum sof_ipc_frame valid_fmt, frame_fmt;
1061+
1062+
source_set_channels(source, fmt->channels_count);
1063+
source_set_rate(source, fmt->sampling_frequency);
1064+
audio_stream_fmt_conversion(fmt->depth,
1065+
fmt->valid_bit_depth,
1066+
&frame_fmt, &valid_fmt,
1067+
fmt->s_type);
1068+
1069+
source_set_frm_fmt(source, frame_fmt);
1070+
source_set_valid_fmt(source, valid_fmt);
1071+
source_set_buffer_fmt(source, fmt->interleaving_style);
1072+
}
1073+
1074+
void ipc4_update_sink_format(struct sof_sink *sink,
1075+
const struct ipc4_audio_format *fmt)
1076+
{
1077+
enum sof_ipc_frame valid_fmt, frame_fmt;
1078+
1079+
sink_set_channels(sink, fmt->channels_count);
1080+
sink_set_rate(sink, fmt->sampling_frequency);
1081+
audio_stream_fmt_conversion(fmt->depth,
1082+
fmt->valid_bit_depth,
1083+
&frame_fmt, &valid_fmt,
1084+
fmt->s_type);
1085+
1086+
sink_set_frm_fmt(sink, frame_fmt);
1087+
sink_set_valid_fmt(sink, valid_fmt);
1088+
sink_set_buffer_fmt(sink, fmt->interleaving_style);
1089+
}

0 commit comments

Comments
 (0)