Skip to content

Commit e3a9b28

Browse files
committed
ASoC: SOF: ipc4-topology: Enable deep buffer capture
This patch lets a capture PCM to operate with deep buffer by taking dsp_max_burst_size_in_ms from topology if it is defined. Earlier the value from topology was omitted for capture. If not defined, the maximum burst size for capture is set similarly as before to one millisecond. The dma_buffer_size is set similarly as for playback from largest of deep_buffer_dma_ms or SOF_IPC4_MIN_DMA_BUFFER_SIZE times OBS. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent cdadd72 commit e3a9b28

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
619619
struct sof_ipc4_available_audio_format *available_fmt;
620620
struct snd_soc_component *scomp = swidget->scomp;
621621
struct sof_ipc4_copier *ipc4_copier;
622+
struct snd_sof_pcm_stream *sps;
622623
struct snd_sof_pcm *spcm;
623624
int node_type = 0;
624625
int ret, dir;
@@ -663,24 +664,23 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
663664
if (ret)
664665
goto free_available_fmt;
665666

666-
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
667-
struct snd_sof_pcm_stream *sps = &spcm->stream[dir];
667+
sps = &spcm->stream[dir];
668+
sof_update_ipc_object(scomp, &sps->dsp_max_burst_size_in_ms,
669+
SOF_COPIER_DEEP_BUFFER_TOKENS,
670+
swidget->tuples,
671+
swidget->num_tuples, sizeof(u32), 1);
668672

669-
sof_update_ipc_object(scomp, &sps->dsp_max_burst_size_in_ms,
670-
SOF_COPIER_DEEP_BUFFER_TOKENS,
671-
swidget->tuples,
672-
swidget->num_tuples, sizeof(u32), 1);
673-
/* Set default DMA buffer size if it is not specified in topology */
674-
if (!sps->dsp_max_burst_size_in_ms) {
675-
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
676-
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
673+
/* Set default DMA buffer size if it is not specified in topology */
674+
if (!sps->dsp_max_burst_size_in_ms) {
675+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
676+
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
677677

678+
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
678679
sps->dsp_max_burst_size_in_ms = pipeline->use_chain_dma ?
679680
SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE;
680-
}
681-
} else {
682-
/* Capture data is copied from DSP to host in 1ms bursts */
683-
spcm->stream[dir].dsp_max_burst_size_in_ms = 1;
681+
else
682+
/* Capture data is copied from DSP to host in 1ms bursts */
683+
sps->dsp_max_burst_size_in_ms = 1;
684684
}
685685

686686
skip_gtw_cfg:
@@ -2423,7 +2423,13 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24232423
case snd_soc_dapm_dai_out:
24242424
case snd_soc_dapm_aif_out:
24252425
copier_data->gtw_cfg.dma_buffer_size =
2426-
SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs;
2426+
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) *
2427+
copier_data->base_config.obs;
2428+
dev_dbg(sdev->dev, "copier %s, dma buffer%s: %u ms (%u bytes)",
2429+
swidget->widget->name,
2430+
deep_buffer_dma_ms ? " (using Deep Buffer)" : "",
2431+
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms),
2432+
copier_data->gtw_cfg.dma_buffer_size);
24272433
break;
24282434
default:
24292435
break;

0 commit comments

Comments
 (0)