aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-10-27 11:56:24 -0400
committerTakashi Iwai <tiwai@suse.de>2008-10-27 11:56:24 -0400
commite044c39ae258678d6ebb09fccb2a0fdf7ec51847 (patch)
treea7a3360678b340aa939272788cab123dbd426c1b /sound
parentda74ae3e32374755e0fbdfed4074cf839a82f615 (diff)
ALSA: hda - Restore default pin configs for realtek codecs
Some machines have broken BIOS resume that doesn't restore the default pin configuration properly, which results in a wrong detection of HP pin. This causes a silent speaker output due to missing HP detection. Related bug: Novell bug#406101 https://bugzilla.novell.com/show_bug.cgi?id=406101 This patch fixes the issue by saving/restoring the default pin configs by the driver itself. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_realtek.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ef4955c73c88..4eceab9bd109 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -307,6 +307,13 @@ struct alc_spec {
307 /* for PLL fix */ 307 /* for PLL fix */
308 hda_nid_t pll_nid; 308 hda_nid_t pll_nid;
309 unsigned int pll_coef_idx, pll_coef_bit; 309 unsigned int pll_coef_idx, pll_coef_bit;
310
311#ifdef SND_HDA_NEEDS_RESUME
312#define ALC_MAX_PINS 16
313 unsigned int num_pins;
314 hda_nid_t pin_nids[ALC_MAX_PINS];
315 unsigned int pin_cfgs[ALC_MAX_PINS];
316#endif
310}; 317};
311 318
312/* 319/*
@@ -2778,6 +2785,64 @@ static void alc_free(struct hda_codec *codec)
2778 codec->spec = NULL; /* to be sure */ 2785 codec->spec = NULL; /* to be sure */
2779} 2786}
2780 2787
2788#ifdef SND_HDA_NEEDS_RESUME
2789static void store_pin_configs(struct hda_codec *codec)
2790{
2791 struct alc_spec *spec = codec->spec;
2792 hda_nid_t nid, end_nid;
2793
2794 end_nid = codec->start_nid + codec->num_nodes;
2795 for (nid = codec->start_nid; nid < end_nid; nid++) {
2796 unsigned int wid_caps = get_wcaps(codec, nid);
2797 unsigned int wid_type =
2798 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2799 if (wid_type != AC_WID_PIN)
2800 continue;
2801 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
2802 break;
2803 spec->pin_nids[spec->num_pins] = nid;
2804 spec->pin_cfgs[spec->num_pins] =
2805 snd_hda_codec_read(codec, nid, 0,
2806 AC_VERB_GET_CONFIG_DEFAULT, 0);
2807 spec->num_pins++;
2808 }
2809}
2810
2811static void resume_pin_configs(struct hda_codec *codec)
2812{
2813 struct alc_spec *spec = codec->spec;
2814 int i;
2815
2816 for (i = 0; i < spec->num_pins; i++) {
2817 hda_nid_t pin_nid = spec->pin_nids[i];
2818 unsigned int pin_config = spec->pin_cfgs[i];
2819 snd_hda_codec_write(codec, pin_nid, 0,
2820 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2821 pin_config & 0x000000ff);
2822 snd_hda_codec_write(codec, pin_nid, 0,
2823 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2824 (pin_config & 0x0000ff00) >> 8);
2825 snd_hda_codec_write(codec, pin_nid, 0,
2826 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2827 (pin_config & 0x00ff0000) >> 16);
2828 snd_hda_codec_write(codec, pin_nid, 0,
2829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2830 pin_config >> 24);
2831 }
2832}
2833
2834static int alc_resume(struct hda_codec *codec)
2835{
2836 resume_pin_configs(codec);
2837 codec->patch_ops.init(codec);
2838 snd_hda_codec_resume_amp(codec);
2839 snd_hda_codec_resume_cache(codec);
2840 return 0;
2841}
2842#else
2843#define store_pin_configs(codec)
2844#endif
2845
2781/* 2846/*
2782 */ 2847 */
2783static struct hda_codec_ops alc_patch_ops = { 2848static struct hda_codec_ops alc_patch_ops = {
@@ -2786,6 +2851,9 @@ static struct hda_codec_ops alc_patch_ops = {
2786 .init = alc_init, 2851 .init = alc_init,
2787 .free = alc_free, 2852 .free = alc_free,
2788 .unsol_event = alc_unsol_event, 2853 .unsol_event = alc_unsol_event,
2854#ifdef SND_HDA_NEEDS_RESUME
2855 .resume = alc_resume,
2856#endif
2789#ifdef CONFIG_SND_HDA_POWER_SAVE 2857#ifdef CONFIG_SND_HDA_POWER_SAVE
2790 .check_power_status = alc_check_power_status, 2858 .check_power_status = alc_check_power_status,
2791#endif 2859#endif
@@ -3832,6 +3900,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3832 spec->num_mux_defs = 1; 3900 spec->num_mux_defs = 1;
3833 spec->input_mux = &spec->private_imux; 3901 spec->input_mux = &spec->private_imux;
3834 3902
3903 store_pin_configs(codec);
3835 return 1; 3904 return 1;
3836} 3905}
3837 3906
@@ -5250,6 +5319,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5250 } 5319 }
5251 spec->num_mixers++; 5320 spec->num_mixers++;
5252 5321
5322 store_pin_configs(codec);
5253 return 1; 5323 return 1;
5254} 5324}
5255 5325
@@ -10313,6 +10383,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10313 if (err < 0) 10383 if (err < 0)
10314 return err; 10384 return err;
10315 10385
10386 store_pin_configs(codec);
10316 return 1; 10387 return 1;
10317} 10388}
10318 10389
@@ -11447,6 +11518,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11447 if (err < 0) 11518 if (err < 0)
11448 return err; 11519 return err;
11449 11520
11521 store_pin_configs(codec);
11450 return 1; 11522 return 1;
11451} 11523}
11452 11524
@@ -12230,6 +12302,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12230 spec->mixers[spec->num_mixers] = alc269_capture_mixer; 12302 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
12231 spec->num_mixers++; 12303 spec->num_mixers++;
12232 12304
12305 store_pin_configs(codec);
12233 return 1; 12306 return 1;
12234} 12307}
12235 12308
@@ -13316,6 +13389,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13316 spec->mixers[spec->num_mixers] = alc861_capture_mixer; 13389 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
13317 spec->num_mixers++; 13390 spec->num_mixers++;
13318 13391
13392 store_pin_configs(codec);
13319 return 1; 13393 return 1;
13320} 13394}
13321 13395
@@ -14427,6 +14501,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14427 if (err < 0) 14501 if (err < 0)
14428 return err; 14502 return err;
14429 14503
14504 store_pin_configs(codec);
14430 return 1; 14505 return 1;
14431} 14506}
14432 14507
@@ -16258,6 +16333,8 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16258 16333
16259 spec->mixers[spec->num_mixers] = alc662_capture_mixer; 16334 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16260 spec->num_mixers++; 16335 spec->num_mixers++;
16336
16337 store_pin_configs(codec);
16261 return 1; 16338 return 1;
16262} 16339}
16263 16340