Skip to content

Commit d53f6ea

Browse files
committed
ASoC: SOF: ipc4/Intel: Rename dsp_max_burst_size_in_ms to dsp_min_burst_size_in_ms
The meaning of the variable has changed with he Dynamic DeepBuffer and it reflects the smallest burst that the host DMA does. This can be used to set the minimum period time constraint to avoid overshooting by the DMA burst. Change the name and update the related code in Intel hda_dsp_pcm_open() to reflect the revised meaning. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent d8231a7 commit d53f6ea

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

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

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

32-
#define HDA_MAX_PERIOD_TIME_HEADROOM 10
33-
3432
static bool hda_always_enable_dmi_l1;
3533
module_param_named(always_enable_dmi_l1, hda_always_enable_dmi_l1, bool, 0444);
3634
MODULE_PARM_DESC(always_enable_dmi_l1, "SOF HDA always enable DMI l1");
@@ -287,36 +285,17 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
287285
SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S32);
288286

289287
/*
290-
* The dsp_max_burst_size_in_ms is the length of the maximum burst size
288+
* The dsp_min_burst_size_in_ms is the length of the minimum burst size
291289
* of the host DMA in the ALSA buffer.
292290
*
293-
* On playback start the DMA will transfer dsp_max_burst_size_in_ms
294-
* amount of data in one initial burst to fill up the host DMA buffer.
295-
* Consequent DMA burst sizes are shorter and their length can vary.
296-
* To avoid immediate xrun by the initial burst we need to place
297-
* constraint on the period size (via PERIOD_TIME) to cover the size of
298-
* the host buffer.
299-
* We need to add headroom of max 10ms as the firmware needs time to
300-
* settle to the 1ms pacing and initially it can run faster for few
301-
* internal periods.
302-
*
303-
* On capture the DMA will transfer 1ms chunks.
291+
* Set a constraint to period time min to be at least twice as long as
292+
* the minimum burst size to avoid DMA overruns
304293
*/
305-
if (spcm->stream[direction].dsp_max_burst_size_in_ms) {
306-
unsigned int period_time = spcm->stream[direction].dsp_max_burst_size_in_ms;
307-
308-
/*
309-
* add headroom over the maximum burst size to cover the time
310-
* needed for the DMA pace to settle.
311-
* Limit the headroom time to HDA_MAX_PERIOD_TIME_HEADROOM
312-
*/
313-
period_time += min(period_time, HDA_MAX_PERIOD_TIME_HEADROOM);
314-
294+
if (spcm->stream[direction].dsp_min_burst_size_in_ms)
315295
snd_pcm_hw_constraint_minmax(substream->runtime,
316296
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
317-
period_time * USEC_PER_MSEC,
297+
spcm->stream[direction].dsp_min_burst_size_in_ms * USEC_PER_MSEC,
318298
UINT_MAX);
319-
}
320299

321300
/* binding pcm substream to hda stream */
322301
substream->runtime->private_data = &dsp_stream->hstream;

sound/soc/sof/ipc4-topology.c

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

676-
sps->dsp_max_burst_size_in_ms = pipeline->use_chain_dma ?
676+
sps->dsp_min_burst_size_in_ms = pipeline->use_chain_dma ?
677677
SOF_IPC4_CHAIN_DMA_BUFFER_SIZE : SOF_IPC4_MIN_DMA_BUFFER_SIZE;
678678
} else {
679679
/* Capture data is copied from DSP to host in 1ms bursts */
680-
sps->dsp_max_burst_size_in_ms = 1;
680+
sps->dsp_min_burst_size_in_ms = 1;
681681
}
682682

683683
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_max_burst_size_in_ms; /* The maximum size of the host DMA burst in ms */
339+
unsigned int dsp_min_burst_size_in_ms; /* The minimum 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)