Skip to contentSkip to conversation

ASoC: hdac_hdmi: add device PM dependency

PATCH Superseded [email protected] 2 participants 4 messages Apr 1, 2019 – Apr 2, 2019

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

PATCH v2 1/1 ASoC: hdac_hdmi: add device PM dependency

From: Libin Yang <[email protected]>

HDMI audio codec register operation depends on the display audio power domain. The hdmi audio codec dapm event callback must be called after display audio power is turned on.

Add hdac_hdmi_device_link_add() in HDMI audio codec driver. The customer audio driver, such as cAVS/SST and SOF audio driver, can call the function to set the audio power dependency.

---
 sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
 sound/soc/codecs/hdac_hdmi.h |  6 ++++++
 2 files changed, 18 insertions(+)
sound/soc/codecs/hdac_hdmi.c +12 -0
index 5eeb0fe..c991407 100644
@@ -1792,6 +1792,18 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,
 }
 EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init);
 
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags)
+{
+	struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component);
+	struct hdac_device *hdev = hdmi->hdev;
+
+	return device_link_add(consumer, &hdev->dev, flags);
+}
+EXPORT_SYMBOL_GPL(hdac_hdmi_device_link_add);
+
 static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev,
 			struct hdac_hdmi_priv *hdmi, bool detect_pin_caps)
 {
sound/soc/codecs/hdac_hdmi.h +6 -0
index 4fa2fc9..9239c6b 100644
@@ -7,4 +7,10 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm,
 
 int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
 			struct snd_soc_dapm_context *dapm);
+
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags);
+
 #endif /* __HDAC_HDMI_H__ */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 23 lines · On 4/1/19 12:50 AM, [email protected] wrote:

From: Libin Yang <[email protected]>

HDMI audio codec register operation depends on the display audio power domain. The hdmi audio codec dapm event callback must be called after display audio power is turned on.

Add hdac_hdmi_device_link_add() in HDMI audio codec driver. The customer audio driver, such as cAVS/SST and SOF audio driver, can call the function to set the audio power dependency.

---
  sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
  sound/soc/codecs/hdac_hdmi.h |  6 ++++++
  2 files changed, 18 insertions(+)
sound/soc/codecs/hdac_hdmi.c +0 -0
index 5eeb0fe..c991407 100644
@@ -1792,6 +1792,18 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,
  }
  EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init);

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, · line 1803

Quoted 10 lines
sound/soc/codecs/hdac_hdmi.c +9 -0
 
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags)
+{
+	struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component);
+	struct hdac_device *hdev = hdmi->hdev;
+
+	return device_link_add(consumer, &hdev->dev, flags);

Don't you need a matching device_link_free() to avoid a memory leak?

Also what would be the expectations for the flags and do you really want the consumer to set them?

And last, without a patch of the cAVS driver it's hard to see how this might be used.

Quoted 22 lines
sound/soc/codecs/hdac_hdmi.c +3 -0
+}
+EXPORT_SYMBOL_GPL(hdac_hdmi_device_link_add);
+
  static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev,
  			struct hdac_hdmi_priv *hdmi, bool detect_pin_caps)
  {
sound/soc/codecs/hdac_hdmi.h +6 -0
index 4fa2fc9..9239c6b 100644
@@ -7,4 +7,10 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm,
 
  int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
  			struct snd_soc_dapm_context *dapm);
+
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags);
+
  #endif /* __HDAC_HDMI_H__ */
#2 lore raw

Hi Pierre,

Quoted 41 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Monday, April 1, 2019 8:34 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH V2] ASoC: hdac_hdmi: add device PM dependency

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai,

Quoted 21 lines · On 4/1/19 12:50 AM, [email protected] wrote:

From: Libin Yang <[email protected]>

HDMI audio codec register operation depends on the display audio power domain. The hdmi audio codec dapm event callback must be called after display audio power is turned on.

Add hdac_hdmi_device_link_add() in HDMI audio codec driver. The customer audio driver, such as cAVS/SST and SOF audio driver, can call the function to set the audio power dependency.

---
  sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
  sound/soc/codecs/hdac_hdmi.h |  6 ++++++
  2 files changed, 18 insertions(+)
(quoted diff) +0 -0

b/sound/soc/codecs/hdac_hdmi.c index 5eeb0fe..c991407 100644

sound/soc/codecs/hdac_hdmi.c +0 -0
@@ -1792,6 +1792,18 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai,

int device,

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,

