diff mbox series

[v3,01/12] ASoC: intel: boards: define some general functions for hdac_hdmi

Message ID 1554992400-28777-2-git-send-email-libin.yang@intel.com (mailing list archive)
State New, archived
Headers show
Series ASoC: intel: add device_link to HDMI audio | expand

Commit Message

Yang, Libin April 11, 2019, 2:19 p.m. UTC
From: Libin Yang <libin.yang@intel.com>

Create hdac_hdmi_common.h and define some general functions related to
hdac_hdmi codec.

Signed-off-by: Libin Yang <libin.yang@intel.com>
---
 sound/soc/intel/boards/hdac_hdmi_common.h | 36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 sound/soc/intel/boards/hdac_hdmi_common.h

Comments

Takashi Iwai April 11, 2019, 2:47 p.m. UTC | #1
On Thu, 11 Apr 2019 16:19:49 +0200,
libin.yang@intel.com wrote:
> 
> +static int hdac_hdmi_add_device_link(struct device *consumer,
> +				     struct device *supplier,
> +				     struct device_link **link)

Missing inline?

But, before sending v4, please hold on.

I'm thinking whether we can do this rather in the component init of
the hdac-hdmi codec driver.  Can't we get the machine device somehow
at the time of codec component init?

Or even if it's too early, there is also late_probe callback that is
called after binding all...  If we can manage to create a link from
the codec side, we need to change only one place, instead of
scattering allover the tree.


thanks,

Takashi
Yang, Libin April 12, 2019, 2:35 a.m. UTC | #2
Hi Takashi,

>-----Original Message-----
>From: Takashi Iwai [mailto:tiwai@suse.de]
>Sent: Thursday, April 11, 2019 10:48 PM
>To: Yang, Libin <libin.yang@intel.com>
>Cc: alsa-devel@alsa-project.org; broonie@kernel.org; pierre-
>louis.bossart@linux.intel.com
>Subject: Re: [alsa-devel] [PATCH v3 01/12] ASoC: intel: boards: define some
>general functions for hdac_hdmi
>
>On Thu, 11 Apr 2019 16:19:49 +0200,
>libin.yang@intel.com wrote:
>>
>> +static int hdac_hdmi_add_device_link(struct device *consumer,
>> +				     struct device *supplier,
>> +				     struct device_link **link)
>
>Missing inline?
>
>But, before sending v4, please hold on.
>
>I'm thinking whether we can do this rather in the component init of the hdac-
>hdmi codec driver.  Can't we get the machine device somehow at the time of
>codec component init?
>
>Or even if it's too early, there is also late_probe callback that is called after
>binding all...  If we can manage to create a link from the codec side, we need
>to change only one place, instead of scattering allover the tree.

We just can call it in component driver probe(). It will not too early. After
the machine registers the soc card, it will call the component->driver->probe().
So it is safe we call device_link_add() in component driver probe().

I will submit a new patch soon.

Regards,
Libin

>
>
>thanks,
>
>Takashi
diff mbox series

Patch

diff --git a/sound/soc/intel/boards/hdac_hdmi_common.h b/sound/soc/intel/boards/hdac_hdmi_common.h
new file mode 100644
index 0000000..277493d
--- /dev/null
+++ b/sound/soc/intel/boards/hdac_hdmi_common.h
@@ -0,0 +1,36 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright(c) 2019 Intel Corporation.
+ */
+
+/*
+ * This file includes the general functions related to hdac_hdmi codec,
+ * which is used by the different boards
+ */
+
+#ifndef __SOUND_SOC_HDAC_HDMI_COMMON
+#define __SOUND_SOC_HDAC_HDMI_COMMON
+
+static int hdac_hdmi_add_device_link(struct device *consumer,
+				     struct device *supplier,
+				     struct device_link **link)
+{
+	/*
+	 * Setup a device_link between machine device and HDMI codec device.
+	 * The machine device is the consumer and the HDMI codec device is
+	 * the supplier. With this setting, we can make sure that the audio
+	 * domain in display power will be always turned on before operating
+	 * on the HDMI audio codec registers.
+	 */
+	if (!(*link))
+		*link = device_link_add(consumer, supplier, DL_FLAG_RPM_ACTIVE |
+					DL_FLAG_AUTOREMOVE_CONSUMER);
+
+	if (!(*link))
+		dev_warn(consumer,
+			 "failed creating device_link for HDMI codec\n");
+
+	return 0;
+}
+
+#endif /* __SOUND_SOC_HDAC_HDMI_COMMON */