[Sound-open-firmware] [PATCH v3 4/8] topology: create m4 wrapper for mixer control section

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Mon Mar 5 21:40:20 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                      | 45 +++++++++++++++++++
 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, 120 insertions(+), 249 deletions(-)

diff --git a/topology/m4/local.m4 b/topology/m4/local.m4
index b2d4f28..535bb66 100644
--- a/topology/m4/local.m4
+++ b/topology/m4/local.m4
@@ -562,4 +562,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 6bb1a3d..057312d 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,
+	LIST(`	', 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 64761a9..f434ce1 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,
+	LIST(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,
+	LIST(`	', 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 c1cff33..e8c8158 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,
+	LIST(`	', 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 50a1050..507aeac 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,
+	LIST(`	', 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,
+	LIST(`	', 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 56494b4..56aed26 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,
+	LIST(`	', 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 24ae45c..22de572 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,
+	LIST(`	', 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,
+	LIST(`	', 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