mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 08:02:07 +00:00
ASoC: SOF: relax PCM period and buffer size constraints
Current SOF implementation limits period and buffer sizes to multiples of period_min. Period_min is defined in topology, but is in practise set to align with the SOF DSP timer tick (typically 1ms). While this approach helps user-space to avoid period sizes, which are not aligned to the DSP timer tick, it causes problems to applications which want to align data processing size to that of ALSA period size. One example is JACK audio server, which limits period sizes to power of two values. Other ALSA drivers where audio data transfer is driven by a timer tick, like USB, do not constraint period and buffer sizes to exact multiple of the timer tick. To align SOF to follow the same behaviour, drop the additional alignment constraints. As a side-effect, this patch can cause irregularity to period wakeup timing. This happens when application chooses settings which were previously forbidden. For example, if application configures period size to 2^14 bytes and audio config of S32_LE/2ch/48000Hz, one period represents 42.667ms of audio. Without this patch, this configuration is not allowed by SOF. With the patch applied, configuration is allowed but the wakeups are paced by the DSP timer tick, which is typically 1ms. Application will see period wakeups with a 42/43/42/43ms repeating pattern. Both approaches are valid within ALSA context, but relaxing the constraints is better aligned with existing applications and other ALSA drivers like USB audio. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/20201118140545.2138895-1-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
73ea3a5dbb
commit
9983ac49b7
@ -478,17 +478,10 @@ static int sof_pcm_open(struct snd_soc_component *component,
|
||||
|
||||
caps = &spcm->pcm.caps[substream->stream];
|
||||
|
||||
/* set any runtime constraints based on topology */
|
||||
snd_pcm_hw_constraint_step(substream->runtime, 0,
|
||||
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
|
||||
le32_to_cpu(caps->period_size_min));
|
||||
snd_pcm_hw_constraint_step(substream->runtime, 0,
|
||||
SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
|
||||
le32_to_cpu(caps->period_size_min));
|
||||
|
||||
/* set runtime config */
|
||||
runtime->hw.info = ops->hw_info; /* platform-specific */
|
||||
|
||||
/* set any runtime constraints based on topology */
|
||||
runtime->hw.formats = le64_to_cpu(caps->formats);
|
||||
runtime->hw.period_bytes_min = le32_to_cpu(caps->period_size_min);
|
||||
runtime->hw.period_bytes_max = le32_to_cpu(caps->period_size_max);
|
||||
|
Loading…
Reference in New Issue
Block a user