-
Notifications
You must be signed in to change notification settings - Fork 349
src: dai-zephyr: copy data to all available sinks #9200
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
Merged
kv2019i
merged 1 commit into
thesofproject:main
from
dnikodem:copy_audio_to_all_available_sinks
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,16 +268,56 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, | |
| } | ||
|
|
||
| if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { | ||
| #if CONFIG_IPC_MAJOR_4 | ||
| struct list_item *sink_list; | ||
| /* | ||
| * copy from local buffer to all sinks that are not gateway buffers | ||
| * using the right PCM converter function. | ||
| */ | ||
| list_for_item(sink_list, &dev->bsink_list) { | ||
| struct comp_dev *sink_dev; | ||
| struct comp_buffer *sink; | ||
| int j; | ||
|
|
||
| sink = container_of(sink_list, struct comp_buffer, source_list); | ||
|
|
||
| if (sink == dd->dma_buffer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dma_buffer is not on the list of sinks, so this condition is always false. However, maybe it is OK to leave it as is or replace with assert() "just in case" someone add dma_buffer to sink list in some future refactoring. |
||
| continue; | ||
|
|
||
| sink_dev = sink->sink; | ||
|
|
||
| j = IPC4_SRC_QUEUE_ID(buf_get_id(sink)); | ||
|
|
||
| if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) { | ||
| comp_err(dev, "Sink queue ID: %d >= max output pin count: %d\n", | ||
| j, IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT); | ||
| ret = -EINVAL; | ||
| continue; | ||
| } | ||
|
|
||
| if (!converter[j]) { | ||
| comp_err(dev, "No PCM converter for sink queue %d\n", j); | ||
| ret = -EINVAL; | ||
| continue; | ||
| } | ||
|
|
||
| if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && | ||
| sink->hw_params_configured) { | ||
| ret = stream_copy_from_no_consume(dd->local_buffer, sink, | ||
| converter[j], bytes, dd->chmap); | ||
| } | ||
| } | ||
| #endif | ||
| ret = dma_buffer_copy_to(dd->local_buffer, dd->dma_buffer, | ||
| dd->process, bytes, dd->chmap); | ||
| } else { | ||
| audio_stream_invalidate(&dd->dma_buffer->stream, bytes); | ||
| /* | ||
| * The PCM converter functions used during DMA buffer copy can never fail, | ||
| * so no need to check the return value of dma_buffer_copy_from_no_consume(). | ||
| * so no need to check the return value of stream_copy_from_no_consume(). | ||
| */ | ||
| ret = dma_buffer_copy_from_no_consume(dd->dma_buffer, dd->local_buffer, | ||
| dd->process, bytes, dd->chmap); | ||
| ret = stream_copy_from_no_consume(dd->dma_buffer, dd->local_buffer, | ||
| dd->process, bytes, dd->chmap); | ||
| #if CONFIG_IPC_MAJOR_4 | ||
| struct list_item *sink_list; | ||
| /* Skip in case of endpoint DAI devices created by the copier */ | ||
|
|
@@ -316,9 +356,9 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, | |
|
|
||
| if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && | ||
| sink->hw_params_configured) | ||
| ret = dma_buffer_copy_from_no_consume(dd->dma_buffer, | ||
| sink, converter[j], | ||
| bytes, dd->chmap); | ||
| ret = stream_copy_from_no_consume(dd->dma_buffer, | ||
| sink, converter[j], | ||
| bytes, dd->chmap); | ||
| } | ||
| } | ||
| #endif | ||
|
|
@@ -1553,6 +1593,27 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun | |
| src_frames = audio_stream_get_avail_frames(&dd->local_buffer->stream); | ||
| sink_frames = free_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream); | ||
| frames = MIN(src_frames, sink_frames); | ||
|
|
||
| struct list_item *sink_list; | ||
| /* | ||
| * In the case of playback DAI's with multiple sink buffers, compute the | ||
| * minimum number of frames based on the DMA avail_bytes and the free | ||
| * samples in all active sink buffers. | ||
| */ | ||
| list_for_item(sink_list, &dev->bsink_list) { | ||
| struct comp_dev *sink_dev; | ||
| struct comp_buffer *sink; | ||
|
|
||
| sink = container_of(sink_list, struct comp_buffer, source_list); | ||
| sink_dev = sink->sink; | ||
|
|
||
| if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && | ||
| sink->hw_params_configured) { | ||
| sink_frames = | ||
| audio_stream_get_free_frames(&sink->stream); | ||
| frames = MIN(frames, sink_frames); | ||
| } | ||
| } | ||
| } else { | ||
| struct list_item *sink_list; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.