[Sound-open-firmware] [PATCH v3 1/8] topology: make list loop more generic with formatting argument

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Mon Mar 5 21:40:17 CET 2018


This patch adds changes to make list loop more generic with format argument

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 topology/m4/local.m4                      | 13 ++++++++-----
 topology/sof/pipe-low-latency-capture.m4  |  2 +-
 topology/sof/pipe-low-latency-playback.m4 |  4 ++--
 topology/sof/pipe-pcm-media.m4            |  2 +-
 topology/sof/pipe-tone.m4                 |  3 ++-
 topology/sof/pipe-volume-capture.m4       |  2 +-
 topology/sof/pipe-volume-playback.m4      |  2 +-
 7 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/topology/m4/local.m4 b/topology/m4/local.m4
index 31221f3..1ebe19d 100644
--- a/topology/m4/local.m4
+++ b/topology/m4/local.m4
@@ -10,16 +10,16 @@ define(`argn', `ifelse(`$1', 1, ``$2'',
 
 dnl Defines a list of items from a variable number of params.
 dnl Use as last argument in a macro.
+dnl The first argument specifies the number of tabs to be added for formatting
 define(`LIST_LOOP', `argn(j,$@)
-		ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) $0($@)')')
+$1ifelse(i,`2', `', `define(`i', decr(i))define(`j', incr(j))$0($@)')')
+
+define(`LIST', `pushdef(`i', $#)pushdef(`j', `2')LIST_LOOP($@)popdef(i)popdef(j)')
 
 dnl Sums a list of variable arguments. Use as last argument in macro.
 define(`SUM_LOOP', `eval(argn(j,$@)
 		ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) + $0($@)'))')
 
-dnl Support a varaible list of kcontrols.
-define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') LIST_LOOP($@)')
-
 dnl Memory capabilities
 define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)')
 
@@ -165,7 +165,7 @@ define(`N_PGA', `PGA'PIPELINE_ID`.'$1)
 
 dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc)
 define(`W_PGA',
-`pushdef(`args',`eval($#-6)')SectionVendorTuples."'N_PGA($1)`_tuples_w" {'
+`SectionVendorTuples."'N_PGA($1)`_tuples_w" {'
 `	tokens "sof_comp_tokens"'
 `	tuples."word" {'
 `		SOF_TKN_COMP_PERIOD_SINK_COUNT'		STR($3)
@@ -270,6 +270,9 @@ define(`W_TONE',
 `		"'N_TONE($1)`_data_w"'
 `		"'N_TONE($1)`_data_str"'
 `	]'
+`	mixer ['
+		$6
+`	]'
 `}')
 
 dnl DAI name)
diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4
index 41fc622..6bb1a3d 100644
--- a/topology/sof/pipe-low-latency-capture.m4
+++ b/topology/sof/pipe-low-latency-capture.m4
@@ -48,7 +48,7 @@ SectionControlMixer.STR(PCM PCM_ID Capture Volume) {
 W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0)
 
 # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong
-W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("PCM PCM_ID Capture Volume"))
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(`		', "PCM PCM_ID Capture Volume"))
 
 # Capture Buffers
 W_BUFFER(0, COMP_BUFFER_SIZE(2,
diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4
index 37f8be2..64761a9 100644
--- a/topology/sof/pipe-low-latency-playback.m4
+++ b/topology/sof/pipe-low-latency-playback.m4
@@ -91,10 +91,10 @@ SectionControlMixer.STR(Master Playback Volume) {
 W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2)
 
 # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong
-W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, KCONTROLS("PCM PCM_ID Playback Volume"))
+W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(`		', "PCM PCM_ID Playback Volume"))
 
 # "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong
-W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, KCONTROLS("Master Playback Volume"))
+W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, LIST(`		', "Master Playback Volume"))
 
 # Mixer 0 has 1 sink and source periods.
 W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1)
diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4
index 1766aca..c1cff33 100644
--- a/topology/sof/pipe-pcm-media.m4
+++ b/topology/sof/pipe-pcm-media.m4
@@ -68,7 +68,7 @@ SectionData."media_src_conf" {
 W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2)
 
 # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong
-W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("PCM PCM_ID Playback Volume"))
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(`		', "PCM PCM_ID Playback Volume"))
 
 # "SRC 0" has 2 sink and source periods.
 W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2)
diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4
index a8064ab..f53f77f 100644
--- a/topology/sof/pipe-tone.m4
+++ b/topology/sof/pipe-tone.m4
@@ -32,6 +32,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) {
 	# control uses bespoke driver get/put/info ID 0
 	ops."ctl" {
 		info "volsw"
+		# 256 binds the mixer control to volume get/put handlers
 		get "256"
 		put "256"
 	}
@@ -50,7 +51,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) {
 W_TONE(0, PIPELINE_FORMAT, 2, 0, 0)
 
 # "Tone Volume" has 2 sink period and 2 source periods
-W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("Tone Volume PIPELINE_ID"))
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(`		', "Tone Volume PIPELINE_ID"))
 
 # Low Latency Buffers
 W_BUFFER(0,COMP_BUFFER_SIZE(2,
diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4
index 2fd6b98..56494b4 100644
--- a/topology/sof/pipe-volume-capture.m4
+++ b/topology/sof/pipe-volume-capture.m4
@@ -47,7 +47,7 @@ SectionControlMixer.STR(Master Capture Volume) {
 W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2)
 
 # "Volume" has 2 source and 2 sink periods
-W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Capture Volume"))
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(`		', "Master Capture Volume"))
 
 # Capture Buffers
 W_BUFFER(0, COMP_BUFFER_SIZE(2,
diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4
index 9431177..24ae45c 100644
--- a/topology/sof/pipe-volume-playback.m4
+++ b/topology/sof/pipe-volume-playback.m4
@@ -73,7 +73,7 @@ SectionControlMixer.STR(Master Playback Volume Switch) {
 W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2)
 
 # "Volume" has 2 source and 2 sink periods
-W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Playback Volume Switch", "Master Playback Volume"))
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(`		', "Master Playback Volume Switch", "Master Playback Volume"))
 
 # Playback Buffers
 W_BUFFER(0, COMP_BUFFER_SIZE(2,
-- 
2.14.1



More information about the Sound-open-firmware mailing list