Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org
Cc: tiwai@suse.com, perex@perex.cz,
	amadeuszx.slawinski@linux.intel.com, linux-sound@vger.kernel.org,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [PATCH 07/10] ASoC: Intel: avs: Move to the new control operations
Date: Mon, 17 Feb 2025 11:21:12 +0100	[thread overview]
Message-ID: <20250217102115.3539427-8-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20250217102115.3539427-1-cezary.rojewski@intel.com>

Allow for multi-channel volume controls to be utilized by an application
by moving over to the new implementation. Drop all unused code in the
process.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/control.c  | 72 +---------------------------------
 sound/soc/intel/avs/control.h  |  8 +---
 sound/soc/intel/avs/path.c     |  2 +-
 sound/soc/intel/avs/topology.c |  1 +
 4 files changed, 6 insertions(+), 77 deletions(-)

diff --git a/sound/soc/intel/avs/control.c b/sound/soc/intel/avs/control.c
index a1c7431cfe13..64283aa35281 100644
--- a/sound/soc/intel/avs/control.c
+++ b/sound/soc/intel/avs/control.c
@@ -48,75 +48,7 @@ static struct avs_path_module *avs_get_volume_module(struct avs_dev *adev, u32 i
 	return NULL;
 }
 
-int avs_control_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
-	struct avs_control_data *ctl_data = (struct avs_control_data *)mc->dobj.private;
-	struct avs_dev *adev = avs_get_kcontrol_adev(kcontrol);
-	struct avs_volume_cfg *dspvols = NULL;
-	struct avs_path_module *active_module;
-	size_t num_dspvols;
-	int ret = 0;
-
-	/* prevent access to modules while path is being constructed */
-	mutex_lock(&adev->path_mutex);
-
-	active_module = avs_get_volume_module(adev, ctl_data->id);
-	if (active_module) {
-		ret = avs_ipc_peakvol_get_volume(adev, active_module->module_id,
-						 active_module->instance_id, &dspvols,
-						 &num_dspvols);
-		if (!ret)
-			ucontrol->value.integer.value[0] = dspvols[0].target_volume;
-
-		ret = AVS_IPC_RET(ret);
-		kfree(dspvols);
-	} else {
-		ucontrol->value.integer.value[0] = ctl_data->volume;
-	}
-
-	mutex_unlock(&adev->path_mutex);
-	return ret;
-}
-
-int avs_control_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
-{
-	struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
-	struct avs_control_data *ctl_data = (struct avs_control_data *)mc->dobj.private;
-	struct avs_dev *adev = avs_get_kcontrol_adev(kcontrol);
-	long *volume = &ctl_data->volume;
-	struct avs_path_module *active_module;
-	struct avs_volume_cfg dspvol = {0};
-	long ctlvol = ucontrol->value.integer.value[0];
-	int ret = 0, changed = 0;
-
-	if (ctlvol < 0 || ctlvol > mc->max)
-		return -EINVAL;
-
-	/* prevent access to modules while path is being constructed */
-	mutex_lock(&adev->path_mutex);
-
-	if (*volume != ctlvol) {
-		*volume = ctlvol;
-		changed = 1;
-	}
-
-	active_module = avs_get_volume_module(adev, ctl_data->id);
-	if (active_module) {
-		dspvol.channel_id = AVS_ALL_CHANNELS_MASK;
-		dspvol.target_volume = *volume;
-
-		ret = avs_ipc_peakvol_set_volume(adev, active_module->module_id,
-						 active_module->instance_id, &dspvol);
-		ret = AVS_IPC_RET(ret);
-	}
-
-	mutex_unlock(&adev->path_mutex);
-
-	return ret ? ret : changed;
-}
-
-int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
+int avs_control_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
 {
 	struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
 	struct avs_control_data *ctl_data = mc->dobj.private;
@@ -150,7 +82,7 @@ int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value
 	return 0;
 }
 
-int avs_control_volume_put2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
+int avs_control_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
 {
 	struct avs_path_module *active_module;
 	struct avs_control_data *ctl_data;
diff --git a/sound/soc/intel/avs/control.h b/sound/soc/intel/avs/control.h
index e16fa79962de..66f3fe064e1d 100644
--- a/sound/soc/intel/avs/control.h
+++ b/sound/soc/intel/avs/control.h
@@ -14,15 +14,11 @@
 
 struct avs_control_data {
 	u32 id;
-
-	long volume;
 	long values[SND_SOC_TPLG_MAX_CHAN];
 };
 
-int avs_control_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
-int avs_control_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
-int avs_control_volume_get2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
-int avs_control_volume_put2(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
+int avs_control_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
+int avs_control_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl);
 int avs_control_volume_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo);
 
 #endif
diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index a72ebde7d011..56a2916eec5e 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -370,7 +370,7 @@ static int avs_peakvol_create(struct avs_dev *adev, struct avs_path_module *mod)
 
 	ctl_data = avs_get_module_control(mod);
 	if (ctl_data)
-		volume = ctl_data->volume;
+		volume = ctl_data->values[0];
 
 	/* As 2+ channels controls are unsupported, have a single block for all channels. */
 	cfg_size = struct_size(cfg, vols, 1);
diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c
index 45952fbe9694..ee70e3d0e889 100644
--- a/sound/soc/intel/avs/topology.c
+++ b/sound/soc/intel/avs/topology.c
@@ -1912,6 +1912,7 @@ static const struct snd_soc_tplg_kcontrol_ops avs_control_ops[] = {
 		.id = AVS_CONTROL_OPS_VOLUME,
 		.get = avs_control_volume_get,
 		.put = avs_control_volume_put,
+		.info = avs_control_volume_info,
 	},
 };
 
-- 
2.25.1


  parent reply	other threads:[~2025-02-17 10:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 10:21 [PATCH 00/10] ASoC: Intel: avs: Mute and multi-channel controls support Cezary Rojewski
2025-02-17 10:21 ` [PATCH 01/10] ASoC: topology: Create kcontrols based on their type Cezary Rojewski
2025-02-17 10:21 ` [PATCH 02/10] ASoC: topology: Save num_channels value for mixer controls Cezary Rojewski
2025-02-17 10:21 ` [PATCH 03/10] ASoC: Intel: avs: Make PEAKVOL configurable from topology Cezary Rojewski
2025-02-17 10:21 ` [PATCH 04/10] ASoC: Intel: avs: Add volume control for GAIN module Cezary Rojewski
2025-02-17 10:21 ` [PATCH 05/10] ASoC: Intel: avs: Update VOLUME and add MUTE IPCs Cezary Rojewski
2025-02-17 10:21 ` [PATCH 06/10] ASoC: Intel: avs: New volume control operations Cezary Rojewski
2025-02-17 10:21 ` Cezary Rojewski [this message]
2025-02-17 10:21 ` [PATCH 08/10] ASoC: Intel: avs: Add support for mute for PEAKVOL and GAIN Cezary Rojewski
2025-02-17 10:21 ` [PATCH 09/10] ASoC: Intel: avs: Honor the invert flag for mixer controls Cezary Rojewski
2025-02-17 10:21 ` [PATCH 10/10] ASoC: Intel: avs: Support multi-channel PEAKVOL instantiation Cezary Rojewski
2025-02-25 17:03 ` [PATCH 00/10] ASoC: Intel: avs: Mute and multi-channel controls support Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250217102115.3539427-8-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox