Skip to content

Commit bd9beee

Browse files
committed
Revert "ASoC: SOF: ipc4/Intel: Rename dsp_max_burst_size_in_ms to dsp_min_burst_size_in_ms"
This reverts commit a3cb9cc. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 00f64b4 commit bd9beee

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

sound/soc/sof/intel/hda-pcm.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#define SDnFMT_BITS(x) ((x) << 4)
3030
#define SDnFMT_CHAN(x) ((x) << 0)
3131

32+
#define HDA_MAX_PERIOD_TIME_HEADROOM 10
33+
3234
static bool hda_always_enable_dmi_l1;
3335
module_param_named(always_enable_dmi_l1, hda_always_enable_dmi_l1, bool, 0444);
3436
MODULE_PARM_DESC(always_enable_dmi_l1, "SOF HDA always enable DMI l1");
@@ -295,19 +297,35 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
295297
SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S32);
296298

297299
/*
298-
* The dsp_min_burst_size_in_ms is the length of the minimum burst size
300+
* The dsp_max_burst_size_in_ms is the length of the maximum burst size
299301
* of the host DMA in the ALSA buffer.
300302
*
301-
* Set a constraint to period time min to be at least twice as long as
302-
* the minimum burst size to avoid DMA overruns
303+
* On playback start the DMA will transfer dsp_max_burst_size_in_ms
304+
* amount of data in one initial burst to fill up the host DMA buffer.
305+
* Consequent DMA burst sizes are shorter and their length can vary.
306+
* To avoid immediate xrun by the initial burst we need to place
307+
* constraint on the period size (via PERIOD_TIME) to cover the size of
308+
* the host buffer.
309+
* We need to add headroom of max 10ms as the firmware needs time to
310+
* settle to the 1ms pacing and initially it can run faster for few
311+
* internal periods.
312+
*
313+
* On capture the DMA will transfer 1ms chunks.
303314
*/
304-
if (spcm->stream[direction].dsp_min_burst_size_in_ms) {
305-
unsigned int burst_time = spcm->stream[direction].dsp_min_burst_size_in_ms;
315+
if (spcm->stream[direction].dsp_max_burst_size_in_ms) {
316+
unsigned int period_time = spcm->stream[direction].dsp_max_burst_size_in_ms;
317+
318+
/*
319+
* add headroom over the maximum burst size to cover the time
320+
* needed for the DMA pace to settle.
321+
* Limit the headroom time to HDA_MAX_PERIOD_TIME_HEADROOM
322+
*/
323+
period_time += min(period_time, HDA_MAX_PERIOD_TIME_HEADROOM);
306324

307325
snd_pcm_hw_constraint_minmax(substream->runtime,
308-
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
309-
burst_time * USEC_PER_MSEC * 2,
310-
UINT_MAX);
326+
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
327+
period_time * USEC_PER_MSEC,
328+
UINT_MAX);
311329
}
312330

313331
/* binding pcm substream to hda stream */

sound/soc/sof/ipc4-topology.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,11 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
692692
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
693693
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
694694

695-
sps->dsp_min_burst_size_in_ms = pipeline->use_chain_dma ?
695+
sps->dsp_max_burst_size_in_ms = pipeline->use_chain_dma ?
696696
SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE;
697697
} else {
698698
/* Capture data is copied from DSP to host in 1ms bursts */
699-
sps->dsp_min_burst_size_in_ms = 1;
699+
sps->dsp_max_burst_size_in_ms = 1;
700700
}
701701

702702
skip_gtw_cfg:

sound/soc/sof/sof-audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct snd_sof_pcm_stream {
336336
struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */
337337
bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
338338
bool pause_supported; /* PCM device supports PAUSE operation */
339-
unsigned int dsp_min_burst_size_in_ms; /* The minimum size of the host DMA burst in ms */
339+
unsigned int dsp_max_burst_size_in_ms; /* The maximum size of the host DMA burst in ms */
340340
/*
341341
* flag to indicate that the DSP pipelines should be kept
342342
* active or not while suspending the stream

0 commit comments

Comments
 (0)