diff mbox series

[SRU,H/G/OEM-5.10,1/1] ALSA: hda/hdmi: let new platforms assign the pcm slot dynamically

Message ID 20210305060634.7680-2-hui.wang@canonical.com
State New
Headers show
Series alsa/hda: the hdmi audio dosn't work on TGL machines | expand

Commit Message

Hui Wang March 5, 2021, 6:06 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1917829

If the platform set the dyn_pcm_assign to true, it will call
hdmi_find_pcm_slot() to find a pcm slot when hdmi/dp monitor is
connected and need to create a pcm.

So far only intel_hsw_common_init() and patch_nvhdmi() set the
dyn_pcm_assign to true, here we let tgl platforms assign the pcm slot
dynamically first, if the driver runs for a period of time and there
is no regression reported, we could set no_fixed_assgin to true in
the intel_hsw_common_init(), and then set it to true in the
patch_nvhdmi().

This change comes from the discussion between Takashi and
Kai Vehmanen. Please refer to:
https://github.com/alsa-project/alsa-lib/pull/118

Suggested-and-reviewed-by: Takashi Iwai <tiwai@suse.de>
Suggested-and-reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210301111202.2684-1-hui.wang@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 13046370c4d143b629adc1a51659a8a6497fbbe6 linux-next)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_hdmi.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Stefan Bader March 5, 2021, 9 a.m. UTC | #1
On 05.03.21 07:06, Hui Wang wrote:
> BugLink: https://bugs.launchpad.net/bugs/1917829
> 
> If the platform set the dyn_pcm_assign to true, it will call
> hdmi_find_pcm_slot() to find a pcm slot when hdmi/dp monitor is
> connected and need to create a pcm.
> 
> So far only intel_hsw_common_init() and patch_nvhdmi() set the
> dyn_pcm_assign to true, here we let tgl platforms assign the pcm slot
> dynamically first, if the driver runs for a period of time and there
> is no regression reported, we could set no_fixed_assgin to true in
> the intel_hsw_common_init(), and then set it to true in the
> patch_nvhdmi().
> 
> This change comes from the discussion between Takashi and
> Kai Vehmanen. Please refer to:
> https://github.com/alsa-project/alsa-lib/pull/118
> 
> Suggested-and-reviewed-by: Takashi Iwai <tiwai@suse.de>
> Suggested-and-reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> Link: https://lore.kernel.org/r/20210301111202.2684-1-hui.wang@canonical.com
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> (cherry picked from commit 13046370c4d143b629adc1a51659a8a6497fbbe6 linux-next)
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>   sound/pci/hda/patch_hdmi.c | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index 97adff0cbcab..0d004089fcc6 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -157,6 +157,7 @@ struct hdmi_spec {
>   
>   	bool dyn_pin_out;
>   	bool dyn_pcm_assign;
> +	bool dyn_pcm_no_legacy;
>   	bool intel_hsw_fixup;	/* apply Intel platform-specific fixups */
>   	/*
>   	 * Non-generic VIA/NVIDIA specific
> @@ -1345,6 +1346,12 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
>   {
>   	int i;
>   
> +	/* on the new machines, try to assign the pcm slot dynamically,
> +	 * not use the preferred fixed map (legacy way) anymore.
> +	 */
> +	if (spec->dyn_pcm_no_legacy)
> +		goto last_try;
> +
>   	/*
>   	 * generic_hdmi_build_pcms() may allocate extra PCMs on some
>   	 * platforms (with maximum of 'num_nids + dev_num - 1')
> @@ -1374,6 +1381,7 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
>   			return i;
>   	}
>   
> + last_try:
>   	/* the last try; check the empty slots in pins */
>   	for (i = 0; i < spec->num_nids; i++) {
>   		if (!test_bit(i, &spec->pcm_bitmap))
> @@ -2988,8 +2996,16 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec)
>   	 * the index indicate the port number.
>   	 */
>   	static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
> +	int ret;
>   
> -	return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
> +	ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
> +	if (!ret) {
> +		struct hdmi_spec *spec = codec->spec;
> +
> +		spec->dyn_pcm_no_legacy = true;
> +	}
> +
> +	return ret;
>   }
>   
>   /* Intel Baytrail and Braswell; with eld notifier */
>
Andrea Righi March 5, 2021, 12:12 p.m. UTC | #2
On Fri, Mar 05, 2021 at 02:06:34PM +0800, Hui Wang wrote:
> BugLink: https://bugs.launchpad.net/bugs/1917829
> 
> If the platform set the dyn_pcm_assign to true, it will call
> hdmi_find_pcm_slot() to find a pcm slot when hdmi/dp monitor is
> connected and need to create a pcm.
> 
> So far only intel_hsw_common_init() and patch_nvhdmi() set the
> dyn_pcm_assign to true, here we let tgl platforms assign the pcm slot
> dynamically first, if the driver runs for a period of time and there
> is no regression reported, we could set no_fixed_assgin to true in
> the intel_hsw_common_init(), and then set it to true in the
> patch_nvhdmi().
> 
> This change comes from the discussion between Takashi and
> Kai Vehmanen. Please refer to:
> https://github.com/alsa-project/alsa-lib/pull/118
> 
> Suggested-and-reviewed-by: Takashi Iwai <tiwai@suse.de>
> Suggested-and-reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> Link: https://lore.kernel.org/r/20210301111202.2684-1-hui.wang@canonical.com
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> (cherry picked from commit 13046370c4d143b629adc1a51659a8a6497fbbe6 linux-next)
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Looks good to me.

