mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
ASoC: dapm: Add component level pin switches
The core currently supports pin switches for source/sink widgets, but only at the card level. SDCA components specify the fabric at the level of the individual components, to support this add helpers to allow component level pin switches. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev> Link: https://patch.msgid.link/20250516131011.221310-5-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
3849c958ee
commit
737379e506
@@ -445,6 +445,10 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *uncontrol);
|
||||
int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *uncontrol);
|
||||
int snd_soc_dapm_get_component_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *uncontrol);
|
||||
int snd_soc_dapm_put_component_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *uncontrol);
|
||||
int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
|
||||
const struct snd_soc_dapm_widget *widget, unsigned int num);
|
||||
struct snd_soc_dapm_widget *snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
|
||||
|
||||
@@ -3626,11 +3626,25 @@ int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch);
|
||||
|
||||
static int __snd_soc_dapm_get_pin_switch(struct snd_soc_dapm_context *dapm,
|
||||
const char *pin,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
snd_soc_dapm_mutex_lock(dapm);
|
||||
ucontrol->value.integer.value[0] = snd_soc_dapm_get_pin_status(dapm, pin);
|
||||
snd_soc_dapm_mutex_unlock(dapm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_soc_dapm_get_pin_switch - Get information for a pin switch
|
||||
*
|
||||
* @kcontrol: mixer control
|
||||
* @ucontrol: Value
|
||||
*
|
||||
* Callback to provide information for a pin switch added at the card
|
||||
* level.
|
||||
*/
|
||||
int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
@@ -3638,40 +3652,82 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
||||
const char *pin = (const char *)kcontrol->private_value;
|
||||
|
||||
snd_soc_dapm_mutex_lock(card);
|
||||
|
||||
ucontrol->value.integer.value[0] =
|
||||
snd_soc_dapm_get_pin_status(&card->dapm, pin);
|
||||
|
||||
snd_soc_dapm_mutex_unlock(card);
|
||||
|
||||
return 0;
|
||||
return __snd_soc_dapm_get_pin_switch(&card->dapm, pin, ucontrol);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch);
|
||||
|
||||
/**
|
||||
* snd_soc_dapm_get_component_pin_switch - Get information for a pin switch
|
||||
*
|
||||
* @kcontrol: mixer control
|
||||
* @ucontrol: Value
|
||||
*
|
||||
* Callback to provide information for a pin switch added at the component
|
||||
* level.
|
||||
*/
|
||||
int snd_soc_dapm_get_component_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
const char *pin = (const char *)kcontrol->private_value;
|
||||
|
||||
return __snd_soc_dapm_get_pin_switch(&component->dapm, pin, ucontrol);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_component_pin_switch);
|
||||
|
||||
static int __snd_soc_dapm_put_pin_switch(struct snd_soc_dapm_context *dapm,
|
||||
const char *pin,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
int ret;
|
||||
|
||||
snd_soc_dapm_mutex_lock(dapm);
|
||||
ret = __snd_soc_dapm_set_pin(dapm, pin, !!ucontrol->value.integer.value[0]);
|
||||
snd_soc_dapm_mutex_unlock(dapm);
|
||||
|
||||
snd_soc_dapm_sync(dapm);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_soc_dapm_put_pin_switch - Set information for a pin switch
|
||||
*
|
||||
* @kcontrol: mixer control
|
||||
* @ucontrol: Value
|
||||
*
|
||||
* Callback to provide information for a pin switch added at the card
|
||||
* level.
|
||||
*/
|
||||
int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
||||
const char *pin = (const char *)kcontrol->private_value;
|
||||
int ret;
|
||||
|
||||
snd_soc_dapm_mutex_lock(card);
|
||||
ret = __snd_soc_dapm_set_pin(&card->dapm, pin,
|
||||
!!ucontrol->value.integer.value[0]);
|
||||
snd_soc_dapm_mutex_unlock(card);
|
||||
|
||||
snd_soc_dapm_sync(&card->dapm);
|
||||
return ret;
|
||||
return __snd_soc_dapm_put_pin_switch(&card->dapm, pin, ucontrol);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
|
||||
|
||||
/**
|
||||
* snd_soc_dapm_put_component_pin_switch - Set information for a pin switch
|
||||
*
|
||||
* @kcontrol: mixer control
|
||||
* @ucontrol: Value
|
||||
*
|
||||
* Callback to provide information for a pin switch added at the component
|
||||
* level.
|
||||
*/
|
||||
int snd_soc_dapm_put_component_pin_switch(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
const char *pin = (const char *)kcontrol->private_value;
|
||||
|
||||
return __snd_soc_dapm_put_pin_switch(&component->dapm, pin, ucontrol);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_component_pin_switch);
|
||||
|
||||
struct snd_soc_dapm_widget *
|
||||
snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
|
||||
const struct snd_soc_dapm_widget *widget)
|
||||
|
||||
Reference in New Issue
Block a user