Skip to content

Commit fedfcf1

Browse files
singalsuujfalusi
authored andcommitted
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 6e9a1f6 commit fedfcf1

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
623623
struct sof_ipc4_available_audio_format *available_fmt;
624624
struct snd_soc_component *scomp = swidget->scomp;
625625
struct sof_ipc4_copier *ipc4_copier;
626+
struct snd_sof_pcm_stream *sps;
626627
struct snd_sof_pcm *spcm;
627628
int node_type = 0;
628629
int ret, dir;
@@ -667,24 +668,23 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
667668
if (ret)
668669
goto free_available_fmt;
669670

670-
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
671-
struct snd_sof_pcm_stream *sps = &spcm->stream[dir];
671+
sps = &spcm->stream[dir];
672+
sof_update_ipc_object(scomp, &sps->dsp_max_burst_size_in_ms,
673+
SOF_COPIER_DEEP_BUFFER_TOKENS,
674+
swidget->tuples,
675+
swidget->num_tuples, sizeof(u32), 1);
672676

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

682+
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
682683
sps->dsp_max_burst_size_in_ms = pipeline->use_chain_dma ?
683684
SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE;
684-
}
685-
} else {
686-
/* Capture data is copied from DSP to host in 1ms bursts */
687-
spcm->stream[dir].dsp_max_burst_size_in_ms = 1;
685+
else
686+
/* Capture data is copied from DSP to host in 1ms bursts */
687+
sps->dsp_max_burst_size_in_ms = 1;
688688
}
689689

690690
skip_gtw_cfg:
@@ -2440,10 +2440,19 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24402440
copier_data->gtw_cfg.dma_buffer_size);
24412441
break;
24422442
case snd_soc_dapm_dai_out:
2443-
case snd_soc_dapm_aif_out:
24442443
copier_data->gtw_cfg.dma_buffer_size =
24452444
SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs;
24462445
break;
2446+
case snd_soc_dapm_aif_out:
2447+
copier_data->gtw_cfg.dma_buffer_size =
2448+
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) *
2449+
copier_data->base_config.obs;
2450+
dev_dbg(sdev->dev, "copier %s, dma buffer%s: %u ms (%u bytes)",
2451+
swidget->widget->name,
2452+
deep_buffer_dma_ms ? " (using Deep Buffer)" : "",
2453+
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms),
2454+
copier_data->gtw_cfg.dma_buffer_size);
2455+
break;
24472456
default:
24482457
break;
24492458
}

0 commit comments

Comments
 (0)