Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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 */
Comment thread
kv2019i marked this conversation as resolved.
Outdated
if (ret < 0) {
struct comp_buffer __sparse_cache *source_c, *sink_c;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Comment thread
kv2019i marked this conversation as resolved.
Outdated
if (!dd->local_buffer) {
set_new_local_buffer(dd, dev);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions src/audio/host-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/include/sof/audio/host_copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
4 changes: 4 additions & 0 deletions src/include/sof/lib/dai-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down