Skip to content

Commit fd74425

Browse files
charleskeepaxbroonie
authored andcommitted
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@opensource.cirrus.com> Link: https://patch.msgid.link/20250318171459.3203730-10-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 894a37c commit fd74425

File tree

4 files changed

+9
-47
lines changed

4 files changed

+9
-47
lines changed

include/sound/soc.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct platform_device;
6565
.private_value = SOC_SINGLE_VALUE(reg, shift, 0, max, invert, 0) }
6666
#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
6767
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
68-
.info = snd_soc_info_volsw, .get = snd_soc_get_volsw_range, \
68+
.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
6969
.put = snd_soc_put_volsw_range, \
7070
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
7171
#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
@@ -91,7 +91,7 @@ struct platform_device;
9191
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
9292
.tlv.p = (tlv_array), \
9393
.info = snd_soc_info_volsw, \
94-
.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
94+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
9595
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
9696
#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
9797
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
@@ -117,7 +117,7 @@ struct platform_device;
117117
xmax, xinvert) \
118118
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
119119
.info = snd_soc_info_volsw, \
120-
.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
120+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
121121
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
122122
xshift, xmin, xmax, xinvert) }
123123
#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -165,7 +165,7 @@ struct platform_device;
165165
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
166166
.tlv.p = (tlv_array), \
167167
.info = snd_soc_info_volsw, \
168-
.get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
168+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
169169
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
170170
xshift, xmin, xmax, xinvert) }
171171
#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,
571571
struct snd_ctl_elem_value *ucontrol);
572572
int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
573573
struct snd_ctl_elem_value *ucontrol);
574-
int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
575-
struct snd_ctl_elem_value *ucontrol);
576574
int snd_soc_limit_volume(struct snd_soc_card *card,
577575
const char *name, int max);
578576
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,

sound/soc/codecs/wm5110.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol,
477477
*/
478478
snd_soc_dapm_mutex_lock(dapm);
479479

480-
ret = snd_soc_get_volsw_range(kcontrol, ucontrol);
480+
ret = snd_soc_get_volsw(kcontrol, ucontrol);
481481

482482
snd_soc_dapm_mutex_unlock(dapm);
483483

sound/soc/soc-ops.c

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
248248
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_sx);
249249

250250
/**
251-
* snd_soc_get_volsw - single mixer get callback
251+
* snd_soc_get_volsw - single mixer get callback with range
252252
* @kcontrol: mixer control
253253
* @ucontrol: control element information
254254
*
255-
* Callback to get the value of a single mixer control, or a double mixer
256-
* control that spans 2 registers.
255+
* Callback to get the value, within a range, of a single mixer control, or a
256+
* double mixer control that spans 2 registers.
257257
*
258258
* Returns 0 for success.
259259
*/
@@ -506,42 +506,6 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
506506
}
507507
EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range);
508508

509-
/**
510-
* snd_soc_get_volsw_range - single mixer get callback with range
511-
* @kcontrol: mixer control
512-
* @ucontrol: control element information
513-
*
514-
* Callback to get the value, within a range, of a single mixer control.
515-
*
516-
* Returns 0 for success.
517-
*/
518-
int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
519-
struct snd_ctl_elem_value *ucontrol)
520-
{
521-
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
522-
struct soc_mixer_control *mc =
523-
(struct soc_mixer_control *)kcontrol->private_value;
524-
int max = mc->max - mc->min;
525-
unsigned int mask = soc_mixer_mask(mc);
526-
unsigned int reg_val;
527-
int val;
528-
529-
reg_val = snd_soc_component_read(component, mc->reg);
530-
val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
531-
532-
ucontrol->value.integer.value[0] = val;
533-
534-
if (snd_soc_volsw_is_stereo(mc)) {
535-
reg_val = snd_soc_component_read(component, mc->rreg);
536-
val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
537-
538-
ucontrol->value.integer.value[1] = val;
539-
}
540-
541-
return 0;
542-
}
543-
EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range);
544-
545509
static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
546510
{
547511
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;

sound/soc/soc-topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
131131
snd_soc_put_enum_double, NULL},
132132
{SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
133133
snd_soc_bytes_put, snd_soc_bytes_info},
134-
{SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw_range,
134+
{SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw,
135135
snd_soc_put_volsw_range, snd_soc_info_volsw},
136136
{SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
137137
snd_soc_put_xr_sx, snd_soc_info_xr_sx},

0 commit comments

Comments
 (0)