From 8a5354140a86b6d4057793a9ed28d29ac8ce6ba6 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 22 Aug 2012 16:40:24 +0200
Subject: [PATCH] ALSA: hda - Call snd_hda_jack_report_sync() generically in hda_codec.c
Git-commit: 8a5354140a86b6d4057793a9ed28d29ac8ce6ba6
Patch-mainline: 3.7-rc1
References: FATE#314311

Instead of calling the jack sync in the init callback of each codec,
call it generically at initialization and resume.  By calling it at
the last of resume sequence, a possible race between the jack sync and
the unsol event enablement in the current code will be closed, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_codec.c      |    2 ++
 sound/pci/hda/patch_cirrus.c   |    1 -
 sound/pci/hda/patch_conexant.c |    1 -
 sound/pci/hda/patch_hdmi.c     |    2 --
 sound/pci/hda/patch_realtek.c  |    2 --
 sound/pci/hda/patch_sigmatel.c |    2 --
 6 files changed, 2 insertions(+), 8 deletions(-)

--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3624,6 +3624,7 @@ static void hda_call_codec_resume(struct
 		snd_hda_codec_resume_amp(codec);
 		snd_hda_codec_resume_cache(codec);
 	}
+	snd_hda_jack_report_sync(codec);
 	snd_hda_power_down(codec); /* flag down before returning */
 }
 #endif /* CONFIG_PM */
@@ -3669,6 +3670,7 @@ int snd_hda_codec_build_controls(struct
 		err = codec->patch_ops.build_controls(codec);
 	if (err < 0)
 		return err;
+	snd_hda_jack_report_sync(codec); /* call at the last init point */
 	return 0;
 }
 
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -1068,7 +1068,6 @@ static int cs_init(struct hda_codec *cod
 	init_output(codec);
 	init_input(codec);
 	init_digital(codec);
-	snd_hda_jack_report_sync(codec);
 
 	return 0;
 }
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -4073,7 +4073,6 @@ static int cx_auto_init(struct hda_codec
 	cx_auto_init_output(codec);
 	cx_auto_init_input(codec);
 	cx_auto_init_digital(codec);
-	snd_hda_jack_report_sync(codec);
 	snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
 	return 0;
 }
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1311,7 +1311,6 @@ static int generic_hdmi_init(struct hda_
 		hdmi_init_pin(codec, pin_nid);
 		snd_hda_jack_detect_enable(codec, pin_nid, pin_nid);
 	}
-	snd_hda_jack_report_sync(codec);
 	return 0;
 }
 
@@ -1428,7 +1427,6 @@ static int simple_playback_init(struct h
 		snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE,
 				    AMP_OUT_UNMUTE);
 	snd_hda_jack_detect_enable(codec, pin, pin);
-	snd_hda_jack_report_sync(codec);
 	return 0;
 }
 
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2052,8 +2052,6 @@ static int alc_init(struct hda_codec *co
 
 	alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
 
-	snd_hda_jack_report_sync(codec);
-
 	hda_call_check_power_status(codec, 0x01);
 	return 0;
 }
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4417,8 +4417,6 @@ static int stac92xx_init(struct hda_code
 		stac_toggle_power_map(codec, nid, 0);
 	}
 
-	snd_hda_jack_report_sync(codec);
-
 	/* sync mute LED */
 	if (spec->gpio_led) {
 		if (spec->vmaster_mute.hook)
