diff options
| author | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
| commit | 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e (patch) | |
| tree | d57f3a63479a07b4e0cece029886e76e04feb984 /sound/soc/generic/simple-card-utils.c | |
| parent | 5dc63e56a9cf8df0b59c234a505a1653f1bdf885 (diff) | |
| parent | 53bea86b5712c7491bb3dae12e271666df0a308c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.4 merge window.
Diffstat (limited to 'sound/soc/generic/simple-card-utils.c')
| -rw-r--r-- | sound/soc/generic/simple-card-utils.c | 49 | 
1 files changed, 49 insertions, 0 deletions
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index e35becce9635..56552a616f21 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -786,6 +786,55 @@ int asoc_simple_init_jack(struct snd_soc_card *card,  }  EXPORT_SYMBOL_GPL(asoc_simple_init_jack); +int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, char *prefix) +{ +	struct snd_soc_card *card = simple_priv_to_card(priv); +	struct snd_soc_component *component; +	int found_jack_index = 0; +	int type = 0; +	int num = 0; +	int ret; + +	if (priv->aux_jacks) +		return 0; + +	for_each_card_auxs(card, component) { +		type = snd_soc_component_get_jack_type(component); +		if (type > 0) +			num++; +	} +	if (num < 1) +		return 0; + +	priv->aux_jacks = devm_kcalloc(card->dev, num, +				       sizeof(struct snd_soc_jack), GFP_KERNEL); +	if (!priv->aux_jacks) +		return -ENOMEM; + +	for_each_card_auxs(card, component) { +		char id[128]; +		struct snd_soc_jack *jack; + +		if (found_jack_index >= num) +			break; + +		type = snd_soc_component_get_jack_type(component); +		if (type <= 0) +			continue; + +		/* create jack */ +		jack = &(priv->aux_jacks[found_jack_index++]); +		snprintf(id, sizeof(id), "%s-jack", component->name); +		ret = snd_soc_card_jack_new(card, id, type, jack); +		if (ret) +			continue; + +		(void)snd_soc_component_set_jack(component, jack, NULL); +	} +	return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_init_aux_jacks); +  int asoc_simple_init_priv(struct asoc_simple_priv *priv,  			  struct link_info *li)  {  |