aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c693
1 files changed, 517 insertions, 176 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 1d07e8fa243..5e82acf77c5 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -33,6 +33,7 @@
33#include "hda_codec.h" 33#include "hda_codec.h"
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_beep.h" 35#include "hda_beep.h"
36#include "hda_jack.h"
36 37
37/* unsol event tags */ 38/* unsol event tags */
38#define ALC_FRONT_EVENT 0x01 39#define ALC_FRONT_EVENT 0x01
@@ -183,6 +184,8 @@ struct alc_spec {
183 unsigned int single_input_src:1; 184 unsigned int single_input_src:1;
184 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ 185 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
185 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ 186 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
187 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */
188 unsigned int use_jack_tbl:1; /* 1 for model=auto */
186 189
187 /* auto-mute control */ 190 /* auto-mute control */
188 int automute_mode; 191 int automute_mode;
@@ -283,6 +286,8 @@ static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
283 spec->capsrc_nids[idx] : spec->adc_nids[idx]; 286 spec->capsrc_nids[idx] : spec->adc_nids[idx];
284} 287}
285 288
289static void call_update_outputs(struct hda_codec *codec);
290
286/* select the given imux item; either unmute exclusively or select the route */ 291/* select the given imux item; either unmute exclusively or select the route */
287static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, 292static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
288 unsigned int idx, bool force) 293 unsigned int idx, bool force)
@@ -306,6 +311,19 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
306 return 0; 311 return 0;
307 spec->cur_mux[adc_idx] = idx; 312 spec->cur_mux[adc_idx] = idx;
308 313
314 /* for shared I/O, change the pin-control accordingly */
315 if (spec->shared_mic_hp) {
316 /* NOTE: this assumes that there are only two inputs, the
317 * first is the real internal mic and the second is HP jack.
318 */
319 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
320 AC_VERB_SET_PIN_WIDGET_CONTROL,
321 spec->cur_mux[adc_idx] ?
322 PIN_VREF80 : PIN_HP);
323 spec->automute_speaker = !spec->cur_mux[adc_idx];
324 call_update_outputs(codec);
325 }
326
309 if (spec->dyn_adc_switch) { 327 if (spec->dyn_adc_switch) {
310 alc_dyn_adc_pcm_resetup(codec, idx); 328 alc_dyn_adc_pcm_resetup(codec, idx);
311 adc_idx = spec->dyn_adc_idx[idx]; 329 adc_idx = spec->dyn_adc_idx[idx];
@@ -450,46 +468,6 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
450} 468}
451 469
452/* 470/*
453 * Jack-reporting via input-jack layer
454 */
455
456/* initialization of jacks; currently checks only a few known pins */
457static int alc_init_jacks(struct hda_codec *codec)
458{
459#ifdef CONFIG_SND_HDA_INPUT_JACK
460 struct alc_spec *spec = codec->spec;
461 int err;
462 unsigned int hp_nid = spec->autocfg.hp_pins[0];
463 unsigned int mic_nid = spec->ext_mic_pin;
464 unsigned int dock_nid = spec->dock_mic_pin;
465
466 if (hp_nid) {
467 err = snd_hda_input_jack_add(codec, hp_nid,
468 SND_JACK_HEADPHONE, NULL);
469 if (err < 0)
470 return err;
471 snd_hda_input_jack_report(codec, hp_nid);
472 }
473
474 if (mic_nid) {
475 err = snd_hda_input_jack_add(codec, mic_nid,
476 SND_JACK_MICROPHONE, NULL);
477 if (err < 0)
478 return err;
479 snd_hda_input_jack_report(codec, mic_nid);
480 }
481 if (dock_nid) {
482 err = snd_hda_input_jack_add(codec, dock_nid,
483 SND_JACK_MICROPHONE, NULL);
484 if (err < 0)
485 return err;
486 snd_hda_input_jack_report(codec, dock_nid);
487 }
488#endif /* CONFIG_SND_HDA_INPUT_JACK */
489 return 0;
490}
491
492/*
493 * Jack detections for HP auto-mute and mic-switch 471 * Jack detections for HP auto-mute and mic-switch
494 */ 472 */
495 473
@@ -502,7 +480,6 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
502 hda_nid_t nid = pins[i]; 480 hda_nid_t nid = pins[i];
503 if (!nid) 481 if (!nid)
504 break; 482 break;
505 snd_hda_input_jack_report(codec, nid);
506 present |= snd_hda_jack_detect(codec, nid); 483 present |= snd_hda_jack_detect(codec, nid);
507 } 484 }
508 return present; 485 return present;
@@ -554,7 +531,8 @@ static void update_outputs(struct hda_codec *codec)
554 * in general, HP pins/amps control should be enabled in all cases, 531 * in general, HP pins/amps control should be enabled in all cases,
555 * but currently set only for master_mute, just to be safe 532 * but currently set only for master_mute, just to be safe
556 */ 533 */
557 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 534 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
535 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
558 spec->autocfg.hp_pins, spec->master_mute, true); 536 spec->autocfg.hp_pins, spec->master_mute, true);
559 537
560 if (!spec->automute_speaker) 538 if (!spec->automute_speaker)
@@ -641,19 +619,18 @@ static void alc_mic_automute(struct hda_codec *codec)
641 alc_mux_select(codec, 0, spec->dock_mic_idx, false); 619 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
642 else 620 else
643 alc_mux_select(codec, 0, spec->int_mic_idx, false); 621 alc_mux_select(codec, 0, spec->int_mic_idx, false);
644
645 snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]);
646 if (spec->dock_mic_idx >= 0)
647 snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]);
648} 622}
649 623
650/* unsolicited event for HP jack sensing */ 624/* unsolicited event for HP jack sensing */
651static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 625static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
652{ 626{
627 struct alc_spec *spec = codec->spec;
653 if (codec->vendor_id == 0x10ec0880) 628 if (codec->vendor_id == 0x10ec0880)
654 res >>= 28; 629 res >>= 28;
655 else 630 else
656 res >>= 26; 631 res >>= 26;
632 if (spec->use_jack_tbl)
633 res = snd_hda_jack_get_action(codec, res);
657 switch (res) { 634 switch (res) {
658 case ALC_HP_EVENT: 635 case ALC_HP_EVENT:
659 alc_hp_automute(codec); 636 alc_hp_automute(codec);
@@ -665,6 +642,7 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
665 alc_mic_automute(codec); 642 alc_mic_automute(codec);
666 break; 643 break;
667 } 644 }
645 snd_hda_jack_report_sync(codec);
668} 646}
669 647
670/* call init functions of standard auto-mute helpers */ 648/* call init functions of standard auto-mute helpers */
@@ -954,9 +932,7 @@ static void alc_init_automute(struct hda_codec *codec)
954 continue; 932 continue;
955 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 933 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
956 nid); 934 nid);
957 snd_hda_codec_write_cache(codec, nid, 0, 935 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT);
958 AC_VERB_SET_UNSOLICITED_ENABLE,
959 AC_USRSP_EN | ALC_HP_EVENT);
960 spec->detect_hp = 1; 936 spec->detect_hp = 1;
961 } 937 }
962 938
@@ -968,9 +944,8 @@ static void alc_init_automute(struct hda_codec *codec)
968 continue; 944 continue;
969 snd_printdd("realtek: Enable Line-Out " 945 snd_printdd("realtek: Enable Line-Out "
970 "auto-muting on NID 0x%x\n", nid); 946 "auto-muting on NID 0x%x\n", nid);
971 snd_hda_codec_write_cache(codec, nid, 0, 947 snd_hda_jack_detect_enable(codec, nid,
972 AC_VERB_SET_UNSOLICITED_ENABLE, 948 ALC_FRONT_EVENT);
973 AC_USRSP_EN | ALC_FRONT_EVENT);
974 spec->detect_lo = 1; 949 spec->detect_lo = 1;
975 } 950 }
976 spec->automute_lo_possible = spec->detect_hp; 951 spec->automute_lo_possible = spec->detect_hp;
@@ -1109,13 +1084,10 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1109 return false; /* no corresponding imux */ 1084 return false; /* no corresponding imux */
1110 } 1085 }
1111 1086
1112 snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0, 1087 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT);
1113 AC_VERB_SET_UNSOLICITED_ENABLE,
1114 AC_USRSP_EN | ALC_MIC_EVENT);
1115 if (spec->dock_mic_pin) 1088 if (spec->dock_mic_pin)
1116 snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0, 1089 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin,
1117 AC_VERB_SET_UNSOLICITED_ENABLE, 1090 ALC_MIC_EVENT);
1118 AC_USRSP_EN | ALC_MIC_EVENT);
1119 1091
1120 spec->auto_mic_valid_imux = 1; 1092 spec->auto_mic_valid_imux = 1;
1121 spec->auto_mic = 1; 1093 spec->auto_mic = 1;
@@ -1133,6 +1105,9 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1133 hda_nid_t fixed, ext, dock; 1105 hda_nid_t fixed, ext, dock;
1134 int i; 1106 int i;
1135 1107
1108 if (spec->shared_mic_hp)
1109 return; /* no auto-mic for the shared I/O */
1110
1136 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; 1111 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1137 1112
1138 fixed = ext = dock = 0; 1113 fixed = ext = dock = 0;
@@ -1524,6 +1499,7 @@ static void alc_pick_fixup(struct hda_codec *codec,
1524 const struct alc_fixup *fixlist) 1499 const struct alc_fixup *fixlist)
1525{ 1500{
1526 struct alc_spec *spec = codec->spec; 1501 struct alc_spec *spec = codec->spec;
1502 const struct snd_pci_quirk *q;
1527 int id = -1; 1503 int id = -1;
1528 const char *name = NULL; 1504 const char *name = NULL;
1529 1505
@@ -1538,12 +1514,25 @@ static void alc_pick_fixup(struct hda_codec *codec,
1538 } 1514 }
1539 } 1515 }
1540 if (id < 0) { 1516 if (id < 0) {
1541 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1517 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1542 if (quirk) { 1518 if (q) {
1543 id = quirk->value; 1519 id = q->value;
1520#ifdef CONFIG_SND_DEBUG_VERBOSE
1521 name = q->name;
1522#endif
1523 }
1524 }
1525 if (id < 0) {
1526 for (q = quirk; q->subvendor; q++) {
1527 unsigned int vendorid =
1528 q->subdevice | (q->subvendor << 16);
1529 if (vendorid == codec->subsystem_id) {
1530 id = q->value;
1544#ifdef CONFIG_SND_DEBUG_VERBOSE 1531#ifdef CONFIG_SND_DEBUG_VERBOSE
1545 name = quirk->name; 1532 name = q->name;
1546#endif 1533#endif
1534 break;
1535 }
1547 } 1536 }
1548 } 1537 }
1549 1538
@@ -2040,6 +2029,10 @@ static int alc_build_controls(struct hda_codec *codec)
2040 2029
2041 alc_free_kctls(codec); /* no longer needed */ 2030 alc_free_kctls(codec); /* no longer needed */
2042 2031
2032 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
2033 if (err < 0)
2034 return err;
2035
2043 return 0; 2036 return 0;
2044} 2037}
2045 2038
@@ -2067,6 +2060,8 @@ static int alc_init(struct hda_codec *codec)
2067 2060
2068 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); 2061 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2069 2062
2063 snd_hda_jack_report_sync(codec);
2064
2070 hda_call_check_power_status(codec, 0x01); 2065 hda_call_check_power_status(codec, 0x01);
2071 return 0; 2066 return 0;
2072} 2067}
@@ -2450,7 +2445,6 @@ static void alc_free(struct hda_codec *codec)
2450 return; 2445 return;
2451 2446
2452 alc_shutup(codec); 2447 alc_shutup(codec);
2453 snd_hda_input_jack_free(codec);
2454 alc_free_kctls(codec); 2448 alc_free_kctls(codec);
2455 alc_free_bind_ctls(codec); 2449 alc_free_bind_ctls(codec);
2456 kfree(spec); 2450 kfree(spec);
@@ -2685,6 +2679,9 @@ static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2685 int max_nums = ARRAY_SIZE(spec->private_adc_nids); 2679 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2686 int i, nums = 0; 2680 int i, nums = 0;
2687 2681
2682 if (spec->shared_mic_hp)
2683 max_nums = 1; /* no multi streams with the shared HP/mic */
2684
2688 nid = codec->start_nid; 2685 nid = codec->start_nid;
2689 for (i = 0; i < codec->num_nodes; i++, nid++) { 2686 for (i = 0; i < codec->num_nodes; i++, nid++) {
2690 hda_nid_t src; 2687 hda_nid_t src;
@@ -2747,6 +2744,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2747 continue; 2744 continue;
2748 2745
2749 label = hda_get_autocfg_input_label(codec, cfg, i); 2746 label = hda_get_autocfg_input_label(codec, cfg, i);
2747 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
2748 label = "Headphone Mic";
2750 if (prev_label && !strcmp(label, prev_label)) 2749 if (prev_label && !strcmp(label, prev_label))
2751 type_idx++; 2750 type_idx++;
2752 else 2751 else
@@ -2781,6 +2780,39 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2781 return 0; 2780 return 0;
2782} 2781}
2783 2782
2783/* create a shared input with the headphone out */
2784static int alc_auto_create_shared_input(struct hda_codec *codec)
2785{
2786 struct alc_spec *spec = codec->spec;
2787 struct auto_pin_cfg *cfg = &spec->autocfg;
2788 unsigned int defcfg;
2789 hda_nid_t nid;
2790
2791 /* only one internal input pin? */
2792 if (cfg->num_inputs != 1)
2793 return 0;
2794 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
2795 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
2796 return 0;
2797
2798 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
2799 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
2800 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
2801 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
2802 else
2803 return 0; /* both not available */
2804
2805 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2806 return 0; /* no input */
2807
2808 cfg->inputs[1].pin = nid;
2809 cfg->inputs[1].type = AUTO_PIN_MIC;
2810 cfg->num_inputs = 2;
2811 spec->shared_mic_hp = 1;
2812 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
2813 return 0;
2814}
2815
2784static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 2816static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2785 unsigned int pin_type) 2817 unsigned int pin_type)
2786{ 2818{
@@ -2919,6 +2951,23 @@ static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2919 return 0; 2951 return 0;
2920} 2952}
2921 2953
2954/* check whether the DAC is reachable from the pin */
2955static bool alc_auto_is_dac_reachable(struct hda_codec *codec,
2956 hda_nid_t pin, hda_nid_t dac)
2957{
2958 hda_nid_t srcs[5];
2959 int i, num;
2960
2961 pin = alc_go_down_to_selector(codec, pin);
2962 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2963 for (i = 0; i < num; i++) {
2964 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2965 if (nid == dac)
2966 return true;
2967 }
2968 return false;
2969}
2970
2922static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) 2971static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2923{ 2972{
2924 hda_nid_t sel = alc_go_down_to_selector(codec, pin); 2973 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
@@ -2949,13 +2998,17 @@ static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2949} 2998}
2950 2999
2951static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3000static int alc_auto_fill_multi_ios(struct hda_codec *codec,
2952 unsigned int location); 3001 unsigned int location, int offset);
3002static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3003 hda_nid_t pin, hda_nid_t dac);
2953 3004
2954/* fill in the dac_nids table from the parsed pin configuration */ 3005/* fill in the dac_nids table from the parsed pin configuration */
2955static int alc_auto_fill_dac_nids(struct hda_codec *codec) 3006static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2956{ 3007{
2957 struct alc_spec *spec = codec->spec; 3008 struct alc_spec *spec = codec->spec;
2958 struct auto_pin_cfg *cfg = &spec->autocfg; 3009 struct auto_pin_cfg *cfg = &spec->autocfg;
3010 unsigned int location, defcfg;
3011 int num_pins;
2959 bool redone = false; 3012 bool redone = false;
2960 int i; 3013 int i;
2961 3014
@@ -3010,13 +3063,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3010 3063
3011 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3064 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3012 /* try to fill multi-io first */ 3065 /* try to fill multi-io first */
3013 unsigned int location, defcfg;
3014 int num_pins;
3015
3016 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]); 3066 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
3017 location = get_defcfg_location(defcfg); 3067 location = get_defcfg_location(defcfg);
3018 3068
3019 num_pins = alc_auto_fill_multi_ios(codec, location); 3069 num_pins = alc_auto_fill_multi_ios(codec, location, 0);
3020 if (num_pins > 0) { 3070 if (num_pins > 0) {
3021 spec->multi_ios = num_pins; 3071 spec->multi_ios = num_pins;
3022 spec->ext_channel_count = 2; 3072 spec->ext_channel_count = 2;
@@ -3050,6 +3100,25 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3050 } 3100 }
3051 } 3101 }
3052 3102
3103 if (!spec->multi_ios &&
3104 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3105 cfg->hp_outs) {
3106 /* try multi-ios with HP + inputs */
3107 defcfg = snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0]);
3108 location = get_defcfg_location(defcfg);
3109
3110 num_pins = alc_auto_fill_multi_ios(codec, location, 1);
3111 if (num_pins > 0) {
3112 spec->multi_ios = num_pins;
3113 spec->ext_channel_count = 2;
3114 spec->multiout.num_dacs = num_pins + 1;
3115 }
3116 }
3117
3118 if (cfg->line_out_pins[0])
3119 spec->vmaster_nid =
3120 alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0],
3121 spec->multiout.dac_nids[0]);
3053 return 0; 3122 return 0;
3054} 3123}
3055 3124
@@ -3081,8 +3150,15 @@ static int alc_auto_add_vol_ctl(struct hda_codec *codec,
3081 val); 3150 val);
3082} 3151}
3083 3152
3084#define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \ 3153static int alc_auto_add_stereo_vol(struct hda_codec *codec,
3085 alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3) 3154 const char *pfx, int cidx,
3155 hda_nid_t nid)
3156{
3157 int chs = 1;
3158 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3159 chs = 3;
3160 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs);
3161}
3086 3162
3087/* create a mute-switch for the given mixer widget; 3163/* create a mute-switch for the given mixer widget;
3088 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute 3164 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
@@ -3114,8 +3190,14 @@ static int alc_auto_add_sw_ctl(struct hda_codec *codec,
3114 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); 3190 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
3115} 3191}
3116 3192
3117#define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \ 3193static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx,
3118 alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3) 3194 int cidx, hda_nid_t nid)
3195{
3196 int chs = 1;
3197 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3198 chs = 3;
3199 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs);
3200}
3119 3201
3120static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, 3202static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3121 hda_nid_t pin, hda_nid_t dac) 3203 hda_nid_t pin, hda_nid_t dac)
@@ -3441,17 +3523,19 @@ static void alc_auto_init_extra_out(struct hda_codec *codec)
3441 * multi-io helper 3523 * multi-io helper
3442 */ 3524 */
3443static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3525static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3444 unsigned int location) 3526 unsigned int location,
3527 int offset)
3445{ 3528{
3446 struct alc_spec *spec = codec->spec; 3529 struct alc_spec *spec = codec->spec;
3447 struct auto_pin_cfg *cfg = &spec->autocfg; 3530 struct auto_pin_cfg *cfg = &spec->autocfg;
3448 hda_nid_t prime_dac = spec->private_dac_nids[0]; 3531 hda_nid_t prime_dac = spec->private_dac_nids[0];
3449 int type, i, num_pins = 0; 3532 int type, i, dacs, num_pins = 0;
3450 3533
3534 dacs = spec->multiout.num_dacs;
3451 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 3535 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3452 for (i = 0; i < cfg->num_inputs; i++) { 3536 for (i = 0; i < cfg->num_inputs; i++) {
3453 hda_nid_t nid = cfg->inputs[i].pin; 3537 hda_nid_t nid = cfg->inputs[i].pin;
3454 hda_nid_t dac; 3538 hda_nid_t dac = 0;
3455 unsigned int defcfg, caps; 3539 unsigned int defcfg, caps;
3456 if (cfg->inputs[i].type != type) 3540 if (cfg->inputs[i].type != type)
3457 continue; 3541 continue;
@@ -3463,7 +3547,13 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3463 caps = snd_hda_query_pin_caps(codec, nid); 3547 caps = snd_hda_query_pin_caps(codec, nid);
3464 if (!(caps & AC_PINCAP_OUT)) 3548 if (!(caps & AC_PINCAP_OUT))
3465 continue; 3549 continue;
3466 dac = alc_auto_look_for_dac(codec, nid); 3550 if (offset && offset + num_pins < dacs) {
3551 dac = spec->private_dac_nids[offset + num_pins];
3552 if (!alc_auto_is_dac_reachable(codec, nid, dac))
3553 dac = 0;
3554 }
3555 if (!dac)
3556 dac = alc_auto_look_for_dac(codec, nid);
3467 if (!dac) 3557 if (!dac)
3468 continue; 3558 continue;
3469 spec->multi_io[num_pins].pin = nid; 3559 spec->multi_io[num_pins].pin = nid;
@@ -3472,11 +3562,11 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3472 spec->private_dac_nids[spec->multiout.num_dacs++] = dac; 3562 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
3473 } 3563 }
3474 } 3564 }
3475 spec->multiout.num_dacs = 1; 3565 spec->multiout.num_dacs = dacs;
3476 if (num_pins < 2) { 3566 if (num_pins < 2) {
3477 /* clear up again */ 3567 /* clear up again */
3478 memset(spec->private_dac_nids, 0, 3568 memset(spec->private_dac_nids + dacs, 0,
3479 sizeof(spec->private_dac_nids)); 3569 sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - dacs));
3480 spec->private_dac_nids[0] = prime_dac; 3570 spec->private_dac_nids[0] = prime_dac;
3481 return 0; 3571 return 0;
3482 } 3572 }
@@ -3700,6 +3790,8 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
3700 char boost_label[32]; 3790 char boost_label[32];
3701 3791
3702 label = hda_get_autocfg_input_label(codec, cfg, i); 3792 label = hda_get_autocfg_input_label(codec, cfg, i);
3793 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
3794 label = "Headphone Mic";
3703 if (prev_label && !strcmp(label, prev_label)) 3795 if (prev_label && !strcmp(label, prev_label))
3704 type_idx++; 3796 type_idx++;
3705 else 3797 else
@@ -3812,6 +3904,7 @@ static void set_capture_mixer(struct hda_codec *codec)
3812static void alc_auto_init_std(struct hda_codec *codec) 3904static void alc_auto_init_std(struct hda_codec *codec)
3813{ 3905{
3814 struct alc_spec *spec = codec->spec; 3906 struct alc_spec *spec = codec->spec;
3907 spec->use_jack_tbl = 1;
3815 alc_auto_init_multi_out(codec); 3908 alc_auto_init_multi_out(codec);
3816 alc_auto_init_extra_out(codec); 3909 alc_auto_init_extra_out(codec);
3817 alc_auto_init_analog_input(codec); 3910 alc_auto_init_analog_input(codec);
@@ -3904,6 +3997,9 @@ static int alc_parse_auto_config(struct hda_codec *codec,
3904 err = alc_auto_create_speaker_out(codec); 3997 err = alc_auto_create_speaker_out(codec);
3905 if (err < 0) 3998 if (err < 0)
3906 return err; 3999 return err;
4000 err = alc_auto_create_shared_input(codec);
4001 if (err < 0)
4002 return err;
3907 err = alc_auto_create_input_ctls(codec); 4003 err = alc_auto_create_input_ctls(codec);
3908 if (err < 0) 4004 if (err < 0)
3909 return err; 4005 return err;
@@ -3951,6 +4047,37 @@ static const struct hda_amp_list alc880_loopbacks[] = {
3951#endif 4047#endif
3952 4048
3953/* 4049/*
4050 * ALC880 fix-ups
4051 */
4052enum {
4053 ALC880_FIXUP_GPIO2,
4054 ALC880_FIXUP_MEDION_RIM,
4055};
4056
4057static const struct alc_fixup alc880_fixups[] = {
4058 [ALC880_FIXUP_GPIO2] = {
4059 .type = ALC_FIXUP_VERBS,
4060 .v.verbs = alc_gpio2_init_verbs,
4061 },
4062 [ALC880_FIXUP_MEDION_RIM] = {
4063 .type = ALC_FIXUP_VERBS,
4064 .v.verbs = (const struct hda_verb[]) {
4065 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4066 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4067 { }
4068 },
4069 .chained = true,
4070 .chain_id = ALC880_FIXUP_GPIO2,
4071 },
4072};
4073
4074static const struct snd_pci_quirk alc880_fixup_tbl[] = {
4075 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
4076 {}
4077};
4078
4079
4080/*
3954 * board setups 4081 * board setups
3955 */ 4082 */
3956#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4083#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
@@ -3996,6 +4123,11 @@ static int patch_alc880(struct hda_codec *codec)
3996 } 4123 }
3997 4124
3998 if (board_config == ALC_MODEL_AUTO) { 4125 if (board_config == ALC_MODEL_AUTO) {
4126 alc_pick_fixup(codec, NULL, alc880_fixup_tbl, alc880_fixups);
4127 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4128 }
4129
4130 if (board_config == ALC_MODEL_AUTO) {
3999 /* automatic parse from the BIOS config */ 4131 /* automatic parse from the BIOS config */
4000 err = alc880_parse_auto_config(codec); 4132 err = alc880_parse_auto_config(codec);
4001 if (err < 0) 4133 if (err < 0)
@@ -4010,8 +4142,10 @@ static int patch_alc880(struct hda_codec *codec)
4010#endif 4142#endif
4011 } 4143 }
4012 4144
4013 if (board_config != ALC_MODEL_AUTO) 4145 if (board_config != ALC_MODEL_AUTO) {
4146 spec->vmaster_nid = 0x0c;
4014 setup_preset(codec, &alc880_presets[board_config]); 4147 setup_preset(codec, &alc880_presets[board_config]);
4148 }
4015 4149
4016 if (!spec->no_analog && !spec->adc_nids) { 4150 if (!spec->no_analog && !spec->adc_nids) {
4017 alc_auto_fill_adc_caps(codec); 4151 alc_auto_fill_adc_caps(codec);
@@ -4029,7 +4163,7 @@ static int patch_alc880(struct hda_codec *codec)
4029 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4163 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4030 } 4164 }
4031 4165
4032 spec->vmaster_nid = 0x0c; 4166 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4033 4167
4034 codec->patch_ops = alc_patch_ops; 4168 codec->patch_ops = alc_patch_ops;
4035 if (board_config == ALC_MODEL_AUTO) 4169 if (board_config == ALC_MODEL_AUTO)
@@ -4137,8 +4271,10 @@ static int patch_alc260(struct hda_codec *codec)
4137#endif 4271#endif
4138 } 4272 }
4139 4273
4140 if (board_config != ALC_MODEL_AUTO) 4274 if (board_config != ALC_MODEL_AUTO) {
4141 setup_preset(codec, &alc260_presets[board_config]); 4275 setup_preset(codec, &alc260_presets[board_config]);
4276 spec->vmaster_nid = 0x08;
4277 }
4142 4278
4143 if (!spec->no_analog && !spec->adc_nids) { 4279 if (!spec->no_analog && !spec->adc_nids) {
4144 alc_auto_fill_adc_caps(codec); 4280 alc_auto_fill_adc_caps(codec);
@@ -4158,8 +4294,6 @@ static int patch_alc260(struct hda_codec *codec)
4158 4294
4159 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4295 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4160 4296
4161 spec->vmaster_nid = 0x08;
4162
4163 codec->patch_ops = alc_patch_ops; 4297 codec->patch_ops = alc_patch_ops;
4164 if (board_config == ALC_MODEL_AUTO) 4298 if (board_config == ALC_MODEL_AUTO)
4165 spec->init_hook = alc_auto_init_std; 4299 spec->init_hook = alc_auto_init_std;
@@ -4196,15 +4330,78 @@ static int patch_alc260(struct hda_codec *codec)
4196 * Pin config fixes 4330 * Pin config fixes
4197 */ 4331 */
4198enum { 4332enum {
4199 PINFIX_ABIT_AW9D_MAX, 4333 ALC882_FIXUP_ABIT_AW9D_MAX,
4200 PINFIX_LENOVO_Y530, 4334 ALC882_FIXUP_LENOVO_Y530,
4201 PINFIX_PB_M5210, 4335 ALC882_FIXUP_PB_M5210,
4202 PINFIX_ACER_ASPIRE_7736, 4336 ALC882_FIXUP_ACER_ASPIRE_7736,
4203 PINFIX_ASUS_W90V, 4337 ALC882_FIXUP_ASUS_W90V,
4338 ALC889_FIXUP_VAIO_TT,
4339 ALC888_FIXUP_EEE1601,
4340 ALC882_FIXUP_EAPD,
4341 ALC883_FIXUP_EAPD,
4342 ALC883_FIXUP_ACER_EAPD,
4343 ALC882_FIXUP_GPIO3,
4344 ALC889_FIXUP_COEF,
4345 ALC882_FIXUP_ASUS_W2JC,
4346 ALC882_FIXUP_ACER_ASPIRE_4930G,
4347 ALC882_FIXUP_ACER_ASPIRE_8930G,
4348 ALC882_FIXUP_ASPIRE_8930G_VERBS,
4349 ALC885_FIXUP_MACPRO_GPIO,
4204}; 4350};
4205 4351
4352static void alc889_fixup_coef(struct hda_codec *codec,
4353 const struct alc_fixup *fix, int action)
4354{
4355 if (action != ALC_FIXUP_ACT_INIT)
4356 return;
4357 alc889_coef_init(codec);
4358}
4359
4360/* toggle speaker-output according to the hp-jack state */
4361static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4362{
4363 unsigned int gpiostate, gpiomask, gpiodir;
4364
4365 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4366 AC_VERB_GET_GPIO_DATA, 0);
4367
4368 if (!muted)
4369 gpiostate |= (1 << pin);
4370 else
4371 gpiostate &= ~(1 << pin);
4372
4373 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4374 AC_VERB_GET_GPIO_MASK, 0);
4375 gpiomask |= (1 << pin);
4376
4377 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4378 AC_VERB_GET_GPIO_DIRECTION, 0);
4379 gpiodir |= (1 << pin);
4380
4381
4382 snd_hda_codec_write(codec, codec->afg, 0,
4383 AC_VERB_SET_GPIO_MASK, gpiomask);
4384 snd_hda_codec_write(codec, codec->afg, 0,
4385 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4386
4387 msleep(1);
4388
4389 snd_hda_codec_write(codec, codec->afg, 0,
4390 AC_VERB_SET_GPIO_DATA, gpiostate);
4391}
4392
4393/* set up GPIO at initialization */
4394static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
4395 const struct alc_fixup *fix, int action)
4396{
4397 if (action != ALC_FIXUP_ACT_INIT)
4398 return;
4399 alc882_gpio_mute(codec, 0, 0);
4400 alc882_gpio_mute(codec, 1, 0);
4401}
4402
4206static const struct alc_fixup alc882_fixups[] = { 4403static const struct alc_fixup alc882_fixups[] = {
4207 [PINFIX_ABIT_AW9D_MAX] = { 4404 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
4208 .type = ALC_FIXUP_PINS, 4405 .type = ALC_FIXUP_PINS,
4209 .v.pins = (const struct alc_pincfg[]) { 4406 .v.pins = (const struct alc_pincfg[]) {
4210 { 0x15, 0x01080104 }, /* side */ 4407 { 0x15, 0x01080104 }, /* side */
@@ -4213,7 +4410,7 @@ static const struct alc_fixup alc882_fixups[] = {
4213 { } 4410 { }
4214 } 4411 }
4215 }, 4412 },
4216 [PINFIX_LENOVO_Y530] = { 4413 [ALC882_FIXUP_LENOVO_Y530] = {
4217 .type = ALC_FIXUP_PINS, 4414 .type = ALC_FIXUP_PINS,
4218 .v.pins = (const struct alc_pincfg[]) { 4415 .v.pins = (const struct alc_pincfg[]) {
4219 { 0x15, 0x99130112 }, /* rear int speakers */ 4416 { 0x15, 0x99130112 }, /* rear int speakers */
@@ -4221,32 +4418,180 @@ static const struct alc_fixup alc882_fixups[] = {
4221 { } 4418 { }
4222 } 4419 }
4223 }, 4420 },
4224 [PINFIX_PB_M5210] = { 4421 [ALC882_FIXUP_PB_M5210] = {
4225 .type = ALC_FIXUP_VERBS, 4422 .type = ALC_FIXUP_VERBS,
4226 .v.verbs = (const struct hda_verb[]) { 4423 .v.verbs = (const struct hda_verb[]) {
4227 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 4424 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4228 {} 4425 {}
4229 } 4426 }
4230 }, 4427 },
4231 [PINFIX_ACER_ASPIRE_7736] = { 4428 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
4232 .type = ALC_FIXUP_SKU, 4429 .type = ALC_FIXUP_SKU,
4233 .v.sku = ALC_FIXUP_SKU_IGNORE, 4430 .v.sku = ALC_FIXUP_SKU_IGNORE,
4234 }, 4431 },
4235 [PINFIX_ASUS_W90V] = { 4432 [ALC882_FIXUP_ASUS_W90V] = {
4236 .type = ALC_FIXUP_PINS, 4433 .type = ALC_FIXUP_PINS,
4237 .v.pins = (const struct alc_pincfg[]) { 4434 .v.pins = (const struct alc_pincfg[]) {
4238 { 0x16, 0x99130110 }, /* fix sequence for CLFE */ 4435 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4239 { } 4436 { }
4240 } 4437 }
4241 }, 4438 },
4439 [ALC889_FIXUP_VAIO_TT] = {
4440 .type = ALC_FIXUP_PINS,
4441 .v.pins = (const struct alc_pincfg[]) {
4442 { 0x17, 0x90170111 }, /* hidden surround speaker */
4443 { }
4444 }
4445 },
4446 [ALC888_FIXUP_EEE1601] = {
4447 .type = ALC_FIXUP_VERBS,
4448 .v.verbs = (const struct hda_verb[]) {
4449 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4450 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
4451 { }
4452 }
4453 },
4454 [ALC882_FIXUP_EAPD] = {
4455 .type = ALC_FIXUP_VERBS,
4456 .v.verbs = (const struct hda_verb[]) {
4457 /* change to EAPD mode */
4458 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4459 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4460 { }
4461 }
4462 },
4463 [ALC883_FIXUP_EAPD] = {
4464 .type = ALC_FIXUP_VERBS,
4465 .v.verbs = (const struct hda_verb[]) {
4466 /* change to EAPD mode */
4467 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4468 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4469 { }
4470 }
4471 },
4472 [ALC883_FIXUP_ACER_EAPD] = {
4473 .type = ALC_FIXUP_VERBS,
4474 .v.verbs = (const struct hda_verb[]) {
4475 /* eanable EAPD on Acer laptops */
4476 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4477 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4478 { }
4479 }
4480 },
4481 [ALC882_FIXUP_GPIO3] = {
4482 .type = ALC_FIXUP_VERBS,
4483 .v.verbs = alc_gpio3_init_verbs,
4484 },
4485 [ALC882_FIXUP_ASUS_W2JC] = {
4486 .type = ALC_FIXUP_VERBS,
4487 .v.verbs = alc_gpio1_init_verbs,
4488 .chained = true,
4489 .chain_id = ALC882_FIXUP_EAPD,
4490 },
4491 [ALC889_FIXUP_COEF] = {
4492 .type = ALC_FIXUP_FUNC,
4493 .v.func = alc889_fixup_coef,
4494 },
4495 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
4496 .type = ALC_FIXUP_PINS,
4497 .v.pins = (const struct alc_pincfg[]) {
4498 { 0x16, 0x99130111 }, /* CLFE speaker */
4499 { 0x17, 0x99130112 }, /* surround speaker */
4500 { }
4501 }
4502 },
4503 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
4504 .type = ALC_FIXUP_PINS,
4505 .v.pins = (const struct alc_pincfg[]) {
4506 { 0x16, 0x99130111 }, /* CLFE speaker */
4507 { 0x1b, 0x99130112 }, /* surround speaker */
4508 { }
4509 },
4510 .chained = true,
4511 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
4512 },
4513 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
4514 /* additional init verbs for Acer Aspire 8930G */
4515 .type = ALC_FIXUP_VERBS,
4516 .v.verbs = (const struct hda_verb[]) {
4517 /* Enable all DACs */
4518 /* DAC DISABLE/MUTE 1? */
4519 /* setting bits 1-5 disables DAC nids 0x02-0x06
4520 * apparently. Init=0x38 */
4521 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
4522 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4523 /* DAC DISABLE/MUTE 2? */
4524 /* some bit here disables the other DACs.
4525 * Init=0x4900 */
4526 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
4527 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4528 /* DMIC fix
4529 * This laptop has a stereo digital microphone.
4530 * The mics are only 1cm apart which makes the stereo
4531 * useless. However, either the mic or the ALC889
4532 * makes the signal become a difference/sum signal
4533 * instead of standard stereo, which is annoying.
4534 * So instead we flip this bit which makes the
4535 * codec replicate the sum signal to both channels,
4536 * turning it into a normal mono mic.
4537 */
4538 /* DMIC_CONTROL? Init value = 0x0001 */
4539 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4540 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
4541 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4542 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4543 { }
4544 }
4545 },
4546 [ALC885_FIXUP_MACPRO_GPIO] = {
4547 .type = ALC_FIXUP_FUNC,
4548 .v.func = alc885_fixup_macpro_gpio,
4549 },
4242}; 4550};
4243 4551
4244static const struct snd_pci_quirk alc882_fixup_tbl[] = { 4552static const struct snd_pci_quirk alc882_fixup_tbl[] = {
4245 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), 4553 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
4246 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", PINFIX_ASUS_W90V), 4554 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4247 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), 4555 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
4248 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 4556 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4249 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), 4557 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
4558 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
4559 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
4560 ALC882_FIXUP_ACER_ASPIRE_4930G),
4561 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
4562 ALC882_FIXUP_ACER_ASPIRE_4930G),
4563 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
4564 ALC882_FIXUP_ACER_ASPIRE_8930G),
4565 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
4566 ALC882_FIXUP_ACER_ASPIRE_8930G),
4567 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
4568 ALC882_FIXUP_ACER_ASPIRE_4930G),
4569 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
4570 ALC882_FIXUP_ACER_ASPIRE_4930G),
4571 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
4572 ALC882_FIXUP_ACER_ASPIRE_4930G),
4573 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
4574 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
4575 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
4576 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
4577 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
4578 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
4579 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
4580
4581 /* All Apple entries are in codec SSIDs */
4582 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
4583 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
4584 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
4585 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
4586 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
4587
4588 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
4589 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
4590 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
4591 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
4592 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
4593 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
4594 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
4250 {} 4595 {}
4251}; 4596};
4252 4597
@@ -4295,8 +4640,7 @@ static int patch_alc882(struct hda_codec *codec)
4295 goto error; 4640 goto error;
4296 4641
4297 board_config = alc_board_config(codec, ALC882_MODEL_LAST, 4642 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
4298 alc882_models, alc882_cfg_tbl); 4643 alc882_models, NULL);
4299
4300 if (board_config < 0) 4644 if (board_config < 0)
4301 board_config = alc_board_codec_sid_config(codec, 4645 board_config = alc_board_codec_sid_config(codec,
4302 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); 4646 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
@@ -4319,18 +4663,12 @@ static int patch_alc882(struct hda_codec *codec)
4319 err = alc882_parse_auto_config(codec); 4663 err = alc882_parse_auto_config(codec);
4320 if (err < 0) 4664 if (err < 0)
4321 goto error; 4665 goto error;
4322#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4323 else if (!err) {
4324 printk(KERN_INFO
4325 "hda_codec: Cannot set up configuration "
4326 "from BIOS. Using base mode...\n");
4327 board_config = ALC882_3ST_DIG;
4328 }
4329#endif
4330 } 4666 }
4331 4667
4332 if (board_config != ALC_MODEL_AUTO) 4668 if (board_config != ALC_MODEL_AUTO) {
4333 setup_preset(codec, &alc882_presets[board_config]); 4669 setup_preset(codec, &alc882_presets[board_config]);
4670 spec->vmaster_nid = 0x0c;
4671 }
4334 4672
4335 if (!spec->no_analog && !spec->adc_nids) { 4673 if (!spec->no_analog && !spec->adc_nids) {
4336 alc_auto_fill_adc_caps(codec); 4674 alc_auto_fill_adc_caps(codec);
@@ -4350,13 +4688,10 @@ static int patch_alc882(struct hda_codec *codec)
4350 4688
4351 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4689 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4352 4690
4353 spec->vmaster_nid = 0x0c;
4354
4355 codec->patch_ops = alc_patch_ops; 4691 codec->patch_ops = alc_patch_ops;
4356 if (board_config == ALC_MODEL_AUTO) 4692 if (board_config == ALC_MODEL_AUTO)
4357 spec->init_hook = alc_auto_init_std; 4693 spec->init_hook = alc_auto_init_std;
4358 4694
4359 alc_init_jacks(codec);
4360#ifdef CONFIG_SND_HDA_POWER_SAVE 4695#ifdef CONFIG_SND_HDA_POWER_SAVE
4361 if (!spec->loopback.amplist) 4696 if (!spec->loopback.amplist)
4362 spec->loopback.amplist = alc882_loopbacks; 4697 spec->loopback.amplist = alc882_loopbacks;
@@ -4384,12 +4719,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
4384 * Pin config fixes 4719 * Pin config fixes
4385 */ 4720 */
4386enum { 4721enum {
4387 PINFIX_FSC_H270, 4722 ALC262_FIXUP_FSC_H270,
4388 PINFIX_HP_Z200, 4723 ALC262_FIXUP_HP_Z200,
4724 ALC262_FIXUP_TYAN,
4725 ALC262_FIXUP_TOSHIBA_RX1,
4726 ALC262_FIXUP_LENOVO_3000,
4727 ALC262_FIXUP_BENQ,
4728 ALC262_FIXUP_BENQ_T31,
4389}; 4729};
4390 4730
4391static const struct alc_fixup alc262_fixups[] = { 4731static const struct alc_fixup alc262_fixups[] = {
4392 [PINFIX_FSC_H270] = { 4732 [ALC262_FIXUP_FSC_H270] = {
4393 .type = ALC_FIXUP_PINS, 4733 .type = ALC_FIXUP_PINS,
4394 .v.pins = (const struct alc_pincfg[]) { 4734 .v.pins = (const struct alc_pincfg[]) {
4395 { 0x14, 0x99130110 }, /* speaker */ 4735 { 0x14, 0x99130110 }, /* speaker */
@@ -4398,18 +4738,68 @@ static const struct alc_fixup alc262_fixups[] = {
4398 { } 4738 { }
4399 } 4739 }
4400 }, 4740 },
4401 [PINFIX_HP_Z200] = { 4741 [ALC262_FIXUP_HP_Z200] = {
4402 .type = ALC_FIXUP_PINS, 4742 .type = ALC_FIXUP_PINS,
4403 .v.pins = (const struct alc_pincfg[]) { 4743 .v.pins = (const struct alc_pincfg[]) {
4404 { 0x16, 0x99130120 }, /* internal speaker */ 4744 { 0x16, 0x99130120 }, /* internal speaker */
4405 { } 4745 { }
4406 } 4746 }
4407 }, 4747 },
4748 [ALC262_FIXUP_TYAN] = {
4749 .type = ALC_FIXUP_PINS,
4750 .v.pins = (const struct alc_pincfg[]) {
4751 { 0x14, 0x1993e1f0 }, /* int AUX */
4752 { }
4753 }
4754 },
4755 [ALC262_FIXUP_TOSHIBA_RX1] = {
4756 .type = ALC_FIXUP_PINS,
4757 .v.pins = (const struct alc_pincfg[]) {
4758 { 0x14, 0x90170110 }, /* speaker */
4759 { 0x15, 0x0421101f }, /* HP */
4760 { 0x1a, 0x40f000f0 }, /* N/A */
4761 { 0x1b, 0x40f000f0 }, /* N/A */
4762 { 0x1e, 0x40f000f0 }, /* N/A */
4763 }
4764 },
4765 [ALC262_FIXUP_LENOVO_3000] = {
4766 .type = ALC_FIXUP_VERBS,
4767 .v.verbs = (const struct hda_verb[]) {
4768 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4769 {}
4770 },
4771 .chained = true,
4772 .chain_id = ALC262_FIXUP_BENQ,
4773 },
4774 [ALC262_FIXUP_BENQ] = {
4775 .type = ALC_FIXUP_VERBS,
4776 .v.verbs = (const struct hda_verb[]) {
4777 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4778 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4779 {}
4780 }
4781 },
4782 [ALC262_FIXUP_BENQ_T31] = {
4783 .type = ALC_FIXUP_VERBS,
4784 .v.verbs = (const struct hda_verb[]) {
4785 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4786 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4787 {}
4788 }
4789 },
4408}; 4790};
4409 4791
4410static const struct snd_pci_quirk alc262_fixup_tbl[] = { 4792static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4411 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200), 4793 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
4412 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), 4794 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ),
4795 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
4796 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
4797 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
4798 ALC262_FIXUP_TOSHIBA_RX1),
4799 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
4800 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
4801 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
4802 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
4413 {} 4803 {}
4414}; 4804};
4415 4805
@@ -4420,14 +4810,9 @@ static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4420 4810
4421/* 4811/*
4422 */ 4812 */
4423#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4424#include "alc262_quirks.c"
4425#endif
4426
4427static int patch_alc262(struct hda_codec *codec) 4813static int patch_alc262(struct hda_codec *codec)
4428{ 4814{
4429 struct alc_spec *spec; 4815 struct alc_spec *spec;
4430 int board_config;
4431 int err; 4816 int err;
4432 4817
4433 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4818 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -4454,37 +4839,13 @@ static int patch_alc262(struct hda_codec *codec)
4454 4839
4455 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 4840 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4456 4841
4457 board_config = alc_board_config(codec, ALC262_MODEL_LAST, 4842 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4458 alc262_models, alc262_cfg_tbl); 4843 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4459
4460 if (board_config < 0) {
4461 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4462 codec->chip_name);
4463 board_config = ALC_MODEL_AUTO;
4464 }
4465
4466 if (board_config == ALC_MODEL_AUTO) {
4467 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4468 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4469 }
4470
4471 if (board_config == ALC_MODEL_AUTO) {
4472 /* automatic parse from the BIOS config */
4473 err = alc262_parse_auto_config(codec);
4474 if (err < 0)
4475 goto error;
4476#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4477 else if (!err) {
4478 printk(KERN_INFO
4479 "hda_codec: Cannot set up configuration "
4480 "from BIOS. Using base mode...\n");
4481 board_config = ALC262_BASIC;
4482 }
4483#endif
4484 }
4485 4844
4486 if (board_config != ALC_MODEL_AUTO) 4845 /* automatic parse from the BIOS config */
4487 setup_preset(codec, &alc262_presets[board_config]); 4846 err = alc262_parse_auto_config(codec);
4847 if (err < 0)
4848 goto error;
4488 4849
4489 if (!spec->no_analog && !spec->adc_nids) { 4850 if (!spec->no_analog && !spec->adc_nids) {
4490 alc_auto_fill_adc_caps(codec); 4851 alc_auto_fill_adc_caps(codec);
@@ -4504,14 +4865,10 @@ static int patch_alc262(struct hda_codec *codec)
4504 4865
4505 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4866 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4506 4867
4507 spec->vmaster_nid = 0x0c;
4508
4509 codec->patch_ops = alc_patch_ops; 4868 codec->patch_ops = alc_patch_ops;
4510 if (board_config == ALC_MODEL_AUTO) 4869 spec->init_hook = alc_auto_init_std;
4511 spec->init_hook = alc_auto_init_std;
4512 spec->shutup = alc_eapd_shutup; 4870 spec->shutup = alc_eapd_shutup;
4513 4871
4514 alc_init_jacks(codec);
4515#ifdef CONFIG_SND_HDA_POWER_SAVE 4872#ifdef CONFIG_SND_HDA_POWER_SAVE
4516 if (!spec->loopback.amplist) 4873 if (!spec->loopback.amplist)
4517 spec->loopback.amplist = alc262_loopbacks; 4874 spec->loopback.amplist = alc262_loopbacks;
@@ -4618,14 +4975,10 @@ static int patch_alc268(struct hda_codec *codec)
4618 if (!spec->no_analog && !spec->cap_mixer) 4975 if (!spec->no_analog && !spec->cap_mixer)
4619 set_capture_mixer(codec); 4976 set_capture_mixer(codec);
4620 4977
4621 spec->vmaster_nid = 0x02;
4622
4623 codec->patch_ops = alc_patch_ops; 4978 codec->patch_ops = alc_patch_ops;
4624 spec->init_hook = alc_auto_init_std; 4979 spec->init_hook = alc_auto_init_std;
4625 spec->shutup = alc_eapd_shutup; 4980 spec->shutup = alc_eapd_shutup;
4626 4981
4627 alc_init_jacks(codec);
4628
4629 return 0; 4982 return 0;
4630 4983
4631 error: 4984 error:
@@ -4967,7 +5320,7 @@ static const struct alc_fixup alc269_fixups[] = {
4967 { } 5320 { }
4968 }, 5321 },
4969 }, 5322 },
4970 [ALC269_FIXUP_DMIC] = { 5323 [ALC269VB_FIXUP_DMIC] = {
4971 .type = ALC_FIXUP_PINS, 5324 .type = ALC_FIXUP_PINS,
4972 .v.pins = (const struct alc_pincfg[]) { 5325 .v.pins = (const struct alc_pincfg[]) {
4973 { 0x12, 0x99a3092f }, /* int-mic */ 5326 { 0x12, 0x99a3092f }, /* int-mic */
@@ -5174,8 +5527,6 @@ static int patch_alc269(struct hda_codec *codec)
5174 5527
5175 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5528 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5176 5529
5177 spec->vmaster_nid = 0x02;
5178
5179 codec->patch_ops = alc_patch_ops; 5530 codec->patch_ops = alc_patch_ops;
5180#ifdef CONFIG_PM 5531#ifdef CONFIG_PM
5181 codec->patch_ops.resume = alc269_resume; 5532 codec->patch_ops.resume = alc269_resume;
@@ -5183,7 +5534,6 @@ static int patch_alc269(struct hda_codec *codec)
5183 spec->init_hook = alc_auto_init_std; 5534 spec->init_hook = alc_auto_init_std;
5184 spec->shutup = alc269_shutup; 5535 spec->shutup = alc269_shutup;
5185 5536
5186 alc_init_jacks(codec);
5187#ifdef CONFIG_SND_HDA_POWER_SAVE 5537#ifdef CONFIG_SND_HDA_POWER_SAVE
5188 if (!spec->loopback.amplist) 5538 if (!spec->loopback.amplist)
5189 spec->loopback.amplist = alc269_loopbacks; 5539 spec->loopback.amplist = alc269_loopbacks;
@@ -5280,8 +5630,6 @@ static int patch_alc861(struct hda_codec *codec)
5280 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 5630 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
5281 } 5631 }
5282 5632
5283 spec->vmaster_nid = 0x03;
5284
5285 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5633 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5286 5634
5287 codec->patch_ops = alc_patch_ops; 5635 codec->patch_ops = alc_patch_ops;
@@ -5406,8 +5754,6 @@ static int patch_alc861vd(struct hda_codec *codec)
5406 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5754 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5407 } 5755 }
5408 5756
5409 spec->vmaster_nid = 0x02;
5410
5411 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5757 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5412 5758
5413 codec->patch_ops = alc_patch_ops; 5759 codec->patch_ops = alc_patch_ops;
@@ -5790,7 +6136,6 @@ static int patch_alc662(struct hda_codec *codec)
5790 break; 6136 break;
5791 } 6137 }
5792 } 6138 }
5793 spec->vmaster_nid = 0x02;
5794 6139
5795 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6140 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5796 6141
@@ -5798,8 +6143,6 @@ static int patch_alc662(struct hda_codec *codec)
5798 spec->init_hook = alc_auto_init_std; 6143 spec->init_hook = alc_auto_init_std;
5799 spec->shutup = alc_eapd_shutup; 6144 spec->shutup = alc_eapd_shutup;
5800 6145
5801 alc_init_jacks(codec);
5802
5803#ifdef CONFIG_SND_HDA_POWER_SAVE 6146#ifdef CONFIG_SND_HDA_POWER_SAVE
5804 if (!spec->loopback.amplist) 6147 if (!spec->loopback.amplist)
5805 spec->loopback.amplist = alc662_loopbacks; 6148 spec->loopback.amplist = alc662_loopbacks;
@@ -5846,8 +6189,6 @@ static int patch_alc680(struct hda_codec *codec)
5846 if (!spec->no_analog && !spec->cap_mixer) 6189 if (!spec->no_analog && !spec->cap_mixer)
5847 set_capture_mixer(codec); 6190 set_capture_mixer(codec);
5848 6191
5849 spec->vmaster_nid = 0x02;
5850
5851 codec->patch_ops = alc_patch_ops; 6192 codec->patch_ops = alc_patch_ops;
5852 spec->init_hook = alc_auto_init_std; 6193 spec->init_hook = alc_auto_init_std;
5853 6194