ALSA: hda - bug fix for invalid connection list of Haswell HDMI codec pin
PATCH 1/1 ALSA: hda - bug fix for invalid connection list of Haswell HDMI codec pin
From: Mengdong Lin <[email protected]>
Haswell HDMI codec pins may report invalid connection list entries, which will cause failure to play audio via HDMI.
So this patch
- allow generic hdmi patch to pick up and apply fixups for different codecs.
- add fixup for Haswell to workaround this hardware issue: enable DP1.2 mode and override invalid connection list entries reported by hardware.
sound/pci/hda/patch_hdmi.c +73 -0
@@ -38,6 +38,7 @@#include <sound/tlv.h> #include "hda_codec.h" #include "hda_local.h" +#include "hda_auto_parser.h" #include "hda_jack.h" static bool static_hdmi_pcm;
@@ -79,6 +80,7 @@ struct hdmi_spec_per_pin { };struct hdmi_spec { +struct hda_gen_spec gen;int num_cvts;struct hdmi_spec_per_cvt cvts[MAX_HDMI_CVTS ];
@@ -1687,6 +1689,69 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = { .unsol_event = hdmi_unsol_event, }; +static void intel_haswell_fixup_enable_dp12_mode (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PRE_PROBE ) +return ; + + vendor_param =snd_hda_codec_read (codec,0x08 ,0 ,0xf81 ,0 ); +if (vendor_param ==-1 || vendor_param &0x02 ) +return ; + + vendor_param |=0x02 ; +snd_hda_codec_read (codec,0x08 ,0 ,0x781 , vendor_param); +} + +static void intel_haswell_fixup_connect_list (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +hda_nid_t list[3 ] = {0x2 ,0x3 ,0x4 }; +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PROBE ) +return ; + + vendor_param =snd_hda_codec_read (codec,0x08 ,0 ,0xf81 ,0 ); +if (vendor_param ==-1 || !(vendor_param &0x02 )) +return ; + +snd_hda_override_conn_list (codec,0x06 ,3 , list); +hdmi_read_pin_conn (codec,1 ); +} + + +/* available models for fixup */ +enum { +INTEL_HASWELL , +INTEL_HASWELL_CONNECT_LIST , +}; + +static const struct hda_model_fixup hdmi_models[] = { + {.id =INTEL_HASWELL , .name ="Haswell" }, + {} +}; + +static const struct snd_pci_quirk hdmi_fixup_tbl[] = { +SND_PCI_QUIRK (0x8086 ,0x2010 ,"Haswell" ,INTEL_HASWELL ), + {}/* terminator */ +}; + +static const struct hda_fixup hdmi_fixups[] = { + [INTEL_HASWELL ] = { + .type =HDA_FIXUP_FUNC , + .v.func = intel_haswell_fixup_enable_dp12_mode, + .chained = true, + .chain_id =INTEL_HASWELL_CONNECT_LIST , + }, + [INTEL_HASWELL_CONNECT_LIST ] = { + .type =HDA_FIXUP_FUNC , + .v.func = intel_haswell_fixup_connect_list, + }, +}; +static int patch_generic_hdmi (struct hda_codec *codec) {struct hdmi_spec *spec;
@@ -1696,11 +1761,19 @@ static int patch_generic_hdmi(struct hda_codec *codec)return -ENOMEM ; codec->spec = spec; +snd_hda_gen_init (&spec->gen); + +snd_hda_pick_fixup (codec, hdmi_models, hdmi_fixup_tbl, hdmi_fixups); +snd_hda_apply_fixup (codec,HDA_FIXUP_ACT_PRE_PROBE ); +if (hdmi_parse_codec (codec) <0 ) { codec->spec =NULL ;kfree (spec);return -EINVAL ; } + +snd_hda_apply_fixup (codec,HDA_FIXUP_ACT_PROBE ); + codec->patch_ops = generic_hdmi_patch_ops;generic_hdmi_init_per_pins (codec);
Signature · 1 line
1.7.9.5
At Fri, 14 Dec 2012 13:57:30 -0500,
Quoted 10 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.
So this patch
- allow generic hdmi patch to pick up and apply fixups for different codecs.
- add fixup for Haswell to workaround this hardware issue: enable DP1.2 mode and override invalid connection list entries reported by hardware.
How is DP1.2 enablement involved with this?
I don't see a link between DP1.2 and the lack of connection list...
Quoted 24 lines
Signed-off-by Mengdong Lin <[email protected]>Signed-off-by Xingchao Wang <[email protected]>sound/pci/hda/patch_hdmi.c +2
-0@@ -38,6 +38,7 @@#include <sound/tlv.h> #include "hda_codec.h" #include "hda_local.h" +#include "hda_auto_parser.h" #include "hda_jack.h" static bool static_hdmi_pcm;@@ -79,6 +80,7 @@ struct hdmi_spec_per_pin { };struct hdmi_spec { +struct hda_gen_spec gen;int num_cvts;struct hdmi_spec_per_cvt cvts[MAX_HDMI_CVTS ];
sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1698
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +7
-0@@ -1687,6 +1689,69 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = { .unsol_event = hdmi_unsol_event, }; +static void intel_haswell_fixup_enable_dp12_mode (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PRE_PROBE ) +return ;
Isn't this needed after S4?
Quoted 6 lines
sound/pci/hda/patch_hdmi.c +6
-0+ vendor_param =snd_hda_codec_read (codec,0x08 ,0 ,0xf81 ,0 ); +if (vendor_param ==-1 || vendor_param &0x02 ) +return ; + + vendor_param |=0x02 ; +snd_hda_codec_read (codec,0x08 ,0 ,0x781 , vendor_param);
sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1715
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +10
-0+} + +static void intel_haswell_fixup_connect_list (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +hda_nid_t list[3 ] = {0x2 ,0x3 ,0x4 }; +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PROBE ) +return ;
Is this ACT_PROBE, that is, applied only after parsing the codec? Usually a fixup for overriding the connection list is applied before parsing the tree.
thanks,
Takashi
Quoted 64 lines
sound/pci/hda/patch_hdmi.c +46
-0+ vendor_param =snd_hda_codec_read (codec,0x08 ,0 ,0xf81 ,0 ); +if (vendor_param ==-1 || !(vendor_param &0x02 )) +return ; + +snd_hda_override_conn_list (codec,0x06 ,3 , list); +hdmi_read_pin_conn (codec,1 ); +} + + +/* available models for fixup */ +enum { +INTEL_HASWELL , +INTEL_HASWELL_CONNECT_LIST , +}; + +static const struct hda_model_fixup hdmi_models[] = { + {.id =INTEL_HASWELL , .name ="Haswell" }, + {} +}; + +static const struct snd_pci_quirk hdmi_fixup_tbl[] = { +SND_PCI_QUIRK (0x8086 ,0x2010 ,"Haswell" ,INTEL_HASWELL ), + {}/* terminator */ +}; + +static const struct hda_fixup hdmi_fixups[] = { + [INTEL_HASWELL ] = { + .type =HDA_FIXUP_FUNC , + .v.func = intel_haswell_fixup_enable_dp12_mode, + .chained = true, + .chain_id =INTEL_HASWELL_CONNECT_LIST , + }, + [INTEL_HASWELL_CONNECT_LIST ] = { + .type =HDA_FIXUP_FUNC , + .v.func = intel_haswell_fixup_connect_list, + }, +}; +static int patch_generic_hdmi (struct hda_codec *codec) {struct hdmi_spec *spec;@@ -1696,11 +1761,19 @@ static int patch_generic_hdmi(struct hda_codec *codec)return -ENOMEM ; codec->spec = spec; +snd_hda_gen_init (&spec->gen); + +snd_hda_pick_fixup (codec, hdmi_models, hdmi_fixup_tbl, hdmi_fixups); +snd_hda_apply_fixup (codec,HDA_FIXUP_ACT_PRE_PROBE ); +if (hdmi_parse_codec (codec) <0 ) { codec->spec =NULL ;kfree (spec);return -EINVAL ; } + +snd_hda_apply_fixup (codec,HDA_FIXUP_ACT_PROBE ); + codec->patch_ops = generic_hdmi_patch_ops;generic_hdmi_init_per_pins (codec);Signature · 1 line
1.7.9.5
Quoted 5 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Takashi Iwai
Sent: Friday, December 14, 2012 3:10 PM
Quoted 11 lines
sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1715
Quoted 7 lines
sound/pci/hda/patch_hdmi.c +7
-0+static void intel_haswell_fixup_connect_list (struct hda_codec *codec, +const struct hda_fixup *fix,int action) { +hda_nid_t list[3 ] = {0x2 ,0x3 ,0x4 }; +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PROBE ) +return ;Is this
ACT_PROBE, that is, applied only after parsing the codec? Usually a fixup for overriding the connection list is applied before parsing the tree.
Yes, this fixup is applied after parsing the codec.
Because during parsing, the pin nid#6 may still report invalid connection list entries 0x00000000 in snd_hda_get_raw_connections(), which should be 0x00040302 to stand for 3 output convertors. So we need to overwrite its connection list with the proper value.
But, do you mean we can change this to the pre-probe stage, so that snd_hda_get_raw_connections() need not be called during the parsing the codec? I'll do a test.
Thanks
Mengdong
At Fri, 14 Dec 2012 07:26:28 +0000,
Quoted 19 lines · Mengdong
Quoted 6 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Takashi Iwai
Sent: Friday, December 14, 2012 3:10 PMQuoted 11 lines
sound/pci/hda/patch_hdmi.c static const struct hda_codec_ops generic_hdmi_patch_ops = { · line 1715
Quoted 7 lines
sound/pci/hda/patch_hdmi.c +7
-0+static void intel_haswell_fixup_connect_list (struct hda_codec *codec, +const struct hda_fixup *fix,int action) { +hda_nid_t list[3 ] = {0x2 ,0x3 ,0x4 }; +unsigned int vendor_param; + +if (action !=HDA_FIXUP_ACT_PROBE ) +return ;Is this
ACT_PROBE, that is, applied only after parsing the codec? Usually a fixup for overriding the connection list is applied before parsing the tree.
Quoted 7 lines
Yes, this fixup is applied after parsing the codec.
Because during parsing, the pin nid#6 may still report invalid connection list entries0x00000000insnd_hda_get_raw_connections(), which should be0x00040302to stand for 3 output convertors. So we need to overwrite its connection list with the proper value.But, do you mean we can change this to the pre-probe stage, so that
snd_hda_get_raw_connections()need not be called during the parsing the codec? I'll do a test.
Yes. It may work currently but it might be broken if the parser code is changed, for example. I see no reason why the fixup must be applied after parsing the tree.
Takashi
Quoted 5 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, December 14, 2012 3:50 PM
Quoted 8 lines
Quoted 2 lines
But, do you mean we can change this to the pre-probe stage, so that
snd_hda_get_raw_connections()need not be called during the parsing thecodec? I'll do a test.
Yes. It may work currently but it might be broken if the parser code is changed, for example. I see no reason why the fixup must be applied after parsing the tree.
Hi Takashi,
You're right. Overriding the connection list can work after being merged into the pre-probe stage and so only one fix-up is enough.
I'll update the patch. Many thanks for your advice!
- Mengdong