From 3f12097f363728719f788b6dd43519d68a73b471 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Mon, 13 Jun 2022 13:20:44 +0800 Subject: [PATCH] topology2: add support for sampling rate The original calculation will generate 44 sample size for 44.1khz, actually it at least needs 45 sample size. This patch uses ceil value for such rate, also inlcude 11.025kh, 22.05kh, 88.2khz, 176.4khz. Signed-off-by: Rander Wang --- tools/topology/topology2/include/common/audio_format.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/topology/topology2/include/common/audio_format.conf b/tools/topology/topology2/include/common/audio_format.conf index 9ce8e35cb..7fc3f0e70 100644 --- a/tools/topology/topology2/include/common/audio_format.conf +++ b/tools/topology/topology2/include/common/audio_format.conf @@ -232,6 +232,7 @@ Class.Base."audio_format" { out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256)) | ($out_sample_type * 65536)]" # math expression for computing input/put buffer sizes - ibs "$[($in_channels * ($in_rate / 1000)) * ($in_bit_depth / 8)]" - obs "$[($out_channels * ($out_rate / 1000)) * ($out_bit_depth / 8)]" + # for 11.025 22.05, 44.1, 88.2 and 176.4khz, we need to round it to ceiling value + ibs "$[($in_channels * ($[($in_rate + 999)] / 1000)) * ($in_bit_depth / 8)]" + obs "$[($out_channels * ($[($out_rate + 999)] / 1000)) * ($out_bit_depth / 8)]" }