From 805ab3efa0b94f7f7026a3431f32afefe6fc1ba7 Mon Sep 17 00:00:00 2001 From: Yong Zhi Date: Wed, 25 Jan 2023 17:12:13 -0600 Subject: [PATCH] topology2: cavs-rt5682: add reference capture for MAX98357A speaker amp Use lbm_mode to loopback playback data for PCM27. Add copier module in DAI BE for demux function. Signed-off-by: Yong Zhi --- tools/topology/topology2/cavs-rt5682.conf | 22 +++- .../include/pipelines/cavs/dai-copier-be.conf | 102 ++++++++++++++++++ .../platform/intel/speaker-echo-ref.conf | 58 ++++++++++ .../topology2/sof-ace-tplg/CMakeLists.txt | 2 +- 4 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 tools/topology/topology2/include/pipelines/cavs/dai-copier-be.conf create mode 100644 tools/topology/topology2/platform/intel/speaker-echo-ref.conf diff --git a/tools/topology/topology2/cavs-rt5682.conf b/tools/topology/topology2/cavs-rt5682.conf index b04957d990ea..63787b19eb07 100644 --- a/tools/topology/topology2/cavs-rt5682.conf +++ b/tools/topology/topology2/cavs-rt5682.conf @@ -16,6 +16,7 @@ + @@ -70,6 +71,12 @@ Define { SPEAKER_PLAYBACK_PCM_STREAM_NAME 'Speaker Playback' SPEAKER_SSP_DAI_INDEX 1 SPEAKER_HW_CONFIG_NAME 'SPEAKER HWCFG' + INCLUDE_ECHO_REF false + ECHO_REF_HOST_PIPELINE_ID 7 + ECHO_REF_DAI_PIPELINE_ID 8 + ECHO_REF_HOST_PIPELINE_SINK 'copier.host.7.1' + ECHO_REF_DAI_PIPELINE_SRC 'copier.SSP.8.1' + ECHO_REF_COPIER_MODULE 'copier.module.8.2' } # override defaults with platform-specific config @@ -91,6 +98,11 @@ IncludeByKey.NUM_HDMIS { IncludeByKey.DEEPBUFFER_FW_DMA_MS{ "[1-1000]" "platform/intel/deep-buffer.conf" } + +IncludeByKey.INCLUDE_ECHO_REF { + "true" "platform/intel/speaker-echo-ref.conf" +} + # # List of all DAIs # @@ -116,7 +128,15 @@ Object.Dai { SSP."1" { id $SPK_ID dai_index $SPEAKER_SSP_DAI_INDEX - direction "playback" + IncludeByKey.INCLUDE_ECHO_REF { + "false" { + direction "playback" + } + "true" { + direction "duplex" + quirks "lbm_mode" + } + } name $SPEAKER_CODEC_NAME default_hw_conf_id 0 sample_bits 32 diff --git a/tools/topology/topology2/include/pipelines/cavs/dai-copier-be.conf b/tools/topology/topology2/include/pipelines/cavs/dai-copier-be.conf new file mode 100644 index 000000000000..bc1e6a390c31 --- /dev/null +++ b/tools/topology/topology2/include/pipelines/cavs/dai-copier-be.conf @@ -0,0 +1,102 @@ +# +# BE DAI copier pipeline +# +# All attributes defined herein are namespaced by alsatplg to +# "Object.Pipeline.dai-copier-be.N.attribute_name" +# +# Usage: dai-copier-be pipeline object can be instantiated as: +# +# Object.Pipeline.dai-copier-be."N" { +# period 1000 +# time_domain "timer" +# channels 2 +# rate 48000 +# } +# +# Where N is the unique pipeline ID within the same alsaconf node. +# + + + + + +Class.Pipeline."dai-copier-be" { + + DefineAttribute."index" {} + + + + attributes { + !constructor [ + "index" + ] + + unique "instance" + } + + Object.Widget { + copier."1" { + type dai_in + node_type $HDA_LINK_OUTPUT_CLASS + num_audio_formats 3 + # 32-bit 48KHz 2ch + Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + # 32-bit 48KHz 4ch + Object.Base.audio_format.2 { + in_channels 4 + in_bit_depth 32 + in_valid_bit_depth 32 + out_channels 4 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + in_ch_cfg $CHANNEL_CONFIG_3_POINT_1 + in_ch_map $CHANNEL_MAP_3_POINT_1 + out_ch_cfg $CHANNEL_CONFIG_3_POINT_1 + out_ch_map $CHANNEL_MAP_3_POINT_1 + } + # 24-bit 48KHz 2ch + Object.Base.audio_format.3 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + } + + copier."2" { + type buffer + copier_type "module" + num_audio_formats 1 + + Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$ibs * 2]" + } + } + + pipeline."1" { + priority 0 + lp_mode 0 + } + } + + time_domain "timer" + dynamic_pipeline 1 + channels 2 + channels_min 2 + channels_max 2 + rate 48000 + rate_min 48000 + rate_max 48000 +} diff --git a/tools/topology/topology2/platform/intel/speaker-echo-ref.conf b/tools/topology/topology2/platform/intel/speaker-echo-ref.conf new file mode 100644 index 000000000000..3870a91e6802 --- /dev/null +++ b/tools/topology/topology2/platform/intel/speaker-echo-ref.conf @@ -0,0 +1,58 @@ +Define { + ECHO_REF_STREAM_NAME "Echo reference" +} + +Object.Pipeline { + passthrough-capture.2 { + index $ECHO_REF_HOST_PIPELINE_ID + + Object.Widget.copier.1 { + stream_name $ECHO_REF_STREAM_NAME + } + } + + dai-copier-be.2 { + index $ECHO_REF_DAI_PIPELINE_ID + + Object.Widget.copier."1" { + dai_index 1 + dai_type "SSP" + type dai_out + copier_type "SSP" + stream_name $SPEAKER_CODEC_NAME + node_type $I2S_LINK_INPUT_CLASS + Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$ibs * 2]" + } + } + } +} + +Object.PCM { + pcm."2" { + name "EchoRef" + id 27 + direction "capture" + Object.Base.fe_dai.1 {} + + Object.PCM.pcm_caps.1 { + name $ECHO_REF_STREAM_NAME + formats 'S16_LE,S24_LE,S32_LE' + } + } +} + +Object.Base { + route."7" { + source $ECHO_REF_DAI_PIPELINE_SRC + sink $ECHO_REF_COPIER_MODULE + } + route."8" { + source $ECHO_REF_COPIER_MODULE + sink $ECHO_REF_HOST_PIPELINE_SINK + } +} diff --git a/tools/topology/topology2/sof-ace-tplg/CMakeLists.txt b/tools/topology/topology2/sof-ace-tplg/CMakeLists.txt index c719f5ca9d25..85d9120a3ac3 100644 --- a/tools/topology/topology2/sof-ace-tplg/CMakeLists.txt +++ b/tools/topology/topology2/sof-ace-tplg/CMakeLists.txt @@ -21,7 +21,7 @@ DEEPBUFFER_FW_DMA_MS=100" PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-rt711-4ch.bin,DEEPBUFFER_FW_DMA_MS=100" "cavs-rt5682\;sof-mtl-max98357a-rt5682\;PLATFORM=mtl,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,\ -PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-max98357a-rt5682.bin,DEEPBUFFER_FW_DMA_MS=10" +PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-max98357a-rt5682.bin,DEEPBUFFER_FW_DMA_MS=10,INCLUDE_ECHO_REF=true" "cavs-rt5682\;sof-mtl-max98357a-rt5682-ssp2-ssp0\;PLATFORM=mtl,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,\ PDM1_MIC_B_ENABLE=1,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-max98357a-rt5682.bin,\