forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: ipc4-topology: Change DeepBuffer from static to dynamic mode #5673
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
Open
ujfalusi
wants to merge
2
commits into
thesofproject:topic/sof-dev
Choose a base branch
from
ujfalusi:peter/sof/pr/dynamic_deepbuffer_ipc4
base: topic/sof-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−71
Open
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 |
|---|---|---|
|
|
@@ -669,22 +669,15 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget) | |
| goto free_available_fmt; | ||
|
|
||
| sps = &spcm->stream[dir]; | ||
| sof_update_ipc_object(scomp, &sps->dsp_max_burst_size_in_ms, | ||
| SOF_COPIER_DEEP_BUFFER_TOKENS, | ||
| swidget->tuples, | ||
| swidget->num_tuples, sizeof(u32), 1); | ||
|
|
||
| /* Set default DMA buffer size if it is not specified in topology */ | ||
| if (!sps->dsp_max_burst_size_in_ms) { | ||
| if (dir == SNDRV_PCM_STREAM_PLAYBACK) { | ||
| struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget; | ||
| struct sof_ipc4_pipeline *pipeline = pipe_widget->private; | ||
|
|
||
| if (dir == SNDRV_PCM_STREAM_PLAYBACK) | ||
| sps->dsp_max_burst_size_in_ms = pipeline->use_chain_dma ? | ||
| SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE; | ||
| else | ||
| /* Capture data is copied from DSP to host in 1ms bursts */ | ||
| sps->dsp_max_burst_size_in_ms = 1; | ||
| sps->dsp_min_burst_size_in_ms = pipeline->use_chain_dma ? | ||
| SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE; | ||
| } else { | ||
| /* Capture data is copied from DSP to host in 1ms bursts */ | ||
| sps->dsp_min_burst_size_in_ms = 1; | ||
| } | ||
|
|
||
| skip_gtw_cfg: | ||
|
|
@@ -2042,6 +2035,67 @@ static void sof_ipc4_host_config(struct snd_sof_dev *sdev, struct snd_sof_widget | |
| copier_data->gtw_cfg.node_id |= SOF_IPC4_NODE_INDEX(host_dma_id); | ||
| } | ||
|
|
||
| static void sof_ipc4_set_host_dma_buffer_size(struct snd_sof_widget *swidget, | ||
| unsigned int fe_period_bytes) | ||
| { | ||
| unsigned int min_size, max_size, headroom, host_period_bytes; | ||
| struct snd_soc_component *scomp = swidget->scomp; | ||
| struct sof_ipc4_copier_data *copier_data; | ||
| struct sof_ipc4_copier *ipc4_copier; | ||
| unsigned int deep_buffer_dma_ms = 0; | ||
| u32 buffer_bytes; | ||
| int ret; | ||
|
|
||
| ipc4_copier = (struct sof_ipc4_copier *)swidget->private; | ||
| copier_data = &ipc4_copier->data; | ||
|
|
||
| if (swidget->id == snd_soc_dapm_aif_in) | ||
| host_period_bytes = copier_data->base_config.ibs; | ||
| else | ||
| host_period_bytes = copier_data->base_config.obs; | ||
|
|
||
| min_size = SOF_IPC4_MIN_DMA_BUFFER_SIZE * host_period_bytes; | ||
| headroom = min(SOF_IPC4_ALSA_PERIOD_MAX_HEADROOM_MS * host_period_bytes, | ||
| fe_period_bytes / 2); | ||
|
|
||
| /* parse the deep buffer dma size */ | ||
| ret = sof_update_ipc_object(scomp, &deep_buffer_dma_ms, | ||
| SOF_COPIER_DEEP_BUFFER_TOKENS, swidget->tuples, | ||
| swidget->num_tuples, sizeof(u32), 1); | ||
| if (ret) { | ||
| dev_dbg(scomp->dev, | ||
| "Failed to parse deep buffer dma size for %s\n", | ||
| swidget->widget->name); | ||
| buffer_bytes = min_size; | ||
| goto out; | ||
|
Collaborator
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. not just
Collaborator
Author
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. no, we want to print the dma buffer configuration. |
||
| } | ||
|
|
||
| max_size = deep_buffer_dma_ms * host_period_bytes; | ||
|
|
||
| /* | ||
| * Non Deepbuffer and small ALSA periods must use the minimal host DMA | ||
| * buffer size. | ||
| * Note: smaller than 2x the minimum host DMA buffer size for ALSA | ||
| * period is not allowed and should be protected by platform code with | ||
| * constraint | ||
| */ | ||
| if (deep_buffer_dma_ms <= SOF_IPC4_MIN_DMA_BUFFER_SIZE || | ||
| (min_size * 2) > fe_period_bytes) | ||
| buffer_bytes = min_size; | ||
| else | ||
| buffer_bytes = min(max_size, fe_period_bytes - headroom); | ||
|
|
||
| out: | ||
| dev_dbg(scomp->dev, | ||
| "%s, dma buffer%s: %u ms (max: %u) / %u bytes, ALSA period: %u / %u\n", | ||
| swidget->widget->name, deep_buffer_dma_ms ? " (using Deep Buffer)" : "", | ||
| buffer_bytes / host_period_bytes, | ||
| deep_buffer_dma_ms ? deep_buffer_dma_ms : SOF_IPC4_MIN_DMA_BUFFER_SIZE, | ||
| buffer_bytes, fe_period_bytes / host_period_bytes, fe_period_bytes); | ||
|
|
||
| copier_data->gtw_cfg.dma_buffer_size = buffer_bytes; | ||
| } | ||
|
|
||
| static int | ||
| sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, | ||
| struct snd_pcm_hw_params *fe_params, | ||
|
|
@@ -2063,7 +2117,6 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, | |
| u32 **data; | ||
| int ipc_size, ret, out_ref_valid_bits; | ||
| u32 out_ref_rate, out_ref_channels, out_ref_type; | ||
| u32 deep_buffer_dma_ms = 0; | ||
| bool single_output_bitdepth; | ||
| int i; | ||
|
|
||
|
|
@@ -2081,16 +2134,6 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, | |
| str_yes_no(pipeline->use_chain_dma), | ||
| platform_params->stream_tag); | ||
|
|
||
| /* parse the deep buffer dma size */ | ||
| ret = sof_update_ipc_object(scomp, &deep_buffer_dma_ms, | ||
| SOF_COPIER_DEEP_BUFFER_TOKENS, swidget->tuples, | ||
| swidget->num_tuples, sizeof(u32), 1); | ||
| if (ret) { | ||
| dev_err(scomp->dev, "Failed to parse deep buffer dma size for %s\n", | ||
| swidget->widget->name); | ||
| return ret; | ||
| } | ||
|
|
||
| ipc4_copier = (struct sof_ipc4_copier *)swidget->private; | ||
| gtw_attr = ipc4_copier->gtw_attr; | ||
| copier_data = &ipc4_copier->data; | ||
|
|
@@ -2425,34 +2468,19 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, | |
| * in topology. | ||
| */ | ||
| switch (swidget->id) { | ||
| case snd_soc_dapm_aif_in: | ||
| case snd_soc_dapm_aif_out: | ||
| sof_ipc4_set_host_dma_buffer_size(swidget, | ||
| params_period_bytes(fe_params)); | ||
| break; | ||
| case snd_soc_dapm_dai_in: | ||
| copier_data->gtw_cfg.dma_buffer_size = | ||
| SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.ibs; | ||
| break; | ||
| case snd_soc_dapm_aif_in: | ||
| copier_data->gtw_cfg.dma_buffer_size = | ||
| max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) * | ||
| copier_data->base_config.ibs; | ||
| dev_dbg(sdev->dev, "copier %s, dma buffer%s: %u ms (%u bytes)", | ||
| swidget->widget->name, | ||
| deep_buffer_dma_ms ? " (using Deep Buffer)" : "", | ||
| max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms), | ||
| copier_data->gtw_cfg.dma_buffer_size); | ||
| break; | ||
| case snd_soc_dapm_dai_out: | ||
| copier_data->gtw_cfg.dma_buffer_size = | ||
| SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs; | ||
| break; | ||
| case snd_soc_dapm_aif_out: | ||
| copier_data->gtw_cfg.dma_buffer_size = | ||
| max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) * | ||
| copier_data->base_config.obs; | ||
| dev_dbg(sdev->dev, "copier %s, dma buffer%s: %u ms (%u bytes)", | ||
| swidget->widget->name, | ||
| deep_buffer_dma_ms ? " (using Deep Buffer)" : "", | ||
| max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms), | ||
| copier_data->gtw_cfg.dma_buffer_size); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to double check - this is correct - using a "min" value to set a "max" constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the min value to set the min constraint, max is UINT_MAX, This is why I'm renaming the variable.