From dde0e8029cf77099519b1672cf6c9da86307b447 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 17 Apr 2024 13:56:21 +0300 Subject: [PATCH 1/3] topology2: common: pcm_caps: Increase periods_max from 16 to 1024 There is no technical reason to limit how many periods applications use. Generic sound cards tends to allow 32768 periods (period size range is 16 - 524288) but that is an overshot, let's raise the limit to 1024. Signed-off-by: Peter Ujfalusi --- tools/topology/topology2/include/common/pcm_caps.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/topology/topology2/include/common/pcm_caps.conf b/tools/topology/topology2/include/common/pcm_caps.conf index 44cfb755eb11..dcd6f6aeab7d 100644 --- a/tools/topology/topology2/include/common/pcm_caps.conf +++ b/tools/topology/topology2/include/common/pcm_caps.conf @@ -84,7 +84,7 @@ Class.PCM."pcm_caps" { formats "S32_LE,S24_LE,S16_LE" rates "48000" periods_min 2 - periods_max 16 + periods_max 1024 channels_min 2 channels_max 2 period_size_min 192 From c6f0b6169a7788089386d4885af911fa880e6813 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 17 Apr 2024 14:55:19 +0300 Subject: [PATCH 2/3] topology2: common: pcm_caps: Revisit default period and buffer sizes Increase the default period_size_max to a much larger value which is commonly used by sound cards from 16384 to 2097152. Adjust the buffer_size limits to minimum 384 (2 * period_size_min) and the maximum to 4194304 (2 * period_size_max). Applications do not need to use these large buffers, but there is no technical reason to not allow them, like they available on other sound hardware. Signed-off-by: Peter Ujfalusi --- tools/topology/topology2/include/common/pcm_caps.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/topology/topology2/include/common/pcm_caps.conf b/tools/topology/topology2/include/common/pcm_caps.conf index dcd6f6aeab7d..d4cc20568311 100644 --- a/tools/topology/topology2/include/common/pcm_caps.conf +++ b/tools/topology/topology2/include/common/pcm_caps.conf @@ -87,8 +87,8 @@ Class.PCM."pcm_caps" { periods_max 1024 channels_min 2 channels_max 2 - period_size_min 192 - period_size_max 16384 - buffer_size_min 65536 - buffer_size_max 65536 + period_size_min 192 # "$[((2 * $channels_min) * 48000) / 1000]" (48K, S16_LE, 1ms) + period_size_max 2097152 # Large enough to cover user's needs + buffer_size_min 384 # "$[$period_size_min * $periods_min]" + buffer_size_max 4194304 # "$[2 * $period_size_max]" } From 402ae25ce671f21379e7abce91b779e5d0a4f86f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 17 Apr 2024 15:21:36 +0300 Subject: [PATCH 3/3] topology2: intel: deep-buffer: Adjust the buffer_size_min only There is no benefit on changing the period/buffer size_max as it is set by default to a reasonably large value already. What matters is the buffer_size_min: it needs to be larger than the amount of data that one DMA burst will transfer, which is equal to the DeepBuffer size. For safety reasons the minimum buffer size has to be larger than this. Signed-off-by: Peter Ujfalusi --- .../topology2/platform/intel/deep-buffer.conf | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/topology/topology2/platform/intel/deep-buffer.conf b/tools/topology/topology2/platform/intel/deep-buffer.conf index 5dd85e960d51..549c4180a26c 100644 --- a/tools/topology/topology2/platform/intel/deep-buffer.conf +++ b/tools/topology/topology2/platform/intel/deep-buffer.conf @@ -33,9 +33,14 @@ Object.PCM.pcm [ Object.PCM.pcm_caps.1 { name $DEEP_BUFFER_PCM_NAME formats 'S16_LE,S24_LE,S32_LE' - # align with $DEEPBUFFER_FW_DMA_MS - period_size_max 65535 - buffer_size_max 262144 + # To avoid DMA spinning on a buffer we need bigger + # buffer than the host buffer size, let's say twice as + # big + # (S16_LE, Stereo, 48KHz, DEEPBUFFER_FW_DMA_MS) * 2 + # + # Note: The lower limit for the buffer size is rate + # dependent + buffer_size_min "$[(((2 * $channels_min) * 48) * $DEEPBUFFER_FW_DMA_MS) * 2]" } } ] @@ -83,9 +88,14 @@ IncludeByKey.DEEP_BUF_SPK { Object.PCM.pcm_caps.1 { name $DEEP_BUFFER_PCM_NAME_2 formats 'S16_LE,S24_LE,S32_LE' - # align with $DEEPBUFFER_FW_DMA_MS - period_size_max 65535 - buffer_size_max 262144 + # To avoid DMA spinning on a buffer we need bigger + # buffer than the host buffer size, let's say twice as + # big + # (S16_LE, Stereo, 48KHz, DEEPBUFFER_FW_DMA_MS) * 2 + # + # Note: The lower limit for the buffer size is rate + # dependent + buffer_size_min "$[(((2 * $channels_min) * 48) * $DEEPBUFFER_FW_DMA_MS) * 2]" } } ]