diff mbox series

[v2,2/3] ASoC: simple-card: move hp and mic detection to soc_card probe

Message ID 20180611051559.18082-2-suzuki.katsuhiro@socionext.com
State New
Headers show
Series [v2,1/3] ASoC: simple-card-utils: move hp and mic detect gpios from simple-card | expand

Commit Message

Katsuhiro Suzuki June 11, 2018, 5:15 a.m. UTC
This patch moves headphone and microphone detection to probe() of
snd_soc_card from init() of snd_soc_dai_link. This is because init()
is called (and an input device /dev/input/eventX is created too)
twice or above if simple card has two or more DAI links.

Signed-off-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>


---

Changes from v1:
  - Newly added
---
 sound/soc/generic/simple-card.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

-- 
2.17.1

Comments

Kuninori Morimoto June 11, 2018, 5:27 a.m. UTC | #1
Hi Katsuhiro-san

> This patch moves headphone and microphone detection to probe() of

> snd_soc_card from init() of snd_soc_dai_link. This is because init()

> is called (and an input device /dev/input/eventX is created too)

> twice or above if simple card has two or more DAI links.

> 

> Signed-off-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>


or above ?

> -	ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX);

> -	if (ret < 0)

> -		return ret;

> -

> -	ret = asoc_simple_card_init_mic(rtd->card, &priv->mic_jack, PREFIX);

> -	if (ret < 0)

> -		return ret;

(snip)
> +	ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL);

> +	if (ret < 0)

> +		return ret;

> +

> +	ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL);

> +	if (ret < 0)

> +		return ret;


I think we want to keep "PREFIX" ?


Best regards
---
Kuninori Morimoto
Katsuhiro Suzuki June 11, 2018, 5:39 a.m. UTC | #2
Hello Morimoto-san,

> -----Original Message-----

> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

> Sent: Monday, June 11, 2018 2:27 PM

> To: Suzuki, Katsuhiro <suzuki.katsuhiro@socionext.com>

> Cc: Mark Brown <broonie@kernel.org>; alsa-devel@alsa-project.org; Masami

Hiramatsu
> <masami.hiramatsu@linaro.org>; Jassi Brar <jaswinder.singh@linaro.org>;

> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org

> Subject: Re: [PATCH v2 2/3] ASoC: simple-card: move hp and mic detection to

soc_card
> probe

> 

> 

> Hi Katsuhiro-san

> 

> > This patch moves headphone and microphone detection to probe() of

> > snd_soc_card from init() of snd_soc_dai_link. This is because init()

> > is called (and an input device /dev/input/eventX is created too)

> > twice or above if simple card has two or more DAI links.

> >

> > Signed-off-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>

> 

> or above ?

> 


It seems if simple card has multiple DAI links, it creates multiple input 
devices.

For example simple card has 3-links, 3 input devices /dev/input/event0,
event1, event2 are created. Is it correct?


> > -	ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX);

> > -	if (ret < 0)

> > -		return ret;

> > -

> > -	ret = asoc_simple_card_init_mic(rtd->card, &priv->mic_jack, PREFIX);

> > -	if (ret < 0)

> > -		return ret;

> (snip)

> > +	ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL);

> > +	if (ret < 0)

> > +		return ret;

> > +

> > +	ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL);

> > +	if (ret < 0)

> > +		return ret;

> 

> I think we want to keep "PREFIX" ?

> 


Oops... Thank you. I'll fix it.


Regards,
--
Katsuhiro Suzuki


> 

> Best regards

> ---

> Kuninori Morimoto
Kuninori Morimoto June 11, 2018, 5:43 a.m. UTC | #3
Hi Katsuhiro

> > > This patch moves headphone and microphone detection to probe() of

> > > snd_soc_card from init() of snd_soc_dai_link. This is because init()

> > > is called (and an input device /dev/input/eventX is created too)

> > > twice or above if simple card has two or more DAI links.

(snip)
> It seems if simple card has multiple DAI links, it creates multiple input 

> devices.

> 

> For example simple card has 3-links, 3 input devices /dev/input/event0,

> event1, event2 are created. Is it correct?


Oh, I see, fair enough.
I'm sorry, it was my English skill error.

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 1bbd9e46bf2a..9eb26ee06892 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -149,14 +149,6 @@  static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 	if (ret < 0)
 		return ret;
 
-	ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX);
-	if (ret < 0)
-		return ret;
-
-	ret = asoc_simple_card_init_mic(rtd->card, &priv->mic_jack, PREFIX);
-	if (ret < 0)
-		return ret;
-
 	return 0;
 }
 
@@ -350,6 +342,22 @@  static int asoc_simple_card_parse_of(struct simple_card_data *priv)
 	return ret;
 }
 
+static int asoc_simple_soc_card_probe(struct snd_soc_card *card)
+{
+	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
+	int ret;
+
+	ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL);
+	if (ret < 0)
+		return ret;
+
+	ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
 static int asoc_simple_card_probe(struct platform_device *pdev)
 {
 	struct simple_card_data *priv;
@@ -385,6 +393,7 @@  static int asoc_simple_card_probe(struct platform_device *pdev)
 	card->dev		= dev;
 	card->dai_link		= priv->dai_link;
 	card->num_links		= num;
+	card->probe		= asoc_simple_soc_card_probe;
 
 	if (np && of_device_is_available(np)) {