From 84dab8990f0e36d27e8e31fa70ead8a2bee21981 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 8 Jun 2018 23:15:40 -0700 Subject: [PATCH] tone: add get command handler to return tone state This patch adds the get() handler to respond to requests for the current tone state. Signed-off-by: Ranjani Sridharan --- src/audio/tone.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/audio/tone.c b/src/audio/tone.c index eee60914f..d02e35f5b 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -462,6 +462,25 @@ static int tone_params(struct comp_dev *dev) return 0; } +static int tone_cmd_get_value(struct comp_dev *dev, + struct sof_ipc_ctrl_data *cdata) +{ + struct comp_data *cd = comp_get_drvdata(dev); + int j; + + trace_tone("mgt"); + + if (cdata->cmd == SOF_CTRL_CMD_SWITCH) { + for (j = 0; j < cdata->num_elems; j++) { + cdata->chanv[j].channel = j; + cdata->chanv[j].value = !cd->sg[j].mute; + trace_value(j); + trace_value(cd->sg[j].mute); + } + } + return 0; +} + static int tone_cmd_set_value(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata) { struct comp_data *cd = comp_get_drvdata(dev); @@ -480,6 +499,7 @@ static int tone_cmd_set_value(struct comp_dev *dev, struct sof_ipc_ctrl_data *cd trace_tone_error("che"); return -EINVAL; } + if (val) tonegen_unmute(&cd->sg[ch]); else @@ -583,6 +603,9 @@ static int tone_cmd(struct comp_dev *dev, int cmd, void *data) case COMP_CMD_SET_VALUE: ret = tone_cmd_set_value(dev, cdata); break; + case COMP_CMD_GET_VALUE: + ret = tone_cmd_get_value(dev, cdata); + break; } return ret;