[Sound-open-firmware] [PATCH 1/5] topology: create m4 wrapper for mixer control section

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Mon Mar 5 07:53:10 CET 2018


This patch adds m4 wrapper for mixercontrol section in
pipeline definition

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 topology/m4/local.m4                      | 55 +++++++++++++++++++++--
 topology/sof/pipe-low-latency-capture.m4  | 36 ++++-----------
 topology/sof/pipe-low-latency-playback.m4 | 73 +++++++------------------------
 topology/sof/pipe-pcm-media.m4            | 37 ++++------------
 topology/sof/pipe-tone.m4                 | 73 +++++++------------------------
 topology/sof/pipe-volume-capture.m4       | 35 ++++-----------
 topology/sof/pipe-volume-playback.m4      | 70 +++++++----------------------
 7 files changed, 127 insertions(+), 252 deletions(-)

diff --git a/topology/m4/local.m4 b/topology/m4/local.m4
index a340ec3..4521314 100644
--- a/topology/m4/local.m4
+++ b/topology/m4/local.m4
@@ -7,9 +7,13 @@ define(`STR', `"'$1`"')
 define(`argn', `ifelse(`$1', 1, ``$2'',
        `argn(decr(`$1'), shift(shift($@)))')')
 
-define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') KCONTROL_LOOP($@)')
-define(`KCONTROL_LOOP', `argn(j,$@)
-		ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) $0($@)')')
+define(`KCONTROLS', `pushdef(`i', $#)pushdef(`j', `1')KCONTROL_LOOP($@)popdef(i)popdef(j)')
+define(`KCONTROL_LOOP',`argn(j,$@)
+		ifelse(i,`1', `',`define(`i', decr(i))define(`j', incr(j))$0($@)')')
+
+define(`MIXERCONTROLS', `pushdef(`i', $#)pushdef(`j', `1')MIXERCONTROL_LOOP($@)popdef(i)popdef(j)')
+define(`MIXERCONTROL_LOOP',`argn(j,$@)
+	ifelse(i,`1', `',`define(`i', decr(i))define(`j', incr(j))$0($@)')')
 
 dnl create direct DAPM/pipeline link between 2 widgets)
 define(`dapm', `"$1, , $2"')
@@ -549,4 +553,49 @@ define(`PCM_DUPLEX_ADD',
 `	}'
 `}')
 
+dnl KCONTROL_CHANNEL(name, reg, shift)
+define(`KCONTROL_CHANNEL',
+`channel.STR($1) {'
+`		reg STR($2)'
+`		shift STR($3)'
+`	}')
+
+dnl CONTROLMIXER_MAX(comment, value)
+define(`CONTROLMIXER_MAX',
+`#$1'
+`	max STR($2)')
+
+dnl CONTROLMIXER_TLV(comment, value)
+define(`CONTROLMIXER_TLV',
+`#$1'
+`	tlv STR($2)')
+
+dnl CONTROLMIXER_OPS(info, comment, get, put)
+define(`CONTROLMIXER_OPS',
+`ops."ctl" {'
+`		info STR($1)'
+`		#$2'
+`		get STR($3)'
+`		put STR($4)'
+`	}')
+
+dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS)
+define(`C_CONTROLMIXER',
+`SectionControlMixer.STR($1) {'
+`'
+`	# control belongs to this index group'
+`	index STR($2)'
+`'
+`	#$7'
+`	$8'
+`	# control uses bespoke driver get/put/info ID'
+`	$3'
+`'
+`	$4'
+`	invert STR($5)'
+`	$6'
+`}')
+
 divert(0) dnl
+
+
diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4
index 2602ebd..a82dee1 100644
--- a/topology/sof/pipe-low-latency-capture.m4
+++ b/topology/sof/pipe-low-latency-capture.m4
@@ -10,34 +10,14 @@ include(`local.m4')
 #
 # Controls
 #
-
-SectionControlMixer.STR(PCM PCM_ID Capture Volume) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "0"
-		shift "0"
-	}
-	channel."FR" {
-		reg "0"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 40 steps from -90dB to +20dB for 3dB
-	max "40"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 40),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 0, 0), KCONTROL_CHANNEL(FR, 0, 1)))
 
 #
 # Components and Buffers
diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4
index ebb14ec..3b8d6aa 100644
--- a/topology/sof/pipe-low-latency-playback.m4
+++ b/topology/sof/pipe-low-latency-playback.m4
@@ -25,62 +25,23 @@ include(`local.m4')
 #
 # Controls
 #
-
-SectionControlMixer.STR(PCM PCM_ID Playback Volume) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "0"
-		shift "0"
-	}
-	channel."FR" {
-		reg "0"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
-
-SectionControlMixer.STR(Master Playback Volume) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 0, 0), KCONTROL_CHANNEL(FR, 0, 1)))
+
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
 
 #
 # Components and Buffers
diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4
index 526ae35..65dc62d 100644
--- a/topology/sof/pipe-pcm-media.m4
+++ b/topology/sof/pipe-pcm-media.m4
@@ -13,35 +13,14 @@ include(`local.m4')
 #
 # Controls
 #
-
-SectionControlMixer.STR(PCM PCM_ID Playback Volume) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
-
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
 
 #
 # SRC Configuration
diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4
index 8f92680..b735146 100644
--- a/topology/sof/pipe-tone.m4
+++ b/topology/sof/pipe-tone.m4
@@ -14,62 +14,23 @@ include(`local.m4')
 # Controls
 #
 
-SectionControlMixer.STR(Tone Volume PIPELINE_ID) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# 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"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
-
-SectionControlMixer.STR(Tone Switch PIPELINE_ID) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "2"
-		shift "0"
-	}
-	channel."FR" {
-		reg "2"
-		shift "1"
-	}
-
-	# 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"
-	}
-
-	# max 1 indicates switch type mixer control
-	max "1"
-	invert "false"
-}
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(Tone Volume PIPELINE_ID, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
+
+# Switch type Mixer Control with max value of 1
+C_CONTROLMIXER(Tone Switch PIPELINE_ID, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(max 1 indicates switch type control, 1),
+	false,
+	,
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 2, 0), KCONTROL_CHANNEL(FR, 2, 1)))
 
 #
 # Components and Buffers
diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4
index 58e5393..1cde24e 100644
--- a/topology/sof/pipe-volume-capture.m4
+++ b/topology/sof/pipe-volume-capture.m4
@@ -10,33 +10,14 @@ include(`local.m4')
 #
 # Controls
 #
-SectionControlMixer.STR(Master Capture Volume) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
 
 #
 # Components and Buffers
diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4
index 8aa02fb..a6b5a1d 100644
--- a/topology/sof/pipe-volume-playback.m4
+++ b/topology/sof/pipe-volume-playback.m4
@@ -10,60 +10,24 @@ include(`local.m4')
 #
 # Controls
 #
-SectionControlMixer.STR(Master Playback Volume) {
+# Volume Mixer control with max value of 32
+C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(, 32),
+	false,
+	CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
+
+# Volume Mixer Switch control with max value of 1
+C_CONTROLMIXER(Master Playback Volume Switch, PIPELINE_ID,
+	CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256),
+	CONTROLMIXER_MAX(max value 1 indicates switch type control, 1),
+	false,
+	,
+	Channel register and shift for Front Left/Right,
+	MIXERCONTROLS(KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1)))
 
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# TLV 32 steps from -90dB to +6dB for 3dB
-	max "32"
-	invert "false"
-	tlv "vtlv_m90s3"
-}
-
-SectionControlMixer.STR(Master Playback Volume Switch) {
-
-	# control belongs to this index group
-	index STR(PIPELINE_ID)
-
-	# Channel register and shift for Front Left/Right
-	channel."FL" {
-		reg "1"
-		shift "0"
-	}
-	channel."FR" {
-		reg "1"
-		shift "1"
-	}
-
-	# control uses bespoke driver get/put/info ID 0
-	ops."ctl" {
-		info "volsw"
-		get "256"
-		put "256"
-	}
-
-	# Volume mute on/off
-	max "1"
-	invert "false"
-}
 #
 # Components and Buffers
 #
-- 
2.14.1



More information about the Sound-open-firmware mailing list