Add a new helper function that returns a kcontrol by name, but will
factor in the components name_prefix, to handle situations where
multiple components are present with the same controls.
Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
---
New since v1 of the series.
include/sound/soc-component.h | 2 ++
sound/soc/soc-component.c | 16 ++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index ceca69b46a821..61534ac0edd1d 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -462,6 +462,8 @@ int snd_soc_component_force_enable_pin_unlocked(
const char *pin);
/* component controls */
+struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
+ const char * const ctl);
int snd_soc_component_notify_control(struct snd_soc_component *component,
const char * const ctl);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 4d7c2e3c929a9..1c0971823fb4d 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -236,11 +236,10 @@ int snd_soc_component_force_enable_pin_unlocked(
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
-int snd_soc_component_notify_control(struct snd_soc_component *component,
- const char * const ctl)
+struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
+ const char * const ctl)
{
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- struct snd_kcontrol *kctl;
/* When updating, change also snd_soc_dapm_widget_name_cmp() */
if (component->name_prefix)
@@ -248,7 +247,16 @@ int snd_soc_component_notify_control(struct snd_soc_component *component,
else
snprintf(name, ARRAY_SIZE(name), "%s", ctl);
- kctl = snd_soc_card_get_kcontrol(component->card, name);
+ return snd_soc_card_get_kcontrol(component->card, name);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_get_kcontrol);
+
+int snd_soc_component_notify_control(struct snd_soc_component *component,
+ const char * const ctl)
+{
+ struct snd_kcontrol *kctl;
+
+ kctl = snd_soc_component_get_kcontrol(component, ctl);
if (!kctl)
return soc_component_ret(component, -EINVAL);
--
2.39.2
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]