Allow topology pipelines to define their scheduling.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- topology/m4/build.m4 | 96 +++++++++++--- topology/m4/local.m4 | 359 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 392 insertions(+), 63 deletions(-)
diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 0c40e4e..66f6562 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -1,44 +1,100 @@ -#"PIPELINE_PCM_ADD(pipeline, id, pcm, pcm_buf, int_buf, frames, deadline) +divert(-1) + +dnl PIPELINE_PCM_ADD(pipeline, id, pcm, max channels, format, frames, deadline, priority, core) define(`PIPELINE_PCM_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' -`undefine(`BUF_PCM_SIZE')' -`undefine(`BUF_INT_SIZE')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' `undefine(`SCHEDULE_FRAMES')' `undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' +`undefine(`PIPELINE_DMAC')' +`undefine(`PIPELINE_DMAC_CHAN')' +`define(`PIPELINE_ID', $2)' `define(`PCM_ID', $3)' +`define(`PIPELINE_CHANNELS', $4)' +`define(`PIPELINE_FORMAT', $5)' +`define(`SCHEDULE_FRAMES', $6)' +`define(`SCHEDULE_DEADLINE', $7)' +`define(`SCHEDULE_PRIORITY', $8)' +`define(`SCHEDULE_CORE', $9)' +`define(`PIPELINE_DMAC', $10)' +`define(`PIPELINE_DMAC_CHAN', $11)' +`include($1)' +) + +dnl PIPELINE_PCM_DAI_ADD(pipeline, id, pcm, max channels, format, frames, +dnl deadline, priority, core, dai type, dai_index, stream_name, periods) +define(`PIPELINE_PCM_DAI_ADD', +`undefine(`PCM_ID')' +`undefine(`PIPELINE_ID')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' +`undefine(`PIPELINE_DMAC')' +`undefine(`PIPELINE_DMAC_CHAN')' +`undefine(`DAI_TYPE')' +`undefine(`DAI_INDEX')' +`undefine(`DAI_SNAME')' +`undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', $2)' -`define(`BUF_PCM_SIZE', STR($4))' -`define(`BUF_INT_SIZE', STR($5))' -`define(`SCHEDULE_FRAMES', STR($6))' -`define(`SCHEDULE_DEADLINE', STR($7))' +`define(`PCM_ID', $3)' +`define(`PIPELINE_CHANNELS', $4)' +`define(`PIPELINE_FORMAT', $5)' +`define(`SCHEDULE_FRAMES', $6)' +`define(`SCHEDULE_DEADLINE', $7)' +`define(`SCHEDULE_PRIORITY', $8)' +`define(`SCHEDULE_CORE', $9)' +`define(`PIPELINE_DMAC', $10)' +`define(`PIPELINE_DMAC_CHAN', $11)' +`define(`DAI_TYPE', STR($12))' +`define(`DAI_INDEX', STR($13))' +`define(`DAI_SNAME', $14)' +`define(`DAI_PERIODS', $15)' +`define(`DAI_NAME', $12$13)' `include($1)' )
-#PIPELINE_ADD(pipeline, id), int_buf, frames, deadline) +dnl PIPELINE_ADD(pipeline, id, max channels, format, frames, deadline, priority, core) define(`PIPELINE_ADD', `undefine(`PIPELINE_ID')' -`undefine(`BUF_INT_SIZE')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' `undefine(`SCHEDULE_FRAMES')' `undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' `define(`PIPELINE_ID', $2)' -`define(`BUF_INT_SIZE', STR($3))' -`define(`SCHEDULE_FRAMES', STR($4))' -`define(`SCHEDULE_DEADLINE', STR($5))' +`define(`PIPELINE_CHANNELS', $3)' +`define(`PIPELINE_FORMAT', $4)' +`define(`SCHEDULE_FRAMES', $5)' +`define(`SCHEDULE_DEADLINE', $6)' +`define(`SCHEDULE_PRIORITY', $7)' +`define(`SCHEDULE_CORE', $8)' `include($1)' )
-#DAI_ADD(pipeline, dai_name, stream_name, win, wout)) +dnl DAI_ADD(pipeline, dai type, dai_index, stream_name, buffer, periods) define(`DAI_ADD', `undefine(`PIPELINE_ID')' -`undefine(`DAI_NAME')' +`undefine(`DAI_TYPE')' +`undefine(`DAI_INDEX')' `undefine(`DAI_SNAME')' -`undefine(`IN_BUF')' -`undefine(`OUT_BUF')' +`undefine(`DAI_BUF')' +`undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', 0)' -`define(`DAI_NAME', $2)' -`define(`DAI_SNAME', $3)' -`define(`IN_BUF', $4)' -`define(`OUT_BUF', $5)' +`define(`DAI_TYPE', STR($2))' +`define(`DAI_INDEX', STR($3))' +`define(`DAI_SNAME', $4)' +`define(`DAI_BUF', $5)' +`define(`DAI_NAME', $2$3)' +`define(`DAI_PERIODS', $6)' `include($1)' ) + +divert(0)dnl diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 2408830..a888438 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -1,32 +1,57 @@ +divert(-1) + define(`concat',`$1$2')
define(`STR', `"'$1`"')
-#create direct DAPM/pipeline link between 2 widgets) +dnl create direct DAPM/pipeline link between 2 widgets) define(`dapm', `"$1, , $2"')
-#SRC name) +dnl SRC name) define(`N_SRC', `SRC'PIPELINE_ID`.'$1)
-#W_SRC(name, data)) -define(`W_SRC', `SectionWidget."'N_SRC($1)`" {' +dnl W_SRC(name, format, periods_sink, periods_source, data, preload) +define(`W_SRC', +`SectionVendorTuples."'N_SRC($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_SRC($1)`_data_w" {' +` tuples "'N_SRC($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_SRC($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_SRC($1)`_data_str" {' +` tuples "'N_SRC($1)`_tuples_str"' +`}' +`SectionWidget."'N_SRC($1)`" {' ` index "'PIPELINE_ID`"' ` type "src"' ` no_pm "true"' ` data [' +` "'N_SRC($1)`_data_w"' +` "'N_SRC($1)`_data_str"' ` "'$2`"' ` ]' `}')
-#Buffer name) +dnl Buffer name) define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1)
-#W_BUFFER(name, size)) +dnl W_BUFFER(name, size) define(`W_BUFFER', `SectionVendorTuples."'N_BUFFER($1)`_tuples" {' ` tokens "sof_buffer_tokens"' ` tuples."word" {' -` SOF_TKN_BUF_SIZE' $2 +` SOF_TKN_BUF_SIZE' STR($2) ` }' `}' `SectionData."'N_BUFFER($1)`_data" {' @@ -41,119 +66,367 @@ define(`W_BUFFER', ` ]' `}')
-#PCM name) +dnl PCM name) define(`N_PCM', `PCM'PCM_ID)
-#W_PCM_PLAYBACK(stream)) -define(`W_PCM_PLAYBACK', `SectionWidget."'N_PCM`" {' +dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl PCM platform configuration +define(`W_PCM_PLAYBACK', +`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCM($1)`_data_w_comp" {' +` tuples "'N_PCM($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCM($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCM($1)`_data" {' +` tuples "'N_PCM($1)`_tuples"' +`}' +`SectionWidget."'N_PCM`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' +` data [' +` "'N_PCM($1)`_data"' +` "'N_PCM($1)`_data_w_comp"' +` ]' `}')
-#W_PCM_CAPTURE(stream)) -define(`W_PCM_CAPTURE', `SectionWidget."'N_PCM`" {' +dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +define(`W_PCM_CAPTURE', +`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCM($1)`_data_w_comp" {' +` tuples "'N_PCM($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCM($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCM($1)`_data" {' +` tuples "'N_PCM($1)`_tuples"' +`}' +`SectionWidget."'N_PCM`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' +` data [' +` "'N_PCM($1)`_data"' +` "'N_PCM($1)`_data_w_comp"' +` ]' `}')
-#PGA name) +dnl PGA name) define(`N_PGA', `PGA'PIPELINE_ID`.'$1)
-#W_PGA(name)) -define(`W_PGA', `SectionWidget."'N_PGA($1)`" {' +dnl W_PGA(name, format, periods_sink, periods_source, preload) +define(`W_PGA', +`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_PGA($1)`_data_w" {' +` tuples "'N_PGA($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_PGA($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_PGA($1)`_data_str" {' +` tuples "'N_PGA($1)`_tuples_str"' +`}' +`SectionWidget."'N_PGA($1)`" {' ` index "'PIPELINE_ID`"' ` type "pga"' ` no_pm "true"' +` data [' +` "'N_PGA($1)`_data_w"' +` "'N_PGA($1)`_data_str"' +` ]' `}')
-#Mixer Name) +dnl Mixer Name) define(`N_MIXER', `MIXER'PIPELINE_ID`.'$1)
-#Pipe Buffer name in pipeline (pipeline, buffer) +dnl Pipe Buffer name in pipeline (pipeline, buffer) define(`NPIPELINE_MIXER', `MIXER'$1`.'$2)
-#W_MIXER(name)) -define(`W_MIXER', `SectionWidget."'N_MIXER($1)`" {' +dnl W_MIXER(name, format, periods_sink, periods_source, preload) +define(`W_MIXER', +`SectionVendorTuples."'N_MIXER($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_w" {' +` tuples "'N_MIXER($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_MIXER($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_str" {' +` tuples "'N_MIXER($1)`_tuples_str"' +`}' +`SectionWidget."'N_MIXER($1)`" {' ` index "'PIPELINE_ID`"' ` type "mixer"' ` no_pm "true"' +` data [' +` "'N_MIXER($1)`_data_w"' +` "'N_MIXER($1)`_data_str"' +` ]' `}')
-#Tone name) +dnl Tone name) define(`N_TONE', `TONE'PIPELINE_ID`.'$1)
-#W_TONE(name)) -define(`W_TONE', `SectionWidget."'N_TONE($1)`" {' +dnl W_TONE(name, format, periods_sink, periods_source, preload) +define(`W_TONE', +`SectionVendorTuples."'N_TONE($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_TONE($1)`_data_w" {' +` tuples "'N_TONE($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_TONE($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_TONE($1)`_data_str" {' +` tuples "'N_TONE($1)`_tuples_str"' +`}' +`SectionWidget."'N_TONE($1)`" {' ` index "'PIPELINE_ID`"' ` type "siggen"' ` no_pm "true"' +` data [' +` "'N_TONE($1)`_data_w"' +` "'N_TONE($1)`_data_str"' +` ]' `}')
-#DAI name) +dnl DAI name) define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN')
-#W_DAI_OUT(stream, data)) -define(`W_DAI_OUT', `SectionWidget."'N_DAI_OUT`" {' +dnl W_DAI_OUT(stream, type, index, data, periods_sink, periods_source, preload) +define(`W_DAI_OUT', +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w_comp" {' +` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $3 +` }' +`}' +`SectionData."'N_DAI_OUT($1)`_data_w" {' +` tuples "'N_DAI_OUT($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $2 +` }' +`}' +`SectionData."'N_DAI_OUT($1)`_data_str" {' +` tuples "'N_DAI_OUT($1)`_tuples_str"' +`}' +`SectionWidget."'N_DAI_OUT`" {' ` index "'PIPELINE_ID`"' -` type "dai_out"' +` type "dai_in"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'$2`"' +` "'N_DAI_OUT($1)`_data_w"' +` "'N_DAI_IN($1)`_data_w_comp"' +` "'N_DAI_OUT($1)`_data_str"' +` "'$4`"' ` ]' `}')
-#W_DAI_IN(stream, data)) -define(`W_DAI_IN', `SectionWidget."'N_DAI_IN`" {' +dnl W_DAI_IN(stream, type, index, data, periods_sink, periods_source, preload) +define(`W_DAI_IN', +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w_comp" {' +` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $3 +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w" {' +` tuples "'N_DAI_IN($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $2 +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_str" {' +` tuples "'N_DAI_IN($1)`_tuples_str"' +`}' +`SectionWidget."'N_DAI_IN`" {' ` index "'PIPELINE_ID`"' -` type "dai_in"' +` type "dai_out"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'$2`"' +` "'N_DAI_IN($1)`_data_w"' +` "'N_DAI_IN($1)`_data_w_comp"' +` "'N_DAI_IN($1)`_data_str"' +` "'$4`"' ` ]' `}')
-#Pipe Buffer name in pipeline (pipeline, buffer) +dnl Pipe Buffer name in pipeline (pipeline, buffer) define(`NPIPELINE_BUFFER', `BUF'$1`.'$2)
-#Pipeline name) -define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID) +dnl Pipeline name) +define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID`.'$1)
-#W_PIPELINE(stream, deadline, platform)) +dnl W_PIPELINE(stream, deadline, priority, frames, core, platform) define(`W_PIPELINE', -`SectionVendorTuples."'N_PIPELINE`_tuples" {' +`SectionVendorTuples."'N_PIPELINE($1)`_tuples" {' ` tokens "sof_sched_tokens"' ` tuples."word" {' -` SOF_TKN_SCHED_DEADLINE' $2 +` SOF_TKN_SCHED_DEADLINE' STR($2) +` SOF_TKN_SCHED_PRIORITY' STR($3) +` SOF_TKN_SCHED_CORE' STR($5) +` SOF_TKN_SCHED_FRAMES' STR($4) ` }' `}' -`SectionData."'N_PIPELINE`_data" {' -` tuples "'N_PIPELINE`_tuples"' +`SectionData."'N_PIPELINE($1)`_data" {' +` tuples "'N_PIPELINE($1)`_tuples"' `}' -`SectionWidget."'N_PIPELINE`" {' +`SectionWidget."'N_PIPELINE($1)`" {' ` index "'PIPELINE_ID`"' ` type "scheduler"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'N_PIPELINE`_data"' -` "'$3`"' +` "'N_PIPELINE($1)`_data"' +` "'$6`"' ` ]' `}')
-#D_DAI(id, playback, capture, data)) +dnl D_DAI(id, playback, capture, data)) define(`D_DAI', `SectionDAI."'N_DAI`" {' ` index "'PIPELINE_ID`"' ` id "'$1`"' ` playback "'$2`"' ` capture "'$3`"' `}') + +dnl DAI_CLOCK(clock, freq, codec_master) +define(`DAI_CLOCK', + $1 STR($3) + $1_freq STR($2)) + + +dnl DAI_TDM(slots, width, tx_mask, rx_mask) +define(`DAI_TDM', +` tdm_slots 'STR($1) +` tdm_slot_width 'STR($2) +` tx_slots 'STR($3) +` rx_slots 'STR($4) +) + +dnl DAI_CONFIG(type, idx, name, sname, format, mclk, bclk, fsync, tdm) +define(`DAI_CONFIG', +`SectionHWConfig."'$1$2`" {' +`' +` id "'$2`"' +` format "'$5`"' +`' +` '$6 +` '$7 +` '$8 +` '$9 +`}' +`' +`SectionBE."'$3`" {' +` index "0"' +`' +` stream_name "'$4`"' +` hw_configs [' +` "'$1$2`"' +` ]' +`}') + +dnl COMP_SAMPLE_SIZE(FMT) +define(`COMP_SAMPLE_SIZE', +`ifelse( + $1, `s16le', `2', + $1, `s24_4le', `4', + $1, `s32le', `4', + `4')') + + +dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) +define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') + + +divert(0) dnl