From 43e86cab6088fe10db903c46b58a4c9b0456810a Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 9 Feb 2018 23:48:43 -0800 Subject: [PATCH] volume: fix logic for volume mute/unmute This patch fixes the volume mute/unmute logic in volume to handle cases when volume is already muted/unmuted Signed-off-by: Ranjani Sridharan --- 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 3b3e2aaa2..8e54607fb 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++) {