Skip to content

Commit 842bb8b

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-topology: Save the DMA maximum burst size for PCMs
When setting up the pcm widget, save the DSP buffer size (in ms) for platform code to place a constraint on playback. On playback the DMA will fill the buffer on start and if the period size is smaller it will immediately overrun. On capture the DMA will move data in 1ms bursts. Cc: stable@vger.kernel.org # 6.8 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://msgid.link/r/20240321130814.4412-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fb9f812 commit 842bb8b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,9 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
412412
struct sof_ipc4_available_audio_format *available_fmt;
413413
struct snd_soc_component *scomp = swidget->scomp;
414414
struct sof_ipc4_copier *ipc4_copier;
415+
struct snd_sof_pcm *spcm;
415416
int node_type = 0;
416-
int ret;
417+
int ret, dir;
417418

418419
ipc4_copier = kzalloc(sizeof(*ipc4_copier), GFP_KERNEL);
419420
if (!ipc4_copier)
@@ -447,6 +448,25 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
447448
}
448449
dev_dbg(scomp->dev, "host copier '%s' node_type %u\n", swidget->widget->name, node_type);
449450

451+
spcm = snd_sof_find_spcm_comp(scomp, swidget->comp_id, &dir);
452+
if (!spcm)
453+
goto skip_gtw_cfg;
454+
455+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
456+
struct snd_sof_pcm_stream *sps = &spcm->stream[dir];
457+
458+
sof_update_ipc_object(scomp, &sps->dsp_max_burst_size_in_ms,
459+
SOF_COPIER_DEEP_BUFFER_TOKENS,
460+
swidget->tuples,
461+
swidget->num_tuples, sizeof(u32), 1);
462+
/* Set default DMA buffer size if it is not specified in topology */
463+
if (!sps->dsp_max_burst_size_in_ms)
464+
sps->dsp_max_burst_size_in_ms = SOF_IPC4_MIN_DMA_BUFFER_SIZE;
465+
} else {
466+
/* Capture data is copied from DSP to host in 1ms bursts */
467+
spcm->stream[dir].dsp_max_burst_size_in_ms = 1;
468+
}
469+
450470
skip_gtw_cfg:
451471
ipc4_copier->gtw_attr = kzalloc(sizeof(*ipc4_copier->gtw_attr), GFP_KERNEL);
452472
if (!ipc4_copier->gtw_attr) {

0 commit comments

Comments
 (0)