buffer: use an accessor to read struct audio_stream::frame_fmt

This patch adds audio_stream_get_frm_fmt() to read
struct audio_stream::frame_fmt and converts all users. Apart from
hiding internals of the structure, it also enforces the use of the
__sparse_cache annotation.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2023-04-21 14:53:03 +02:00 committed by Liam Girdwood
parent 3ab21638cf
commit 017b8ebcde
36 changed files with 98 additions and 84 deletions

View File

@ -754,12 +754,12 @@ static int asrc_prepare(struct comp_dev *dev)
sink_c = buffer_acquire(sinkb);
/* get source data format and period bytes */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
source_period_bytes = audio_stream_period_bytes(&source_c->stream,
cd->source_frames);
/* get sink data format and period bytes */
cd->sink_format = sink_c->stream.frame_fmt;
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
sink_period_bytes = audio_stream_period_bytes(&sink_c->stream,
cd->sink_frames);
@ -785,7 +785,7 @@ static int asrc_prepare(struct comp_dev *dev)
}
/* ASRC supports S16_LE, S24_4LE and S32_LE formats */
switch (source_c->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&source_c->stream)) {
case SOF_IPC_FRAME_S16_LE:
cd->asrc_func = src_copy_s16;
break;

View File

@ -1410,7 +1410,7 @@ static void copier_dma_cb(void *arg, enum notify_id type, void *data)
else
sink = buffer_acquire(cd->hd->dma_buffer);
frames = bytes / get_sample_bytes(sink->stream.frame_fmt);
frames = bytes / get_sample_bytes(audio_stream_get_frm_fmt(&sink->stream));
frames = frames / sink->stream.channels;
ret = apply_attenuation(dev, cd, sink, frames);

View File

@ -30,7 +30,7 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
int32_t *dst = audio_stream_get_rptr(&sink->stream);
/* only support attenuation in format of 32bit */
switch (sink->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&sink->stream)) {
case SOF_IPC_FRAME_S16_LE:
comp_err(dev, "16bit sample isn't supported by attenuation");
return -EINVAL;
@ -49,7 +49,8 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
return 0;
default:
comp_err(dev, "unsupported format %d for attenuation", sink->stream.frame_fmt);
comp_err(dev, "unsupported format %d for attenuation",
audio_stream_get_frm_fmt(&sink->stream));
return -EINVAL;
}
}

View File

@ -36,7 +36,7 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
ae_int32x2 *out = (ae_int32x2 *)dst;
/* only support attenuation in format of 32bit */
switch (sink->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&sink->stream)) {
case SOF_IPC_FRAME_S16_LE:
comp_err(dev, "16bit sample isn't supported by attenuation");
return -EINVAL;
@ -66,7 +66,8 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
return 0;
default:
comp_err(dev, "unsupported format %d for attenuation", sink->stream.frame_fmt);
comp_err(dev, "unsupported format %d for attenuation",
audio_stream_get_frm_fmt(&sink->stream));
return -EINVAL;
}
}

View File

