Skip to content

Commit 13829cc

Browse files
committed
ASoC: SOF: Intel: hda-pcm: Place the constraint on period time instead of buffer time
Instead of constraining the buffer time to be double of the host buffer size it is better to set it for the priod time. This will implicitly constrain the buffer time to at least 2x of the host buffer size (num_periods is at least 2) and prohibits applications to set smaller period size than what will be covered by the initial DMA burst. Fixes: 02ea2a0 ("ASoC: SOF: Intel: hda-pcm: Use dsp_max_burst_size_in_ms to place constraint") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 88e54e5 commit 13829cc

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,16 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
291291
* On playback start the DMA will transfer dsp_max_burst_size_in_ms
292292
* amount of data in one initial burst to fill up the host DMA buffer.
293293
* Consequent DMA burst sizes are shorter and their length can vary.
294-
* To make sure that userspace allocate large enough ALSA buffer we need
295-
* to place a constraint on the buffer time.
294+
* To avoid immediate xrun by the initial burst we need to place
295+
* constraint on the period size (via PERIOD_TIME) to cover the size of
296+
* the host buffer.
296297
*
297298
* On capture the DMA will transfer 1ms chunks.
298-
*
299-
* Exact dsp_max_burst_size_in_ms constraint is racy, so set the
300-
* constraint to a minimum of 2x dsp_max_burst_size_in_ms.
301299
*/
302300
if (spcm->stream[direction].dsp_max_burst_size_in_ms)
303301
snd_pcm_hw_constraint_minmax(substream->runtime,
304-
SNDRV_PCM_HW_PARAM_BUFFER_TIME,
305-
spcm->stream[direction].dsp_max_burst_size_in_ms * USEC_PER_MSEC * 2,
302+
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
303+
spcm->stream[direction].dsp_max_burst_size_in_ms * USEC_PER_MSEC,
306304
UINT_MAX);
307305

308306
/* binding pcm substream to hda stream */

0 commit comments

Comments
 (0)