tools: topology1: imx8ulp: correct BCLK frequency

8ULP has two supported BT HFP scenarios: NBS and WBS. For
NBS the frequency of FSYNC is 8k, while for WBS the frequency
of FSYNC is 16k. Since the BCLK is computed as:
	Freq(BCLK) = TDM_SLOTS * TDM_SLOT_WIDTH * Freq(FSYNC)
then that means we're going to end up with two different BCLK
frequencies (one for each supported scenario).

Currently, what we do is pass the frequency of FSYNC
as a build argument, while keeping the frequency of BCLK
constant (set to 256000, which would be the same value as the
one used in WBS). This causes the following issues:

	1) The Zephyr native SAI driver returns an error
	when trying to commit the configuration because the
	frequency of BCLK doesn't abide by the aforementioned
	formula.

	2) We end up consuming twice as many samples in a given
	unit of time.

To fix these issues, use the aforementioned formula to compute
the frequency of BCLK.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
Laurentiu Mihalcea 2024-03-15 15:13:23 +02:00 committed by Kai Vehmanen
parent 03dd62abbd
commit bbd20a9766
2 changed files with 24 additions and 2 deletions

View File

@ -75,10 +75,21 @@ DAI_ADD(sof/pipe-dai-capture.m4,
dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture)
PCM_DUPLEX_ADD(Port0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2)
# BCLK frequency is computed using the following formula:
# Freq(BCLK) = Freq(FSYNC) * TDM_SLOTS * TDM_SLOT_WIDTH
#
# For 8ULP this yields the following frequencies
# (based on supported BT HFP configurations):
#
# 1) NBS (Freq(FSYNC) = 8k)
# Freq(BCLK) = 8k * 16 * 1 = 128000
#
# 2) WBS (Freq(FSYNC) = 16k)
# Freq(BCLK) = 16k * 16 * 1 = 256000
dnl DAI_CONFIG(type, idx, link_id, name, sai_config)
DAI_CONFIG(SAI, 6, 0, sai6-bt-sco-pcm-wb,
SAI_CONFIG(I2S, SAI_CLOCK(mclk, 12288000, codec_mclk_out),
SAI_CLOCK(bclk, 256000, codec_consumer),
SAI_CLOCK(bclk, `eval(FSYNC_RATE * 16)', codec_consumer),
SAI_CLOCK(fsync, `FSYNC_RATE', codec_consumer),
SAI_TDM(1, 16, 1, 1),
SAI_CONFIG_DATA(SAI, 6, 0)))

View File

@ -76,10 +76,21 @@ DAI_ADD(sof/pipe-dai-capture.m4,
dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture)
PCM_DUPLEX_ADD(Port0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2)
# BCLK frequency is computed using the following formula:
# Freq(BCLK) = Freq(SYNC) * TDM_SLOTS * TDM_SLOT_WIDTH
#
# For 8ULP this yields the following frequencies (based on
# supported BT HFP configurations):
#
# 1) NBS (Freq(FSYNC) = 8k)
# Freq(BCLK) = 8k * 16 * 1 = 128000
#
# 2) WBS (Freq(FSYNC) = 16k)
# Freq(BCLK) = 16k * 16 * 1 = 256000
dnl DAI_CONFIG(type, idx, link_id, name, sai_config)
DAI_CONFIG(SAI, 5, 0, sai5-bt-sco-pcm-wb,
SAI_CONFIG(I2S, SAI_CLOCK(mclk, 12288000, codec_mclk_out),
SAI_CLOCK(bclk, 256000, codec_consumer),
SAI_CLOCK(bclk, `eval(FSYNC_RATE * 16)', codec_consumer),
SAI_CLOCK(fsync, `FSYNC_RATE', codec_consumer),
SAI_TDM(1, 16, 1, 1),
SAI_CONFIG_DATA(SAI, 5, 0)))