aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-07-08 10:55:13 -0400
committerTakashi Iwai <tiwai@suse.de>2011-07-08 10:55:13 -0400
commit3e6179b8445bf76123cfab1e0af4833cc7618a4a (patch)
tree81e6c0af47532303eb0fad0f7df04e866fdd7a3d /sound/pci/hda/patch_realtek.c
parent8452a982fb8a1d02d755a53a913c087a0d31aa18 (diff)
ALSA: hda - Merge alc*_parse_auto_config() functions in patch_realtek.c
Now all alc*_parse_auto_config() do almost same thing except for the NID list to ignore and the PINs for SSID-check, we can merge all these to a single function. A good amount of code reduction. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c686
1 files changed, 160 insertions, 526 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 10de78d8bc2..aaa27557e04 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1338,11 +1338,11 @@ do_sku:
1338 return 1; 1338 return 1;
1339} 1339}
1340 1340
1341static void alc_ssid_check(struct hda_codec *codec, 1341/* Check the validity of ALC subsystem-id
1342 hda_nid_t porta, hda_nid_t porte, 1342 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1343 hda_nid_t portd, hda_nid_t porti) 1343static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
1344{ 1344{
1345 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) { 1345 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
1346 struct alc_spec *spec = codec->spec; 1346 struct alc_spec *spec = codec->spec;
1347 snd_printd("realtek: " 1347 snd_printd("realtek: "
1348 "Enable default setup for auto mode as fallback\n"); 1348 "Enable default setup for auto mode as fallback\n");
@@ -3527,22 +3527,31 @@ static inline int has_cdefine_beep(struct hda_codec *codec)
3527/* return 1 if successful, 0 if the proper config is not found, 3527/* return 1 if successful, 0 if the proper config is not found,
3528 * or a negative error code 3528 * or a negative error code
3529 */ 3529 */
3530static int alc880_parse_auto_config(struct hda_codec *codec) 3530static int alc_parse_auto_config(struct hda_codec *codec,
3531 const hda_nid_t *ignore_nids,
3532 const hda_nid_t *ssid_nids)
3531{ 3533{
3532 struct alc_spec *spec = codec->spec; 3534 struct alc_spec *spec = codec->spec;
3533 int err; 3535 int err;
3534 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3535 3536
3536 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3537 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3537 alc880_ignore); 3538 ignore_nids);
3538 if (err < 0) 3539 if (err < 0)
3539 return err; 3540 return err;
3540 if (!spec->autocfg.line_outs) 3541 if (!spec->autocfg.line_outs) {
3542 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
3543 spec->multiout.max_channels = 2;
3544 spec->no_analog = 1;
3545 goto dig_only;
3546 }
3541 return 0; /* can't find valid BIOS pin config */ 3547 return 0; /* can't find valid BIOS pin config */
3542 3548 }
3543 err = alc_auto_fill_dac_nids(codec); 3549 err = alc_auto_fill_dac_nids(codec);
3544 if (err < 0) 3550 if (err < 0)
3545 return err; 3551 return err;
3552 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
3553 if (err < 0)
3554 return err;
3546 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg); 3555 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
3547 if (err < 0) 3556 if (err < 0)
3548 return err; 3557 return err;
@@ -3558,19 +3567,35 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3558 3567
3559 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3568 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3560 3569
3570 dig_only:
3561 alc_auto_parse_digital(codec); 3571 alc_auto_parse_digital(codec);
3562 3572
3563 if (spec->kctls.list) 3573 if (!spec->no_analog)
3564 add_mixer(spec, spec->kctls.list); 3574 alc_remove_invalid_adc_nids(codec);
3575
3576 if (ssid_nids)
3577 alc_ssid_check(codec, ssid_nids);
3565 3578
3566 alc_remove_invalid_adc_nids(codec); 3579 if (!spec->no_analog) {
3580 alc_auto_check_switches(codec);
3581 err = alc_auto_add_mic_boost(codec);
3582 if (err < 0)
3583 return err;
3584 }
3567 3585
3568 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); 3586 if (spec->kctls.list)
3569 alc_auto_check_switches(codec); 3587 add_mixer(spec, spec->kctls.list);
3570 3588
3571 return 1; 3589 return 1;
3572} 3590}
3573 3591
3592static int alc880_parse_auto_config(struct hda_codec *codec)
3593{
3594 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3595 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3596 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
3597}
3598
3574#ifdef CONFIG_SND_HDA_POWER_SAVE 3599#ifdef CONFIG_SND_HDA_POWER_SAVE
3575static const struct hda_amp_list alc880_loopbacks[] = { 3600static const struct hda_amp_list alc880_loopbacks[] = {
3576 { 0x0b, HDA_INPUT, 0 }, 3601 { 0x0b, HDA_INPUT, 0 },
@@ -3643,22 +3668,26 @@ static int patch_alc880(struct hda_codec *codec)
3643#endif 3668#endif
3644 } 3669 }
3645 3670
3646 err = snd_hda_attach_beep_device(codec, 0x1);
3647 if (err < 0) {
3648 alc_free(codec);
3649 return err;
3650 }
3651
3652 if (board_config != ALC_MODEL_AUTO) 3671 if (board_config != ALC_MODEL_AUTO)
3653 setup_preset(codec, &alc880_presets[board_config]); 3672 setup_preset(codec, &alc880_presets[board_config]);
3654 3673
3655 if (!spec->adc_nids && spec->input_mux) { 3674 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
3656 alc_auto_fill_adc_caps(codec); 3675 alc_auto_fill_adc_caps(codec);
3657 alc_rebuild_imux_for_auto_mic(codec); 3676 alc_rebuild_imux_for_auto_mic(codec);
3658 alc_remove_invalid_adc_nids(codec); 3677 alc_remove_invalid_adc_nids(codec);
3659 } 3678 }
3660 set_capture_mixer(codec); 3679
3661 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 3680 if (!spec->no_analog && !spec->cap_mixer)
3681 set_capture_mixer(codec);
3682
3683 if (!spec->no_analog) {
3684 err = snd_hda_attach_beep_device(codec, 0x1);
3685 if (err < 0) {
3686 alc_free(codec);
3687 return err;
3688 }
3689 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3690 }
3662 3691
3663 spec->vmaster_nid = 0x0c; 3692 spec->vmaster_nid = 0x0c;
3664 3693
@@ -3679,43 +3708,9 @@ static int patch_alc880(struct hda_codec *codec)
3679 */ 3708 */
3680static int alc260_parse_auto_config(struct hda_codec *codec) 3709static int alc260_parse_auto_config(struct hda_codec *codec)
3681{ 3710{
3682 struct alc_spec *spec = codec->spec;
3683 int err;
3684 static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; 3711 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
3685 3712 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
3686 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3713 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
3687 alc260_ignore);
3688 if (err < 0)
3689 return err;
3690 err = alc_auto_fill_dac_nids(codec);
3691 if (err < 0)
3692 return err;
3693 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
3694 if (err < 0)
3695 return err;
3696 err = alc_auto_create_hp_out(codec);
3697 if (err < 0)
3698 return err;
3699 err = alc_auto_create_speaker_out(codec);
3700 if (err < 0)
3701 return err;
3702 err = alc_auto_create_input_ctls(codec);
3703 if (err < 0)
3704 return err;
3705
3706 spec->multiout.max_channels = 2;
3707
3708 alc_auto_parse_digital(codec);
3709
3710 if (spec->kctls.list)
3711 add_mixer(spec, spec->kctls.list);
3712
3713 alc_remove_invalid_adc_nids(codec);
3714
3715 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
3716 alc_auto_check_switches(codec);
3717
3718 return 1;
3719} 3714}
3720 3715
3721#ifdef CONFIG_SND_HDA_POWER_SAVE 3716#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3800,22 +3795,26 @@ static int patch_alc260(struct hda_codec *codec)
3800#endif 3795#endif
3801 } 3796 }
3802 3797
3803 err = snd_hda_attach_beep_device(codec, 0x1);
3804 if (err < 0) {
3805 alc_free(codec);
3806 return err;
3807 }
3808
3809 if (board_config != ALC_MODEL_AUTO) 3798 if (board_config != ALC_MODEL_AUTO)
3810 setup_preset(codec, &alc260_presets[board_config]); 3799 setup_preset(codec, &alc260_presets[board_config]);
3811 3800
3812 if (!spec->adc_nids && spec->input_mux) { 3801 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
3813 alc_auto_fill_adc_caps(codec); 3802 alc_auto_fill_adc_caps(codec);
3814 alc_rebuild_imux_for_auto_mic(codec); 3803 alc_rebuild_imux_for_auto_mic(codec);
3815 alc_remove_invalid_adc_nids(codec); 3804 alc_remove_invalid_adc_nids(codec);
3816 } 3805 }
3817 set_capture_mixer(codec); 3806
3818 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 3807 if (!spec->no_analog && !spec->cap_mixer)
3808 set_capture_mixer(codec);
3809
3810 if (!spec->no_analog) {
3811 err = snd_hda_attach_beep_device(codec, 0x1);
3812 if (err < 0) {
3813 alc_free(codec);
3814 return err;
3815 }
3816 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
3817 }
3819 3818
3820 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 3819 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
3821 3820
@@ -3904,53 +3903,9 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
3904/* almost identical with ALC880 parser... */ 3903/* almost identical with ALC880 parser... */
3905static int alc882_parse_auto_config(struct hda_codec *codec) 3904static int alc882_parse_auto_config(struct hda_codec *codec)
3906{ 3905{
3907 struct alc_spec *spec = codec->spec;
3908 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; 3906 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
3909 int err; 3907 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3910 3908 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
3911 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3912 alc882_ignore);
3913 if (err < 0)
3914 return err;
3915 if (!spec->autocfg.line_outs)
3916 return 0; /* can't find valid BIOS pin config */
3917
3918 err = alc_auto_fill_dac_nids(codec);
3919 if (err < 0)
3920 return err;
3921 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
3922 if (err < 0)
3923 return err;
3924 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
3925 if (err < 0)
3926 return err;
3927 err = alc_auto_create_hp_out(codec);
3928 if (err < 0)
3929 return err;
3930 err = alc_auto_create_speaker_out(codec);
3931 if (err < 0)
3932 return err;
3933 err = alc_auto_create_input_ctls(codec);
3934 if (err < 0)
3935 return err;
3936
3937 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3938
3939 alc_auto_parse_digital(codec);
3940
3941 if (spec->kctls.list)
3942 add_mixer(spec, spec->kctls.list);
3943
3944 err = alc_auto_add_mic_boost(codec);
3945 if (err < 0)
3946 return err;
3947
3948 alc_remove_invalid_adc_nids(codec);
3949
3950 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
3951 alc_auto_check_switches(codec);
3952
3953 return 1; /* config found */
3954} 3909}
3955 3910
3956/* 3911/*
@@ -4019,27 +3974,26 @@ static int patch_alc882(struct hda_codec *codec)
4019#endif 3974#endif
4020 } 3975 }
4021 3976
4022 if (has_cdefine_beep(codec)) {
4023 err = snd_hda_attach_beep_device(codec, 0x1);
4024 if (err < 0) {
4025 alc_free(codec);
4026 return err;
4027 }
4028 }
4029
4030 if (board_config != ALC_MODEL_AUTO) 3977 if (board_config != ALC_MODEL_AUTO)
4031 setup_preset(codec, &alc882_presets[board_config]); 3978 setup_preset(codec, &alc882_presets[board_config]);
4032 3979
4033 if (!spec->adc_nids && spec->input_mux) { 3980 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
4034 alc_auto_fill_adc_caps(codec); 3981 alc_auto_fill_adc_caps(codec);
4035 alc_rebuild_imux_for_auto_mic(codec); 3982 alc_rebuild_imux_for_auto_mic(codec);
4036 alc_remove_invalid_adc_nids(codec); 3983 alc_remove_invalid_adc_nids(codec);
4037 } 3984 }
4038 3985
4039 set_capture_mixer(codec); 3986 if (!spec->no_analog && !spec->cap_mixer)
3987 set_capture_mixer(codec);
4040 3988
4041 if (has_cdefine_beep(codec)) 3989 if (!spec->no_analog && has_cdefine_beep(codec)) {
3990 err = snd_hda_attach_beep_device(codec, 0x1);
3991 if (err < 0) {
3992 alc_free(codec);
3993 return err;
3994 }
4042 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 3995 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3996 }
4043 3997
4044 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 3998 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4045 3999
@@ -4064,56 +4018,9 @@ static int patch_alc882(struct hda_codec *codec)
4064 */ 4018 */
4065static int alc262_parse_auto_config(struct hda_codec *codec) 4019static int alc262_parse_auto_config(struct hda_codec *codec)
4066{ 4020{
4067 struct alc_spec *spec = codec->spec;
4068 int err;
4069 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 4021 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4070 4022 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4071 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4023 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
4072 alc262_ignore);
4073 if (err < 0)
4074 return err;
4075 if (!spec->autocfg.line_outs) {
4076 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
4077 spec->multiout.max_channels = 2;
4078 spec->no_analog = 1;
4079 goto dig_only;
4080 }
4081 return 0; /* can't find valid BIOS pin config */
4082 }
4083 err = alc_auto_fill_dac_nids(codec);
4084 if (err < 0)
4085 return err;
4086 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4087 if (err < 0)
4088 return err;
4089 err = alc_auto_create_hp_out(codec);
4090 if (err < 0)
4091 return err;
4092 err = alc_auto_create_speaker_out(codec);
4093 if (err < 0)
4094 return err;
4095 err = alc_auto_create_input_ctls(codec);
4096 if (err < 0)
4097 return err;
4098
4099 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4100
4101 dig_only:
4102 alc_auto_parse_digital(codec);
4103
4104 if (spec->kctls.list)
4105 add_mixer(spec, spec->kctls.list);
4106
4107 err = alc_auto_add_mic_boost(codec);
4108 if (err < 0)
4109 return err;
4110
4111 alc_remove_invalid_adc_nids(codec);
4112
4113 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
4114 alc_auto_check_switches(codec);
4115
4116 return 1;
4117} 4024}
4118 4025
4119/* 4026/*
@@ -4221,26 +4128,26 @@ static int patch_alc262(struct hda_codec *codec)
4221#endif 4128#endif
4222 } 4129 }
4223 4130
4224 if (!spec->no_analog && has_cdefine_beep(codec)) {
4225 err = snd_hda_attach_beep_device(codec, 0x1);
4226 if (err < 0) {
4227 alc_free(codec);
4228 return err;
4229 }
4230 }
4231
4232 if (board_config != ALC_MODEL_AUTO) 4131 if (board_config != ALC_MODEL_AUTO)
4233 setup_preset(codec, &alc262_presets[board_config]); 4132 setup_preset(codec, &alc262_presets[board_config]);
4234 4133
4235 if (!spec->adc_nids && spec->input_mux) { 4134 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
4236 alc_auto_fill_adc_caps(codec); 4135 alc_auto_fill_adc_caps(codec);
4237 alc_rebuild_imux_for_auto_mic(codec); 4136 alc_rebuild_imux_for_auto_mic(codec);
4238 alc_remove_invalid_adc_nids(codec); 4137 alc_remove_invalid_adc_nids(codec);
4239 } 4138 }
4240 if (!spec->cap_mixer && !spec->no_analog) 4139
4140 if (!spec->no_analog && !spec->cap_mixer)
4241 set_capture_mixer(codec); 4141 set_capture_mixer(codec);
4242 if (!spec->no_analog && has_cdefine_beep(codec)) 4142
4143 if (!spec->no_analog && has_cdefine_beep(codec)) {
4144 err = snd_hda_attach_beep_device(codec, 0x1);
4145 if (err < 0) {
4146 alc_free(codec);
4147 return err;
4148 }
4243 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4149 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4150 }
4244 4151
4245 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4152 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4246 4153
@@ -4292,65 +4199,16 @@ static const struct hda_verb alc268_beep_init_verbs[] = {
4292 */ 4199 */
4293static int alc268_parse_auto_config(struct hda_codec *codec) 4200static int alc268_parse_auto_config(struct hda_codec *codec)
4294{ 4201{
4202 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4295 struct alc_spec *spec = codec->spec; 4203 struct alc_spec *spec = codec->spec;
4296 int err; 4204 int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
4297 static const hda_nid_t alc268_ignore[] = { 0 }; 4205 if (err > 0) {
4298 4206 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
4299 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4207 add_mixer(spec, alc268_beep_mixer);
4300 alc268_ignore); 4208 add_verb(spec, alc268_beep_init_verbs);
4301 if (err < 0)
4302 return err;
4303 if (!spec->autocfg.line_outs) {
4304 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
4305 spec->multiout.max_channels = 2;
4306 spec->no_analog = 1;
4307 goto dig_only;
4308 } 4209 }
4309 return 0; /* can't find valid BIOS pin config */
4310 } 4210 }
4311 4211 return err;
4312 err = alc_auto_fill_dac_nids(codec);
4313 if (err < 0)
4314 return err;
4315 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
4316 if (err < 0)
4317 return err;
4318 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4319 if (err < 0)
4320 return err;
4321 err = alc_auto_create_hp_out(codec);
4322 if (err < 0)
4323 return err;
4324 err = alc_auto_create_speaker_out(codec);
4325 if (err < 0)
4326 return err;
4327 err = alc_auto_create_input_ctls(codec);
4328 if (err < 0)
4329 return err;
4330
4331 spec->multiout.max_channels = 2;
4332
4333 dig_only:
4334 /* digital only support output */
4335 alc_auto_parse_digital(codec);
4336 if (spec->kctls.list)
4337 add_mixer(spec, spec->kctls.list);
4338
4339 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
4340 add_mixer(spec, alc268_beep_mixer);
4341 add_verb(spec, alc268_beep_init_verbs);
4342 }
4343
4344 err = alc_auto_add_mic_boost(codec);
4345 if (err < 0)
4346 return err;
4347
4348 alc_remove_invalid_adc_nids(codec);
4349
4350 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
4351 alc_auto_check_switches(codec);
4352
4353 return 1;
4354} 4212}
4355 4213
4356/* 4214/*
@@ -4435,7 +4293,7 @@ static int patch_alc268(struct hda_codec *codec)
4435 alc_remove_invalid_adc_nids(codec); 4293 alc_remove_invalid_adc_nids(codec);
4436 } 4294 }
4437 4295
4438 if (!spec->cap_mixer && !spec->no_analog) 4296 if (!spec->no_analog && !spec->cap_mixer)
4439 set_capture_mixer(codec); 4297 set_capture_mixer(codec);
4440 4298
4441 spec->vmaster_nid = 0x02; 4299 spec->vmaster_nid = 0x02;
@@ -4519,54 +4377,14 @@ enum {
4519 */ 4377 */
4520static int alc269_parse_auto_config(struct hda_codec *codec) 4378static int alc269_parse_auto_config(struct hda_codec *codec)
4521{ 4379{
4522 struct alc_spec *spec = codec->spec;
4523 int err;
4524 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 4380 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
4381 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
4382 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4383 struct alc_spec *spec = codec->spec;
4384 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ?
4385 alc269va_ssids : alc269_ssids;
4525 4386
4526 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4387 return alc_parse_auto_config(codec, alc269_ignore, ssids);
4527 alc269_ignore);
4528 if (err < 0)
4529 return err;
4530
4531 err = alc_auto_fill_dac_nids(codec);
4532 if (err < 0)
4533 return err;
4534 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4535 if (err < 0)
4536 return err;
4537 err = alc_auto_create_hp_out(codec);
4538 if (err < 0)
4539 return err;
4540 err = alc_auto_create_speaker_out(codec);
4541 if (err < 0)
4542 return err;
4543 err = alc_auto_create_input_ctls(codec);
4544 if (err < 0)
4545 return err;
4546
4547 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4548
4549 alc_auto_parse_digital(codec);
4550
4551 if (spec->kctls.list)
4552 add_mixer(spec, spec->kctls.list);
4553
4554 alc_remove_invalid_adc_nids(codec);
4555
4556 if (spec->codec_variant != ALC269_TYPE_ALC269VA)
4557 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
4558 else
4559 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
4560 alc_auto_check_switches(codec);
4561
4562 err = alc_auto_add_mic_boost(codec);
4563 if (err < 0)
4564 return err;
4565
4566 if (!spec->cap_mixer && !spec->no_analog)
4567 set_capture_mixer(codec);
4568
4569 return 1;
4570} 4388}
4571 4389
4572static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) 4390static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
@@ -4857,14 +4675,6 @@ static int patch_alc269(struct hda_codec *codec)
4857#endif 4675#endif
4858 } 4676 }
4859 4677
4860 if (has_cdefine_beep(codec)) {
4861 err = snd_hda_attach_beep_device(codec, 0x1);
4862 if (err < 0) {
4863 alc_free(codec);
4864 return err;
4865 }
4866 }
4867
4868 if (board_config != ALC_MODEL_AUTO) 4678 if (board_config != ALC_MODEL_AUTO)
4869 setup_preset(codec, &alc269_presets[board_config]); 4679 setup_preset(codec, &alc269_presets[board_config]);
4870 4680
@@ -4878,16 +4688,23 @@ static int patch_alc269(struct hda_codec *codec)
4878 } 4688 }
4879#endif 4689#endif
4880 4690
4881 if (!spec->adc_nids) { /* wasn't filled automatically? use default */ 4691 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
4882 alc_auto_fill_adc_caps(codec); 4692 alc_auto_fill_adc_caps(codec);
4883 alc_rebuild_imux_for_auto_mic(codec); 4693 alc_rebuild_imux_for_auto_mic(codec);
4884 alc_remove_invalid_adc_nids(codec); 4694 alc_remove_invalid_adc_nids(codec);
4885 } 4695 }
4886 4696
4887 if (!spec->cap_mixer) 4697 if (!spec->no_analog && !spec->cap_mixer)
4888 set_capture_mixer(codec); 4698 set_capture_mixer(codec);
4889 if (has_cdefine_beep(codec)) 4699
4700 if (!spec->no_analog && has_cdefine_beep(codec)) {
4701 err = snd_hda_attach_beep_device(codec, 0x1);
4702 if (err < 0) {
4703 alc_free(codec);
4704 return err;
4705 }
4890 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 4706 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
4707 }
4891 4708
4892 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4709 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4893 4710
@@ -4918,51 +4735,9 @@ static int patch_alc269(struct hda_codec *codec)
4918 4735
4919static int alc861_parse_auto_config(struct hda_codec *codec) 4736static int alc861_parse_auto_config(struct hda_codec *codec)
4920{ 4737{
4921 struct alc_spec *spec = codec->spec;
4922 int err;
4923 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 4738 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4924 4739 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
4925 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4740 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
4926 alc861_ignore);
4927 if (err < 0)
4928 return err;
4929 if (!spec->autocfg.line_outs)
4930 return 0; /* can't find valid BIOS pin config */
4931
4932 err = alc_auto_fill_dac_nids(codec);
4933 if (err < 0)
4934 return err;
4935 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
4936 if (err < 0)
4937 return err;
4938 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4939 if (err < 0)
4940 return err;
4941 err = alc_auto_create_hp_out(codec);
4942 if (err < 0)
4943 return err;
4944 err = alc_auto_create_speaker_out(codec);
4945 if (err < 0)
4946 return err;
4947 err = alc_auto_create_input_ctls(codec);
4948 if (err < 0)
4949 return err;
4950
4951 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4952
4953 alc_auto_parse_digital(codec);
4954
4955 if (spec->kctls.list)
4956 add_mixer(spec, spec->kctls.list);
4957
4958 alc_remove_invalid_adc_nids(codec);
4959
4960 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
4961 alc_auto_check_switches(codec);
4962
4963 set_capture_mixer(codec);
4964
4965 return 1;
4966} 4741}
4967 4742
4968#ifdef CONFIG_SND_HDA_POWER_SAVE 4743#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -5048,24 +4823,26 @@ static int patch_alc861(struct hda_codec *codec)
5048#endif 4823#endif
5049 } 4824 }
5050 4825
5051 err = snd_hda_attach_beep_device(codec, 0x23);
5052 if (err < 0) {
5053 alc_free(codec);
5054 return err;
5055 }
5056
5057 if (board_config != ALC_MODEL_AUTO) 4826 if (board_config != ALC_MODEL_AUTO)
5058 setup_preset(codec, &alc861_presets[board_config]); 4827 setup_preset(codec, &alc861_presets[board_config]);
5059 4828
5060 if (!spec->adc_nids) { 4829 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
5061 alc_auto_fill_adc_caps(codec); 4830 alc_auto_fill_adc_caps(codec);
5062 alc_rebuild_imux_for_auto_mic(codec); 4831 alc_rebuild_imux_for_auto_mic(codec);
5063 alc_remove_invalid_adc_nids(codec); 4832 alc_remove_invalid_adc_nids(codec);
5064 } 4833 }
5065 4834
5066 if (!spec->cap_mixer) 4835 if (!spec->no_analog && !spec->cap_mixer)
5067 set_capture_mixer(codec); 4836 set_capture_mixer(codec);
5068 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 4837
4838 if (!spec->no_analog) {
4839 err = snd_hda_attach_beep_device(codec, 0x23);
4840 if (err < 0) {
4841 alc_free(codec);
4842 return err;
4843 }
4844 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
4845 }
5069 4846
5070 spec->vmaster_nid = 0x03; 4847 spec->vmaster_nid = 0x03;
5071 4848
@@ -5099,53 +4876,9 @@ static int patch_alc861(struct hda_codec *codec)
5099 4876
5100static int alc861vd_parse_auto_config(struct hda_codec *codec) 4877static int alc861vd_parse_auto_config(struct hda_codec *codec)
5101{ 4878{
5102 struct alc_spec *spec = codec->spec;
5103 int err;
5104 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 4879 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
5105 4880 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5106 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4881 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
5107 alc861vd_ignore);
5108 if (err < 0)
5109 return err;
5110 if (!spec->autocfg.line_outs)
5111 return 0; /* can't find valid BIOS pin config */
5112
5113 err = alc_auto_fill_dac_nids(codec);
5114 if (err < 0)
5115 return err;
5116 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
5117 if (err < 0)
5118 return err;
5119 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
5120 if (err < 0)
5121 return err;
5122 err = alc_auto_create_hp_out(codec);
5123 if (err < 0)
5124 return err;
5125 err = alc_auto_create_speaker_out(codec);
5126 if (err < 0)
5127 return err;
5128 err = alc_auto_create_input_ctls(codec);
5129 if (err < 0)
5130 return err;
5131
5132 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5133
5134 alc_auto_parse_digital(codec);
5135
5136 if (spec->kctls.list)
5137 add_mixer(spec, spec->kctls.list);
5138
5139 alc_remove_invalid_adc_nids(codec);
5140
5141 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
5142 alc_auto_check_switches(codec);
5143
5144 err = alc_auto_add_mic_boost(codec);
5145 if (err < 0)
5146 return err;
5147
5148 return 1;
5149} 4882}
5150 4883
5151enum { 4884enum {
@@ -5226,12 +4959,6 @@ static int patch_alc861vd(struct hda_codec *codec)
5226#endif 4959#endif
5227 } 4960 }
5228 4961
5229 err = snd_hda_attach_beep_device(codec, 0x23);
5230 if (err < 0) {
5231 alc_free(codec);
5232 return err;
5233 }
5234
5235 if (board_config != ALC_MODEL_AUTO) 4962 if (board_config != ALC_MODEL_AUTO)
5236 setup_preset(codec, &alc861vd_presets[board_config]); 4963 setup_preset(codec, &alc861vd_presets[board_config]);
5237 4964
@@ -5240,14 +4967,23 @@ static int patch_alc861vd(struct hda_codec *codec)
5240 add_verb(spec, alc660vd_eapd_verbs); 4967 add_verb(spec, alc660vd_eapd_verbs);
5241 } 4968 }
5242 4969
5243 if (!spec->adc_nids) { 4970 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
5244 alc_auto_fill_adc_caps(codec); 4971 alc_auto_fill_adc_caps(codec);
5245 alc_rebuild_imux_for_auto_mic(codec); 4972 alc_rebuild_imux_for_auto_mic(codec);
5246 alc_remove_invalid_adc_nids(codec); 4973 alc_remove_invalid_adc_nids(codec);
5247 } 4974 }
5248 4975
5249 set_capture_mixer(codec); 4976 if (!spec->no_analog && !spec->cap_mixer)
5250 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4977 set_capture_mixer(codec);
4978
4979 if (!spec->no_analog) {
4980 err = snd_hda_attach_beep_device(codec, 0x23);
4981 if (err < 0) {
4982 alc_free(codec);
4983 return err;
4984 }
4985 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4986 }
5251 4987
5252 spec->vmaster_nid = 0x02; 4988 spec->vmaster_nid = 0x02;
5253 4989
@@ -5287,62 +5023,17 @@ static int patch_alc861vd(struct hda_codec *codec)
5287 5023
5288static int alc662_parse_auto_config(struct hda_codec *codec) 5024static int alc662_parse_auto_config(struct hda_codec *codec)
5289{ 5025{
5290 struct alc_spec *spec = codec->spec;
5291 int err;
5292 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; 5026 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
5293 5027 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5294 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 5028 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5295 alc662_ignore); 5029 const hda_nid_t *ssids;
5296 if (err < 0)
5297 return err;
5298 if (!spec->autocfg.line_outs)
5299 return 0; /* can't find valid BIOS pin config */
5300
5301 err = alc_auto_fill_dac_nids(codec);
5302 if (err < 0)
5303 return err;
5304 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
5305 if (err < 0)
5306 return err;
5307 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
5308 if (err < 0)
5309 return err;
5310 err = alc_auto_create_extra_out(codec,
5311 spec->autocfg.speaker_pins[0],
5312 spec->multiout.extra_out_nid[0],
5313 "Speaker");
5314 if (err < 0)
5315 return err;
5316 err = alc_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
5317 spec->multiout.hp_nid,
5318 "Headphone");
5319 if (err < 0)
5320 return err;
5321 err = alc_auto_create_input_ctls(codec);
5322 if (err < 0)
5323 return err;
5324
5325 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5326
5327 alc_auto_parse_digital(codec);
5328
5329 if (spec->kctls.list)
5330 add_mixer(spec, spec->kctls.list);
5331
5332 alc_remove_invalid_adc_nids(codec);
5333 5030
5334 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || 5031 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
5335 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) 5032 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
5336 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21); 5033 ssids = alc663_ssids;
5337 else 5034 else
5338 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); 5035 ssids = alc662_ssids;
5339 alc_auto_check_switches(codec); 5036 return alc_parse_auto_config(codec, alc662_ignore, ssids);
5340
5341 err = alc_auto_add_mic_boost(codec);
5342 if (err < 0)
5343 return err;
5344
5345 return 1;
5346} 5037}
5347 5038
5348static void alc272_fixup_mario(struct hda_codec *codec, 5039static void alc272_fixup_mario(struct hda_codec *codec,
@@ -5489,27 +5180,24 @@ static int patch_alc662(struct hda_codec *codec)
5489#endif 5180#endif
5490 } 5181 }
5491 5182
5492 if (has_cdefine_beep(codec)) {
5493 err = snd_hda_attach_beep_device(codec, 0x1);
5494 if (err < 0) {
5495 alc_free(codec);
5496 return err;
5497 }
5498 }
5499
5500 if (board_config != ALC_MODEL_AUTO) 5183 if (board_config != ALC_MODEL_AUTO)
5501 setup_preset(codec, &alc662_presets[board_config]); 5184 setup_preset(codec, &alc662_presets[board_config]);
5502 5185
5503 if (!spec->adc_nids) { 5186 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
5504 alc_auto_fill_adc_caps(codec); 5187 alc_auto_fill_adc_caps(codec);
5505 alc_rebuild_imux_for_auto_mic(codec); 5188 alc_rebuild_imux_for_auto_mic(codec);
5506 alc_remove_invalid_adc_nids(codec); 5189 alc_remove_invalid_adc_nids(codec);
5507 } 5190 }
5508 5191
5509 if (!spec->cap_mixer) 5192 if (!spec->no_analog && !spec->cap_mixer)
5510 set_capture_mixer(codec); 5193 set_capture_mixer(codec);
5511 5194
5512 if (has_cdefine_beep(codec)) { 5195 if (!spec->no_analog && has_cdefine_beep(codec)) {
5196 err = snd_hda_attach_beep_device(codec, 0x1);
5197 if (err < 0) {
5198 alc_free(codec);
5199 return err;
5200 }
5513 switch (codec->vendor_id) { 5201 switch (codec->vendor_id) {
5514 case 0x10ec0662: 5202 case 0x10ec0662:
5515 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5203 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
@@ -5575,61 +5263,7 @@ static int patch_alc899(struct hda_codec *codec)
5575 5263
5576static int alc680_parse_auto_config(struct hda_codec *codec) 5264static int alc680_parse_auto_config(struct hda_codec *codec)
5577{ 5265{
5578 struct alc_spec *spec = codec->spec; 5266 return alc_parse_auto_config(codec, NULL, NULL);
5579 int err;
5580 static const hda_nid_t alc680_ignore[] = { 0 };
5581
5582 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5583 alc680_ignore);
5584 if (err < 0)
5585 return err;
5586
5587 if (!spec->autocfg.line_outs) {
5588 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
5589 spec->multiout.max_channels = 2;
5590 spec->no_analog = 1;
5591 goto dig_only;
5592 }
5593 return 0; /* can't find valid BIOS pin config */
5594 }
5595
5596 err = alc_auto_fill_dac_nids(codec);
5597 if (err < 0)
5598 return err;
5599
5600 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
5601 if (err < 0)
5602 return err;
5603
5604 err = alc_auto_create_hp_out(codec);
5605 if (err < 0)
5606 return err;
5607
5608 err = alc_auto_create_speaker_out(codec);
5609 if (err < 0)
5610 return err;
5611
5612 err = alc_auto_create_input_ctls(codec);
5613 if (err < 0)
5614 return err;
5615
5616 spec->multiout.max_channels = 2;
5617
5618 dig_only:
5619 /* digital only support output */
5620 alc_auto_parse_digital(codec);
5621 if (spec->kctls.list)
5622 add_mixer(spec, spec->kctls.list);
5623
5624 alc_remove_invalid_adc_nids(codec);
5625
5626 alc_auto_check_switches(codec);
5627
5628 err = alc_auto_add_mic_boost(codec);
5629 if (err < 0)
5630 return err;
5631
5632 return 1;
5633} 5267}
5634 5268
5635/* 5269/*
@@ -5685,13 +5319,13 @@ static int patch_alc680(struct hda_codec *codec)
5685#endif 5319#endif
5686 } 5320 }
5687 5321
5688 if (!spec->adc_nids) { 5322 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
5689 alc_auto_fill_adc_caps(codec); 5323 alc_auto_fill_adc_caps(codec);
5690 alc_rebuild_imux_for_auto_mic(codec); 5324 alc_rebuild_imux_for_auto_mic(codec);
5691 alc_remove_invalid_adc_nids(codec); 5325 alc_remove_invalid_adc_nids(codec);
5692 } 5326 }
5693 5327
5694 if (!spec->cap_mixer) 5328 if (!spec->no_analog && !spec->cap_mixer)
5695 set_capture_mixer(codec); 5329 set_capture_mixer(codec);
5696 5330
5697 spec->vmaster_nid = 0x02; 5331 spec->vmaster_nid = 0x02;