diff mbox series

[4/8] ASoC: SOF: Drop ctrl_cmd parameter for snd_sof_ipc_set_get_comp_data()

Message ID 20211215180404.53254-5-ranjani.sridharan@linux.intel.com (mailing list archive)
State Accepted
Commit 9182f3c40b52ebd91d4796d96186ba10b720b4ba
Headers show
Series Changes to SOF kcontrol data set/get ops | expand

Commit Message

Ranjani Sridharan Dec. 15, 2021, 6:04 p.m. UTC
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

The scontrol->control_data->cmd has been configured during initialization
to the correct sof_ipc_ctrl_cmd.

No need to pass duplicated information, let's use the already available
one via scontrol.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/sof/control.c   | 26 +++++++-------------------
 sound/soc/sof/ipc.c       |  6 ++----
 sound/soc/sof/sof-audio.c |  2 +-
 sound/soc/sof/sof-audio.h |  3 +--
 4 files changed, 11 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 299ee466625e..23a916ea93f8 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -84,8 +84,7 @@  static void snd_sof_refresh_control(struct snd_sof_control *scontrol)
 	/* refresh the component data from DSP */
 	scontrol->comp_data_dirty = false;
 	ret = snd_sof_ipc_set_get_comp_data(scontrol,
-					    SOF_CTRL_TYPE_VALUE_CHAN_GET,
-					    scontrol->cmd, false);
+					    SOF_CTRL_TYPE_VALUE_CHAN_GET, false);
 	if (ret < 0) {
 		dev_err(scomp->dev, "error: failed to get control data: %d\n", ret);
 		/* Set the flag to re-try next time to get the data */
@@ -137,9 +136,7 @@  int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
 	/* notify DSP of mixer updates */
 	if (pm_runtime_active(scomp->dev))
 		snd_sof_ipc_set_get_comp_data(scontrol,
-					      SOF_CTRL_TYPE_VALUE_CHAN_SET,
-					      SOF_CTRL_CMD_VOLUME,
-					      true);
+					      SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
 	return change;
 }
 
@@ -209,9 +206,7 @@  int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
 	/* notify DSP of mixer updates */
 	if (pm_runtime_active(scomp->dev))
 		snd_sof_ipc_set_get_comp_data(scontrol,
-					      SOF_CTRL_TYPE_VALUE_CHAN_SET,
-					      SOF_CTRL_CMD_SWITCH,
-					      true);
+					      SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
 
 	return change;
 }
@@ -257,9 +252,7 @@  int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
 	/* notify DSP of enum updates */
 	if (pm_runtime_active(scomp->dev))
 		snd_sof_ipc_set_get_comp_data(scontrol,
-					      SOF_CTRL_TYPE_VALUE_CHAN_SET,
-					      SOF_CTRL_CMD_ENUM,
-					      true);
+					      SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
 
 	return change;
 }
@@ -334,9 +327,7 @@  int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
 	/* notify DSP of byte control updates */
 	if (pm_runtime_active(scomp->dev))
 		snd_sof_ipc_set_get_comp_data(scontrol,
-					      SOF_CTRL_TYPE_DATA_SET,
-					      scontrol->cmd,
-					      true);
+					      SOF_CTRL_TYPE_DATA_SET, true);
 
 	return 0;
 }
@@ -413,9 +404,7 @@  int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
 	/* notify DSP of byte control updates */
 	if (pm_runtime_active(scomp->dev))
 		snd_sof_ipc_set_get_comp_data(scontrol,
-					      SOF_CTRL_TYPE_DATA_SET,
-					      scontrol->cmd,
-					      true);
+					      SOF_CTRL_TYPE_DATA_SET, true);
 
 	return 0;
 }
@@ -452,8 +441,7 @@  int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
 	cdata->data->magic = SOF_ABI_MAGIC;
 	cdata->data->abi = SOF_ABI_VERSION;
 	/* get all the component data from DSP */
-	ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_CTRL_TYPE_DATA_GET,
-					    scontrol->cmd, false);
+	ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_CTRL_TYPE_DATA_GET, false);
 	if (ret < 0)
 		goto out;
 
diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index bcfe7edee05e..69c8a9964960 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -817,8 +817,7 @@  static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
  * IPC get()/set() for kcontrols.
  */
 int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
-				  enum sof_ipc_ctrl_type ctrl_type,
-				  enum sof_ipc_ctrl_cmd ctrl_cmd, bool set)
+				  enum sof_ipc_ctrl_type ctrl_type, bool set)
 {
 	struct snd_soc_component *scomp = scontrol->scomp;
 	struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
@@ -874,13 +873,12 @@  int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
 	}
 
 	/* Select the IPC cmd based on the ctrl_cmd and the direction */
-	if (ctrl_cmd == SOF_CTRL_CMD_BINARY)
+	if (cdata->cmd == SOF_CTRL_CMD_BINARY)
 		ipc_cmd = set ? SOF_IPC_COMP_SET_DATA : SOF_IPC_COMP_GET_DATA;
 	else
 		ipc_cmd = set ? SOF_IPC_COMP_SET_VALUE : SOF_IPC_COMP_GET_VALUE;
 
 	cdata->rhdr.hdr.cmd = SOF_IPC_GLB_COMP_MSG | ipc_cmd;
-	cdata->cmd = ctrl_cmd;
 	cdata->type = ctrl_type;
 	cdata->comp_id = scontrol->comp_id;
 	cdata->msg_index = 0;
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index dacc0122c3b4..269eca26eab9 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -34,7 +34,7 @@  static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *
 		return 0;
 	}
 
-	ret = snd_sof_ipc_set_get_comp_data(scontrol, ctrl_type, scontrol->cmd, true);
+	ret = snd_sof_ipc_set_get_comp_data(scontrol, ctrl_type, true);
 	if (ret < 0)
 		dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n",
 			scontrol->comp_id);
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index f4316cd742a7..5bcc842e4792 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -240,8 +240,7 @@  static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
  * Mixer IPC
  */
 int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
-				  enum sof_ipc_ctrl_type ctrl_type,
-				  enum sof_ipc_ctrl_cmd ctrl_cmd, bool set);
+				  enum sof_ipc_ctrl_type ctrl_type, bool set);
 
 /* DAI link fixup */
 int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);