From d3902b59248442b35a9803cb35545a6e1d2922de Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Wed, 28 Sep 2022 20:44:23 +0300 Subject: [PATCH] topology2: add generic Bluetooth offload pipeline Add generic Bluetooth offload pipeline and two example topologies based on cavs-nocodec that are using the new Bluetooth pipelines. 1) cavs-nocodec-bt.conf Example topology that matches configuration used on may Intel SOF boards (SSP2, Bluetooth SCO and A2DP configurations). 2) cavs-nocodec-bt-lbm.conf Variant of first topology that configures all mode with SSP loopback mode, allowing to verify the pipeline operation by capturing the audio back from the same PCM. Requires alsa-utils patch "topology: nhlt: intel: ssp: fix obvious typo for 'codec_provider'" to correctly generate the NHLT blobs for 8/16khz modes. Link: https://github.com/alsa-project/alsa-utils/pull/174 Co-developed-by: Kai Vehmanen Signed-off-by: Kai Vehmanen Signed-off-by: Jaska Uimonen --- .../topology2/avs-tplg/CMakeLists.txt | 6 + tools/topology/topology2/cavs-nocodec-bt.conf | 300 ++++++++++++++++++ .../topology2/platform/intel/bt-default.conf | 25 ++ .../topology2/platform/intel/bt-generic.conf | 233 ++++++++++++++ .../platform/intel/bt-ssp-config-lbm.conf | 56 ++++ .../platform/intel/bt-ssp-config.conf | 52 +++ 6 files changed, 672 insertions(+) create mode 100644 tools/topology/topology2/cavs-nocodec-bt.conf create mode 100644 tools/topology/topology2/platform/intel/bt-default.conf create mode 100644 tools/topology/topology2/platform/intel/bt-generic.conf create mode 100644 tools/topology/topology2/platform/intel/bt-ssp-config-lbm.conf create mode 100644 tools/topology/topology2/platform/intel/bt-ssp-config.conf diff --git a/tools/topology/topology2/avs-tplg/CMakeLists.txt b/tools/topology/topology2/avs-tplg/CMakeLists.txt index 906768c508ff..76fc993f8bae 100644 --- a/tools/topology/topology2/avs-tplg/CMakeLists.txt +++ b/tools/topology/topology2/avs-tplg/CMakeLists.txt @@ -36,6 +36,12 @@ NHLT_BIN=nhlt-sof-tgl-rt711-rt1308-4ch.bin" "cavs-sdw\;sof-adl-rt711-4ch\;DEEPBUFFER_FW_DMA_MS=100,NUM_DMICS=4,DMIC0_ID=2,\ DMIC1_ID=3,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,HDMI1_ID=4,HDMI2_ID=5,\ HDMI3_ID=6,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-adl-rt711-4ch.bin" + +# BT offload +"cavs-nocodec-bt\;sof-nocodec-bt\;PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-nocodec-bt.bin" +# BT offload loopback test topology (lbm) +"cavs-nocodec-bt\;sof-nocodec-bt-lbm\;BT_LOOPBACK_MODE=true,\ +PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-nocodec-bt-lbm.bin" ) add_custom_target(topology2_cavs) diff --git a/tools/topology/topology2/cavs-nocodec-bt.conf b/tools/topology/topology2/cavs-nocodec-bt.conf new file mode 100644 index 000000000000..4fb5c1babb91 --- /dev/null +++ b/tools/topology/topology2/cavs-nocodec-bt.conf @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Define { + MCLK 24576000 + NUM_DMICS 0 + # override DMIC default definitions + DMIC0_HOST_PIPELINE_ID 13 + DMIC0_DAI_PIPELINE_ID 14 + DMIC0_HOST_PIPELINE_SINK 'copier.host.13.1' + DMIC0_DAI_PIPELINE_SRC 'copier.DMIC.14.1' + DMIC0_NAME 'NoCodec-6' + DMIC1_NAME 'NoCodec-7' + DMIC0_PCM_CAPS 'Passthrough Capture 13' + DMIC0_PIPELINE_STREAM_NAME 'copier.DMIC.14.1' + + # override BT configuration + BT_NAME "NoCodec-2" + BT_PB_PCM_CAPS "SSP2 Playback" + BT_CP_PCM_CAPS "SSP2 Capture" + + PLATFORM "none" +} + +# override defaults with platform-specific config +IncludeByKey.PLATFORM { + "mtl" "platform/intel/mtl.conf" +} + +# include DMIC config if needed. +IncludeByKey.NUM_DMICS { + "[1-4]" "platform/intel/dmic-generic.conf" +} + +# +# List of all DAIs +# +#SSP Index: 0, Direction: duplex +Object.Dai { + SSP."0" { + id 0 + dai_index 0 + direction "duplex" + name NoCodec-0 + default_hw_conf_id 0 + sample_bits 32 + quirks "lbm_mode" + io_clk $MCLK + Object.Base.hw_config."SSP0" { + id 0 + mclk_freq $MCLK + bclk_freq 3072000 + tdm_slot_width 32 + } + } + SSP."1" { + id 1 + dai_index 1 + direction "duplex" + name NoCodec-1 + default_hw_conf_id 0 + sample_bits 32 + quirks "lbm_mode" + io_clk $MCLK + + Object.Base.hw_config."SSP1" { + id 0 + mclk_freq $MCLK + bclk_freq 3072000 + tdm_slot_width 32 + } + } +} + +# +# Pipeline definitions +# + +# Pipeline ID:1 PCM ID: 0 +Object.Pipeline { + # playback pipelines + passthrough-be.1 { + index 2 + direction playback + Object.Widget.pipeline.1 { + stream_name 'NoCodec-0' + } + + Object.Widget.copier.1 { + dai_index 0 + dai_type "SSP" + copier_type "SSP" + stream_name "NoCodec-0" + node_type $I2S_LINK_OUTPUT_CLASS + } + } + + passthrough-playback.1 { + index 1 + Object.Widget.pipeline.1 { + stream_name 'NoCodec-0' + } + Object.Widget.copier.1 { + stream_name 'SSP0 Playback' + } + } + + passthrough-be.2 { + index 4 + direction playback + Object.Widget.pipeline.1 { + stream_name 'NoCodec-1' + } + + Object.Widget.copier.1 { + dai_index 1 + dai_type "SSP" + copier_type "SSP" + stream_name "NoCodec-1" + node_type $I2S_LINK_OUTPUT_CLASS + } + } + + passthrough-playback.2 { + index 3 + Object.Widget.pipeline.1 { + stream_name 'NoCodec-1' + } + Object.Widget.copier.1 { + stream_name 'SSP1 Playback' + } + } + + # capture pipelines + passthrough-capture.1 { + index 7 + Object.Widget.pipeline.1 { + stream_name 'NoCodec-0' + } + Object.Widget.copier.1 { + stream_name 'SSP0 Capture' + } + } + + passthrough-be.4 { + index 8 + direction capture + Object.Widget.pipeline.1 { + stream_name 'NoCodec-0' + } + + Object.Widget.copier."1" { + dai_index 0 + dai_type "SSP" + type dai_out + copier_type "SSP" + stream_name "NoCodec-0" + 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]" + } + } + } + + passthrough-capture.2 { + index 9 + Object.Widget.pipeline.1 { + stream_name 'NoCodec-1' + } + Object.Widget.copier.1 { + stream_name 'SSP1 Capture' + } + } + + passthrough-be.5 { + index 10 + direction capture + Object.Widget.pipeline.1 { + stream_name 'NoCodec-1' + } + + Object.Widget.copier."1" { + dai_index 1 + dai_type "SSP" + type dai_out + copier_type "SSP" + stream_name "NoCodec-1" + 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."0" { + name "Port0" + id 0 + direction "duplex" + Object.Base.fe_dai."Port0" {} + + Object.PCM.pcm_caps."playback" { + name "SSP0 Playback" + formats 'S16_LE,S24_LE,S32_LE' + } + + Object.PCM.pcm_caps."capture" { + name "SSP0 Capture" + formats 'S16_LE,S24_LE,S32_LE' + } + } + pcm."1" { + name "Port1" + id 1 + direction "duplex" + Object.Base.fe_dai."Port1" {} + + Object.PCM.pcm_caps."playback" { + name "SSP1 Playback" + formats 'S16_LE,S24_LE,S32_LE' + } + + Object.PCM.pcm_caps."capture" { + name "SSP1 Capture" + formats 'S16_LE,S24_LE,S32_LE' + } + } +} + +Object.Base { + route."1" { + source "copier.host.1.1" + sink "copier.SSP.2.1" + } + + route."2" { + source "copier.host.3.1" + sink "copier.SSP.4.1" + } + + route."3" { + source "copier.host.5.1" + sink "copier.SSP.6.1" + } + + route."4" { + source "copier.SSP.8.1" + sink "copier.host.7.1" + } + + route."5" { + source "copier.SSP.10.1" + sink "copier.host.9.1" + } + + route."6" { + source "copier.SSP.12.1" + sink "copier.host.11.1" + } +} diff --git a/tools/topology/topology2/platform/intel/bt-default.conf b/tools/topology/topology2/platform/intel/bt-default.conf new file mode 100644 index 000000000000..49aff11fa953 --- /dev/null +++ b/tools/topology/topology2/platform/intel/bt-default.conf @@ -0,0 +1,25 @@ +# Default BT variable definitions +Define { + BT_INDEX 2 + FORMAT s16le + BT_MCLK 38400000 + BT_NAME "SSP2-BT" + + BT_PB_HOST_PIPELINE_ID 5 + BT_PB_DAI_PIPELINE_ID 6 + BT_PB_HOST_PIPELINE_SINK "copier.host.5.1" + BT_PB_DAI_PIPELINE_SRC "copier.SSP.6.1" + BT_PB_PIPELINE_STREAM_NAME "copier.SSP.6.1" + BT_PB_PCM_CAPS "BT Playback" + + BT_CP_HOST_PIPELINE_ID 11 + BT_CP_DAI_PIPELINE_ID 12 + BT_CP_HOST_PIPELINE_SINK "copier.host.11.1" + BT_CP_DAI_PIPELINE_SRC "copier.SSP.12.1" + BT_CP_PIPELINE_STREAM_NAME "copier.SSP.11.1" + BT_CP_PCM_CAPS "BT Capture" + + BT_PCM_ID 2 + + BT_LOOPBACK_MODE false +} diff --git a/tools/topology/topology2/platform/intel/bt-generic.conf b/tools/topology/topology2/platform/intel/bt-generic.conf new file mode 100644 index 000000000000..c4da50ab971b --- /dev/null +++ b/tools/topology/topology2/platform/intel/bt-generic.conf @@ -0,0 +1,233 @@ +IncludeByKey.BT_LOOPBACK_MODE { + "true" "platform/intel/bt-ssp-config-lbm.conf" +} + +IncludeByKey.BT_LOOPBACK_MODE { + "false" "platform/intel/bt-ssp-config.conf" +} + +Object.Pipeline { + # playback pipelines + passthrough-be.3 { + index $BT_PB_DAI_PIPELINE_ID + direction playback + Object.Widget.pipeline.1 { + stream_name $BT_PB_PIPELINE_STREAM_NAME + } + + Object.Widget.copier.1 { + dai_index $BT_INDEX + dai_type "SSP" + copier_type "SSP" + stream_name $BT_NAME + node_type $I2S_LINK_OUTPUT_CLASS + num_audio_formats 3 + Object.Base.audio_format.0 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 2 + out_channels 2 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.2 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 8000 + out_rate 8000 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.3 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 16000 + out_rate 16000 + dma_buffer_size "$[$obs * 2]" + } + } + } + + passthrough-playback.3 { + index $BT_PB_HOST_PIPELINE_ID + Object.Widget.pipeline.1 { + stream_name $BT_PB_PIPELINE_STREAM_NAME + } + Object.Widget.copier.1 { + stream_name 'SSP2 Playback' + num_audio_formats 3 + Object.Base.audio_format.0 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 2 + out_channels 2 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.2 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 8000 + out_rate 8000 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.3 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 16000 + out_rate 16000 + dma_buffer_size "$[$obs * 2]" + } + } + } + + # capture pipelines + passthrough-capture.3 { + index $BT_CP_HOST_PIPELINE_ID + Object.Widget.pipeline.1 { + stream_name $BT_CP_PIPELINE_STREAM_NAME + } + Object.Widget.copier.1 { + stream_name 'SSP2 Capture' + #stream_name $BT_PCM_CAPS + num_audio_formats 3 + Object.Base.audio_format.0 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 2 + out_channels 2 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.2 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 8000 + out_rate 8000 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.3 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 16000 + out_rate 16000 + dma_buffer_size "$[$obs * 2]" + } + } + } + + passthrough-be.6 { + index $BT_CP_DAI_PIPELINE_ID + direction "capture" + Object.Widget.pipeline.1 { + stream_name $BT_CP_PIPELINE_STREAM_NAME + } + + Object.Widget.copier."1" { + dai_index $BT_INDEX + dai_type "SSP" + type dai_out + copier_type "SSP" + stream_name $BT_NAME + node_type $I2S_LINK_INPUT_CLASS + num_audio_formats 4 + Object.Base.audio_format.0 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 2 + out_channels 2 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.1 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 8000 + out_rate 8000 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.2 { + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 16 + out_valid_bit_depth 16 + in_channels 1 + out_channels 1 + in_rate 16000 + out_rate 16000 + dma_buffer_size "$[$obs * 2]" + } + } + } +} + +Object.Base { + route."5" { + source $BT_PB_DAI_PIPELINE_SRC + sink $BT_PB_HOST_PIPELINE_SINK + } + + route."6" { + source $BT_CP_DAI_PIPELINE_SRC + sink $BT_CP_HOST_PIPELINE_SINK + } +} + +Object.PCM { + pcm."BT" { + name "Port2" + id $BT_PCM_ID + direction "duplex" + + Object.Base.fe_dai."Port2" {} + + Object.PCM.pcm_caps."playback" { + name $BT_PB_PCM_CAPS + formats 'S16_LE' + rate_min 8000 + rate_max 48000 + channels_min 1 + channels_max 2 + } + + Object.PCM.pcm_caps."capture" { + name $BT_CP_PCM_CAPS + formats 'S16_LE' + rate_min 8000 + rate_max 48000 + channels_min 1 + channels_max 2 + } + } +} diff --git a/tools/topology/topology2/platform/intel/bt-ssp-config-lbm.conf b/tools/topology/topology2/platform/intel/bt-ssp-config-lbm.conf new file mode 100644 index 000000000000..9d959b6b43f0 --- /dev/null +++ b/tools/topology/topology2/platform/intel/bt-ssp-config-lbm.conf @@ -0,0 +1,56 @@ +Object.Dai { + SSP."BT" { + id $BT_INDEX + dai_index $BT_INDEX + direction "duplex" + name $BT_NAME + default_hw_conf_id 0 + sample_bits 16 + quirks "lbm_mode" + io_clk $BT_MCLK + Object.Base.hw_config.1 { + id 0 + name "BT-SCO-WB" + mclk_freq $BT_MCLK + bclk_freq 256000 + bclk_invert true + tdm_slot_width 16 + format "DSP_A" + bclk "codec_consumer" + fsync "codec_consumer" + fsync_freq 16000 + tdm_slots 1 + tx_slots 1 + rx_slots 1 + } + Object.Base.hw_config.2 { + id 1 + name "BT-SCO-NB" + mclk_freq $BT_MCLK + bclk_freq 128000 + bclk_invert true + tdm_slot_width 16 + format "DSP_A" + bclk "codec_consumer" + fsync "codec_consumer" + fsync_freq 8000 + tdm_slots 1 + tx_slots 1 + rx_slots 1 + } + Object.Base.hw_config.3 { + id 2 + name "BT-A2DP" + mclk_freq $BT_MCLK + bclk_freq 3072000 + tdm_slot_width 16 + format "DSP_A" + bclk "codec_consumer" + fsync "codec_consumer" + fsync_freq 48000 + tdm_slots 2 + tx_slots 3 + rx_slots 3 + } + } +} diff --git a/tools/topology/topology2/platform/intel/bt-ssp-config.conf b/tools/topology/topology2/platform/intel/bt-ssp-config.conf new file mode 100644 index 000000000000..05e04ae96930 --- /dev/null +++ b/tools/topology/topology2/platform/intel/bt-ssp-config.conf @@ -0,0 +1,52 @@ +Object.Dai { + SSP."BT" { + id $BT_INDEX + dai_index $BT_INDEX + direction "duplex" + name $BT_NAME + default_hw_conf_id 0 + sample_bits 16 + io_clk $BT_MCLK + Object.Base.hw_config."SSP2_0" { + id 0 + mclk_freq $BT_MCLK + bclk_freq 256000 + bclk_invert true + tdm_slot_width 16 + format "DSP_A" + bclk "codec_provider" + fsync "codec_provider" + fsync_freq 16000 + tdm_slots 1 + tx_slots 1 + rx_slots 1 + } + Object.Base.hw_config."SSP2_1" { + id 1 + mclk_freq $BT_MCLK + bclk_freq 128000 + bclk_invert true + tdm_slot_width 16 + format "DSP_A" + bclk "codec_provider" + fsync "codec_provider" + fsync_freq 8000 + tdm_slots 1 + tx_slots 1 + rx_slots 1 + } + Object.Base.hw_config."SSP2_2" { + id 2 + mclk_freq $BT_MCLK + bclk_freq 1536000 + tdm_slot_width 16 + format "DSP_A" + bclk "codec_consumer" + fsync "codec_consumer" + fsync_freq 48000 + tdm_slots 2 + tx_slots 3 + rx_slots 0 + } + } +}