Quoted 9 lines
sound/soc/codecs/hdac_hdmi.c +6 -0
  }
  EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init);
 
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags)
+{
+	struct hdac_hdmi_priv *hdmi =

snd_soc_component_get_drvdata(component);

Quoted 5 lines

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, · line 1803

Quoted 3 lines
sound/soc/codecs/hdac_hdmi.c +3 -0
+	struct hdac_device *hdev = hdmi->hdev;
+
+	return device_link_add(consumer, &hdev->dev, flags);

Don't you need a matching device_link_free() to avoid a memory leak?

Right. Sorry for my poor patch and thanks for pointing it out. I will refine it and test tomorrow.

Quoted 3 lines

Also what would be the expectations for the flags and do you really want the consumer to set them?

A consumer setting the flag will be more flexible. For the flag, I'm currently thinking to use DL_FLAG_RPM_ACTIVE. Not sure if it is a good flag.

Quoted 3 lines

And last, without a patch of the cAVS driver it's hard to see how this might be used.

I tried on SOF, it worked. I will check if I have a cAVS environment and will have a test on cAVS.

Regards,
Libin

Quoted 24 lines
Quoted 24 lines
sound/soc/codecs/hdac_hdmi.c +3 -0
+}
+EXPORT_SYMBOL_GPL(hdac_hdmi_device_link_add);
+
  static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev,
  			struct hdac_hdmi_priv *hdmi, bool detect_pin_caps)
  {
(quoted diff) +0 -0

b/sound/soc/codecs/hdac_hdmi.h index 4fa2fc9..9239c6b 100644

sound/soc/codecs/hdac_hdmi.h +6 -0
@@ -7,4 +7,10 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int
 pcm,
 
  int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
  			struct snd_soc_dapm_context *dapm);
+
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags);
+
  #endif /* __HDAC_HDMI_H__ */
#3 lore raw
In reply to Pierre-Louis Bossart

Hi Pierre,

Thanks for pointing out my patch's defect. I think we should call xxx_del() instread of xxx_free().

Hi all,

I found it's a little confusing when releasing the link. I will send out a RFC patch based on Pierre's suggestion. Please kindly help review the logic of releasing the link.

Regards,
Libin

Quoted 103 lines

-----Original Message-----
From: Yang, Libin
Sent: Monday, April 1, 2019 9:44 PM
To: 'Pierre-Louis Bossart' <[email protected]>; alsa- [email protected]; [email protected]; [email protected]
Subject: RE: [alsa-devel] [PATCH V2] ASoC: hdac_hdmi: add device PM dependency

Hi Pierre,

Quoted 43 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Monday, April 1, 2019 8:34 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH V2] ASoC: hdac_hdmi: add device PM dependency

Quoted 21 lines · On 4/1/19 12:50 AM, [email protected] wrote:

From: Libin Yang <[email protected]>

HDMI audio codec register operation depends on the display audio power domain. The hdmi audio codec dapm event callback must be called after display audio power is turned on.

Add hdac_hdmi_device_link_add() in HDMI audio codec driver. The customer audio driver, such as cAVS/SST and SOF audio driver, can call the function to set the audio power dependency.

---
  sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
  sound/soc/codecs/hdac_hdmi.h |  6 ++++++
  2 files changed, 18 insertions(+)
(quoted diff) +0 -0

b/sound/soc/codecs/hdac_hdmi.c index 5eeb0fe..c991407 100644

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai · line 1792

Quoted 1 line
sound/soc/codecs/hdac_hdmi.c +0 -0
@@ -1792,6 +1792,18 @@ int hdac_hdmi_jack_init(struct snd_soc_dai
 *dai,

int device,

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,

Quoted 9 lines
sound/soc/codecs/hdac_hdmi.c +6 -0
  }
  EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init);
 
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags)
+{
+	struct hdac_hdmi_priv *hdmi =

snd_soc_component_get_drvdata(component);

Quoted 5 lines

sound/soc/codecs/hdac_hdmi.c int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, · line 1803

Quoted 3 lines
sound/soc/codecs/hdac_hdmi.c +3 -0
+	struct hdac_device *hdev = hdmi->hdev;
+
+	return device_link_add(consumer, &hdev->dev, flags);

Don't you need a matching device_link_free() to avoid a memory leak?

Right. Sorry for my poor patch and thanks for pointing it out. I will refine it and test tomorrow.

Quoted 3 lines

Also what would be the expectations for the flags and do you really want the consumer to set them?

A consumer setting the flag will be more flexible. For the flag, I'm currently thinking to use DL_FLAG_RPM_ACTIVE. Not sure if it is a good flag.

Quoted 3 lines

And last, without a patch of the cAVS driver it's hard to see how this might be used.

I tried on SOF, it worked. I will check if I have a cAVS environment and will have a test on cAVS.

Regards,
Libin

Quoted 24 lines
Quoted 24 lines
sound/soc/codecs/hdac_hdmi.c +3 -0
+}
+EXPORT_SYMBOL_GPL(hdac_hdmi_device_link_add);
+
  static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev,
  			struct hdac_hdmi_priv *hdmi, bool detect_pin_caps)

{

(quoted diff) +0 -0

b/sound/soc/codecs/hdac_hdmi.h index 4fa2fc9..9239c6b 100644

sound/soc/codecs/hdac_hdmi.h +6 -0
@@ -7,4 +7,10 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int
 pcm,
 
  int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
  			struct snd_soc_dapm_context *dapm);
+
+struct device_link *
+hdac_hdmi_device_link_add(struct device *consumer,
+			  struct snd_soc_component *component,
+			  u32 flags);
+
  #endif /* __HDAC_HDMI_H__ */