Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipeline 2.0 - introduce abstract audio_buffer api #9260

Merged
merged 6 commits into from
Jul 10, 2024
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
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace15_mtpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y
CONFIG_DAI_DMIC_HAS_OWNERSHIP=y
CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y
CONFIG_DAI_INTEL_SSP=y
CONFIG_PIPELINE_2_0=y
CONFIG_ZEPHYR_DP_SCHEDULER=y
CONFIG_DMA=y
CONFIG_DMA_INTEL_ADSP_GPDMA=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace20_lnl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y
CONFIG_DAI_DMIC_HAS_OWNERSHIP=n
CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y
CONFIG_DAI_INTEL_SSP=y
CONFIG_PIPELINE_2_0=y
CONFIG_ZEPHYR_DP_SCHEDULER=y
CONFIG_DMA=y
CONFIG_DMA_INTEL_ADSP_GPDMA=n
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace30_ptl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONFIG_DAI_INTEL_DMIC_NHLT=y
CONFIG_DAI_DMIC_HAS_OWNERSHIP=n
CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y
CONFIG_DAI_INTEL_SSP=y
CONFIG_PIPELINE_2_0=y
CONFIG_ZEPHYR_DP_SCHEDULER=y
CONFIG_DMA=y
CONFIG_DMA_INTEL_ADSP_GPDMA=n
Expand Down
16 changes: 8 additions & 8 deletions src/audio/audio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <rtos/symbol.h>

#include <sof/audio/audio_stream.h>
#include <sof/audio/audio_buffer.h>
#include <sof/audio/buffer.h>
#include <sof/audio/dp_queue.h>

