Commit 606c0cee authored by Wu Fengguang's avatar Wu Fengguang Committed by Takashi Iwai

ALSA: hda - enable HDMI audio pin out at module loading time

We found that enabling/disabling HDMI audio pin out at stream start/stop
time will kill the leading 500ms or so sound samples. Avoid this by enabling
pin out once and for ever at module loading time.

The leading ~500ms audio samples will still be lost when switching from
X-channel playback to Y-channel playback where X != Y. However there's no
much we can do about it: the audio infoframe has to change and it looks like
either G45 or YAMAHA requires some time to switch the configuration.
Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a1667e4e
...@@ -49,11 +49,6 @@ static struct hda_verb pinout_enable_verb[] = { ...@@ -49,11 +49,6 @@ static struct hda_verb pinout_enable_verb[] = {
{} /* terminator */ {} /* terminator */
}; };
static struct hda_verb pinout_disable_verb[] = {
{PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00},
{}
};
static struct hda_verb unsolicited_response_verb[] = { static struct hda_verb unsolicited_response_verb[] = {
{PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN |
INTEL_HDMI_EVENT_TAG}, INTEL_HDMI_EVENT_TAG},
...@@ -248,10 +243,6 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid, ...@@ -248,10 +243,6 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid,
static void hdmi_enable_output(struct hda_codec *codec) static void hdmi_enable_output(struct hda_codec *codec)
{ {
/* Enable Audio InfoFrame Transmission */
hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
AC_DIPXMIT_BEST);
/* Unmute */ /* Unmute */
if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP)
snd_hda_codec_write(codec, PIN_NID, 0, snd_hda_codec_write(codec, PIN_NID, 0,
...@@ -260,17 +251,24 @@ static void hdmi_enable_output(struct hda_codec *codec) ...@@ -260,17 +251,24 @@ static void hdmi_enable_output(struct hda_codec *codec)
snd_hda_sequence_write(codec, pinout_enable_verb); snd_hda_sequence_write(codec, pinout_enable_verb);
} }
static void hdmi_disable_output(struct hda_codec *codec) /*
* Enable Audio InfoFrame Transmission
*/
static void hdmi_start_infoframe_trans(struct hda_codec *codec)
{ {
snd_hda_sequence_write(codec, pinout_disable_verb); hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
snd_hda_codec_write(codec, PIN_NID, 0, AC_DIPXMIT_BEST);
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); }
/* /*
* FIXME: noises may arise when playing music after reloading the * Disable Audio InfoFrame Transmission
* kernel module, until the next X restart or monitor repower.
*/ */
static void hdmi_stop_infoframe_trans(struct hda_codec *codec)
{
hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
AC_DIPXMIT_DISABLE);
} }
static int hdmi_get_channel_count(struct hda_codec *codec) static int hdmi_get_channel_count(struct hda_codec *codec)
...@@ -489,6 +487,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, ...@@ -489,6 +487,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
hdmi_setup_channel_mapping(codec, &ai); hdmi_setup_channel_mapping(codec, &ai);
hdmi_fill_audio_infoframe(codec, &ai); hdmi_fill_audio_infoframe(codec, &ai);
hdmi_start_infoframe_trans(codec);
} }
...@@ -566,7 +565,7 @@ static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo, ...@@ -566,7 +565,7 @@ static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo,
{ {
struct intel_hdmi_spec *spec = codec->spec; struct intel_hdmi_spec *spec = codec->spec;
hdmi_disable_output(codec); hdmi_stop_infoframe_trans(codec);
return snd_hda_multi_out_dig_close(codec, &spec->multiout); return snd_hda_multi_out_dig_close(codec, &spec->multiout);
} }
...@@ -586,8 +585,6 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -586,8 +585,6 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
hdmi_setup_audio_infoframe(codec, substream); hdmi_setup_audio_infoframe(codec, substream);
hdmi_enable_output(codec);
return 0; return 0;
} }
...@@ -632,8 +629,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec) ...@@ -632,8 +629,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec)
static int intel_hdmi_init(struct hda_codec *codec) static int intel_hdmi_init(struct hda_codec *codec)
{ {
/* disable audio output as early as possible */ hdmi_enable_output(codec);
hdmi_disable_output(codec);
snd_hda_sequence_write(codec, unsolicited_response_verb); snd_hda_sequence_write(codec, unsolicited_response_verb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment