All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional
@ 2015-07-12  6:56 Anatol Pomozov
  2015-07-12  6:56 ` [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget Anatol Pomozov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Anatol Pomozov @ 2015-07-12  6:56 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, lars, kwestfie, Anatol Pomozov

The option is not needed if chip is always on or managed by some other part
of system like platform card driver.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
---
 Documentation/devicetree/bindings/sound/max98357a.txt | 6 +++++-
 sound/soc/codecs/max98357a.c                          | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/max98357a.txt b/Documentation/devicetree/bindings/sound/max98357a.txt
index a7a149a..28645a2 100644
--- a/Documentation/devicetree/bindings/sound/max98357a.txt
+++ b/Documentation/devicetree/bindings/sound/max98357a.txt
@@ -4,7 +4,11 @@ This node models the Maxim MAX98357A DAC.
 
 Required properties:
 - compatible   : "maxim,max98357a"
-- sdmode-gpios : GPIO specifier for the GPIO -> DAC SDMODE pin
+
+Optional properties:
+- sdmode-gpios : GPIO specifier for the chip's SD_MODE pin.
+        If this option is not specified then driver does not manage
+        the pin state (e.g. chip is always on).
 
 Example:
 
diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index 3a2fda0..6d4246a 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -31,6 +31,9 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
 {
 	struct gpio_desc *sdmode = snd_soc_dai_get_drvdata(dai);
 
+	if (!sdmode)
+		return 0;
+
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
@@ -61,7 +64,7 @@ static int max98357a_codec_probe(struct snd_soc_codec *codec)
 	struct gpio_desc *sdmode;
 
 	sdmode = devm_gpiod_get(codec->dev, "sdmode", GPIOD_OUT_LOW);
-	if (IS_ERR(sdmode)) {
+	if (IS_ERR(sdmode) && (PTR_ERR(sdmode) != -ENOENT)) {
 		dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n",
 				__func__, PTR_ERR(sdmode));
 		return PTR_ERR(sdmode);
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget
  2015-07-12  6:56 [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Anatol Pomozov
@ 2015-07-12  6:56 ` Anatol Pomozov
  2015-07-12 10:33   ` Lars-Peter Clausen
  2015-07-12  6:56 ` [PATCH 3/3] ASoC: max98357a: Do not print error message on gpio get Anatol Pomozov
  2015-07-12 10:31 ` [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Lars-Peter Clausen
  2 siblings, 1 reply; 6+ messages in thread
From: Anatol Pomozov @ 2015-07-12  6:56 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, lars, kwestfie, Anatol Pomozov

Spec does not say anything about DAC called SDMode.
Create a dapm path that consists of path from I2S input to Speaker output.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
---
 sound/soc/codecs/max98357a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index 6d4246a..0d87d35 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -51,12 +51,12 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
-	SND_SOC_DAPM_DAC("SDMode", NULL, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
 	SND_SOC_DAPM_OUTPUT("Speaker"),
 };
 
 static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
-	{"Speaker", NULL, "SDMode"},
+	{"Speaker", NULL, "AIFRX"},
 };
 
 static int max98357a_codec_probe(struct snd_soc_codec *codec)
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ASoC: max98357a: Do not print error message on gpio get
  2015-07-12  6:56 [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Anatol Pomozov
  2015-07-12  6:56 ` [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget Anatol Pomozov
@ 2015-07-12  6:56 ` Anatol Pomozov
  2015-07-12 10:31 ` [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Lars-Peter Clausen
  2 siblings, 0 replies; 6+ messages in thread
From: Anatol Pomozov @ 2015-07-12  6:56 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, lars, kwestfie, Anatol Pomozov

gpiolib system already prints enough info if there are any problems with
the gpio.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
---
 sound/soc/codecs/max98357a.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index 0d87d35..d669b0c 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -64,11 +64,9 @@ static int max98357a_codec_probe(struct snd_soc_codec *codec)
 	struct gpio_desc *sdmode;
 
 	sdmode = devm_gpiod_get(codec->dev, "sdmode", GPIOD_OUT_LOW);
-	if (IS_ERR(sdmode) && (PTR_ERR(sdmode) != -ENOENT)) {
-		dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n",
-				__func__, PTR_ERR(sdmode));
+	if (IS_ERR(sdmode) && (PTR_ERR(sdmode) != -ENOENT))
 		return PTR_ERR(sdmode);
-	}
+
 	snd_soc_codec_set_drvdata(codec, sdmode);
 
 	return 0;
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional
  2015-07-12  6:56 [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Anatol Pomozov
  2015-07-12  6:56 ` [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget Anatol Pomozov
  2015-07-12  6:56 ` [PATCH 3/3] ASoC: max98357a: Do not print error message on gpio get Anatol Pomozov
@ 2015-07-12 10:31 ` Lars-Peter Clausen
  2 siblings, 0 replies; 6+ messages in thread
From: Lars-Peter Clausen @ 2015-07-12 10:31 UTC (permalink / raw)
  To: Anatol Pomozov, alsa-devel; +Cc: kwestfie, broonie

On 07/12/2015 08:56 AM, Anatol Pomozov wrote:
[...]
> @@ -61,7 +64,7 @@ static int max98357a_codec_probe(struct snd_soc_codec *codec)
>   	struct gpio_desc *sdmode;
>
>   	sdmode = devm_gpiod_get(codec->dev, "sdmode", GPIOD_OUT_LOW);
> -	if (IS_ERR(sdmode)) {
> +	if (IS_ERR(sdmode) && (PTR_ERR(sdmode) != -ENOENT)) {

There is is devm_gpiod_get_optional() exactly for this use case. It will 
return NULL if no GPIO is specified.

>   		dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n",
>   				__func__, PTR_ERR(sdmode));
>   		return PTR_ERR(sdmode);
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget
  2015-07-12  6:56 ` [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget Anatol Pomozov
@ 2015-07-12 10:33   ` Lars-Peter Clausen
  2015-07-12 15:15     ` Anatol Pomozov
  0 siblings, 1 reply; 6+ messages in thread
From: Lars-Peter Clausen @ 2015-07-12 10:33 UTC (permalink / raw)
  To: Anatol Pomozov, alsa-devel; +Cc: kwestfie, broonie

On 07/12/2015 08:56 AM, Anatol Pomozov wrote:
> Spec does not say anything about DAC called SDMode.
> Create a dapm path that consists of path from I2S input to Speaker output.
>
> Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
> ---
>   sound/soc/codecs/max98357a.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
> index 6d4246a..0d87d35 100644
> --- a/sound/soc/codecs/max98357a.c
> +++ b/sound/soc/codecs/max98357a.c
> @@ -51,12 +51,12 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
>   }
>
>   static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
> -	SND_SOC_DAPM_DAC("SDMode", NULL, SND_SOC_NOPM, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
>   	SND_SOC_DAPM_OUTPUT("Speaker"),
>   };
>
>   static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
> -	{"Speaker", NULL, "SDMode"},
> +	{"Speaker", NULL, "AIFRX"},

ASoC automatically creates a widget for the playback stream. You can connect 
that directly here without the need for the AIF_IN widget. E.g.:

	{ "Speaker", NULL, "HiFi Playback" },

>   };
>
>   static int max98357a_codec_probe(struct snd_soc_codec *codec)
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget
  2015-07-12 10:33   ` Lars-Peter Clausen
@ 2015-07-12 15:15     ` Anatol Pomozov
  0 siblings, 0 replies; 6+ messages in thread
From: Anatol Pomozov @ 2015-07-12 15:15 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel@alsa-project.org, Mark Brown, Kenneth Westfield

Hi

On Sun, Jul 12, 2015 at 3:33 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 07/12/2015 08:56 AM, Anatol Pomozov wrote:
>>
>> Spec does not say anything about DAC called SDMode.
>> Create a dapm path that consists of path from I2S input to Speaker output.
>>
>> Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
>> ---
>>   sound/soc/codecs/max98357a.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
>> index 6d4246a..0d87d35 100644
>> --- a/sound/soc/codecs/max98357a.c
>> +++ b/sound/soc/codecs/max98357a.c
>> @@ -51,12 +51,12 @@ static int max98357a_daiops_trigger(struct
>> snd_pcm_substream *substream,
>>   }
>>
>>   static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
>> -       SND_SOC_DAPM_DAC("SDMode", NULL, SND_SOC_NOPM, 0, 0),
>> +       SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0,
>> 0),
>>         SND_SOC_DAPM_OUTPUT("Speaker"),
>>   };
>>
>>   static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
>> -       {"Speaker", NULL, "SDMode"},
>> +       {"Speaker", NULL, "AIFRX"},
>
>
> ASoC automatically creates a widget for the playback stream. You can connect
> that directly here without the need for the AIF_IN widget. E.g.:
>
>         { "Speaker", NULL, "HiFi Playback" },

Thanks for the useful review. Tested it on my board and it works
great. Will resend updated changes soon.

>
>
>>   };
>>
>>   static int max98357a_codec_probe(struct snd_soc_codec *codec)
>>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-12 15:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-12  6:56 [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Anatol Pomozov
2015-07-12  6:56 ` [PATCH 2/3] ASoC: max98357a: Specify digital input as a dapm widget Anatol Pomozov
2015-07-12 10:33   ` Lars-Peter Clausen
2015-07-12 15:15     ` Anatol Pomozov
2015-07-12  6:56 ` [PATCH 3/3] ASoC: max98357a: Do not print error message on gpio get Anatol Pomozov
2015-07-12 10:31 ` [PATCH 1/3] ASoC: max98357a: Make 'sdmode-gpios' dts property optional Lars-Peter Clausen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.