From 36692b36c976cbb99d006bf2a0c4fe58cb487e17 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 19 Mar 2020 19:26:06 +0200 Subject: [PATCH 1/8] topology: add bit, byte and abi_version macros to utils Bit and byte manipulation macros are needed for building binary blobs, so add them. Add also macro to generate sof_abi_version. Signed-off-by: Jaska Uimonen --- tools/topology/m4/utils.m4 | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/topology/m4/utils.m4 b/tools/topology/m4/utils.m4 index d34701335745..6538f6a1afd8 100644 --- a/tools/topology/m4/utils.m4 +++ b/tools/topology/m4/utils.m4 @@ -114,5 +114,46 @@ define(`VIRTUAL_WIDGET', ` no_pm "true"' `}', `fatal_error(`Invalid parameters ($#) to VIRTUAL_WIDGET')')') +dnl create SOF_ABI_VERSION if not defined +dnl you can give the abi.h with -DSOF_ABI_FILE=(full path to abi.h) +dnl otherwise this will be empty macro +ifdef(`SOF_ABI_VERSION', `', +ifdef(`SOF_ABI_FILE', +`define(`SOF_MAJOR',' +`esyscmd(`grep "#define SOF_ABI_MAJOR "' SOF_ABI_FILE `| grep -E ".[[:digit:]]$" -o'))dnl' +`define(`SOF_MINOR',' +`esyscmd(`grep "#define SOF_ABI_MINOR "' SOF_ABI_FILE `| grep -E ".[[:digit:]]$" -o'))dnl' +`define(`SOF_PATCH',' +`esyscmd(`grep "#define SOF_ABI_PATCH "' SOF_ABI_FILE `| grep -E ".[[:digit:]]$" -o'))dnl' +`define(`SOF_MAJOR_SHIFT',' +`esyscmd(`grep "#define SOF_ABI_MAJOR_SHIFT"' SOF_ABI_FILE `| grep -E ".[[:digit:]]$" -o'))dnl' +`define(`SOF_MINOR_SHIFT',' +`esyscmd(`grep "#define SOF_ABI_MINOR_SHIFT"' SOF_ABI_FILE `| grep -E ".[[:digit:]]$" -o'))dnl' +`define(`SOF_ABI_VERSION',' +`eval(eval((SOF_MAJOR) << (SOF_MAJOR_SHIFT))dnl' +`| eval((SOF_MINOR) << (SOF_MINOR_SHIFT))))dnl' + `')) + +dnl print number's 4 bytes from right to left as hex values +define(`PRINT_BYTES_4', +`format(`0x%02x', eval(($1)&0xFF)),'dnl +`format(`0x%02x', eval(($1>>8)&0xFF)),'dnl +`format(`0x%02x', eval(($1>>16)&0xFF)),'dnl +`format(`0x%02x', eval(($1>>24)&0xFF))')dnl + +dnl print number's 2 bytes from right to left as hex values +define(`PRINT_BYTES_2', +`format(`0x%02x', eval(($1)&0xFF)),'dnl +`format(`0x%02x', eval(($1>>8)&0xFF))')dnl + +dnl print a number's right most byte as hex values +define(`PRINT_BYTE', +`format(`0x%02x', eval(($1)&0xFF))')dnl + +dnl make a byte from 8 binary values, right to left in increasing argument order +define(`BITS_TO_BYTE', +`eval(eval($1 << 0) | eval($2 << 1) | eval($3 << 2) | eval($4 << 3)dnl +| eval($5 << 4) | eval($6 << 5) | eval($7 << 6) | eval($8 << 7))')dnl + divert(0) dnl From 2d57fa85f2c0a2c71a397a304bf942aebda954f8 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 19 Mar 2020 20:50:08 +0200 Subject: [PATCH 2/8] topology: add binary blob macro for muxdemux Add macro for binary blob generation for muxdemux. With this macro the stream routing matrix will be easier to visualize and manipulate. Signed-off-by: Jaska Uimonen --- tools/topology/m4/muxdemux.m4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/topology/m4/muxdemux.m4 b/tools/topology/m4/muxdemux.m4 index b1f7a8bd9fb9..0bb24304de57 100644 --- a/tools/topology/m4/muxdemux.m4 +++ b/tools/topology/m4/muxdemux.m4 @@ -2,6 +2,35 @@ divert(-1) dnl Define macro for demux widget +dnl Hard coded values for mux/demux config blob +define(mux_sof_magic, 0x00464F53) +define(mux_stream_struct_size, 16) +define(mux_config_struct_size, 8) + +dnl Fill bytes of struct mux_stream_config (mux.h) +dnl reserved fields in the struct are set to 0 +define(`ROUTE_MATRIX', + `PRINT_BYTES_4($1),PRINT_BYTE(0),PRINT_BYTE($2),PRINT_BYTE($3),'dnl +`PRINT_BYTE($4),' + `PRINT_BYTE($5),PRINT_BYTE($6),PRINT_BYTE($7),PRINT_BYTE($8),'dnl +`PRINT_BYTE($9),PRINT_BYTE(0),PRINT_BYTE(0),PRINT_BYTE(0)') + +dnl Fill bytes of mux/demux config binary blob +dnl blob is made of sof_abi_hdr (header.h), sof_mux_config (mux.h) and +dnl list of ROUTE_MATRIXes. +dnl reserved fields in the struct are set to 0 +define(`MUXDEMUX_CONFIG', +`SectionData.STR($1) {' +`bytes "'`PRINT_BYTES_4(mux_sof_magic),PRINT_BYTES_4(0),' + `PRINT_BYTES_4(eval(mux_config_struct_size + (mux_stream_struct_size * $2))),'dnl +`PRINT_BYTES_4(SOF_ABI_VERSION),' + `PRINT_BYTES_4(0),PRINT_BYTES_4(0),' + `PRINT_BYTES_4(0),PRINT_BYTES_4(0),' + `PRINT_BYTES_2(0),PRINT_BYTES_2(0),PRINT_BYTES_2($2),PRINT_BYTES_2(0),' + `$3'`"' + `}' +) + dnl Mux name) define(`N_MUXDEMUX', `MUXDEMUX'PIPELINE_ID`.'$1) From aa0bf5d24a7f927472e5c7e2e770019ca4b68992 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 24 Mar 2020 16:51:00 +0200 Subject: [PATCH 3/8] topology: add mux config to sof-apl-demux-pcm512x.m4 Add mux config to top level topology. Signed-off-by: Jaska Uimonen --- tools/topology/sof-apl-demux-pcm512x.m4 | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/topology/sof-apl-demux-pcm512x.m4 b/tools/topology/sof-apl-demux-pcm512x.m4 index 59f2d86cd630..02db458102de 100644 --- a/tools/topology/sof-apl-demux-pcm512x.m4 +++ b/tools/topology/sof-apl-demux-pcm512x.m4 @@ -7,6 +7,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') include(`ssp.m4') +include(`muxdemux.m4') # Include TLV library include(`common/tlv.m4') @@ -19,6 +20,36 @@ include(`platform/intel/bxt.m4') DEBUG_START +dnl Configure demux +dnl name, pipeline_id, routing_matrix_rows +dnl Diagonal 1's in routing matrix mean that every input channel is +dnl copied to corresponding output channels in all output streams. +dnl I.e. row index is the input channel, 1 means it is copied to +dnl corresponding output channel (column index), 0 means it is discarded. +dnl There's a separate matrix for all outputs. +define(matrix1, `ROUTE_MATRIX(1, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +define(matrix2, `ROUTE_MATRIX(5, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +dnl name, num_streams, route_matrix list +MUXDEMUX_CONFIG(demux_priv, 2, LIST(` ', `matrix1,', `matrix2')) + # # Define the pipelines # @@ -29,6 +60,8 @@ DEBUG_START # PCM4 <---- demux # + + dnl PIPELINE_PCM_ADD(pipeline, dnl pipe id, pcm, max channels, format, dnl period, priority, core, From 064d985eb07e674c2e4e4725bf534b17d6588ea7 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 24 Mar 2020 16:51:25 +0200 Subject: [PATCH 4/8] topology: add mux config to sof-cml-demux-rt5682.m4 Add mux config to top level topology. Signed-off-by: Jaska Uimonen --- tools/topology/sof-cml-demux-rt5682.m4 | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/topology/sof-cml-demux-rt5682.m4 b/tools/topology/sof-cml-demux-rt5682.m4 index 0205c08ba3dc..091da96935d9 100644 --- a/tools/topology/sof-cml-demux-rt5682.m4 +++ b/tools/topology/sof-cml-demux-rt5682.m4 @@ -7,6 +7,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') include(`ssp.m4') +include(`muxdemux.m4') # Include TLV library include(`common/tlv.m4') @@ -19,6 +20,35 @@ include(`platform/intel/'PLATFORM`.m4') DEBUG_START +dnl Configure demux +dnl name, pipeline_id, routing_matrix_rows +dnl Diagonal 1's in routing matrix mean that every input channel is +dnl copied to corresponding output channels in all output streams. +dnl I.e. row index is the input channel, 1 means it is copied to +dnl corresponding output channel (column index), 0 means it is discarded. +dnl There's a separate matrix for all outputs. +define(matrix1, `ROUTE_MATRIX(1, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +define(matrix2, `ROUTE_MATRIX(5, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +dnl name, num_streams, route_matrix list +MUXDEMUX_CONFIG(demux_priv, 2, LIST(` ', `matrix1,', `matrix2')) # # Define the pipelines From b28d96f476c5d920afcb1f77b3deee39e5221987 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 24 Mar 2020 16:51:41 +0200 Subject: [PATCH 5/8] topology: add mux config to sof-icl-rt711-rt1308-rt715-hdmi.m4 Add mux config to top level topology. Signed-off-by: Jaska Uimonen --- .../sof-icl-rt711-rt1308-rt715-hdmi.m4 | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/topology/sof-icl-rt711-rt1308-rt715-hdmi.m4 b/tools/topology/sof-icl-rt711-rt1308-rt715-hdmi.m4 index 39eadfa2d5b0..806946711113 100644 --- a/tools/topology/sof-icl-rt711-rt1308-rt715-hdmi.m4 +++ b/tools/topology/sof-icl-rt711-rt1308-rt715-hdmi.m4 @@ -7,6 +7,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') include(`alh.m4') +include(`muxdemux.m4') # Include TLV library include(`common/tlv.m4') @@ -19,6 +20,39 @@ include(`platform/intel/'PLATFORM`.m4') DEBUG_START +dnl Configure demux +dnl name, pipeline_id, routing_matrix_rows +dnl Diagonal 1's in routing matrix mean that every input channel is +dnl copied to corresponding output channels in all output streams. +dnl I.e. row index is the input channel, 1 means it is copied to +dnl corresponding output channel (column index), 0 means it is discarded. +dnl There's a separate matrix for all outputs. +ifdef(`MONO', `', +` +define(matrix1, `ROUTE_MATRIX(3, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +define(matrix2, `ROUTE_MATRIX(4, + `BITS_TO_BYTE(1, 0, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 1, 0 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 1 ,0 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,1 ,0 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,1 ,0 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,1 ,0 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,1 ,0)', + `BITS_TO_BYTE(0, 0, 0 ,0 ,0 ,0 ,0 ,1)')') + +dnl name, num_streams, route_matrix list +MUXDEMUX_CONFIG(demux_priv, 2, LIST(` ', `matrix1,', `matrix2')) +') + # # Define the pipelines # From 31058e296110dbd77ce371fbc78b502740273496 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 19 Mar 2020 20:50:50 +0200 Subject: [PATCH 6/8] topology: remove default demux config from pipe-volume-demux-playback Remove default demux parameters and start using blob defined in top level topology. Signed-off-by: Jaska Uimonen --- tools/topology/sof/pipe-volume-demux-playback.m4 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/topology/sof/pipe-volume-demux-playback.m4 b/tools/topology/sof/pipe-volume-demux-playback.m4 index 4b30c77797e7..7e9dc201ca90 100644 --- a/tools/topology/sof/pipe-volume-demux-playback.m4 +++ b/tools/topology/sof/pipe-volume-demux-playback.m4 @@ -22,9 +22,6 @@ include(`muxdemux.m4') include(`mixercontrol.m4') include(`bytecontrol.m4') -# Use default parameters -include(`demux_coef_default.m4') - # demux Bytes control with max value of 255 C_CONTROLBYTES(DEMUX, PIPELINE_ID, CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), @@ -32,7 +29,7 @@ C_CONTROLBYTES(DEMUX, PIPELINE_ID, , , , CONTROLBYTES_MAX(, 304), , - DEMUX_priv) + demux_priv) # Volume Mixer control with max value of 32 C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, From a26efebea73530af31f14d558153c1c7a783e1a2 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 24 Mar 2020 20:07:08 +0200 Subject: [PATCH 7/8] topology: remove unused demux default coeffs Demux default coeffs has been replaced by top level demux configuration, so remove it. Signed-off-by: Jaska Uimonen --- tools/topology/m4/demux_coef_default.m4 | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 tools/topology/m4/demux_coef_default.m4 diff --git a/tools/topology/m4/demux_coef_default.m4 b/tools/topology/m4/demux_coef_default.m4 deleted file mode 100644 index 503da3039f1b..000000000000 --- a/tools/topology/m4/demux_coef_default.m4 +++ /dev/null @@ -1,11 +0,0 @@ -CONTROLBYTES_PRIV(DEMUX_priv, -` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,' -` 0x28,0x00,0x00,0x00,0x00,0x60,0x00,0x03,' -` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' -` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' -` 0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,' -` 0x01,0x00,0x00,0x00,0x02,0x01,0x02,0x04,' -` 0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,' -` 0x05,0x00,0x00,0x00,0x02,0x01,0x02,0x04,' -` 0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00"' -) From ede497d3f30905457045bd938416b76943dfcd6f Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 24 Mar 2020 20:07:47 +0200 Subject: [PATCH 8/8] topology: remove unused demux pipeline pipe-demux-playback.m4 is not used by any topology, so remove it. Signed-off-by: Jaska Uimonen --- tools/topology/sof/pipe-demux-playback.m4 | 80 ----------------------- 1 file changed, 80 deletions(-) delete mode 100644 tools/topology/sof/pipe-demux-playback.m4 diff --git a/tools/topology/sof/pipe-demux-playback.m4 b/tools/topology/sof/pipe-demux-playback.m4 deleted file mode 100644 index 9c7795b56f52..000000000000 --- a/tools/topology/sof/pipe-demux-playback.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# Demux Pipeline -# -# Low Latency Playback with demux. -# -# Pipeline Endpoints for connection are :- -# -# Playback Demux -# B1 (DAI buffer) -# -# -# host PCM_P -- B0 --> Demux(M) -- B1--> sink DAI0 -# | -# pipeline n+1 --> DAI -# - -# Include topology builder -include(`utils.m4') -include(`buffer.m4') -include(`pcm.m4') -include(`pga.m4') -include(`muxdemux.m4') -include(`mixercontrol.m4') -include(`bytecontrol.m4') - -# Use default parameters -include(`demux_coef_default.m4') - -# demux Bytes control with max value of 255 -C_CONTROLBYTES(DEMUX, PIPELINE_ID, - CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), - CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), - , , , - CONTROLBYTES_MAX(, 304), - , - DEMUX_priv) -# -# Components and Buffers -# - -# Host "Low latency Playback" PCM -# with 2 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Low Latency Playback, 2, 0) - -# Mux 0 has 2 sink and source periods. -W_MUXDEMUX(0, 1, PIPELINE_FORMAT, 2, 2, LIST(` ', "DEMUX")) - -# Low Latency Buffers -W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, COMP_PERIOD_FRAMES(PCM_MAX_RATE, SCHEDULE_PERIOD)), - PLATFORM_HOST_MEM_CAP) -W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, COMP_PERIOD_FRAMES(PCM_MAX_RATE, SCHEDULE_PERIOD)), - PLATFORM_COMP_MEM_CAP) - -# -# Pipeline Graph -# -# host PCM_P --B0--> volume(0P) --B1--> Mux(M) --B2--> volume(LL) ---B3--> sink DAI0 - -P_GRAPH(pipe-ll-playback-PIPELINE_ID, PIPELINE_ID, - LIST(` ', - `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', - `dapm(N_MUXDEMUX(0), N_BUFFER(0))', - `dapm(N_BUFFER(1), N_MUXDEMUX(0))')) - -# -# Pipeline Source and Sinks -# -indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) -indir(`define', concat(`PIPELINE_DEMUX_', PIPELINE_ID), N_MUXDEMUX(0)) -indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Playback PCM_ID) - -# -# PCM Configuration -# - - -# PCM capabilities supported by FW -PCM_CAPABILITIES(Low Latency Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) -