[Sound-open-firmware] [PATCH] topology: Allow multiple kcontrols for volume widget
Ranjani Sridharan
ranjani.sridharan at linux.intel.com
Sat Feb 10 08:49:17 CET 2018
This patch adds support for multiple kcontrols for the volume
widget and adds a mute switch kcontrol to the volume playback
pipeline.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
Tested with:
Minnowboard Turbot rt5651
SOF master: fad6f2e8490e8a1b21668a783204006e180725b5
SOF-Tool master: 58079d09994c2b243990bd23e5aff481bfd0f6c7
https://github.com/plbossart/sound/tree/topic/sof-v4.14:
6fa721a8b7c6567eea0a2181bf9a3d2a12c31b00
---
---
topology/m4/local.m4 | 21 ++++++++++++++-------
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 | 2 +-
topology/sof/pipe-volume-capture.m4 | 2 +-
topology/sof/pipe-volume-playback.m4 | 28 +++++++++++++++++++++++++++-
7 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/topology/m4/local.m4 b/topology/m4/local.m4
index ad72a11..02d79a5 100644
--- a/topology/m4/local.m4
+++ b/topology/m4/local.m4
@@ -4,6 +4,13 @@ define(`concat',`$1$2')
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($@)')')
+
dnl create direct DAPM/pipeline link between 2 widgets)
define(`dapm', `"$1, , $2"')
@@ -143,14 +150,14 @@ define(`W_PCM_CAPTURE',
dnl PGA name)
define(`N_PGA', `PGA'PIPELINE_ID`.'$1)
-dnl W_PGA(name, kcontrol, format, periods_sink, periods_source, preload)
+dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc)
define(`W_PGA',
-`SectionVendorTuples."'N_PGA($1)`_tuples_w" {'
+`pushdef(`args',`eval($#-6)')SectionVendorTuples."'N_PGA($1)`_tuples_w" {'
` 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)
+` 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" {'
@@ -159,7 +166,7 @@ define(`W_PGA',
`SectionVendorTuples."'N_PGA($1)`_tuples_str" {'
` tokens "sof_comp_tokens"'
` tuples."string" {'
-` SOF_TKN_COMP_FORMAT' STR($3)
+` SOF_TKN_COMP_FORMAT' STR($2)
` }'
`}'
`SectionData."'N_PGA($1)`_data_str" {'
@@ -174,7 +181,7 @@ define(`W_PGA',
` "'N_PGA($1)`_data_str"'
` ]'
` mixer ['
-` "'$2`"'
+ $6
` ]'
`}')
diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4
index 0c989a7..2602ebd 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, PCM PCM_ID Capture Volume, PIPELINE_FORMAT, 2, 2, 0)
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("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 cd04ccf..ebb14ec 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, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 1, 2, 1)
+W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, KCONTROLS("PCM PCM_ID Playback Volume"))
# "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong
-W_PGA(1, Master Playback Volume, PIPELINE_FORMAT, 2, 1, 1)
+W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, KCONTROLS("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 7bfb35a..526ae35 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, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 2, 2, 2)
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("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 ccead10..e04a1b9 100644
--- a/topology/sof/pipe-tone.m4
+++ b/topology/sof/pipe-tone.m4
@@ -50,7 +50,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, Tone Volume PIPELINE_ID, PIPELINE_FORMAT, 2, 2, 0)
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("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 3030907..58e5393 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, Master Capture Volume, PIPELINE_FORMAT, 2, 2, 2)
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("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 54bc13d..8aa02fb 100644
--- a/topology/sof/pipe-volume-playback.m4
+++ b/topology/sof/pipe-volume-playback.m4
@@ -38,6 +38,32 @@ SectionControlMixer.STR(Master Playback Volume) {
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
#
@@ -47,7 +73,7 @@ SectionControlMixer.STR(Master Playback Volume) {
W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2)
# "Volume" has 2 source and 2 sink periods
-W_PGA(0, Master Playback Volume, PIPELINE_FORMAT, 2, 2, 2)
+W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("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