Skip to contentSkip to conversation

ASoC: cAVS: add device_link to HDMI audio

PATCH In review [email protected] 5 participants 10 messages Apr 8, 2019 – Apr 10, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: cAVS: add device_link to HDMI audio

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.

---
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
 sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++
 3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +15 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
 #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+
+	if (!ctx->link)
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
 {
 	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
@@ -48,6 +60,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp1 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi1",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -58,6 +71,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp2 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi2",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -68,6 +82,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp3 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi3",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
index 87c50af..df5cc6b 100644
@@ -29,6 +29,7 @@ struct skl_hda_private {
 	int pcm_count;
 	int dai_index;
 	const char *platform_name;
+	struct device_link *link;
 };
 
 extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
sound/soc/intel/boards/skl_hda_dsp_generic.c +12 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
 	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
 }
 
+static int skl_hda_audio_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
 static struct platform_driver skl_hda_audio = {
 	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
 	.driver = {
 		.name = "skl_hda_dsp_generic",
 		.pm = &snd_soc_pm_ops,
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Mon, 08 Apr 2019 03:21:53 +0200, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.

Quoted 5 lines

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.

Looks good to me. Maybe it's worth to put a brief comment in skl_hdmi_init() why this device link is needed, though.

Feel free to take my ack:

thanks,

Takashi

Quoted 98 lines
---
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
 sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++
 3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +15 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
 #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+
+	if (!ctx->link)
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
 {
 	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
@@ -48,6 +60,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp1 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi1",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -58,6 +71,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp2 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi2",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -68,6 +82,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.cpu_dai_name = "iDisp3 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi3",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
index 87c50af..df5cc6b 100644
@@ -29,6 +29,7 @@ struct skl_hda_private {
 	int pcm_count;
 	int dai_index;
 	const char *platform_name;
+	struct device_link *link;
 };
 
 extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
sound/soc/intel/boards/skl_hda_dsp_generic.c +12 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
 	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
 }
 
+static int skl_hda_audio_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
 static struct platform_driver skl_hda_audio = {
 	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
 	.driver = {
 		.name = "skl_hda_dsp_generic",
 		.pm = &snd_soc_pm_ops,
Signature · 6 lines
2.7.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw

Hi Takashi,

Quoted 18 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, April 8, 2019 8:35 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; pierre- [email protected]
Subject: Re: [alsa-devel] [PATCH] ASoC: cAVS: add device_link to HDMI audio

Quoted 6 lines · On Mon, 08 Apr 2019 03:21:53 +0200, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec

driver.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.

Looks good to me. Maybe it's worth to put a brief comment in skl_hdmi_init() why this device link is needed, though.

I will do it. Thanks for the review and the advice.

Regards,
Libin

Quoted 111 lines

Feel free to take my ack:

thanks,

Takashi

Quoted 19 lines
---
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++
 3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +4 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
 #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd) {
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+

sound/soc/intel/boards/skl_hda_dsp_common.c line 22

Quoted 10 lines
sound/soc/intel/boards/skl_hda_dsp_common.c +7 -1
+	if (!ctx->link)
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)  {
 	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card); @@
-48,6 +60,7 @@ struct snd_soc_dai_link

skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

sound/soc/intel/boards/skl_hda_dsp_common.c struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

Quoted 7 lines
sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
 		.cpu_dai_name = "iDisp1 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi1",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, @@ -58,6 +71,7

@@ struct

sound/soc/intel/boards/skl_hda_dsp_common.c struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

Quoted 8 lines

snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
 		.cpu_dai_name = "iDisp2 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi2",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, @@ -68,6 +82,7

@@ struct

sound/soc/intel/boards/skl_hda_dsp_generic.c static int skl_hda_audio_probe(struct

Quoted 28 lines

snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
 		.cpu_dai_name = "iDisp3 Pin",
 		.codec_name = "ehdaudio0D2",
 		.codec_dai_name = "intel-hdmi-hifi3",
+		.init = skl_hdmi_init,
 		.dpcm_playback = 1,
 		.no_pcm = 1,
 		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, diff --git

a/sound/soc/intel/boards/skl_hda_dsp_common.h
b/sound/soc/intel/boards/skl_hda_dsp_common.h
index 87c50af..df5cc6b 100644

sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
@@ -29,6 +29,7 @@ struct skl_hda_private {
 	int pcm_count;
 	int dai_index;
 	const char *platform_name;
+	struct device_link *link;
 };
 
 extern struct snd_soc_dai_link

skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];

sound/soc/intel/boards/skl_hda_dsp_generic.c +0 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct

platform_device *pdev)

Quoted 26 lines
sound/soc/intel/boards/skl_hda_dsp_generic.c +11 -1
 	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);  }
 
