volume: fix get_cmd() for SWITCH command

Switch controls can only have 0/1 for values. Fix the get_cmd() callback
to return the channel mute status for SWITCH commands instead
of the current volume gain.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2020-09-22 12:38:02 -07:00 committed by Liam Girdwood
parent cad15f0405
commit 5abdf3778b
1 changed files with 13 additions and 5 deletions

View File

@ -629,10 +629,8 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev,
return -EINVAL;
}
if (cdata->cmd == SOF_CTRL_CMD_VOLUME ||
cdata->cmd == SOF_CTRL_CMD_SWITCH) {
comp_dbg(dev, "volume_ctrl_get_cmd(), SOF_CTRL_CMD_VOLUME / SOF_CTRL_CMD_SWITCH, cdata->comp_id = %u",
cdata->comp_id);
switch (cdata->cmd) {
case SOF_CTRL_CMD_VOLUME:
for (j = 0; j < cdata->num_elems; j++) {
cdata->chanv[j].channel = j;
cdata->chanv[j].value = cd->tvolume[j];
@ -640,7 +638,17 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev,
cdata->chanv[j].channel,
cdata->chanv[j].value);
}
} else {
break;
case SOF_CTRL_CMD_SWITCH:
for (j = 0; j < cdata->num_elems; j++) {
cdata->chanv[j].channel = j;
cdata->chanv[j].value = !cd->muted[j];
comp_info(dev, "volume_ctrl_get_cmd(), channel = %u, value = %u",
cdata->chanv[j].channel,
cdata->chanv[j].value);
}
break;
default:
comp_err(dev, "volume_ctrl_get_cmd(): invalid cdata->cmd");
return -EINVAL;
}