diff mbox series

[SRU,Focal,1/4] ASoC: SOF: enable dual control for pga

Message ID 20200224011311.7178-2-hui.wang@canonical.com
State New
Headers show
Series alsa/sof: let sof driver work with topology with volume and led control (focal) | expand

Commit Message

Hui Wang Feb. 24, 2020, 1:13 a.m. UTC
From: Jaska Uimonen <jaska.uimonen@linux.intel.com>

BugLink: https://bugs.launchpad.net/bugs/1864398

Currently sof pga element supports only 1 kcontrol and you can't create
for example a mixer element with combined volume slider and mute switch.
So enable sof pga to have more than 1 kcontrol associated with it. Also
check for possible NULL tlv pointer as switch element might not have it.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191008164443.1358-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit a68c6b6cc77b841dc37c17a5d9a7074e26801af5)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/soc/sof/topology.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index fa299e078156..96c20c889fa4 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1581,7 +1581,7 @@  static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
 	if (!volume)
 		return -ENOMEM;
 
-	if (le32_to_cpu(tw->num_kcontrols) != 1) {
+	if (!le32_to_cpu(tw->num_kcontrols)) {
 		dev_err(sdev->dev, "error: invalid kcontrol count %d for volume\n",
 			tw->num_kcontrols);
 		ret = -EINVAL;
@@ -1618,7 +1618,8 @@  static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
 	swidget->private = volume;
 
 	list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
-		if (scontrol->comp_id == swidget->comp_id) {
+		if (scontrol->comp_id == swidget->comp_id &&
+		    scontrol->volume_table) {
 			min_step = scontrol->min_volume_step;
 			max_step = scontrol->max_volume_step;
 			volume->min_value = scontrol->volume_table[min_step];