+static int skl_hda_audio_remove(struct platform_device *pdev) {
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
 static struct platform_driver skl_hda_audio = {
 	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
 	.driver = {
 		.name = "skl_hda_dsp_generic",
 		.pm = &snd_soc_pm_ops,
--

2.7.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
In reply to [email protected]
Quoted 10 lines · On 4/7/19 8:21 PM, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.

Quoted 5 lines
---
  sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
  sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
  sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++

It's Monday morning and I have mixed feelings about this fix.

0. What does 'resume from S3' mean? from the description it looks like the application was playing already before entering S3? I am ready to bet it's a use case that was never tested in the past given that Chromebooks tend to stop all streams before entering S3...

1. As discussed in other threads, Takashi suggested that maybe the INFO_RESUME flag should be removed? What would be the impact should we indeed remove this flag, is this patch still necessary?

2. if this is really a generic issue then shouldn't it be fixed for all users of the iDISP link? Why stop at the HDAudio machine driver?

3. we already have the component model to deal with interaction between i915 and audio, now we are adding a second layer. That looks clunky.

Thanks
-Pierre

Quoted 87 lines
  3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +15 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
  #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+
+	if (!ctx->link)
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
  int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
  {
  	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
@@ -48,6 +60,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp1 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi1",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -58,6 +71,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp2 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi2",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
@@ -68,6 +82,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp3 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi3",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,
sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
index 87c50af..df5cc6b 100644
@@ -29,6 +29,7 @@ struct skl_hda_private {
  	int pcm_count;
  	int dai_index;
  	const char *platform_name;
+	struct device_link *link;
  };
 
  extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
sound/soc/intel/boards/skl_hda_dsp_generic.c +12 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
  	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
  }
 
+static int skl_hda_audio_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
  static struct platform_driver skl_hda_audio = {
  	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
  	.driver = {
  		.name = "skl_hda_dsp_generic",
  		.pm = &snd_soc_pm_ops,
#4 lore raw

Hi Pierre,

Quoted 27 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Monday, April 8, 2019 9:15 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH] ASoC: cAVS: add device_link to HDMI audio

Quoted 5 lines · On 4/7/19 8:21 PM, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec

driver.

Quoted 10 lines

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct.

---
  sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
  sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
  sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++
Quoted 6 lines

It's Monday morning and I have mixed feelings about this fix.

0. What does 'resume from S3' mean? from the description it looks like the application was playing already before entering S3? I am ready to bet it's a use case that was never tested in the past given that Chromebooks tend to stop all streams before entering S3...

Yes, this patch is fixing the case of HDMI audio S3 with playback. Chrome has different behavior from aplay and etc. As you described, chrome will stop the streams when suspend and start the stream when resume. So suspend/resume when HDMI playback in chrome will never hit this bug. And our QA test result does show chrome is OK even without this patch.

Quoted 4 lines

1. As discussed in other threads, Takashi suggested that maybe the INFO_RESUME flag should be removed? What would be the impact should we indeed remove this flag, is this patch still necessary?

That is another issue. Actually, our sof has 2 bugs in HDMI S3 with playback. One is DMA link setting. The other is the bug this patch try to fix. Another thread is used to fix the DMA link setting.

Quoted 3 lines

2. if this is really a generic issue then shouldn't it be fixed for all users of the iDISP link? Why stop at the HDAudio machine driver?

I will submit other patches for other machine drivers. Which HDAudio machine driver do you mean?

Quoted 3 lines

3. we already have the component model to deal with interaction between i915 and audio, now we are adding a second layer. That looks clunky.

The component model between i915 and audio is used to communicate between display driver and audio driver. This patch is used to setup the consumer and supplier relationship.

Regards,
Libin

Quoted 97 lines

Thanks
-Pierre

Quoted 16 lines
  3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +5 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
  #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd) {
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+
+	if (!ctx->link)

sound/soc/intel/boards/skl_hda_dsp_common.c

Quoted 10 lines
sound/soc/intel/boards/skl_hda_dsp_common.c +6 -1
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
  int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
  {
  	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card); @@
-48,6 +60,7 @@ struct snd_soc_dai_link

skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

sound/soc/intel/boards/skl_hda_dsp_common.c struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

Quoted 7 lines

.cpu_dai_name = "iDisp1 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi1",

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, @@ -58,6 +71,7

@@ struct

sound/soc/intel/boards/skl_hda_dsp_common.c struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {

Quoted 8 lines

snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
.cpu_dai_name = "iDisp2 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi2",

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, @@ -68,6 +82,7

@@ struct

sound/soc/intel/boards/skl_hda_dsp_generic.c static int skl_hda_audio_probe(struct

Quoted 28 lines

snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
.cpu_dai_name = "iDisp3 Pin", .codec_name = "ehdaudio0D2", .codec_dai_name = "intel-hdmi-hifi3",

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,
  		.trigger[0] = SND_SOC_DPCM_TRIGGER_POST, diff --git

a/sound/soc/intel/boards/skl_hda_dsp_common.h
b/sound/soc/intel/boards/skl_hda_dsp_common.h
index 87c50af..df5cc6b 100644

sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
@@ -29,6 +29,7 @@ struct skl_hda_private {
  	int pcm_count;
  	int dai_index;
  	const char *platform_name;
+	struct device_link *link;
  };
 
  extern struct snd_soc_dai_link

skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];

sound/soc/intel/boards/skl_hda_dsp_generic.c +0 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct

platform_device *pdev)

Quoted 20 lines
sound/soc/intel/boards/skl_hda_dsp_generic.c +11 -0
  	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
  }
 
+static int skl_hda_audio_remove(struct platform_device *pdev) {
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
  static struct platform_driver skl_hda_audio = {
  	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
  	.driver = {
  		.name = "skl_hda_dsp_generic",
  		.pm = &snd_soc_pm_ops,
#5 lore raw
Quoted 6 lines
Quoted 3 lines

2. if this is really a generic issue then shouldn't it be fixed for all users of the iDISP link? Why stop at the HDAudio machine driver?

I will submit other patches for other machine drivers. Which HDAudio machine driver do you mean?

if you plan on updating other drivers, then by all means let's use a common set of helper functions. I see you have follow-up patches on github already, let's avoid copy/paste if possible if the same functionality is needed in multiple places.

Quoted 7 lines
Quoted 3 lines

3. we already have the component model to deal with interaction between i915 and audio, now we are adding a second layer. That looks clunky.

The component model between i915 and audio is used to communicate between display driver and audio driver. This patch is used to setup the consumer and supplier relationship.

consumer of what? it's very vague for people who haven't really looked into the details.

#6 lore raw

Hi Pierre,

Quoted 11 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Monday, April 8, 2019 10:43 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH] ASoC: cAVS: add device_link to HDMI audio

Quoted 3 lines
Quoted 2 lines

2. if this is really a generic issue then shouldn't it be fixed for all users of the iDISP link? Why stop at the HDAudio machine driver?

Quoted 7 lines
Quoted 2 lines

I will submit other patches for other machine drivers. Which HDAudio machine driver do you mean?

if you plan on updating other drivers, then by all means let's use a common set of helper functions. I see you have follow-up patches on github already, let's avoid copy/paste if possible if the same functionality is needed in multiple places.

Sure, I will do it. Thanks for suggestion.

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

3. we already have the component model to deal with interaction between i915 and audio, now we are adding a second layer. That looks clunky.

The component model between i915 and audio is used to communicate between display driver and audio driver. This patch is used to setup the consumer and supplier relationship.

consumer of what? it's very vague for people who haven't really looked into the details.

In our case, the consumer is the machine device, and it's the consumer of the HDMI codec device. I will add the comments in the patch.

Regards,
Libin

#7 lore raw
In reply to Pierre-Louis Bossart
Quoted 30 lines · Pierre-Louis Bossart
Quoted 13 lines · On 4/7/19 8:21 PM, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be
operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.

This patch adds the device_link between cAVS generic machine device (consumer) and hdmi codec device (supplier) to make sure the sequence is
always correct.

Quoted 5 lines
---
  sound/soc/intel/boards/skl_hda_dsp_common.c  | 15 +++++++++++++++
  sound/soc/intel/boards/skl_hda_dsp_common.h  |  1 +
  sound/soc/intel/boards/skl_hda_dsp_generic.c | 12 ++++++++++++

It's Monday morning and I have mixed feelings about this fix.

0. What does 'resume from S3' mean? from the description it looks like
the application was playing already before entering S3? I am ready to
bet it's a use case that was never tested in the past given that Chromebooks tend to stop all streams before entering S3...

Quoted 4 lines

1. As discussed in other threads, Takashi suggested that maybe the INFO_RESUME flag should be removed? What would be the impact should we
indeed remove this flag, is this patch still necessary?

Hi Pierre,

I can confirm that this patch is necessary even if INFO_RESUME is not set.

Thanks,
Ranjani

Quoted 113 lines

2. if this is really a generic issue then shouldn't it be fixed for all
users of the iDISP link? Why stop at the HDAudio machine driver?

3. we already have the component model to deal with interaction between
i915 and audio, now we are adding a second layer. That looks clunky.

Thanks
-Pierre

Quoted 94 lines
  3 files changed, 28 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_common.c +12 -0
index 9b30c0e..01c8937 100644
@@ -17,6 +17,18 @@
 
  #define NAME_SIZE	32
 
+static int skl_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(rtd-
 >card);
+	struct snd_soc_dai *dai = rtd->codec_dai;
+
+	if (!ctx->link)
+		ctx->link = device_link_add(rtd->card->dev, dai->dev,
+					    DL_FLAG_RPM_ACTIVE);
+
+	return 0;
+}
+
  int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
  {
  	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
@@ -48,6 +60,7 @@ struct snd_soc_dai_link
 skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp1 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi1",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,

.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
@@ -58,6 +71,7 @@ struct snd_soc_dai_link
 skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp2 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi2",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,

.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,

sound/soc/intel/boards/skl_hda_dsp_common.c +1 -0
@@ -68,6 +82,7 @@ struct snd_soc_dai_link
 skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
  		.cpu_dai_name = "iDisp3 Pin",
  		.codec_name = "ehdaudio0D2",
  		.codec_dai_name = "intel-hdmi-hifi3",
+		.init = skl_hdmi_init,
  		.dpcm_playback = 1,
  		.no_pcm = 1,

.trigger[0] = SND_SOC_DPCM_TRIGGER_POST,

sound/soc/intel/boards/skl_hda_dsp_common.h +1 -0
index 87c50af..df5cc6b 100644
@@ -29,6 +29,7 @@ struct skl_hda_private {
  	int pcm_count;
  	int dai_index;
  	const char *platform_name;
+	struct device_link *link;
  };
 
  extern struct snd_soc_dai_link

skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];

sound/soc/intel/boards/skl_hda_dsp_generic.c +12 -0
index b9a21e6..ceca11e 100644
@@ -166,8 +166,20 @@ static int skl_hda_audio_probe(struct
 platform_device *pdev)
  	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
  }
 
+static int skl_hda_audio_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+
+	if (ctx->link)
+		device_link_del(ctx->link);
+
+	return 0;
+}
+
  static struct platform_driver skl_hda_audio = {
  	.probe = skl_hda_audio_probe,
+	.remove = skl_hda_audio_remove,
  	.driver = {
  		.name = "skl_hda_dsp_generic",
Quoted 2 lines

.pm = &snd_soc_pm_ops,

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#8 lore raw
In reply to [email protected]
Quoted 5 lines · On Mon, Apr 08, 2019 at 09:21:53AM +0800, [email protected] wrote:

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver.

This doesn't apply against current code, please check and resend.

#9 lore raw

Hi Mark,

Quoted 9 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, April 10, 2019 7:30 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; pierre- [email protected]
Subject: Re: [alsa-devel] [PATCH] ASoC: cAVS: add device_link to HDMI audio

On Mon, Apr 08, 2019 at 09:21:53AM +0800, [email protected] wrote:

Quoted 8 lines
Quoted 5 lines

From: Libin Yang <[email protected]>

In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec

driver.

This doesn't apply against current code, please check and resend.

Got it. Thanks. I will update the patch based on the latest code.

Regards,
Libin