Acked-by: Andrea Righi <andrea.righi@canonical.com>

> ---
>  sound/pci/hda/patch_hdmi.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index 97adff0cbcab..0d004089fcc6 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -157,6 +157,7 @@ struct hdmi_spec {
>  
>  	bool dyn_pin_out;
>  	bool dyn_pcm_assign;
> +	bool dyn_pcm_no_legacy;
>  	bool intel_hsw_fixup;	/* apply Intel platform-specific fixups */
>  	/*
>  	 * Non-generic VIA/NVIDIA specific
> @@ -1345,6 +1346,12 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
>  {
>  	int i;
>  
> +	/* on the new machines, try to assign the pcm slot dynamically,
> +	 * not use the preferred fixed map (legacy way) anymore.
> +	 */
> +	if (spec->dyn_pcm_no_legacy)
> +		goto last_try;
> +
>  	/*
>  	 * generic_hdmi_build_pcms() may allocate extra PCMs on some
>  	 * platforms (with maximum of 'num_nids + dev_num - 1')
> @@ -1374,6 +1381,7 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
>  			return i;
>  	}
>  
> + last_try:
>  	/* the last try; check the empty slots in pins */
>  	for (i = 0; i < spec->num_nids; i++) {
>  		if (!test_bit(i, &spec->pcm_bitmap))
> @@ -2988,8 +2996,16 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec)
>  	 * the index indicate the port number.
>  	 */
>  	static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
> +	int ret;
>  
> -	return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
> +	ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
> +	if (!ret) {
> +		struct hdmi_spec *spec = codec->spec;
> +
> +		spec->dyn_pcm_no_legacy = true;
> +	}
> +
> +	return ret;
>  }
>  
>  /* Intel Baytrail and Braswell; with eld notifier */
> -- 
> 2.25.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 97adff0cbcab..0d004089fcc6 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -157,6 +157,7 @@  struct hdmi_spec {
 
 	bool dyn_pin_out;
 	bool dyn_pcm_assign;
+	bool dyn_pcm_no_legacy;
 	bool intel_hsw_fixup;	/* apply Intel platform-specific fixups */
 	/*
 	 * Non-generic VIA/NVIDIA specific
@@ -1345,6 +1346,12 @@  static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
 {
 	int i;
 
+	/* on the new machines, try to assign the pcm slot dynamically,
+	 * not use the preferred fixed map (legacy way) anymore.
+	 */
+	if (spec->dyn_pcm_no_legacy)
+		goto last_try;
+
 	/*
 	 * generic_hdmi_build_pcms() may allocate extra PCMs on some
 	 * platforms (with maximum of 'num_nids + dev_num - 1')
@@ -1374,6 +1381,7 @@  static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
 			return i;
 	}
 
+ last_try:
 	/* the last try; check the empty slots in pins */
 	for (i = 0; i < spec->num_nids; i++) {
 		if (!test_bit(i, &spec->pcm_bitmap))
@@ -2988,8 +2996,16 @@  static int patch_i915_tgl_hdmi(struct hda_codec *codec)
 	 * the index indicate the port number.
 	 */
 	static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
+	int ret;
 
-	return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
+	ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
+	if (!ret) {
+		struct hdmi_spec *spec = codec->spec;
+
+		spec->dyn_pcm_no_legacy = true;
+	}
+
+	return ret;
 }
 
 /* Intel Baytrail and Braswell; with eld notifier */