static size_t audio_stream_get_free_size(struct sof_sink *sink)
{
Expand Down Expand Up @@ -207,22 +207,22 @@ void audio_stream_init(struct audio_stream *audio_stream, void *buff_addr, uint3
}

/* get a handler to source API */
#if CONFIG_ZEPHYR_DP_SCHEDULER
#if CONFIG_PIPELINE_2_0
struct sof_source *audio_stream_get_source(struct audio_stream *audio_stream)
{
return audio_stream->dp_queue_source ?
dp_queue_get_source(audio_stream->dp_queue_source) :
return audio_stream->secondary_buffer_source ?
audio_buffer_get_source(audio_stream->secondary_buffer_source) :
&audio_stream->_source_api;
}

struct sof_sink *audio_stream_get_sink(struct audio_stream *audio_stream)
{
return audio_stream->dp_queue_sink ?
dp_queue_get_sink(audio_stream->dp_queue_sink) :
return audio_stream->secondary_buffer_sink ?
audio_buffer_get_sink(audio_stream->secondary_buffer_sink) :
&audio_stream->_sink_api;
}

#else /* CONFIG_ZEPHYR_DP_SCHEDULER */
#else /* CONFIG_PIPELINE_2_0 */

struct sof_source *audio_stream_get_source(struct audio_stream *audio_stream)
{
Expand All @@ -233,4 +233,4 @@ struct sof_sink *audio_stream_get_sink(struct audio_stream *audio_stream)
{
return &audio_stream->_sink_api;
}
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
#endif /* CONFIG_PIPELINE_2_0 */
57 changes: 25 additions & 32 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <sof/audio/buffer.h>
#include <sof/audio/component.h>
#include <sof/audio/dp_queue.h>
#include <sof/audio/audio_buffer.h>
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/audio/sink_source_utils.h>
Expand Down Expand Up @@ -95,55 +95,48 @@ struct comp_buffer *buffer_alloc(size_t size, uint32_t caps, uint32_t flags, uin
return buffer;
}

#if CONFIG_ZEPHYR_DP_SCHEDULER
int buffer_create_shadow_dp_queue(struct comp_buffer *buffer, bool at_input)
#if CONFIG_PIPELINE_2_0
int buffer_attach_secondary_buffer(struct comp_buffer *buffer, bool at_input,
struct sof_audio_buffer *secondary_buffer)
{
if (buffer->stream.dp_queue_sink || buffer->stream.dp_queue_source) {
buf_err(buffer, "Only one shadow dp_queue may be attached to a buffer");
if (buffer->stream.secondary_buffer_sink || buffer->stream.secondary_buffer_source) {
buf_err(buffer, "Only one secondary buffer may be attached to a buffer");
return -EINVAL;
}

struct dp_queue *dp_queue =
dp_queue_create(source_get_min_available(&buffer->stream._source_api),
sink_get_min_free_space(&buffer->stream._sink_api),
buffer->is_shared ? DP_QUEUE_MODE_SHARED : DP_QUEUE_MODE_LOCAL,
buf_get_id(buffer), &buffer->stream.runtime_stream_params);

if (!dp_queue)
return -ENOMEM;

if (at_input)
buffer->stream.dp_queue_sink = dp_queue;
buffer->stream.secondary_buffer_sink = secondary_buffer;
else
buffer->stream.dp_queue_source = dp_queue;
buffer->stream.secondary_buffer_source = secondary_buffer;

buf_info(buffer, "dp_queue attached to buffer as a shadow, at_input: %u", at_input);
buf_info(buffer, "ring_buffer attached to buffer as a secondary, at_input: %u", at_input);
return 0;
}

int buffer_sync_shadow_dp_queue(struct comp_buffer *buffer, size_t limit)
int buffer_sync_secondary_buffer(struct comp_buffer *buffer, size_t limit)
{
int err;

struct sof_source *data_src;
struct sof_sink *data_dst;

if (buffer->stream.dp_queue_sink) {
if (buffer->stream.secondary_buffer_sink) {
/*
* comp_buffer sink API is shadowed, that means there's a dp_queue at data input
* get data from dp_queue_sink (use source API)
* comp_buffer sink API is shadowed, that means there's a secondary_buffer
* at data input
* get data from secondary_buffer (use source API)
* copy to comp_buffer (use sink API)
*/
data_src = dp_queue_get_source(buffer->stream.dp_queue_sink);
data_src = audio_buffer_get_source(buffer->stream.secondary_buffer_sink);
data_dst = &buffer->stream._sink_api;
} else if (buffer->stream.dp_queue_source) {
} else if (buffer->stream.secondary_buffer_source) {
/*
* comp_buffer source API is shadowed, that means there's a dp_queue at data output
* comp_buffer source API is shadowed, that means there's a secondary_buffer
* at data output
* get data from comp_buffer (use source API)
* copy to dp_queue_source (use sink API)
* copy to secondary_buffer (use sink API)
*/
data_src = &buffer->stream._source_api;
data_dst = dp_queue_get_sink(buffer->stream.dp_queue_source);
data_dst = audio_buffer_get_sink(buffer->stream.secondary_buffer_source);

} else {
return -EINVAL;
Expand All @@ -160,7 +153,7 @@ int buffer_sync_shadow_dp_queue(struct comp_buffer *buffer, size_t limit)
err = source_to_sink_copy(data_src, data_dst, true, to_copy);
return err;
}
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
#endif /* CONFIG_PIPELINE_2_0 */

struct comp_buffer *buffer_alloc_range(size_t preferred_size, size_t minimum_size, uint32_t caps,
uint32_t flags, uint32_t align, bool is_shared)
Expand Down Expand Up @@ -384,10 +377,10 @@ void buffer_free(struct comp_buffer *buffer)

/* In case some listeners didn't unregister from buffer's callbacks */
notifier_unregister_all(NULL, buffer);
#if CONFIG_ZEPHYR_DP_SCHEDULER
dp_queue_free(buffer->stream.dp_queue_sink);
dp_queue_free(buffer->stream.dp_queue_source);
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
#if CONFIG_PIPELINE_2_0
audio_buffer_free(buffer->stream.secondary_buffer_sink);
audio_buffer_free(buffer->stream.secondary_buffer_source);
#endif /* CONFIG_PIPELINE_2_0 */
rfree(buffer->stream.addr);
rfree(buffer);
}
Expand Down
Loading
Loading