Skip to contentSkip to conversation

ALSA: hda - bug fix for invalid connection list of Haswell HDMI codec pins

PATCH Applied [email protected] 3 participants 6 messages Dec 18, 2012 – Jan 17, 2013 Sound

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ALSA: hda - bug fix for invalid connection list of Haswell HDMI codec pins

From: Mengdong Lin <[email protected]>

Haswell HDMI codec pins may report invalid connection list entries, which will cause failure to play audio via HDMI or Display Port.

So this patch adds fixup for Haswell to workaround this hardware issue:
enable DP1.2 mode and override the pins' connection list entries with proper value.

sound/pci/hda/patch_hdmi.c +28 -0
index 71555cc..59abe73 100644
@@ -1687,6 +1687,30 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
 	.unsol_event		= hdmi_unsol_event,
 };
 
+static void intel_haswell_fixup_connect_list(struct hda_codec *codec)
+{
+	unsigned int vendor_param;
+	hda_nid_t list[3] = {0x2, 0x3, 0x4};
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || vendor_param & 0x02)
+		return;
+
+	/* enable DP1.2 mode */
+	vendor_param |= 0x02;
+	snd_hda_codec_read(codec, 0x08, 0, 0x781, vendor_param);
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || !(vendor_param & 0x02))
+		return;
+
+	/* override 3 pins connection list */
+	snd_hda_override_conn_list(codec, 0x05, 3, list);
+	snd_hda_override_conn_list(codec, 0x06, 3, list);
+	snd_hda_override_conn_list(codec, 0x07, 3, list);
+}
+
+
 static int patch_generic_hdmi(struct hda_codec *codec)
 {
 	struct hdmi_spec *spec;
@@ -1696,6 +1720,10 @@ static int patch_generic_hdmi(struct hda_codec *codec)
 		return -ENOMEM;
 
 	codec->spec = spec;
+
+	if (codec->vendor_id == 0x80862807)
+		intel_haswell_fixup_connect_list(codec);
+
 	if (hdmi_parse_codec(codec) < 0) {
 		codec->spec = NULL;
 		kfree(spec);
Signature · 1 line
1.7.9.5
Applied
#1 lore raw

At Tue, 18 Dec 2012 16:59:15 -0500,

Quoted 6 lines · [email protected] wrote:

From: Mengdong Lin <[email protected]>

Haswell HDMI codec pins may report invalid connection list entries, which will cause failure to play audio via HDMI or Display Port.

Quoted 6 lines

So this patch adds fixup for Haswell to workaround this hardware issue:
enable DP1.2 mode and override the pins' connection list entries with proper value.

Thanks, applied now.

Takashi

Quoted 50 lines
sound/pci/hda/patch_hdmi.c +28 -0
index 71555cc..59abe73 100644
@@ -1687,6 +1687,30 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
 	.unsol_event		= hdmi_unsol_event,
 };
 
+static void intel_haswell_fixup_connect_list(struct hda_codec *codec)
+{
+	unsigned int vendor_param;
+	hda_nid_t list[3] = {0x2, 0x3, 0x4};
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || vendor_param & 0x02)
+		return;
+
+	/* enable DP1.2 mode */
+	vendor_param |= 0x02;
+	snd_hda_codec_read(codec, 0x08, 0, 0x781, vendor_param);
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || !(vendor_param & 0x02))
+		return;
+
+	/* override 3 pins connection list */
+	snd_hda_override_conn_list(codec, 0x05, 3, list);
+	snd_hda_override_conn_list(codec, 0x06, 3, list);
+	snd_hda_override_conn_list(codec, 0x07, 3, list);
+}
+
+
 static int patch_generic_hdmi(struct hda_codec *codec)
 {
 	struct hdmi_spec *spec;
@@ -1696,6 +1720,10 @@ static int patch_generic_hdmi(struct hda_codec *codec)
 		return -ENOMEM;
 
 	codec->spec = spec;
+
+	if (codec->vendor_id == 0x80862807)
+		intel_haswell_fixup_connect_list(codec);
+
 	if (hdmi_parse_codec(codec) < 0) {
 		codec->spec = NULL;
 		kfree(spec);
Signature · 1 line
1.7.9.5
#2 lore raw
In reply to [email protected]
Quoted 22 lines · On 12/18/2012 10:59 PM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

Haswell HDMI codec pins may report invalid connection list entries, which will cause failure to play audio via HDMI or Display Port.

So this patch adds fixup for Haswell to workaround this hardware issue:
enable DP1.2 mode and override the pins' connection list entries with proper value.

sound/pci/hda/patch_hdmi.c +2 -0
index 71555cc..59abe73 100644
@@ -1687,6 +1687,30 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
  	.unsol_event		= hdmi_unsol_event,
  };
 
+static void intel_haswell_fixup_connect_list(struct hda_codec *codec)
+{

sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1701

Quoted 10 lines
sound/pci/hda/patch_hdmi.c +10 -0
+	unsigned int vendor_param;
+	hda_nid_t list[3] = {0x2, 0x3, 0x4};
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || vendor_param & 0x02)
+		return;
+
+	/* enable DP1.2 mode */
+	vendor_param |= 0x02;
+	snd_hda_codec_read(codec, 0x08, 0, 0x781, vendor_param);

Hi,

When trying to get Haswell HDMI audio working, I discovered that this verb when executed can get pins to change state from D0 to D3.

As the fixup is executed after hda_call_codec_resume this means that the pins will remain in D3. I'm not entirely sure of this, but I think we have no runtime power transitions if we are on AC power, so this could potentially be for a very long time.

sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1710

Quoted 4 lines
sound/pci/hda/patch_hdmi.c +4 -0
+	/* override 3 pins connection list */
+	snd_hda_override_conn_list(codec, 0x05, 3, list);
+	snd_hda_override_conn_list(codec, 0x06, 3, list);
+	snd_hda_override_conn_list(codec, 0x07, 3, list);

So before the DP 1.2 verb is executed, the connections are
just 5 -> 2, 6 -> 3, 7 -> 4, but afterwards, every pin node can connect to every cvt node, and connection select verbs must change as a result?

Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
#3 lore raw

At Tue, 15 Jan 2013 11:51:23 +0100,

Quoted 37 lines · David Henningsson
Quoted 22 lines · On 12/18/2012 10:59 PM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

Haswell HDMI codec pins may report invalid connection list entries, which will cause failure to play audio via HDMI or Display Port.

So this patch adds fixup for Haswell to workaround this hardware issue:
enable DP1.2 mode and override the pins' connection list entries with proper value.

sound/pci/hda/patch_hdmi.c +2 -0
index 71555cc..59abe73 100644
@@ -1687,6 +1687,30 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
  	.unsol_event		= hdmi_unsol_event,
  };
 