@ -716,16 +716,16 @@ static int crossover_prepare(struct comp_dev *dev)
source_c = buffer_acquire(source);
/* Get source data format */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
/* Validate frame format and buffer size of sinks */
list_for_item(sink_list, &dev->bsink_list) {
sink = container_of(sink_list, struct comp_buffer, source_list);
sink_c = buffer_acquire(sink);
if (cd->source_format != sink_c->stream.frame_fmt) {
if (cd->source_format != audio_stream_get_frm_fmt(&sink_c->stream)) {
comp_err(dev, "crossover_prepare(): Source fmt %d and sink fmt %d are different for sink %d.",
cd->source_format, sink_c->stream.frame_fmt,
cd->source_format, audio_stream_get_frm_fmt(&sink_c->stream),
sink_c->pipeline_id);
ret = -EINVAL;
} else {

View File

@ -332,8 +332,8 @@ static int dai_playback_params(struct comp_dev *dev, uint32_t period_bytes,
struct dma_sg_config *config = &dd->config;
struct comp_buffer __sparse_cache *dma_buf = buffer_acquire(dd->dma_buffer),
*local_buf = buffer_acquire(dd->local_buffer);
uint32_t local_fmt = local_buf->stream.frame_fmt;
uint32_t dma_fmt = dma_buf->stream.frame_fmt;
uint32_t local_fmt = audio_stream_get_frm_fmt(&local_buf->stream);
uint32_t dma_fmt = audio_stream_get_frm_fmt(&dma_buf->stream);
uint32_t fifo;
int err = 0;
@ -394,8 +394,8 @@ static int dai_capture_params(struct comp_dev *dev, uint32_t period_bytes,
struct dma_sg_config *config = &dd->config;
struct comp_buffer __sparse_cache *dma_buf = buffer_acquire(dd->dma_buffer),
*local_buf = buffer_acquire(dd->local_buffer);
uint32_t local_fmt = local_buf->stream.frame_fmt;
uint32_t dma_fmt = dma_buf->stream.frame_fmt;
uint32_t local_fmt = audio_stream_get_frm_fmt(&local_buf->stream);
uint32_t dma_fmt = audio_stream_get_frm_fmt(&dma_buf->stream);
uint32_t fifo;
int err = 0;
@ -941,7 +941,7 @@ static int dai_copy(struct comp_dev *dev)
buf_c = buffer_acquire(dd->dma_buffer);
dma_fmt = buf_c->stream.frame_fmt;
dma_fmt = audio_stream_get_frm_fmt(&buf_c->stream);
sampling = get_sample_bytes(dma_fmt);
buffer_release(buf_c);

View File

@ -441,8 +441,8 @@ static int dai_playback_params(struct comp_dev *dev, uint32_t period_bytes,
struct dma_block_config *prev = NULL;
struct comp_buffer __sparse_cache *dma_buf = buffer_acquire(dd->dma_buffer),
*local_buf = buffer_acquire(dd->local_buffer);
uint32_t local_fmt = local_buf->stream.frame_fmt;
uint32_t dma_fmt = dma_buf->stream.frame_fmt;
uint32_t local_fmt = audio_stream_get_frm_fmt(&local_buf->stream);
uint32_t dma_fmt = audio_stream_get_frm_fmt(&dma_buf->stream);
uint32_t fifo, max_block_count, buf_size;
int i, err = 0;
@ -579,8 +579,8 @@ static int dai_capture_params(struct comp_dev *dev, uint32_t period_bytes,
struct dma_block_config *prev = NULL;
struct comp_buffer __sparse_cache *dma_buf = buffer_acquire(dd->dma_buffer),
*local_buf = buffer_acquire(dd->local_buffer);
uint32_t local_fmt = local_buf->stream.frame_fmt;
uint32_t dma_fmt = dma_buf->stream.frame_fmt;
uint32_t local_fmt = audio_stream_get_frm_fmt(&local_buf->stream);
uint32_t dma_fmt = audio_stream_get_frm_fmt(&dma_buf->stream);
uint32_t fifo, max_block_count, buf_size;
int i, err = 0;
@ -1241,7 +1241,7 @@ static int dai_copy(struct comp_dev *dev)
buf_c = buffer_acquire(dd->dma_buffer);
dma_fmt = buf_c->stream.frame_fmt;
dma_fmt = audio_stream_get_frm_fmt(&buf_c->stream);
sampling = get_sample_bytes(dma_fmt);
buffer_release(buf_c);

View File

@ -359,10 +359,10 @@ static int dcblock_prepare(struct comp_dev *dev)
sink_c = buffer_acquire(sinkb);
/* get source data format */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
/* get sink data format and period bytes */
cd->sink_format = sink_c->stream.frame_fmt;
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
sink_period_bytes = audio_stream_period_bytes(&sink_c->stream, dev->frames);
if (audio_stream_get_size(&sink_c->stream) < sink_period_bytes) {

View File

@ -391,7 +391,7 @@ static int drc_prepare(struct comp_dev *dev)
source_c = buffer_acquire(sourceb);
/* get source data format */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
/* Initialize DRC */
comp_info(dev, "drc_prepare(), source_format=%d, sink_format=%d",
@ -419,9 +419,9 @@ static int drc_prepare(struct comp_dev *dev)
sink_c = buffer_acquire(sinkb);
/* validate sink data format and period bytes */
if (cd->source_format != sink_c->stream.frame_fmt) {
if (cd->source_format != audio_stream_get_frm_fmt(&sink_c->stream)) {
comp_err(dev, "drc_prepare(): Source fmt %d and sink fmt %d are different.",
cd->source_format, sink_c->stream.frame_fmt);
cd->source_format, audio_stream_get_frm_fmt(&sink_c->stream));
ret = -EINVAL;
goto out_sink;
}

View File

@ -529,7 +529,7 @@ static int eq_fir_process(struct processing_module *mod,
return ret;
} else if (cd->fir_delay_size) {
comp_dbg(mod->dev, "eq_fir_process(), active");
ret = set_fir_func(mod, source->frame_fmt);
ret = set_fir_func(mod, audio_stream_get_frm_fmt(source));
if (ret < 0)
return ret;
} else {
@ -593,7 +593,7 @@ static int eq_fir_prepare(struct processing_module *mod)
sink_c = buffer_acquire(sinkb);
eq_fir_set_alignment(&source_c->stream, &sink_c->stream);
channels = sink_c->stream.channels;
frame_fmt = source_c->stream.frame_fmt;
frame_fmt = audio_stream_get_frm_fmt(&source_c->stream);
buffer_release(sink_c);
buffer_release(source_c);

View File

@ -720,8 +720,8 @@ static int eq_iir_verify_params(struct comp_dev *dev,
* pcm frame_fmt and will not make any conversion (sink and source
* frame_fmt will be equal).
*/
buffer_flag = eq_iir_find_func(source_c->stream.frame_fmt,
sink_c->stream.frame_fmt, fm_configured,
buffer_flag = eq_iir_find_func(audio_stream_get_frm_fmt(&source_c->stream),
audio_stream_get_frm_fmt(&sink_c->stream), fm_configured,
ARRAY_SIZE(fm_configured)) ?
BUFF_PARAMS_FRAME_FMT : 0;
@ -808,8 +808,8 @@ static int eq_iir_process(struct processing_module *mod,
/* Check for changed configuration */
if (comp_is_new_data_blob_available(cd->model_handler)) {
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
ret = eq_iir_new_blob(mod, cd, source->frame_fmt,
sink->frame_fmt, source->channels);
ret = eq_iir_new_blob(mod, cd, audio_stream_get_frm_fmt(source),
audio_stream_get_frm_fmt(sink), source->channels);
if (ret)
return ret;
}
@ -919,8 +919,8 @@ static int eq_iir_prepare(struct processing_module *mod)
/* get source and sink data format */
channels = sink_c->stream.channels;
source_format = source_c->stream.frame_fmt;
sink_format = sink_c->stream.frame_fmt;
source_format = audio_stream_get_frm_fmt(&source_c->stream);
sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
buffer_release(sink_c);
buffer_release(source_c);

View File

@ -181,7 +181,7 @@ static int ghd_params(struct comp_dev *dev,
if (source_c->stream.channels != 1) {
comp_err(dev, "ghd_params(): Only single-channel supported");
ret = -EINVAL;
} else if (source_c->stream.frame_fmt != SOF_IPC_FRAME_S16_LE) {
} else if (audio_stream_get_frm_fmt(&source_c->stream) != SOF_IPC_FRAME_S16_LE) {
comp_err(dev, "ghd_params(): Only S16_LE supported");
ret = -EINVAL;
} else if (source_c->stream.rate != KPB_SAMPLNG_FREQUENCY) {

View File

@ -555,7 +555,7 @@ static int google_rtc_audio_processing_prepare(struct comp_dev *dev)
}
output_c = buffer_acquire(cd->output);
frame_fmt = output_c->stream.frame_fmt;
frame_fmt = audio_stream_get_frm_fmt(&output_c->stream);
rate = output_c->stream.rate;
buffer_release(output_c);

View File

@ -851,8 +851,8 @@ int host_zephyr_params(struct host_data *hd, struct comp_dev *dev,
host_copy_normal;
/* set processing function */
hd->process = pcm_get_conversion_function(host_buf_c->stream.frame_fmt,
host_buf_c->stream.frame_fmt);
hd->process = pcm_get_conversion_function(audio_stream_get_frm_fmt(&host_buf_c->stream),
audio_stream_get_frm_fmt(&host_buf_c->stream));
out:
buffer_release(host_buf_c);

View File

@ -860,11 +860,13 @@ int host_zephyr_params(struct host_data *hd, struct comp_dev *dev,
/* set processing function */
if (params->direction == SOF_IPC_STREAM_CAPTURE)
hd->process = pcm_get_conversion_function(host_buf_c->stream.frame_fmt,
dma_buf_c->stream.frame_fmt);
hd->process = pcm_get_conversion_function(
audio_stream_get_frm_fmt(&host_buf_c->stream),
audio_stream_get_frm_fmt(&dma_buf_c->stream));
else
hd->process = pcm_get_conversion_function(dma_buf_c->stream.frame_fmt,
host_buf_c->stream.frame_fmt);
hd->process = pcm_get_conversion_function(
audio_stream_get_frm_fmt(&dma_buf_c->stream),
audio_stream_get_frm_fmt(&host_buf_c->stream));
config->src_width = audio_stream_sample_bytes(&dma_buf_c->stream);
config->dest_width = config->src_width;

View File

@ -249,7 +249,7 @@ static inline int32_t set_capture_func(struct comp_dev *dev)
sink_list);
/* The igo_nr supports S16_LE data. Format converter is needed. */
switch (sourceb->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&sourceb->stream)) {
#if CONFIG_FORMAT_S16LE
case SOF_IPC_FRAME_S16_LE:
comp_info(dev, "set_capture_func(), SOF_IPC_FRAME_S16_LE");

View File

@ -209,13 +209,13 @@ static int mfcc_prepare(struct processing_module *mod)
sink_c = buffer_acquire(sinkb);
/* get source data format */
source_format = source_c->stream.frame_fmt;
source_format = audio_stream_get_frm_fmt(&source_c->stream);
/* set align requirements */
mfcc_set_alignment(&source_c->stream, &sink_c->stream);
/* get sink data format and period bytes */
sink_format = sink_c->stream.frame_fmt;
sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
sink_period_bytes = audio_stream_period_bytes(&sink_c->stream, dev->frames);
comp_info(dev, "mfcc_prepare(), source_format = %d, sink_format = %d",
source_format, sink_format);

View File

@ -93,7 +93,7 @@ static int dts_effect_populate_buffer_configuration(struct comp_dev *dev,
buffer_fmt = source_c->buffer_fmt;
stream = &source_c->stream;
frame_fmt = stream->frame_fmt;
frame_fmt = audio_stream_get_frm_fmt(stream);
rate = stream->rate;
channels = stream->channels;

View File

@ -251,9 +251,9 @@ static int waves_effect_check(struct comp_dev *dev)
}
/* different frame format not supported */
if (src_fmt->frame_fmt != snk_fmt->frame_fmt) {
if (src_fmt->frame_fmt != audio_stream_get_frm_fmt(snk_fmt)) {
comp_err(dev, "waves_effect_check() source %d sink %d sample format mismatch",
src_fmt->frame_fmt, snk_fmt->frame_fmt);
audio_stream_get_frm_fmt(src_fmt), audio_stream_get_frm_fmt(snk_fmt));
ret = -EINVAL;
goto out;
}
@ -265,7 +265,7 @@ static int waves_effect_check(struct comp_dev *dev)
goto out;
}
if (!format_is_supported(src_fmt->frame_fmt)) {
if (!format_is_supported(audio_stream_get_frm_fmt(src_fmt))) {
comp_err(dev, "waves_effect_check() float samples not supported");
ret = -EINVAL;
goto out;
@ -318,10 +318,10 @@ static int waves_effect_init(struct processing_module *mod)
comp_dbg(dev, "waves_effect_init() start");
sample_format = format_convert_sof_to_me(src_fmt->frame_fmt);
sample_format = format_convert_sof_to_me(audio_stream_get_frm_fmt(src_fmt));
if (sample_format < 0) {
comp_err(dev, "waves_effect_init() sof sample format %d not supported",
src_fmt->frame_fmt);
audio_stream_get_frm_fmt(src_fmt));
ret = -EINVAL;
goto out;
}

View File

@ -534,7 +534,7 @@ static int multiband_drc_prepare(struct comp_dev *dev)
source_c = buffer_acquire(sourceb);
/* get source data format */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
/* Initialize DRC */
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
@ -574,10 +574,10 @@ static int multiband_drc_prepare(struct comp_dev *dev)
sink_c = buffer_acquire(sinkb);
/* validate sink data format and period bytes */
if (cd->source_format != sink_c->stream.frame_fmt) {
if (cd->source_format != audio_stream_get_frm_fmt(&sink_c->stream)) {
comp_err(dev,
"multiband_drc_prepare(): Source fmt %d and sink fmt %d are different.",
cd->source_format, sink_c->stream.frame_fmt);
cd->source_format, audio_stream_get_frm_fmt(&sink_c->stream));
ret = -EINVAL;
goto out_sink;
}

View File

@ -306,7 +306,7 @@ static void set_mux_params(struct processing_module *mod)
sink_c->stream.valid_sample_fmt = valid_fmt;
sink_c->buffer_fmt = out_fmt.interleaving_style;
params->frame_fmt = sink_c->stream.frame_fmt;
params->frame_fmt = audio_stream_get_frm_fmt(&sink_c->stream);
for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)
sink_c->chmap[i] = (out_fmt.ch_map >> i * 4) & 0xf;

View File

@ -535,7 +535,7 @@ mux_func mux_get_processing_function(struct processing_module *mod)
for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) {
struct comp_buffer __sparse_cache *sink_c = buffer_acquire(sinkb);
enum sof_ipc_frame fmt = sink_c->stream.frame_fmt;
enum sof_ipc_frame fmt = audio_stream_get_frm_fmt(&sink_c->stream);
if (fmt == mux_func_map[i].frame_format)
@ -559,7 +559,7 @@ demux_func demux_get_processing_function(struct processing_module *mod)
for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) {
struct comp_buffer __sparse_cache *source_c = buffer_acquire(sourceb);
enum sof_ipc_frame fmt = source_c->stream.frame_fmt;
enum sof_ipc_frame fmt = audio_stream_get_frm_fmt(&source_c->stream);
buffer_release(source_c);

View File

@ -138,7 +138,7 @@ static void pipeline_update_buffer_pcm_params(struct comp_buffer __sparse_cache
int i;
params->buffer_fmt = buffer->buffer_fmt;
params->frame_fmt = buffer->stream.frame_fmt;
params->frame_fmt = audio_stream_get_frm_fmt(&buffer->stream);
params->rate = buffer->stream.rate;
params->channels = buffer->stream.channels;
for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)

View File

@ -873,8 +873,8 @@ static int rtnr_prepare(struct comp_dev *dev)
/* Get sink data format */
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink_c = buffer_acquire(sinkb);
cd->sink_format = sink_c->stream.frame_fmt;
cd->sink_stream.frame_fmt = sink_c->stream.frame_fmt;
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
cd->sink_stream.frame_fmt = audio_stream_get_frm_fmt(&sink_c->stream);
buffer_release(sink_c);
/* Check source and sink PCM format and get processing function */

View File

@ -463,11 +463,11 @@ static int selector_prepare(struct comp_dev *dev)
sink_c = buffer_acquire(sinkb);
/* get source data format and period bytes */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
cd->source_period_bytes = audio_stream_period_bytes(&source_c->stream, dev->frames);
/* get sink data format and period bytes */
cd->sink_format = sink_c->stream.frame_fmt;
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
cd->sink_period_bytes = audio_stream_period_bytes(&sink_c->stream, dev->frames);
/* There is an assumption that sink component will report out
@ -920,11 +920,11 @@ static int selector_prepare(struct processing_module *mod)
audio_stream_init_alignment_constants(4, 1, &sink_c->stream);
/* get source data format and period bytes */
cd->source_format = source_c->stream.frame_fmt;
cd->source_format = audio_stream_get_frm_fmt(&source_c->stream);
cd->source_period_bytes = audio_stream_period_bytes(&source_c->stream, dev->frames);
/* get sink data format and period bytes */
cd->sink_format = sink_c->stream.frame_fmt;
cd->sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
cd->sink_period_bytes = audio_stream_period_bytes(&sink_c->stream, dev->frames);
/* There is an assumption that sink component will report out

View File

@ -558,8 +558,12 @@ static int smart_amp_process(struct comp_dev *dev,
static smart_amp_proc get_smart_amp_process(struct comp_dev *dev)
{
struct smart_amp_data *sad = comp_get_drvdata(dev);
struct comp_buffer __sparse_cache *source_buf = buffer_acquire(sad->source_buf);
enum sof_ipc_frame fmt = audio_stream_get_frm_fmt(&source_buf->stream);
switch (sad->source_buf->stream.frame_fmt) {
buffer_release(source_buf);
switch (fmt) {
case SOF_IPC_FRAME_S16_LE:
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
@ -710,7 +714,7 @@ static int smart_amp_prepare(struct comp_dev *dev)
}
}
switch (source_c->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&source_c->stream)) {
case SOF_IPC_FRAME_S16_LE:
bitwidth = 16;
break;
@ -722,7 +726,7 @@ static int smart_amp_prepare(struct comp_dev *dev)
break;
default:
comp_err(dev, "[DSM] smart_amp_process() error: not supported frame format %d",
source_c->stream.frame_fmt);
audio_stream_get_frm_fmt(&source_c->stream));
goto error;
}

View File

@ -592,7 +592,7 @@ static int smart_amp_get_buffer(int32_t *buf, uint32_t frames,
output.buf16 = (int16_t *)buf;
output.buf32 = (int32_t *)buf;
switch (stream->frame_fmt) {
switch (audio_stream_get_frm_fmt(stream)) {
case SOF_IPC_FRAME_S16_LE:
for (idx = 0 ; idx < frames ; idx++) {
for (ch = 0 ; ch < num_ch; ch++) {
@ -642,7 +642,7 @@ static int smart_amp_put_buffer(int32_t *buf, uint32_t frames,
output.buf16 = audio_stream_get_wptr(stream);
output.buf32 = audio_stream_get_wptr(stream);
switch (stream->frame_fmt) {
switch (audio_stream_get_frm_fmt(stream)) {
case SOF_IPC_FRAME_S16_LE:
for (idx = 0 ; idx < frames ; idx++) {
for (ch = 0 ; ch < num_ch_out; ch++) {
@ -708,7 +708,7 @@ int smart_amp_ff_copy(struct comp_dev *dev, uint32_t frames,
if (ret)
goto err;
switch (source->frame_fmt) {
switch (audio_stream_get_frm_fmt(source)) {
case SOF_IPC_FRAME_S16_LE:
maxim_dsm_ff_proc(hspk, dev,
hspk->buf.frame_in,
@ -767,7 +767,7 @@ int smart_amp_fb_copy(struct comp_dev *dev, uint32_t frames,
if (ret)
goto err;
switch (source->frame_fmt) {
switch (audio_stream_get_frm_fmt(source)) {
case SOF_IPC_FRAME_S16_LE:
maxim_dsm_fb_proc(hspk, dev, hspk->buf.frame_iv,
frames * num_ch, sizeof(int16_t));
@ -784,6 +784,6 @@ int smart_amp_fb_copy(struct comp_dev *dev, uint32_t frames,
return 0;
err:
comp_err(dev, "[DSM] Not supported frame format : %d",
source->frame_fmt);
audio_stream_get_frm_fmt(source));
return ret;
}

View File

@ -467,7 +467,7 @@ static void src_copy_sxx(struct comp_dev *dev, struct comp_data *cd,
{
int frames = cd->param.blk_in;
switch (sink->frame_fmt) {
switch (audio_stream_get_frm_fmt(sink)) {
case SOF_IPC_FRAME_S16_LE:
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
@ -766,7 +766,7 @@ static int src_params_general(struct comp_dev *dev, struct comp_data *cd,
/* Allocate needed memory for delay lines */
comp_info(dev, "src_params(), source_rate = %u, sink_rate = %u, format = %d",
cd->source_rate, cd->sink_rate, source_c->stream.frame_fmt);
cd->source_rate, cd->sink_rate, audio_stream_get_frm_fmt(&source_c->stream));
comp_info(dev, "src_params(), sourceb->channels = %u, sinkb->channels = %u, dev->frames = %u",
source_c->stream.channels, sink_c->stream.channels, dev->frames);
err = src_buffer_lengths(dev, cd, source_c->stream.channels);
@ -861,8 +861,8 @@ static int src_prepare_general(struct comp_dev *dev, struct comp_data *cd)
#endif
/* get source/sink data format */
source_format = source_c->stream.frame_fmt;
sink_format = sink_c->stream.frame_fmt;
source_format = audio_stream_get_frm_fmt(&source_c->stream);
sink_format = audio_stream_get_frm_fmt(&sink_c->stream);
ret = src_check_buffer_sizes(dev, cd, &source_c->stream, &sink_c->stream);
if (ret < 0)

View File

@ -745,7 +745,7 @@ static int tdfb_prepare(struct processing_module *mod)
sink_c = buffer_acquire(sinkb);
tdfb_set_alignment(&source_c->stream, &sink_c->stream);
frame_fmt = source_c->stream.frame_fmt;
frame_fmt = audio_stream_get_frm_fmt(&source_c->stream);
source_channels = source_c->stream.channels;
sink_channels = sink_c->stream.channels;
rate = source_c->stream.rate;

View File

@ -112,6 +112,12 @@ static inline uint32_t audio_stream_get_free(const struct audio_stream __sparse_
return buf->free;
}
static inline enum sof_ipc_frame audio_stream_get_frm_fmt(
const struct audio_stream __sparse_cache *buf)
{
return buf->frame_fmt;
}
/**
* Retrieves readable address of a sample at specified index (see versions of
* this macro specialized for various sample types).

View File

@ -68,7 +68,7 @@ static inline mixer_func mixer_get_processing_function(struct comp_dev *dev,
/* map the volume function for source and sink buffers */
for (i = 0; i < mixer_func_count; i++) {
if (sinkb->stream.frame_fmt != mixer_func_map[i].frame_fmt)
if (audio_stream_get_frm_fmt(&sinkb->stream) != mixer_func_map[i].frame_fmt)
continue;
return mixer_func_map[i].func;

View File

@ -190,7 +190,7 @@ static inline vol_scale_func vol_get_processing_function(struct comp_dev *dev,
/* map the volume function for source and sink buffers */
for (i = 0; i < volume_func_count; i++) {
if (sinkb->stream.frame_fmt != volume_func_map[i].frame_fmt)
if (audio_stream_get_frm_fmt(&sinkb->stream) != volume_func_map[i].frame_fmt)
continue;
return volume_func_map[i].func;

View File

@ -87,7 +87,7 @@ static void comp_update_params(uint32_t flag,
struct comp_buffer __sparse_cache *buffer)
{
if (flag & BUFF_PARAMS_FRAME_FMT)
params->frame_fmt = buffer->stream.frame_fmt;
params->frame_fmt = audio_stream_get_frm_fmt(&buffer->stream);
if (flag & BUFF_PARAMS_BUFFER_FMT)
params->buffer_fmt = buffer->buffer_fmt;

View File

@ -829,7 +829,7 @@ static void probe_cb_produce(void *arg, enum notify_id type, void *data)
}
if (_probe->probe_points[i].purpose == PROBE_PURPOSE_EXTRACTION) {
format = probe_gen_format(buffer->stream.frame_fmt,
format = probe_gen_format(audio_stream_get_frm_fmt(&buffer->stream),
buffer->stream.rate,
buffer->stream.channels);
ret = probe_gen_header(buffer_id,

View File

@ -767,7 +767,7 @@ static int test_keyword_params(struct comp_dev *dev,
sink_list);
source_c = buffer_acquire(sourceb);
channels = source_c->stream.channels;
frame_fmt = source_c->stream.frame_fmt;
frame_fmt = audio_stream_get_frm_fmt(&source_c->stream);
rate = source_c->stream.rate;
buffer_release(source_c);

View File

@ -162,7 +162,7 @@ static void smart_amp_set_params(struct comp_dev *dev,
sink_c->stream.valid_sample_fmt = valid_fmt;
sink_c->buffer_fmt = out_fmt.interleaving_style;
params->frame_fmt = sink_c->stream.frame_fmt;
params->frame_fmt = audio_stream_get_frm_fmt(&sink_c->stream);
sink_c->hw_params_configured = true;
@ -636,7 +636,7 @@ static int smart_amp_process_s32(struct comp_dev *dev,
static smart_amp_proc get_smart_amp_process(struct comp_dev *dev,
struct comp_buffer __sparse_cache *buf)
{
switch (buf->stream.frame_fmt) {
switch (audio_stream_get_frm_fmt(&buf->stream)) {
case SOF_IPC_FRAME_S16_LE:
return smart_amp_process_s16;
case SOF_IPC_FRAME_S24_4LE: