mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
ASoC: soc-component: Add new snd_soc_component_get_kcontrol() helpers
Add new helper functions snd_soc_component_get_kcontrol() and snd_soc_component_get_kcontrol_locked() 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@opensource.cirrus.com> Link: https://patch.msgid.link/20240802105734.2309788-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
becfa08bfe
commit
c8a132e2e0
@ -462,6 +462,11 @@ 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);
|
||||
struct snd_kcontrol *
|
||||
snd_soc_component_get_kcontrol_locked(struct snd_soc_component *component,
|
||||
const char * const ctl);
|
||||
int snd_soc_component_notify_control(struct snd_soc_component *component,
|
||||
const char * const ctl);
|
||||
|
||||
|
@ -236,19 +236,45 @@ int snd_soc_component_force_enable_pin_unlocked(
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
|
||||
|
||||
static void soc_get_kcontrol_name(struct snd_soc_component *component,
|
||||
char *buf, int size, const char * const ctl)
|
||||
{
|
||||
/* When updating, change also snd_soc_dapm_widget_name_cmp() */
|
||||
if (component->name_prefix)
|
||||
snprintf(buf, size, "%s %s", component->name_prefix, ctl);
|
||||
else
|
||||
snprintf(buf, size, "%s", 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];
|
||||
|
||||
soc_get_kcontrol_name(component, name, ARRAY_SIZE(name), ctl);
|
||||
|
||||
return snd_soc_card_get_kcontrol(component->card, name);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_get_kcontrol);
|
||||
|
||||
struct snd_kcontrol *
|
||||
snd_soc_component_get_kcontrol_locked(struct snd_soc_component *component,
|
||||
const char * const ctl)
|
||||
{
|
||||
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
||||
|
||||
soc_get_kcontrol_name(component, name, ARRAY_SIZE(name), ctl);
|
||||
|
||||
return snd_soc_card_get_kcontrol_locked(component->card, name);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_component_get_kcontrol_locked);
|
||||
|
||||
int snd_soc_component_notify_control(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)
|
||||
snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl);
|
||||
else
|
||||
snprintf(name, ARRAY_SIZE(name), "%s", ctl);
|
||||
|
||||
kctl = snd_soc_card_get_kcontrol(component->card, name);
|
||||
kctl = snd_soc_component_get_kcontrol(component, ctl);
|
||||
if (!kctl)
|
||||
return soc_component_ret(component, -EINVAL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user