+static void intel_haswell_fixup_connect_list(struct hda_codec *codec)
+{

sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1701

Quoted 10 lines
sound/pci/hda/patch_hdmi.c +10 -0
+	unsigned int vendor_param;
+	hda_nid_t list[3] = {0x2, 0x3, 0x4};
+
+	vendor_param = snd_hda_codec_read(codec, 0x08, 0, 0xf81, 0);
+	if (vendor_param == -1 || vendor_param & 0x02)
+		return;
+
+	/* enable DP1.2 mode */
+	vendor_param |= 0x02;
+	snd_hda_codec_read(codec, 0x08, 0, 0x781, vendor_param);

Hi,

Quoted 2 lines

When trying to get Haswell HDMI audio working, I discovered that this verb when executed can get pins to change state from D0 to D3.

Oh, does this verb do it? It's bad.

Also, Mengdong, could you define these verbs (0x781 & 0xf81) in hda_codec.h to understand and read the code better?

Quoted 4 lines

As the fixup is executed after hda_call_codec_resume this means that the pins will remain in D3. I'm not entirely sure of this, but I think we have no runtime power transitions if we are on AC power, so this could potentially be for a very long time.

Actually you spotted a potential bug -- the code isn't called in the resume callback. This is a code called directly from parse_generic_hdmi(), so it's called only once to override the connections. But the verb 0x781 isn't set.

I thought we can simply replace the call
snd_hda_codec_read(codec, 0x08, 0, 0x781, ...)
with snd_hda_codec_write_cache(), so that the same verb will be executed automatically on resume. But, if this verb has any bad side effect (like touching D state), it's no good idea to do it in the cache resume.

Quoted 8 lines

sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1710

Quoted 4 lines
sound/pci/hda/patch_hdmi.c +4 -0
+	/* override 3 pins connection list */
+	snd_hda_override_conn_list(codec, 0x05, 3, list);
+	snd_hda_override_conn_list(codec, 0x06, 3, list);
+	snd_hda_override_conn_list(codec, 0x07, 3, list);

So before the DP 1.2 verb is executed, the connections are just 5 -> 2, 6 -> 3, 7 -> 4, but afterwards, every pin node can connect to every cvt node, and connection select verbs must change as a result?

This is my understanding, but maybe a bit more comments would be helpful...

thanks,

Takashi

#4 lore raw
Quoted 7 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, January 15, 2013 7:33 PM

Quoted 2 lines

When trying to get Haswell HDMI audio working, I discovered that this verb when executed can get pins to change state from D0 to D3.

Oh, does this verb do it? It's bad.

No, I think these verbs ((0x781 & 0xf81) don't change pin state. So I'm asking David to share more Information.

Quoted 2 lines

Also, Mengdong, could you define these verbs (0x781 & 0xf81) in hda_codec.h to understand and read the code better?

Okay, I will.

Quoted 8 lines
Quoted 4 lines

As the fixup is executed after hda_call_codec_resume this means that the pins will remain in D3. I'm not entirely sure of this, but I think we have no runtime power transitions if we are on AC power, so this could potentially be for a very long time.

Actually you spotted a potential bug -- the code isn't called in the resume callback. This is a code called directly from parse_generic_hdmi(), so it's called only once to override the connections. But the verb 0x781 isn't set.

Yes. intel_haswell_fixup_connect_list() is called only once from parse_generic_hdmi().

Quoted 5 lines

I thought we can simply replace the call snd_hda_codec_read(codec, 0x08, 0, 0x781, ...) with snd_hda_codec_write_cache(), so that the same verb will be executed automatically on resume. But, if this verb has any bad side effect (like touching D state), it's no good idea to do it in the cache resume.

But at first, we need to find out whether snd_hda_codec_read (codec, 0x08, 0, 0x781, ...) cannot bring the codec out of D3 before executing 0x781. I suspect it's not the executing the verb but before that that the whole codec (including the pins) enters D3.

Thanks
Mengdong

#5 lore raw
In reply to David Henningsson
Quoted 5 lines

-----Original Message-----
From: David Henningsson [mailto:[email protected]]
Sent: Tuesday, January 15, 2013 6:51 PM

Quoted 7 lines

When trying to get Haswell HDMI audio working, I discovered that this verb when executed can get pins to change state from D0 to D3.

As the fixup is executed after hda_call_codec_resume this means that the pins will remain in D3. I'm not entirely sure of this, but I think we have no runtime power transitions if we are on AC power, so this could potentially be for a very long time.

Hi David,

Is the "power save" enabled for the codec, by setting a non-zero value to the "power_save" parameter under /sys/module/snd_hda_intel/parametesrs?

The verb 0x0f81/0x0781/ is a vendor verb to query/configure HDMI, but it will not touch the pin's D-state.

I suspect the codec is suspended in D3 during the interval between commands execution, since codec_exec_verb() will call snd_hda_power_down() after a command is done and so the codec will be suspended if 'power save' is enabled. And snd_hda_codec_read() just tries to resume the codec when executing a new command, the calling sequence is snd_hda_codec_read-> codec_exec_verb -> snd_hda_power_up.

Quoted 9 lines

sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1710

Quoted 5 lines
sound/pci/hda/patch_hdmi.c +4 -0
+	/* override 3 pins connection list */
+	snd_hda_override_conn_list(codec, 0x05, 3, list);
+	snd_hda_override_conn_list(codec, 0x06, 3, list);
+	snd_hda_override_conn_list(codec, 0x07, 3, list);

So before the DP 1.2 verb is executed, the connections are just 5 -> 2, 6 -> 3, 7 -> 4, but afterwards, every pin node can connect to every cvt node, and connection select verbs must change as a result?

Yes. Without DP 1.2 there is a 1:1 mapping between pins and convertors. But HDMI cannot play sound. And even DP 1.2 is enabled, HDMI codec can still report invalid empty connect list during initialization. This is a HW issue for Haswell B0 processor.

Which version of Haswell processor is on your machine? Could you share the 'cpu stepping' in BIOS under platform information menu.

We'll verify this issue and side effect of the patch after we got a processor upgrade.

Sorry for the late reply.

Thanks
Mengdong