[Sound-open-firmware] [PATCH] volume: fix logic for volume mute/unmute

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Sat Feb 10 08:48:43 CET 2018


This patch fixes the volume mute/unmute logic in volume
to handle cases when volume is already muted/unmuted

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>

---
Tested with:
Minnowboard Turbot rt5651
SOF master: 1edc69c7c0af4808764590990d37076da80c8627
SOF-Tool master: 57be4f5b8c96ba5839598046be4b4543ce8cf63b
https://github.com/plbossart/sound/tree/topic/sof-v4.14:
6fa721a8b7c6567eea0a2181bf9a3d2a12c31b00
---
---
 src/audio/volume.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/audio/volume.c b/src/audio/volume.c
index 3b3e2aa..8e54607 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -440,7 +440,9 @@ static inline void volume_set_chan_mute(struct comp_dev *dev, int chan)
 {
 	struct comp_data *cd = comp_get_drvdata(dev);
 
-	cd->mvolume[chan] = cd->volume[chan];
+	/* Check if not muted already */
+	if (cd->volume[chan] != 0)
+		cd->mvolume[chan] = cd->volume[chan];
 	cd->tvolume[chan] = 0;
 }
 
@@ -448,7 +450,9 @@ static inline void volume_set_chan_unmute(struct comp_dev *dev, int chan)
 {
 	struct comp_data *cd = comp_get_drvdata(dev);
 
-	cd->tvolume[chan] = cd->mvolume[chan];
+	/* Check if muted */
+	if (cd->volume[chan] == 0)
+		cd->tvolume[chan] = cd->mvolume[chan];
 }
 
 static int volume_ctrl_set_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata)
@@ -521,7 +525,7 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c
 		return -EINVAL;
 	}
 
-	if (cdata->cmd == SOF_CTRL_CMD_VOLUME) {
+	if (cdata->cmd == SOF_CTRL_CMD_VOLUME || SOF_CTRL_CMD_SWITCH) {
 		trace_volume("vgt");
 		trace_value(cdata->comp_id);
 		for (j = 0; j < cdata->num_elems; j++) {
-- 
2.14.1



More information about the Sound-open-firmware mailing list