diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index ced4df6f397c..bcbfd91dd2ad 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -259,7 +259,6 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { ret = dma_buffer_copy_to(local_buf, dma_buf, dd->process, bytes); - buffer_release(local_buf); } else { struct list_item *sink_list; @@ -269,7 +268,6 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, * so no need to check the return value of dma_buffer_copy_from_no_consume(). */ ret = dma_buffer_copy_from_no_consume(dma_buf, local_buf, dd->process, bytes); - buffer_release(local_buf); #if CONFIG_IPC_MAJOR_4 /* Skip in case of endpoint DAI devices created by the copier */ if (converter) { @@ -318,7 +316,6 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, audio_stream_consume(&dma_buf->stream, bytes); } - local_buf = buffer_acquire(dd->local_buffer); /* assert dma_buffer_copy succeed */ if (ret < 0) { struct comp_buffer __sparse_cache *source_c, *sink_c; @@ -997,9 +994,12 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev, buffer_c = buffer_acquire(dd->dma_buffer); buffer_set_params(buffer_c, &hw_params, BUFFER_UPDATE_FORCE); + dd->sampling = get_sample_bytes(hw_params.frame_fmt); buffer_release(buffer_c); } + dd->fast_mode = dd->ipc_config.feature_mask & BIT(IPC4_COPIER_FAST_MODE); + return dev->direction == SOF_IPC_STREAM_PLAYBACK ? dai_playback_params(dd, dev, period_bytes, period_count) : dai_capture_params(dd, dev, period_bytes, period_count); @@ -1507,8 +1507,7 @@ static void set_new_local_buffer(struct dai_data *dd, struct comp_dev *dev) /* copy and process stream data from source to sink buffers */ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_func *converter) { - uint32_t dma_fmt; - uint32_t sampling; + uint32_t sampling = dd->sampling; struct comp_buffer __sparse_cache *buf_c; struct dma_status stat; uint32_t avail_bytes; @@ -1540,13 +1539,6 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun avail_bytes = stat.pending_length; free_bytes = stat.free; - buf_c = buffer_acquire(dd->dma_buffer); - - dma_fmt = audio_stream_get_frm_fmt(&buf_c->stream); - sampling = get_sample_bytes(dma_fmt); - - buffer_release(buf_c); - /* handle module runtime unbind */ if (!dd->local_buffer) { set_new_local_buffer(dd, dev); @@ -1608,7 +1600,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun * in order to avoid high load spike * if FAST_MODE is enabled, then one period limitation is omitted */ - if (!(dd->ipc_config.feature_mask & BIT(IPC4_COPIER_FAST_MODE))) + if (!dd->fast_mode) samples = MIN(samples, dd->period_bytes / sampling); copy_bytes = samples * sampling; diff --git a/src/audio/host-legacy.c b/src/audio/host-legacy.c index b32ba947f650..b9a112583586 100644 --- a/src/audio/host-legacy.c +++ b/src/audio/host-legacy.c @@ -970,12 +970,6 @@ static int host_reset(struct comp_dev *dev) return 0; } -/* copy and process stream data from source to sink buffers */ -int host_common_copy(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb) -{ - return hd->copy(hd, dev, cb); -} - static int host_copy(struct comp_dev *dev) { struct host_data *hd = comp_get_drvdata(dev); diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index a1faeea8e152..f34f27350d9f 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -1077,12 +1077,6 @@ static int host_reset(struct comp_dev *dev) return 0; } -/* copy and process stream data from source to sink buffers */ -int host_common_copy(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb) -{ - return hd->copy(hd, dev, cb); -} - static int host_copy(struct comp_dev *dev) { struct host_data *hd = comp_get_drvdata(dev); diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 47bba5590475..e28541560403 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -880,7 +880,11 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev) /* handle special case of HOST/DAI type components */ if (dev->ipc_config.type == SOF_COMP_HOST || dev->ipc_config.type == SOF_COMP_DAI) +#if CONFIG_IPC_MAJOR_3 return module_process_legacy(mod, NULL, 0, NULL, 0); +#else + return module_process_stream(mod, NULL, 0, NULL, 0); +#endif if (mod->stream_copy_single_to_single) return module_adapter_audio_stream_copy_1to1(dev); diff --git a/src/include/sof/audio/host_copier.h b/src/include/sof/audio/host_copier.h index 20cb760e4b79..60f0dccfdb90 100644 --- a/src/include/sof/audio/host_copier.h +++ b/src/include/sof/audio/host_copier.h @@ -112,7 +112,11 @@ void host_common_reset(struct host_data *hd, uint16_t state); int host_common_trigger(struct host_data *hd, struct comp_dev *dev, int cmd); int host_common_params(struct host_data *hd, struct comp_dev *dev, struct sof_ipc_stream_params *params, notifier_callback_t cb); -int host_common_copy(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb); +/* copy and process stream data from source to sink buffers */ +static inline int host_common_copy(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb) +{ + return hd->copy(hd, dev, cb); +} void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t bytes); void host_common_one_shot(struct host_data *hd, uint32_t bytes); int copier_host_create(struct comp_dev *dev, struct copier_data *cd, diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 86badf8b6851..28f5c0765d0c 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -356,4 +356,16 @@ int find_module_source_index(struct module_source_info __sparse_cache *msi, return -EINVAL; } +static inline int module_process_stream(struct processing_module *mod, + struct input_stream_buffer *input_buffers, + int num_input_buffers, + struct output_stream_buffer *output_buffers, + int num_output_buffers) +{ + struct module_data *md = &mod->priv; + + return md->ops->process_audio_stream(mod, input_buffers, num_input_buffers, + output_buffers, num_output_buffers); +} + #endif /* __SOF_AUDIO_MODULE_GENERIC__ */ diff --git a/src/include/sof/lib/dai-zephyr.h b/src/include/sof/lib/dai-zephyr.h index 412fe12e1cc7..49fbd2e02aa8 100644 --- a/src/include/sof/lib/dai-zephyr.h +++ b/src/include/sof/lib/dai-zephyr.h @@ -168,6 +168,10 @@ struct dai_data { /* llp slot info in memory windows */ struct llp_slot_info slot_info; + /* save current sampling for current dai device */ + uint32_t sampling; + /* fast mode, use one byte memory to save repreated cycles */ + bool fast_mode; }; /* these 3 are here to satisfy clk.c and ssp.h interconnection, will be removed leter */