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 <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2018-02-09 23:48:43 -08:00 committed by Liam Girdwood
parent d6426bc305
commit 43e86cab60
1 changed files with 7 additions and 3 deletions

View File

@ -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++) {