Commit 300689fb authored by Sascha Hauer's avatar Sascha Hauer Committed by Mark Brown

ASoC: soc-generic-dmaengine-pcm: set period_bytes_min based on maxburst

In dmaengine_pcm_set_runtime_hwparams() period_bytes_min is hardcoded to
256. For some applications that may be too big. This patch changes that
to calculate the value based on dma_data->maxburst. The correct value
would be maxburst multiplied by the address width of the hardware FIFO.
Unfortunately the address width is dynamically calculated based on the
stream parameters and is not known at open time, so the worst case
is chosen here which is 8 bytes, the maximum that is supported by
dmaengine drivers.
Not all drivers may set a maxburst value, so we fall back to the
previously used hardcoded value of 256 bytes.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20220301113446.1053171-1-s.hauer@pengutronix.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 45ea97d7
......@@ -132,7 +132,9 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component,
SNDRV_PCM_INFO_INTERLEAVED;
hw.periods_min = 2;
hw.periods_max = UINT_MAX;
hw.period_bytes_min = 256;
hw.period_bytes_min = dma_data->maxburst * DMA_SLAVE_BUSWIDTH_8_BYTES;
if (!hw.period_bytes_min)
hw.period_bytes_min = 256;
hw.period_bytes_max = dma_get_max_seg_size(dma_dev);
hw.buffer_bytes_max = SIZE_MAX;
hw.fifo_size = dma_data->fifo_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment