[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250318171459.3203730-10-ckeepax@opensource.cirrus.com>
Date: Tue, 18 Mar 2025 17:14:53 +0000
From: Charles Keepax <ckeepax@...nsource.cirrus.com>
To: <broonie@...nel.org>
CC: <lgirdwood@...il.com>, <shenghao-ding@...com>, <kevin-lu@...com>,
<baojun.xu@...com>, <linux-sound@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <patches@...nsource.cirrus.com>
Subject: [PATCH 09/15] ASoC: ops: Remove snd_soc_get_volsw_range()
With the addition of the soc_mixer_reg_to_ctl() helper it is now very
clear that the only difference between snd_soc_get_volsw() and
snd_soc_get_volsw_range() is that the former supports double controls
with both values in the same register. As such we can combine both
functions.
Signed-off-by: Charles Keepax <ckeepax@...nsource.cirrus.com>
---
include/sound/soc.h | 10 ++++------
sound/soc/codecs/wm5110.c | 2 +-
sound/soc/soc-ops.c | 42 +++------------------------------------
sound/soc/soc-topology.c | 2 +-
4 files changed, 9 insertions(+), 47 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index b310f2c599f87..b11c6cdb0201c 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -65,7 +65,7 @@ struct platform_device;
.private_value = SOC_SINGLE_VALUE(reg, shift, 0, max, invert, 0) }
#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
- .info = snd_soc_info_volsw, .get = snd_soc_get_volsw_range, \
+ .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
.put = snd_soc_put_volsw_range, \
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
@@ -91,7 +91,7 @@ struct platform_device;
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
.tlv.p = (tlv_array), \
.info = snd_soc_info_volsw, \
- .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
+ .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
@@ -117,7 +117,7 @@ struct platform_device;
xmax, xinvert) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
.info = snd_soc_info_volsw, \
- .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
+ .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
xshift, xmin, xmax, xinvert) }
#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -165,7 +165,7 @@ struct platform_device;
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
.tlv.p = (tlv_array), \
.info = snd_soc_info_volsw, \
- .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
+ .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
xshift, xmin, xmax, xinvert) }
#define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
@@ -571,8 +571,6 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
-int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol);
int snd_soc_limit_volume(struct snd_soc_card *card,
const char *name, int max);
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 64eee0d2347da..c24b42c375785 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -477,7 +477,7 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol,
*/
snd_soc_dapm_mutex_lock(dapm);
- ret = snd_soc_get_volsw_range(kcontrol, ucontrol);
+ ret = snd_soc_get_volsw(kcontrol, ucontrol);
snd_soc_dapm_mutex_unlock(dapm);
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 1b52ba12df8df..fbda8e21c5a60 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -248,12 +248,12 @@ int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_sx);
/**
- * snd_soc_get_volsw - single mixer get callback
+ * snd_soc_get_volsw - single mixer get callback with range
* @kcontrol: mixer control
* @ucontrol: control element information
*
- * Callback to get the value of a single mixer control, or a double mixer
- * control that spans 2 registers.
+ * Callback to get the value, within a range, of a single mixer control, or a
+ * double mixer control that spans 2 registers.
*
* Returns 0 for success.
*/
@@ -506,42 +506,6 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
}
EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range);
-/**
- * snd_soc_get_volsw_range - single mixer get callback with range
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to get the value, within a range, of a single mixer control.
- *
- * Returns 0 for success.
- */
-int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
- struct soc_mixer_control *mc =
- (struct soc_mixer_control *)kcontrol->private_value;
- int max = mc->max - mc->min;
- unsigned int mask = soc_mixer_mask(mc);
- unsigned int reg_val;
- int val;
-
- reg_val = snd_soc_component_read(component, mc->reg);
- val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
-
- ucontrol->value.integer.value[0] = val;
-
- if (snd_soc_volsw_is_stereo(mc)) {
- reg_val = snd_soc_component_read(component, mc->rreg);
- val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
-
- ucontrol->value.integer.value[1] = val;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range);
-
static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
{
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 9cbddfbbc556b..3c988925c512f 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -131,7 +131,7 @@ static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
snd_soc_put_enum_double, NULL},
{SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
snd_soc_bytes_put, snd_soc_bytes_info},
- {SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw_range,
+ {SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw,
snd_soc_put_volsw_range, snd_soc_info_volsw},
{SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
snd_soc_put_xr_sx, snd_soc_info_xr_sx},
--
2.39.5
Powered by blists - more mailing lists