[v2,07/12] ASoC: davinci-evm: Register machine level DAPM elements with the card
diff mbox

Message ID 1394634460-15889-8-git-send-email-lars@metafoo.de
State Accepted
Commit d343a660d3c94423759382869b7f90c8657ebbf1
Headers show

Commit Message

Lars-Peter Clausen March 12, 2014, 2:27 p.m. UTC
Machine level DAPM widgets and routes should be registered in the card's DAPM
context, rather than in the CODEC's context.

While we are at it also drop the snd_soc_dapm_enable_pin() calls, since pins are
enabled by default and also turn the snd_soc_dapm_disable_pin() calls into
snd_soc_dapm_nc_pin() calls for unconnected pins.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
Changes since v1:
	* Remove snd_soc_dapm_enable_pin() calls
	* Change snd_soc_dapm_disable_pin() calles into snd_soc_dapm_nc_pin()
---
 sound/soc/davinci/davinci-evm.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Peter Ujfalusi March 13, 2014, 10:07 a.m. UTC | #1
On 03/12/2014 04:27 PM, Lars-Peter Clausen wrote:
> Machine level DAPM widgets and routes should be registered in the card's DAPM
> context, rather than in the CODEC's context.
> 
> While we are at it also drop the snd_soc_dapm_enable_pin() calls, since pins are
> enabled by default and also turn the snd_soc_dapm_disable_pin() calls into
> snd_soc_dapm_nc_pin() calls for unconnected pins.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> ---
> Changes since v1:
> 	* Remove snd_soc_dapm_enable_pin() calls
> 	* Change snd_soc_dapm_disable_pin() calles into snd_soc_dapm_nc_pin()
> ---
>  sound/soc/davinci/davinci-evm.c | 22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
> index 70ff377..9c296f7 100644
> --- a/sound/soc/davinci/davinci-evm.c
> +++ b/sound/soc/davinci/davinci-evm.c
> @@ -95,35 +95,29 @@ static const struct snd_soc_dapm_route audio_map[] = {
>  /* Logic for a aic3x as connected on a davinci-evm */
>  static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
>  {
> +	struct snd_soc_card *card = rtd->card;
>  	struct snd_soc_codec *codec = rtd->codec;
> -	struct snd_soc_dapm_context *dapm = &codec->dapm;
>  	struct device_node *np = codec->card->dev->of_node;
>  	int ret;
>  
>  	/* Add davinci-evm specific widgets */
> -	snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
> +	snd_soc_dapm_new_controls(&card->dapm, aic3x_dapm_widgets,
>  				  ARRAY_SIZE(aic3x_dapm_widgets));
>  
>  	if (np) {
> -		ret = snd_soc_of_parse_audio_routing(codec->card,
> -							"ti,audio-routing");
> +		ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
>  		if (ret)
>  			return ret;
>  	} else {
>  		/* Set up davinci-evm specific audio path audio_map */
> -		snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
> +		snd_soc_dapm_add_routes(&card->dapm, audio_map,
> +					ARRAY_SIZE(audio_map));
>  	}
>  
>  	/* not connected */
> -	snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
> -	snd_soc_dapm_disable_pin(dapm, "HPLCOM");
> -	snd_soc_dapm_disable_pin(dapm, "HPRCOM");
> -
> -	/* always connected */
> -	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
> -	snd_soc_dapm_enable_pin(dapm, "Line Out");
> -	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
> -	snd_soc_dapm_enable_pin(dapm, "Line In");
> +	snd_soc_dapm_nc_pin(&codec->dapm, "MONO_LOUT");
> +	snd_soc_dapm_nc_pin(&codec->dapm, "HPLCOM");
> +	snd_soc_dapm_nc_pin(&codec->dapm, "HPRCOM");
>  
>  	return 0;
>  }
>
Mark Brown March 13, 2014, 7:11 p.m. UTC | #2
On Wed, Mar 12, 2014 at 03:27:35PM +0100, Lars-Peter Clausen wrote:
> Machine level DAPM widgets and routes should be registered in the card's DAPM
> context, rather than in the CODEC's context.

Applied, thanks.

Patch
diff mbox

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 70ff377..9c296f7 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -95,35 +95,29 @@  static const struct snd_soc_dapm_route audio_map[] = {
 /* Logic for a aic3x as connected on a davinci-evm */
 static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
 {
+	struct snd_soc_card *card = rtd->card;
 	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_dapm_context *dapm = &codec->dapm;
 	struct device_node *np = codec->card->dev->of_node;
 	int ret;
 
 	/* Add davinci-evm specific widgets */
-	snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
+	snd_soc_dapm_new_controls(&card->dapm, aic3x_dapm_widgets,
 				  ARRAY_SIZE(aic3x_dapm_widgets));
 
 	if (np) {
-		ret = snd_soc_of_parse_audio_routing(codec->card,
-							"ti,audio-routing");
+		ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
 		if (ret)
 			return ret;
 	} else {
 		/* Set up davinci-evm specific audio path audio_map */
-		snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
+		snd_soc_dapm_add_routes(&card->dapm, audio_map,
+					ARRAY_SIZE(audio_map));
 	}
 
 	/* not connected */
-	snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
-	snd_soc_dapm_disable_pin(dapm, "HPLCOM");
-	snd_soc_dapm_disable_pin(dapm, "HPRCOM");
-
-	/* always connected */
-	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
-	snd_soc_dapm_enable_pin(dapm, "Line Out");
-	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
-	snd_soc_dapm_enable_pin(dapm, "Line In");
+	snd_soc_dapm_nc_pin(&codec->dapm, "MONO_LOUT");
+	snd_soc_dapm_nc_pin(&codec->dapm, "HPLCOM");
+	snd_soc_dapm_nc_pin(&codec->dapm, "HPRCOM");
 
 	return 0;
 }