diff options
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 436 |
1 files changed, 193 insertions, 243 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 24b07c9b6a8e..d967836f36bb 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -961,18 +961,12 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
961 | static void alc_automute_pin(struct hda_codec *codec) | 961 | static void alc_automute_pin(struct hda_codec *codec) |
962 | { | 962 | { |
963 | struct alc_spec *spec = codec->spec; | 963 | struct alc_spec *spec = codec->spec; |
964 | unsigned int present, pincap; | ||
965 | unsigned int nid = spec->autocfg.hp_pins[0]; | 964 | unsigned int nid = spec->autocfg.hp_pins[0]; |
966 | int i; | 965 | int i; |
967 | 966 | ||
968 | if (!nid) | 967 | if (!nid) |
969 | return; | 968 | return; |
970 | pincap = snd_hda_query_pin_caps(codec, nid); | 969 | spec->jack_present = snd_hda_jack_detect(codec, nid); |
971 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
972 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
973 | present = snd_hda_codec_read(codec, nid, 0, | ||
974 | AC_VERB_GET_PIN_SENSE, 0); | ||
975 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
976 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { | 970 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
977 | nid = spec->autocfg.speaker_pins[i]; | 971 | nid = spec->autocfg.speaker_pins[i]; |
978 | if (!nid) | 972 | if (!nid) |
@@ -1012,9 +1006,7 @@ static void alc_mic_automute(struct hda_codec *codec) | |||
1012 | 1006 | ||
1013 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; | 1007 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; |
1014 | 1008 | ||
1015 | present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0, | 1009 | present = snd_hda_jack_detect(codec, spec->ext_mic.pin); |
1016 | AC_VERB_GET_PIN_SENSE, 0); | ||
1017 | present &= AC_PINSENSE_PRESENCE; | ||
1018 | if (present) { | 1010 | if (present) { |
1019 | alive = &spec->ext_mic; | 1011 | alive = &spec->ext_mic; |
1020 | dead = &spec->int_mic; | 1012 | dead = &spec->int_mic; |
@@ -1402,6 +1394,17 @@ static void alc_pick_fixup(struct hda_codec *codec, | |||
1402 | add_verb(codec->spec, fix->verbs); | 1394 | add_verb(codec->spec, fix->verbs); |
1403 | } | 1395 | } |
1404 | 1396 | ||
1397 | static int alc_read_coef_idx(struct hda_codec *codec, | ||
1398 | unsigned int coef_idx) | ||
1399 | { | ||
1400 | unsigned int val; | ||
1401 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | ||
1402 | coef_idx); | ||
1403 | val = snd_hda_codec_read(codec, 0x20, 0, | ||
1404 | AC_VERB_GET_PROC_COEF, 0); | ||
1405 | return val; | ||
1406 | } | ||
1407 | |||
1405 | /* | 1408 | /* |
1406 | * ALC888 | 1409 | * ALC888 |
1407 | */ | 1410 | */ |
@@ -1513,7 +1516,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |||
1513 | static void alc_automute_amp(struct hda_codec *codec) | 1516 | static void alc_automute_amp(struct hda_codec *codec) |
1514 | { | 1517 | { |
1515 | struct alc_spec *spec = codec->spec; | 1518 | struct alc_spec *spec = codec->spec; |
1516 | unsigned int val, mute, pincap; | 1519 | unsigned int mute; |
1517 | hda_nid_t nid; | 1520 | hda_nid_t nid; |
1518 | int i; | 1521 | int i; |
1519 | 1522 | ||
@@ -1522,13 +1525,7 @@ static void alc_automute_amp(struct hda_codec *codec) | |||
1522 | nid = spec->autocfg.hp_pins[i]; | 1525 | nid = spec->autocfg.hp_pins[i]; |
1523 | if (!nid) | 1526 | if (!nid) |
1524 | break; | 1527 | break; |
1525 | pincap = snd_hda_query_pin_caps(codec, nid); | 1528 | if (snd_hda_jack_detect(codec, nid)) { |
1526 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
1527 | snd_hda_codec_read(codec, nid, 0, | ||
1528 | AC_VERB_SET_PIN_SENSE, 0); | ||
1529 | val = snd_hda_codec_read(codec, nid, 0, | ||
1530 | AC_VERB_GET_PIN_SENSE, 0); | ||
1531 | if (val & AC_PINSENSE_PRESENCE) { | ||
1532 | spec->jack_present = 1; | 1529 | spec->jack_present = 1; |
1533 | break; | 1530 | break; |
1534 | } | 1531 | } |
@@ -1786,6 +1783,8 @@ static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) | |||
1786 | 1783 | ||
1787 | spec->autocfg.hp_pins[0] = 0x15; | 1784 | spec->autocfg.hp_pins[0] = 0x15; |
1788 | spec->autocfg.speaker_pins[0] = 0x14; | 1785 | spec->autocfg.speaker_pins[0] = 0x14; |
1786 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1787 | spec->autocfg.speaker_pins[2] = 0x17; | ||
1789 | } | 1788 | } |
1790 | 1789 | ||
1791 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) | 1790 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) |
@@ -2410,12 +2409,14 @@ static const char *alc_slave_sws[] = { | |||
2410 | 2409 | ||
2411 | static void alc_free_kctls(struct hda_codec *codec); | 2410 | static void alc_free_kctls(struct hda_codec *codec); |
2412 | 2411 | ||
2412 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2413 | /* additional beep mixers; the actual parameters are overwritten at build */ | 2413 | /* additional beep mixers; the actual parameters are overwritten at build */ |
2414 | static struct snd_kcontrol_new alc_beep_mixer[] = { | 2414 | static struct snd_kcontrol_new alc_beep_mixer[] = { |
2415 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), | 2415 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
2416 | HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT), | 2416 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
2417 | { } /* end */ | 2417 | { } /* end */ |
2418 | }; | 2418 | }; |
2419 | #endif | ||
2419 | 2420 | ||
2420 | static int alc_build_controls(struct hda_codec *codec) | 2421 | static int alc_build_controls(struct hda_codec *codec) |
2421 | { | 2422 | { |
@@ -2452,6 +2453,7 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2452 | return err; | 2453 | return err; |
2453 | } | 2454 | } |
2454 | 2455 | ||
2456 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2455 | /* create beep controls if needed */ | 2457 | /* create beep controls if needed */ |
2456 | if (spec->beep_amp) { | 2458 | if (spec->beep_amp) { |
2457 | struct snd_kcontrol_new *knew; | 2459 | struct snd_kcontrol_new *knew; |
@@ -2461,11 +2463,13 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2461 | if (!kctl) | 2463 | if (!kctl) |
2462 | return -ENOMEM; | 2464 | return -ENOMEM; |
2463 | kctl->private_value = spec->beep_amp; | 2465 | kctl->private_value = spec->beep_amp; |
2464 | err = snd_hda_ctl_add(codec, kctl); | 2466 | err = snd_hda_ctl_add(codec, |
2467 | get_amp_nid_(spec->beep_amp), kctl); | ||
2465 | if (err < 0) | 2468 | if (err < 0) |
2466 | return err; | 2469 | return err; |
2467 | } | 2470 | } |
2468 | } | 2471 | } |
2472 | #endif | ||
2469 | 2473 | ||
2470 | /* if we have no master control, let's create it */ | 2474 | /* if we have no master control, let's create it */ |
2471 | if (!spec->no_analog && | 2475 | if (!spec->no_analog && |
@@ -2779,8 +2783,7 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2779 | unsigned int present; | 2783 | unsigned int present; |
2780 | unsigned char bits; | 2784 | unsigned char bits; |
2781 | 2785 | ||
2782 | present = snd_hda_codec_read(codec, 0x18, 0, | 2786 | present = snd_hda_jack_detect(codec, 0x18); |
2783 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2784 | bits = present ? HDA_AMP_MUTE : 0; | 2787 | bits = present ? HDA_AMP_MUTE : 0; |
2785 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2788 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2786 | } | 2789 | } |
@@ -3480,7 +3483,7 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
3480 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), | 3483 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
3481 | "%s Analog", codec->chip_name); | 3484 | "%s Analog", codec->chip_name); |
3482 | info->name = spec->stream_name_analog; | 3485 | info->name = spec->stream_name_analog; |
3483 | 3486 | ||
3484 | if (spec->stream_analog_playback) { | 3487 | if (spec->stream_analog_playback) { |
3485 | if (snd_BUG_ON(!spec->multiout.dac_nids)) | 3488 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3486 | return -EINVAL; | 3489 | return -EINVAL; |
@@ -4322,10 +4325,26 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4322 | knew->name = kstrdup(name, GFP_KERNEL); | 4325 | knew->name = kstrdup(name, GFP_KERNEL); |
4323 | if (!knew->name) | 4326 | if (!knew->name) |
4324 | return -ENOMEM; | 4327 | return -ENOMEM; |
4328 | if (get_amp_nid_(val)) | ||
4329 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | ||
4325 | knew->private_value = val; | 4330 | knew->private_value = val; |
4326 | return 0; | 4331 | return 0; |
4327 | } | 4332 | } |
4328 | 4333 | ||
4334 | static int add_control_with_pfx(struct alc_spec *spec, int type, | ||
4335 | const char *pfx, const char *dir, | ||
4336 | const char *sfx, unsigned long val) | ||
4337 | { | ||
4338 | char name[32]; | ||
4339 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); | ||
4340 | return add_control(spec, type, name, val); | ||
4341 | } | ||
4342 | |||
4343 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ | ||
4344 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val) | ||
4345 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ | ||
4346 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val) | ||
4347 | |||
4329 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | 4348 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
4330 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | 4349 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
4331 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | 4350 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
@@ -4379,7 +4398,6 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, | |||
4379 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | 4398 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
4380 | const struct auto_pin_cfg *cfg) | 4399 | const struct auto_pin_cfg *cfg) |
4381 | { | 4400 | { |
4382 | char name[32]; | ||
4383 | static const char *chname[4] = { | 4401 | static const char *chname[4] = { |
4384 | "Front", "Surround", NULL /*CLFE*/, "Side" | 4402 | "Front", "Surround", NULL /*CLFE*/, "Side" |
4385 | }; | 4403 | }; |
@@ -4392,26 +4410,26 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4392 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | 4410 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
4393 | if (i == 2) { | 4411 | if (i == 2) { |
4394 | /* Center/LFE */ | 4412 | /* Center/LFE */ |
4395 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4413 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4396 | "Center Playback Volume", | 4414 | "Center", |
4397 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | 4415 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
4398 | HDA_OUTPUT)); | 4416 | HDA_OUTPUT)); |
4399 | if (err < 0) | 4417 | if (err < 0) |
4400 | return err; | 4418 | return err; |
4401 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4419 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4402 | "LFE Playback Volume", | 4420 | "LFE", |
4403 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | 4421 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
4404 | HDA_OUTPUT)); | 4422 | HDA_OUTPUT)); |
4405 | if (err < 0) | 4423 | if (err < 0) |
4406 | return err; | 4424 | return err; |
4407 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4425 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4408 | "Center Playback Switch", | 4426 | "Center", |
4409 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | 4427 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
4410 | HDA_INPUT)); | 4428 | HDA_INPUT)); |
4411 | if (err < 0) | 4429 | if (err < 0) |
4412 | return err; | 4430 | return err; |
4413 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4431 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4414 | "LFE Playback Switch", | 4432 | "LFE", |
4415 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | 4433 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
4416 | HDA_INPUT)); | 4434 | HDA_INPUT)); |
4417 | if (err < 0) | 4435 | if (err < 0) |
@@ -4423,14 +4441,12 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4423 | pfx = "Speaker"; | 4441 | pfx = "Speaker"; |
4424 | else | 4442 | else |
4425 | pfx = chname[i]; | 4443 | pfx = chname[i]; |
4426 | sprintf(name, "%s Playback Volume", pfx); | 4444 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4427 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4428 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 4445 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
4429 | HDA_OUTPUT)); | 4446 | HDA_OUTPUT)); |
4430 | if (err < 0) | 4447 | if (err < 0) |
4431 | return err; | 4448 | return err; |
4432 | sprintf(name, "%s Playback Switch", pfx); | 4449 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4433 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4434 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | 4450 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
4435 | HDA_INPUT)); | 4451 | HDA_INPUT)); |
4436 | if (err < 0) | 4452 | if (err < 0) |
@@ -4446,7 +4462,6 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4446 | { | 4462 | { |
4447 | hda_nid_t nid; | 4463 | hda_nid_t nid; |
4448 | int err; | 4464 | int err; |
4449 | char name[32]; | ||
4450 | 4465 | ||
4451 | if (!pin) | 4466 | if (!pin) |
4452 | return 0; | 4467 | return 0; |
@@ -4460,21 +4475,18 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4460 | spec->multiout.extra_out_nid[0] = nid; | 4475 | spec->multiout.extra_out_nid[0] = nid; |
4461 | /* control HP volume/switch on the output mixer amp */ | 4476 | /* control HP volume/switch on the output mixer amp */ |
4462 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | 4477 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
4463 | sprintf(name, "%s Playback Volume", pfx); | 4478 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4464 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4465 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 4479 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
4466 | if (err < 0) | 4480 | if (err < 0) |
4467 | return err; | 4481 | return err; |
4468 | sprintf(name, "%s Playback Switch", pfx); | 4482 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4469 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4470 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | 4483 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
4471 | if (err < 0) | 4484 | if (err < 0) |
4472 | return err; | 4485 | return err; |
4473 | } else if (alc880_is_multi_pin(pin)) { | 4486 | } else if (alc880_is_multi_pin(pin)) { |
4474 | /* set manual connection */ | 4487 | /* set manual connection */ |
4475 | /* we have only a switch on HP-out PIN */ | 4488 | /* we have only a switch on HP-out PIN */ |
4476 | sprintf(name, "%s Playback Switch", pfx); | 4489 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
4477 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4478 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 4490 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
4479 | if (err < 0) | 4491 | if (err < 0) |
4480 | return err; | 4492 | return err; |
@@ -4487,16 +4499,13 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, | |||
4487 | const char *ctlname, | 4499 | const char *ctlname, |
4488 | int idx, hda_nid_t mix_nid) | 4500 | int idx, hda_nid_t mix_nid) |
4489 | { | 4501 | { |
4490 | char name[32]; | ||
4491 | int err; | 4502 | int err; |
4492 | 4503 | ||
4493 | sprintf(name, "%s Playback Volume", ctlname); | 4504 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
4494 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4495 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4505 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4496 | if (err < 0) | 4506 | if (err < 0) |
4497 | return err; | 4507 | return err; |
4498 | sprintf(name, "%s Playback Switch", ctlname); | 4508 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
4499 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4500 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4509 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4501 | if (err < 0) | 4510 | if (err < 0) |
4502 | return err; | 4511 | return err; |
@@ -4773,8 +4782,12 @@ static void set_capture_mixer(struct hda_codec *codec) | |||
4773 | } | 4782 | } |
4774 | } | 4783 | } |
4775 | 4784 | ||
4785 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
4776 | #define set_beep_amp(spec, nid, idx, dir) \ | 4786 | #define set_beep_amp(spec, nid, idx, dir) \ |
4777 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) | 4787 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
4788 | #else | ||
4789 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | ||
4790 | #endif | ||
4778 | 4791 | ||
4779 | /* | 4792 | /* |
4780 | * OK, here we have finally the patch for ALC880 | 4793 | * OK, here we have finally the patch for ALC880 |
@@ -5087,11 +5100,8 @@ static struct hda_verb alc260_hp_unsol_verbs[] = { | |||
5087 | static void alc260_hp_automute(struct hda_codec *codec) | 5100 | static void alc260_hp_automute(struct hda_codec *codec) |
5088 | { | 5101 | { |
5089 | struct alc_spec *spec = codec->spec; | 5102 | struct alc_spec *spec = codec->spec; |
5090 | unsigned int present; | ||
5091 | 5103 | ||
5092 | present = snd_hda_codec_read(codec, 0x10, 0, | 5104 | spec->jack_present = snd_hda_jack_detect(codec, 0x10); |
5093 | AC_VERB_GET_PIN_SENSE, 0); | ||
5094 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
5095 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | 5105 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); |
5096 | } | 5106 | } |
5097 | 5107 | ||
@@ -5156,11 +5166,8 @@ static struct hda_verb alc260_hp_3013_unsol_verbs[] = { | |||
5156 | static void alc260_hp_3013_automute(struct hda_codec *codec) | 5166 | static void alc260_hp_3013_automute(struct hda_codec *codec) |
5157 | { | 5167 | { |
5158 | struct alc_spec *spec = codec->spec; | 5168 | struct alc_spec *spec = codec->spec; |
5159 | unsigned int present; | ||
5160 | 5169 | ||
5161 | present = snd_hda_codec_read(codec, 0x15, 0, | 5170 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
5162 | AC_VERB_GET_PIN_SENSE, 0); | ||
5163 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
5164 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); | 5171 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); |
5165 | } | 5172 | } |
5166 | 5173 | ||
@@ -5173,12 +5180,8 @@ static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |||
5173 | 5180 | ||
5174 | static void alc260_hp_3012_automute(struct hda_codec *codec) | 5181 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
5175 | { | 5182 | { |
5176 | unsigned int present, bits; | 5183 | unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT; |
5177 | |||
5178 | present = snd_hda_codec_read(codec, 0x10, 0, | ||
5179 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | ||
5180 | 5184 | ||
5181 | bits = present ? 0 : PIN_OUT; | ||
5182 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 5185 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5183 | bits); | 5186 | bits); |
5184 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 5187 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
@@ -5748,8 +5751,7 @@ static void alc260_replacer_672v_automute(struct hda_codec *codec) | |||
5748 | unsigned int present; | 5751 | unsigned int present; |
5749 | 5752 | ||
5750 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | 5753 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ |
5751 | present = snd_hda_codec_read(codec, 0x0f, 0, | 5754 | present = snd_hda_jack_detect(codec, 0x0f); |
5752 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
5753 | if (present) { | 5755 | if (present) { |
5754 | snd_hda_codec_write_cache(codec, 0x01, 0, | 5756 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5755 | AC_VERB_SET_GPIO_DATA, 1); | 5757 | AC_VERB_SET_GPIO_DATA, 1); |
@@ -5989,7 +5991,6 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
5989 | { | 5991 | { |
5990 | hda_nid_t nid_vol; | 5992 | hda_nid_t nid_vol; |
5991 | unsigned long vol_val, sw_val; | 5993 | unsigned long vol_val, sw_val; |
5992 | char name[32]; | ||
5993 | int err; | 5994 | int err; |
5994 | 5995 | ||
5995 | if (nid >= 0x0f && nid < 0x11) { | 5996 | if (nid >= 0x0f && nid < 0x11) { |
@@ -6009,14 +6010,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
6009 | 6010 | ||
6010 | if (!(*vol_bits & (1 << nid_vol))) { | 6011 | if (!(*vol_bits & (1 << nid_vol))) { |
6011 | /* first control for the volume widget */ | 6012 | /* first control for the volume widget */ |
6012 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | 6013 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val); |
6013 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | ||
6014 | if (err < 0) | 6014 | if (err < 0) |
6015 | return err; | 6015 | return err; |
6016 | *vol_bits |= (1 << nid_vol); | 6016 | *vol_bits |= (1 << nid_vol); |
6017 | } | 6017 | } |
6018 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | 6018 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val); |
6019 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); | ||
6020 | if (err < 0) | 6019 | if (err < 0) |
6021 | return err; | 6020 | return err; |
6022 | return 1; | 6021 | return 1; |
@@ -8184,12 +8183,8 @@ static void alc883_mitac_setup(struct hda_codec *codec) | |||
8184 | /* | 8183 | /* |
8185 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | 8184 | static void alc883_mitac_mic_automute(struct hda_codec *codec) |
8186 | { | 8185 | { |
8187 | unsigned int present; | 8186 | unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0; |
8188 | unsigned char bits; | ||
8189 | 8187 | ||
8190 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
8191 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8192 | bits = present ? HDA_AMP_MUTE : 0; | ||
8193 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 8188 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
8194 | } | 8189 | } |
8195 | */ | 8190 | */ |
@@ -8411,10 +8406,8 @@ static struct hda_channel_mode alc888_3st_hp_modes[3] = { | |||
8411 | /* toggle front-jack and RCA according to the hp-jack state */ | 8406 | /* toggle front-jack and RCA according to the hp-jack state */ |
8412 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | 8407 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) |
8413 | { | 8408 | { |
8414 | unsigned int present; | 8409 | unsigned int present = snd_hda_jack_detect(codec, 0x1b); |
8415 | 8410 | ||
8416 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8417 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8418 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8411 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8419 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8412 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8420 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8413 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
@@ -8424,10 +8417,8 @@ static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |||
8424 | /* toggle RCA according to the front-jack state */ | 8417 | /* toggle RCA according to the front-jack state */ |
8425 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | 8418 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) |
8426 | { | 8419 | { |
8427 | unsigned int present; | 8420 | unsigned int present = snd_hda_jack_detect(codec, 0x14); |
8428 | 8421 | ||
8429 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8430 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8431 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8422 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8432 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8423 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8433 | } | 8424 | } |
@@ -8468,8 +8459,7 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8468 | { | 8459 | { |
8469 | unsigned int present; | 8460 | unsigned int present; |
8470 | 8461 | ||
8471 | present = snd_hda_codec_read(codec, 0x18, 0, | 8462 | present = snd_hda_jack_detect(codec, 0x18); |
8472 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8473 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | 8463 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, |
8474 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8464 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8475 | } | 8465 | } |
@@ -8520,24 +8510,16 @@ static void alc883_haier_w66_setup(struct hda_codec *codec) | |||
8520 | 8510 | ||
8521 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8511 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
8522 | { | 8512 | { |
8523 | unsigned int present; | 8513 | int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0; |
8524 | unsigned char bits; | ||
8525 | 8514 | ||
8526 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8527 | & AC_PINSENSE_PRESENCE; | ||
8528 | bits = present ? HDA_AMP_MUTE : 0; | ||
8529 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8515 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8530 | HDA_AMP_MUTE, bits); | 8516 | HDA_AMP_MUTE, bits); |
8531 | } | 8517 | } |
8532 | 8518 | ||
8533 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | 8519 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) |
8534 | { | 8520 | { |
8535 | unsigned int present; | 8521 | int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0; |
8536 | unsigned char bits; | ||
8537 | 8522 | ||
8538 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8539 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8540 | bits = present ? HDA_AMP_MUTE : 0; | ||
8541 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8523 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8542 | HDA_AMP_MUTE, bits); | 8524 | HDA_AMP_MUTE, bits); |
8543 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8525 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
@@ -8688,8 +8670,7 @@ static void alc889A_mb31_automute(struct hda_codec *codec) | |||
8688 | /* Mute only in 2ch or 4ch mode */ | 8670 | /* Mute only in 2ch or 4ch mode */ |
8689 | if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0) | 8671 | if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0) |
8690 | == 0x00) { | 8672 | == 0x00) { |
8691 | present = snd_hda_codec_read(codec, 0x15, 0, | 8673 | present = snd_hda_jack_detect(codec, 0x15); |
8692 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | ||
8693 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8674 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8694 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8675 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8695 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 8676 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
@@ -10032,10 +10013,8 @@ static void alc262_hp_master_update(struct hda_codec *codec) | |||
10032 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | 10013 | static void alc262_hp_bpc_automute(struct hda_codec *codec) |
10033 | { | 10014 | { |
10034 | struct alc_spec *spec = codec->spec; | 10015 | struct alc_spec *spec = codec->spec; |
10035 | unsigned int presence; | 10016 | |
10036 | presence = snd_hda_codec_read(codec, 0x1b, 0, | 10017 | spec->jack_present = snd_hda_jack_detect(codec, 0x1b); |
10037 | AC_VERB_GET_PIN_SENSE, 0); | ||
10038 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | ||
10039 | alc262_hp_master_update(codec); | 10018 | alc262_hp_master_update(codec); |
10040 | } | 10019 | } |
10041 | 10020 | ||
@@ -10049,10 +10028,8 @@ static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |||
10049 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | 10028 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) |
10050 | { | 10029 | { |
10051 | struct alc_spec *spec = codec->spec; | 10030 | struct alc_spec *spec = codec->spec; |
10052 | unsigned int presence; | 10031 | |
10053 | presence = snd_hda_codec_read(codec, 0x15, 0, | 10032 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
10054 | AC_VERB_GET_PIN_SENSE, 0); | ||
10055 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | ||
10056 | alc262_hp_master_update(codec); | 10033 | alc262_hp_master_update(codec); |
10057 | } | 10034 | } |
10058 | 10035 | ||
@@ -10286,13 +10263,8 @@ static void alc262_hippo_automute(struct hda_codec *codec) | |||
10286 | { | 10263 | { |
10287 | struct alc_spec *spec = codec->spec; | 10264 | struct alc_spec *spec = codec->spec; |
10288 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | 10265 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; |
10289 | unsigned int present; | ||
10290 | 10266 | ||
10291 | /* need to execute and sync at first */ | 10267 | spec->jack_present = snd_hda_jack_detect(codec, hp_nid); |
10292 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10293 | present = snd_hda_codec_read(codec, hp_nid, 0, | ||
10294 | AC_VERB_GET_PIN_SENSE, 0); | ||
10295 | spec->jack_present = (present & 0x80000000) != 0; | ||
10296 | alc262_hippo_master_update(codec); | 10268 | alc262_hippo_master_update(codec); |
10297 | } | 10269 | } |
10298 | 10270 | ||
@@ -10618,21 +10590,8 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |||
10618 | unsigned int mute; | 10590 | unsigned int mute; |
10619 | 10591 | ||
10620 | if (force || !spec->sense_updated) { | 10592 | if (force || !spec->sense_updated) { |
10621 | unsigned int present; | 10593 | spec->jack_present = snd_hda_jack_detect(codec, 0x14) || |
10622 | /* need to execute and sync at first */ | 10594 | snd_hda_jack_detect(codec, 0x1b); |
10623 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10624 | /* check laptop HP jack */ | ||
10625 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
10626 | AC_VERB_GET_PIN_SENSE, 0); | ||
10627 | /* need to execute and sync at first */ | ||
10628 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10629 | /* check docking HP jack */ | ||
10630 | present |= snd_hda_codec_read(codec, 0x1b, 0, | ||
10631 | AC_VERB_GET_PIN_SENSE, 0); | ||
10632 | if (present & AC_PINSENSE_PRESENCE) | ||
10633 | spec->jack_present = 1; | ||
10634 | else | ||
10635 | spec->jack_present = 0; | ||
10636 | spec->sense_updated = 1; | 10595 | spec->sense_updated = 1; |
10637 | } | 10596 | } |
10638 | /* unmute internal speaker only if both HPs are unplugged and | 10597 | /* unmute internal speaker only if both HPs are unplugged and |
@@ -10677,12 +10636,7 @@ static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |||
10677 | unsigned int mute; | 10636 | unsigned int mute; |
10678 | 10637 | ||
10679 | if (force || !spec->sense_updated) { | 10638 | if (force || !spec->sense_updated) { |
10680 | unsigned int present_int_hp; | 10639 | spec->jack_present = snd_hda_jack_detect(codec, 0x1b); |
10681 | /* need to execute and sync at first */ | ||
10682 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10683 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | ||
10684 | AC_VERB_GET_PIN_SENSE, 0); | ||
10685 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | ||
10686 | spec->sense_updated = 1; | 10640 | spec->sense_updated = 1; |
10687 | } | 10641 | } |
10688 | if (spec->jack_present) { | 10642 | if (spec->jack_present) { |
@@ -10874,12 +10828,7 @@ static void alc262_ultra_automute(struct hda_codec *codec) | |||
10874 | mute = 0; | 10828 | mute = 0; |
10875 | /* auto-mute only when HP is used as HP */ | 10829 | /* auto-mute only when HP is used as HP */ |
10876 | if (!spec->cur_mux[0]) { | 10830 | if (!spec->cur_mux[0]) { |
10877 | unsigned int present; | 10831 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
10878 | /* need to execute and sync at first */ | ||
10879 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10880 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
10881 | AC_VERB_GET_PIN_SENSE, 0); | ||
10882 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
10883 | if (spec->jack_present) | 10832 | if (spec->jack_present) |
10884 | mute = HDA_AMP_MUTE; | 10833 | mute = HDA_AMP_MUTE; |
10885 | } | 10834 | } |
@@ -10956,7 +10905,6 @@ static int alc262_check_volbit(hda_nid_t nid) | |||
10956 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | 10905 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, |
10957 | const char *pfx, int *vbits) | 10906 | const char *pfx, int *vbits) |
10958 | { | 10907 | { |
10959 | char name[32]; | ||
10960 | unsigned long val; | 10908 | unsigned long val; |
10961 | int vbit; | 10909 | int vbit; |
10962 | 10910 | ||
@@ -10966,28 +10914,25 @@ static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | |||
10966 | if (*vbits & vbit) /* a volume control for this mixer already there */ | 10914 | if (*vbits & vbit) /* a volume control for this mixer already there */ |
10967 | return 0; | 10915 | return 0; |
10968 | *vbits |= vbit; | 10916 | *vbits |= vbit; |
10969 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10970 | if (vbit == 2) | 10917 | if (vbit == 2) |
10971 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | 10918 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); |
10972 | else | 10919 | else |
10973 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | 10920 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); |
10974 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | 10921 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val); |
10975 | } | 10922 | } |
10976 | 10923 | ||
10977 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | 10924 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, |
10978 | const char *pfx) | 10925 | const char *pfx) |
10979 | { | 10926 | { |
10980 | char name[32]; | ||
10981 | unsigned long val; | 10927 | unsigned long val; |
10982 | 10928 | ||
10983 | if (!nid) | 10929 | if (!nid) |
10984 | return 0; | 10930 | return 0; |
10985 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10986 | if (nid == 0x16) | 10931 | if (nid == 0x16) |
10987 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | 10932 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
10988 | else | 10933 | else |
10989 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | 10934 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
10990 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | 10935 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); |
10991 | } | 10936 | } |
10992 | 10937 | ||
10993 | /* add playback controls from the parsed DAC table */ | 10938 | /* add playback controls from the parsed DAC table */ |
@@ -11463,8 +11408,10 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = { | |||
11463 | SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06), | 11408 | SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06), |
11464 | SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO), | 11409 | SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO), |
11465 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO), | 11410 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO), |
11411 | #if 0 /* disable the quirk since model=auto works better in recent versions */ | ||
11466 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", | 11412 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", |
11467 | ALC262_SONY_ASSAMD), | 11413 | ALC262_SONY_ASSAMD), |
11414 | #endif | ||
11468 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", | 11415 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
11469 | ALC262_TOSHIBA_RX1), | 11416 | ALC262_TOSHIBA_RX1), |
11470 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), | 11417 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
@@ -11923,10 +11870,7 @@ static void alc268_acer_automute(struct hda_codec *codec, int force) | |||
11923 | unsigned int mute; | 11870 | unsigned int mute; |
11924 | 11871 | ||
11925 | if (force || !spec->sense_updated) { | 11872 | if (force || !spec->sense_updated) { |
11926 | unsigned int present; | 11873 | spec->jack_present = snd_hda_jack_detect(codec, 0x14); |
11927 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
11928 | AC_VERB_GET_PIN_SENSE, 0); | ||
11929 | spec->jack_present = (present & 0x80000000) != 0; | ||
11930 | spec->sense_updated = 1; | 11874 | spec->sense_updated = 1; |
11931 | } | 11875 | } |
11932 | if (spec->jack_present) | 11876 | if (spec->jack_present) |
@@ -12045,8 +11989,7 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |||
12045 | unsigned int present; | 11989 | unsigned int present; |
12046 | unsigned char bits; | 11990 | unsigned char bits; |
12047 | 11991 | ||
12048 | present = snd_hda_codec_read(codec, 0x15, 0, | 11992 | present = snd_hda_jack_detect(codec, 0x15); |
12049 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12050 | bits = present ? AMP_IN_MUTE(0) : 0; | 11993 | bits = present ? AMP_IN_MUTE(0) : 0; |
12051 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | 11994 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, |
12052 | AMP_IN_MUTE(0), bits); | 11995 | AMP_IN_MUTE(0), bits); |
@@ -12327,11 +12270,9 @@ static struct snd_kcontrol_new alc268_test_mixer[] = { | |||
12327 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | 12270 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, |
12328 | const char *ctlname, int idx) | 12271 | const char *ctlname, int idx) |
12329 | { | 12272 | { |
12330 | char name[32]; | ||
12331 | hda_nid_t dac; | 12273 | hda_nid_t dac; |
12332 | int err; | 12274 | int err; |
12333 | 12275 | ||
12334 | sprintf(name, "%s Playback Volume", ctlname); | ||
12335 | switch (nid) { | 12276 | switch (nid) { |
12336 | case 0x14: | 12277 | case 0x14: |
12337 | case 0x16: | 12278 | case 0x16: |
@@ -12345,7 +12286,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12345 | } | 12286 | } |
12346 | if (spec->multiout.dac_nids[0] != dac && | 12287 | if (spec->multiout.dac_nids[0] != dac && |
12347 | spec->multiout.dac_nids[1] != dac) { | 12288 | spec->multiout.dac_nids[1] != dac) { |
12348 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12289 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
12349 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, | 12290 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, |
12350 | HDA_OUTPUT)); | 12291 | HDA_OUTPUT)); |
12351 | if (err < 0) | 12292 | if (err < 0) |
@@ -12353,12 +12294,11 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12353 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; | 12294 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
12354 | } | 12295 | } |
12355 | 12296 | ||
12356 | sprintf(name, "%s Playback Switch", ctlname); | ||
12357 | if (nid != 0x16) | 12297 | if (nid != 0x16) |
12358 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12298 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12359 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | 12299 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); |
12360 | else /* mono */ | 12300 | else /* mono */ |
12361 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12301 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12362 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); | 12302 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); |
12363 | if (err < 0) | 12303 | if (err < 0) |
12364 | return err; | 12304 | return err; |
@@ -12388,8 +12328,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12388 | 12328 | ||
12389 | nid = cfg->speaker_pins[0]; | 12329 | nid = cfg->speaker_pins[0]; |
12390 | if (nid == 0x1d) { | 12330 | if (nid == 0x1d) { |
12391 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 12331 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker", |
12392 | "Speaker Playback Volume", | ||
12393 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | 12332 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
12394 | if (err < 0) | 12333 | if (err < 0) |
12395 | return err; | 12334 | return err; |
@@ -12407,8 +12346,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12407 | 12346 | ||
12408 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | 12347 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; |
12409 | if (nid == 0x16) { | 12348 | if (nid == 0x16) { |
12410 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 12349 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono", |
12411 | "Mono Playback Switch", | ||
12412 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); | 12350 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); |
12413 | if (err < 0) | 12351 | if (err < 0) |
12414 | return err; | 12352 | return err; |
@@ -13034,8 +12972,7 @@ static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |||
13034 | unsigned int present; | 12972 | unsigned int present; |
13035 | unsigned char bits; | 12973 | unsigned char bits; |
13036 | 12974 | ||
13037 | present = snd_hda_codec_read(codec, 0x15, 0, | 12975 | present = snd_hda_jack_detect(codec, 0x15); |
13038 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13039 | bits = present ? AMP_IN_MUTE(0) : 0; | 12976 | bits = present ? AMP_IN_MUTE(0) : 0; |
13040 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 12977 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
13041 | AMP_IN_MUTE(0), bits); | 12978 | AMP_IN_MUTE(0), bits); |
@@ -13060,12 +12997,10 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |||
13060 | unsigned char bits; | 12997 | unsigned char bits; |
13061 | 12998 | ||
13062 | /* Check laptop headphone socket */ | 12999 | /* Check laptop headphone socket */ |
13063 | present = snd_hda_codec_read(codec, 0x15, 0, | 13000 | present = snd_hda_jack_detect(codec, 0x15); |
13064 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13065 | 13001 | ||
13066 | /* Check port replicator headphone socket */ | 13002 | /* Check port replicator headphone socket */ |
13067 | present |= snd_hda_codec_read(codec, 0x1a, 0, | 13003 | present |= snd_hda_jack_detect(codec, 0x1a); |
13068 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13069 | 13004 | ||
13070 | bits = present ? AMP_IN_MUTE(0) : 0; | 13005 | bits = present ? AMP_IN_MUTE(0) : 0; |
13071 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13006 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
@@ -13089,11 +13024,8 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | |||
13089 | unsigned int present_laptop; | 13024 | unsigned int present_laptop; |
13090 | unsigned int present_dock; | 13025 | unsigned int present_dock; |
13091 | 13026 | ||
13092 | present_laptop = snd_hda_codec_read(codec, 0x18, 0, | 13027 | present_laptop = snd_hda_jack_detect(codec, 0x18); |
13093 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 13028 | present_dock = snd_hda_jack_detect(codec, 0x1b); |
13094 | |||
13095 | present_dock = snd_hda_codec_read(codec, 0x1b, 0, | ||
13096 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13097 | 13029 | ||
13098 | /* Laptop mic port overrides dock mic port, design decision */ | 13030 | /* Laptop mic port overrides dock mic port, design decision */ |
13099 | if (present_dock) | 13031 | if (present_dock) |
@@ -13178,8 +13110,7 @@ static void alc269_speaker_automute(struct hda_codec *codec) | |||
13178 | unsigned int present; | 13110 | unsigned int present; |
13179 | unsigned char bits; | 13111 | unsigned char bits; |
13180 | 13112 | ||
13181 | present = snd_hda_codec_read(codec, 0x15, 0, | 13113 | present = snd_hda_jack_detect(codec, 0x15); |
13182 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13183 | bits = present ? AMP_IN_MUTE(0) : 0; | 13114 | bits = present ? AMP_IN_MUTE(0) : 0; |
13184 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13115 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
13185 | AMP_IN_MUTE(0), bits); | 13116 | AMP_IN_MUTE(0), bits); |
@@ -13525,6 +13456,15 @@ static int patch_alc269(struct hda_codec *codec) | |||
13525 | 13456 | ||
13526 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 13457 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
13527 | 13458 | ||
13459 | if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ | ||
13460 | kfree(codec->chip_name); | ||
13461 | codec->chip_name = kstrdup("ALC259", GFP_KERNEL); | ||
13462 | if (!codec->chip_name) { | ||
13463 | alc_free(codec); | ||
13464 | return -ENOMEM; | ||
13465 | } | ||
13466 | } | ||
13467 | |||
13528 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, | 13468 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
13529 | alc269_models, | 13469 | alc269_models, |
13530 | alc269_cfg_tbl); | 13470 | alc269_cfg_tbl); |
@@ -14157,10 +14097,8 @@ static struct hda_verb alc861_toshiba_init_verbs[] = { | |||
14157 | /* toggle speaker-output according to the hp-jack state */ | 14097 | /* toggle speaker-output according to the hp-jack state */ |
14158 | static void alc861_toshiba_automute(struct hda_codec *codec) | 14098 | static void alc861_toshiba_automute(struct hda_codec *codec) |
14159 | { | 14099 | { |
14160 | unsigned int present; | 14100 | unsigned int present = snd_hda_jack_detect(codec, 0x0f); |
14161 | 14101 | ||
14162 | present = snd_hda_codec_read(codec, 0x0f, 0, | ||
14163 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14164 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, | 14102 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
14165 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 14103 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
14166 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | 14104 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, |
@@ -14260,9 +14198,7 @@ static int alc861_auto_fill_dac_nids(struct hda_codec *codec, | |||
14260 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, | 14198 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, |
14261 | hda_nid_t nid, unsigned int chs) | 14199 | hda_nid_t nid, unsigned int chs) |
14262 | { | 14200 | { |
14263 | char name[32]; | 14201 | return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, |
14264 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
14265 | return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name, | ||
14266 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 14202 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
14267 | } | 14203 | } |
14268 | 14204 | ||
@@ -14627,6 +14563,27 @@ static struct alc_config_preset alc861_presets[] = { | |||
14627 | }, | 14563 | }, |
14628 | }; | 14564 | }; |
14629 | 14565 | ||
14566 | /* Pin config fixes */ | ||
14567 | enum { | ||
14568 | PINFIX_FSC_AMILO_PI1505, | ||
14569 | }; | ||
14570 | |||
14571 | static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = { | ||
14572 | { 0x0b, 0x0221101f }, /* HP */ | ||
14573 | { 0x0f, 0x90170310 }, /* speaker */ | ||
14574 | { } | ||
14575 | }; | ||
14576 | |||
14577 | static const struct alc_fixup alc861_fixups[] = { | ||
14578 | [PINFIX_FSC_AMILO_PI1505] = { | ||
14579 | .pins = alc861_fsc_amilo_pi1505_pinfix | ||
14580 | }, | ||
14581 | }; | ||
14582 | |||
14583 | static struct snd_pci_quirk alc861_fixup_tbl[] = { | ||
14584 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505), | ||
14585 | {} | ||
14586 | }; | ||
14630 | 14587 | ||
14631 | static int patch_alc861(struct hda_codec *codec) | 14588 | static int patch_alc861(struct hda_codec *codec) |
14632 | { | 14589 | { |
@@ -14650,6 +14607,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
14650 | board_config = ALC861_AUTO; | 14607 | board_config = ALC861_AUTO; |
14651 | } | 14608 | } |
14652 | 14609 | ||
14610 | alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups); | ||
14611 | |||
14653 | if (board_config == ALC861_AUTO) { | 14612 | if (board_config == ALC861_AUTO) { |
14654 | /* automatic parse from the BIOS config */ | 14613 | /* automatic parse from the BIOS config */ |
14655 | err = alc861_parse_auto_config(codec); | 14614 | err = alc861_parse_auto_config(codec); |
@@ -15067,9 +15026,9 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
15067 | unsigned int present; | 15026 | unsigned int present; |
15068 | unsigned char bits; | 15027 | unsigned char bits; |
15069 | 15028 | ||
15070 | present = snd_hda_codec_read(codec, 0x18, 0, | 15029 | present = snd_hda_jack_detect(codec, 0x18); |
15071 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
15072 | bits = present ? HDA_AMP_MUTE : 0; | 15030 | bits = present ? HDA_AMP_MUTE : 0; |
15031 | |||
15073 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | 15032 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, |
15074 | HDA_AMP_MUTE, bits); | 15033 | HDA_AMP_MUTE, bits); |
15075 | } | 15034 | } |
@@ -15386,7 +15345,6 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |||
15386 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | 15345 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, |
15387 | const struct auto_pin_cfg *cfg) | 15346 | const struct auto_pin_cfg *cfg) |
15388 | { | 15347 | { |
15389 | char name[32]; | ||
15390 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | 15348 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; |
15391 | hda_nid_t nid_v, nid_s; | 15349 | hda_nid_t nid_v, nid_s; |
15392 | int i, err; | 15350 | int i, err; |
@@ -15403,26 +15361,26 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15403 | 15361 | ||
15404 | if (i == 2) { | 15362 | if (i == 2) { |
15405 | /* Center/LFE */ | 15363 | /* Center/LFE */ |
15406 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15364 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15407 | "Center Playback Volume", | 15365 | "Center", |
15408 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | 15366 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, |
15409 | HDA_OUTPUT)); | 15367 | HDA_OUTPUT)); |
15410 | if (err < 0) | 15368 | if (err < 0) |
15411 | return err; | 15369 | return err; |
15412 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15370 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15413 | "LFE Playback Volume", | 15371 | "LFE", |
15414 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | 15372 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, |
15415 | HDA_OUTPUT)); | 15373 | HDA_OUTPUT)); |
15416 | if (err < 0) | 15374 | if (err < 0) |
15417 | return err; | 15375 | return err; |
15418 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15376 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15419 | "Center Playback Switch", | 15377 | "Center", |
15420 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | 15378 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, |
15421 | HDA_INPUT)); | 15379 | HDA_INPUT)); |
15422 | if (err < 0) | 15380 | if (err < 0) |
15423 | return err; | 15381 | return err; |
15424 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15382 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15425 | "LFE Playback Switch", | 15383 | "LFE", |
15426 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | 15384 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, |
15427 | HDA_INPUT)); | 15385 | HDA_INPUT)); |
15428 | if (err < 0) | 15386 | if (err < 0) |
@@ -15437,8 +15395,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15437 | pfx = "PCM"; | 15395 | pfx = "PCM"; |
15438 | } else | 15396 | } else |
15439 | pfx = chname[i]; | 15397 | pfx = chname[i]; |
15440 | sprintf(name, "%s Playback Volume", pfx); | 15398 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15441 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15442 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | 15399 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, |
15443 | HDA_OUTPUT)); | 15400 | HDA_OUTPUT)); |
15444 | if (err < 0) | 15401 | if (err < 0) |
@@ -15446,8 +15403,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15446 | if (cfg->line_outs == 1 && | 15403 | if (cfg->line_outs == 1 && |
15447 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | 15404 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
15448 | pfx = "Speaker"; | 15405 | pfx = "Speaker"; |
15449 | sprintf(name, "%s Playback Switch", pfx); | 15406 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15450 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15451 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, | 15407 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
15452 | HDA_INPUT)); | 15408 | HDA_INPUT)); |
15453 | if (err < 0) | 15409 | if (err < 0) |
@@ -15465,7 +15421,6 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15465 | { | 15421 | { |
15466 | hda_nid_t nid_v, nid_s; | 15422 | hda_nid_t nid_v, nid_s; |
15467 | int err; | 15423 | int err; |
15468 | char name[32]; | ||
15469 | 15424 | ||
15470 | if (!pin) | 15425 | if (!pin) |
15471 | return 0; | 15426 | return 0; |
@@ -15483,21 +15438,18 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15483 | nid_s = alc861vd_idx_to_mixer_switch( | 15438 | nid_s = alc861vd_idx_to_mixer_switch( |
15484 | alc880_fixed_pin_idx(pin)); | 15439 | alc880_fixed_pin_idx(pin)); |
15485 | 15440 | ||
15486 | sprintf(name, "%s Playback Volume", pfx); | 15441 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15487 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15488 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | 15442 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); |
15489 | if (err < 0) | 15443 | if (err < 0) |
15490 | return err; | 15444 | return err; |
15491 | sprintf(name, "%s Playback Switch", pfx); | 15445 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15492 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15493 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | 15446 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); |
15494 | if (err < 0) | 15447 | if (err < 0) |
15495 | return err; | 15448 | return err; |
15496 | } else if (alc880_is_multi_pin(pin)) { | 15449 | } else if (alc880_is_multi_pin(pin)) { |
15497 | /* set manual connection */ | 15450 | /* set manual connection */ |
15498 | /* we have only a switch on HP-out PIN */ | 15451 | /* we have only a switch on HP-out PIN */ |
15499 | sprintf(name, "%s Playback Switch", pfx); | 15452 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
15500 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
15501 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 15453 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
15502 | if (err < 0) | 15454 | if (err < 0) |
15503 | return err; | 15455 | return err; |
@@ -16387,9 +16339,9 @@ static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |||
16387 | unsigned int present; | 16339 | unsigned int present; |
16388 | unsigned char bits; | 16340 | unsigned char bits; |
16389 | 16341 | ||
16390 | present = snd_hda_codec_read(codec, 0x14, 0, | 16342 | present = snd_hda_jack_detect(codec, 0x14); |
16391 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16392 | bits = present ? HDA_AMP_MUTE : 0; | 16343 | bits = present ? HDA_AMP_MUTE : 0; |
16344 | |||
16393 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 16345 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16394 | HDA_AMP_MUTE, bits); | 16346 | HDA_AMP_MUTE, bits); |
16395 | } | 16347 | } |
@@ -16399,9 +16351,9 @@ static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |||
16399 | unsigned int present; | 16351 | unsigned int present; |
16400 | unsigned char bits; | 16352 | unsigned char bits; |
16401 | 16353 | ||
16402 | present = snd_hda_codec_read(codec, 0x1b, 0, | 16354 | present = snd_hda_jack_detect(codec, 0x1b); |
16403 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16404 | bits = present ? HDA_AMP_MUTE : 0; | 16355 | bits = present ? HDA_AMP_MUTE : 0; |
16356 | |||
16405 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 16357 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16406 | HDA_AMP_MUTE, bits); | 16358 | HDA_AMP_MUTE, bits); |
16407 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 16359 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
@@ -16460,9 +16412,7 @@ static void alc663_m51va_speaker_automute(struct hda_codec *codec) | |||
16460 | unsigned int present; | 16412 | unsigned int present; |
16461 | unsigned char bits; | 16413 | unsigned char bits; |
16462 | 16414 | ||
16463 | present = snd_hda_codec_read(codec, 0x21, 0, | 16415 | present = snd_hda_jack_detect(codec, 0x21); |
16464 | AC_VERB_GET_PIN_SENSE, 0) | ||
16465 | & AC_PINSENSE_PRESENCE; | ||
16466 | bits = present ? HDA_AMP_MUTE : 0; | 16416 | bits = present ? HDA_AMP_MUTE : 0; |
16467 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16417 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16468 | AMP_IN_MUTE(0), bits); | 16418 | AMP_IN_MUTE(0), bits); |
@@ -16475,9 +16425,7 @@ static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |||
16475 | unsigned int present; | 16425 | unsigned int present; |
16476 | unsigned char bits; | 16426 | unsigned char bits; |
16477 | 16427 | ||
16478 | present = snd_hda_codec_read(codec, 0x21, 0, | 16428 | present = snd_hda_jack_detect(codec, 0x21); |
16479 | AC_VERB_GET_PIN_SENSE, 0) | ||
16480 | & AC_PINSENSE_PRESENCE; | ||
16481 | bits = present ? HDA_AMP_MUTE : 0; | 16429 | bits = present ? HDA_AMP_MUTE : 0; |
16482 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16430 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16483 | AMP_IN_MUTE(0), bits); | 16431 | AMP_IN_MUTE(0), bits); |
@@ -16494,9 +16442,7 @@ static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |||
16494 | unsigned int present; | 16442 | unsigned int present; |
16495 | unsigned char bits; | 16443 | unsigned char bits; |
16496 | 16444 | ||
16497 | present = snd_hda_codec_read(codec, 0x15, 0, | 16445 | present = snd_hda_jack_detect(codec, 0x15); |
16498 | AC_VERB_GET_PIN_SENSE, 0) | ||
16499 | & AC_PINSENSE_PRESENCE; | ||
16500 | bits = present ? HDA_AMP_MUTE : 0; | 16446 | bits = present ? HDA_AMP_MUTE : 0; |
16501 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16447 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16502 | AMP_IN_MUTE(0), bits); | 16448 | AMP_IN_MUTE(0), bits); |
@@ -16513,9 +16459,7 @@ static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |||
16513 | unsigned int present; | 16459 | unsigned int present; |
16514 | unsigned char bits; | 16460 | unsigned char bits; |
16515 | 16461 | ||
16516 | present = snd_hda_codec_read(codec, 0x1b, 0, | 16462 | present = snd_hda_jack_detect(codec, 0x1b); |
16517 | AC_VERB_GET_PIN_SENSE, 0) | ||
16518 | & AC_PINSENSE_PRESENCE; | ||
16519 | bits = present ? 0 : PIN_OUT; | 16463 | bits = present ? 0 : PIN_OUT; |
16520 | snd_hda_codec_write(codec, 0x14, 0, | 16464 | snd_hda_codec_write(codec, 0x14, 0, |
16521 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | 16465 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); |
@@ -16525,12 +16469,8 @@ static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |||
16525 | { | 16469 | { |
16526 | unsigned int present1, present2; | 16470 | unsigned int present1, present2; |
16527 | 16471 | ||
16528 | present1 = snd_hda_codec_read(codec, 0x21, 0, | 16472 | present1 = snd_hda_jack_detect(codec, 0x21); |
16529 | AC_VERB_GET_PIN_SENSE, 0) | 16473 | present2 = snd_hda_jack_detect(codec, 0x15); |
16530 | & AC_PINSENSE_PRESENCE; | ||
16531 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16532 | AC_VERB_GET_PIN_SENSE, 0) | ||
16533 | & AC_PINSENSE_PRESENCE; | ||
16534 | 16474 | ||
16535 | if (present1 || present2) { | 16475 | if (present1 || present2) { |
16536 | snd_hda_codec_write_cache(codec, 0x14, 0, | 16476 | snd_hda_codec_write_cache(codec, 0x14, 0, |
@@ -16545,12 +16485,8 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16545 | { | 16485 | { |
16546 | unsigned int present1, present2; | 16486 | unsigned int present1, present2; |
16547 | 16487 | ||
16548 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | 16488 | present1 = snd_hda_jack_detect(codec, 0x1b); |
16549 | AC_VERB_GET_PIN_SENSE, 0) | 16489 | present2 = snd_hda_jack_detect(codec, 0x15); |
16550 | & AC_PINSENSE_PRESENCE; | ||
16551 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16552 | AC_VERB_GET_PIN_SENSE, 0) | ||
16553 | & AC_PINSENSE_PRESENCE; | ||
16554 | 16490 | ||
16555 | if (present1 || present2) { | 16491 | if (present1 || present2) { |
16556 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16492 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
@@ -16710,9 +16646,7 @@ static void alc663_g71v_hp_automute(struct hda_codec *codec) | |||
16710 | unsigned int present; | 16646 | unsigned int present; |
16711 | unsigned char bits; | 16647 | unsigned char bits; |
16712 | 16648 | ||
16713 | present = snd_hda_codec_read(codec, 0x21, 0, | 16649 | present = snd_hda_jack_detect(codec, 0x21); |
16714 | AC_VERB_GET_PIN_SENSE, 0) | ||
16715 | & AC_PINSENSE_PRESENCE; | ||
16716 | bits = present ? HDA_AMP_MUTE : 0; | 16650 | bits = present ? HDA_AMP_MUTE : 0; |
16717 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 16651 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16718 | HDA_AMP_MUTE, bits); | 16652 | HDA_AMP_MUTE, bits); |
@@ -16725,9 +16659,7 @@ static void alc663_g71v_front_automute(struct hda_codec *codec) | |||
16725 | unsigned int present; | 16659 | unsigned int present; |
16726 | unsigned char bits; | 16660 | unsigned char bits; |
16727 | 16661 | ||
16728 | present = snd_hda_codec_read(codec, 0x15, 0, | 16662 | present = snd_hda_jack_detect(codec, 0x15); |
16729 | AC_VERB_GET_PIN_SENSE, 0) | ||
16730 | & AC_PINSENSE_PRESENCE; | ||
16731 | bits = present ? HDA_AMP_MUTE : 0; | 16663 | bits = present ? HDA_AMP_MUTE : 0; |
16732 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 16664 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
16733 | HDA_AMP_MUTE, bits); | 16665 | HDA_AMP_MUTE, bits); |
@@ -17264,21 +17196,17 @@ static int alc662_auto_fill_dac_nids(struct hda_codec *codec, | |||
17264 | return 0; | 17196 | return 0; |
17265 | } | 17197 | } |
17266 | 17198 | ||
17267 | static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, | 17199 | static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, |
17268 | hda_nid_t nid, unsigned int chs) | 17200 | hda_nid_t nid, unsigned int chs) |
17269 | { | 17201 | { |
17270 | char name[32]; | 17202 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
17271 | sprintf(name, "%s Playback Volume", pfx); | ||
17272 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
17273 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 17203 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
17274 | } | 17204 | } |
17275 | 17205 | ||
17276 | static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, | 17206 | static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, |
17277 | hda_nid_t nid, unsigned int chs) | 17207 | hda_nid_t nid, unsigned int chs) |
17278 | { | 17208 | { |
17279 | char name[32]; | 17209 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17280 | sprintf(name, "%s Playback Switch", pfx); | ||
17281 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17282 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); | 17210 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); |
17283 | } | 17211 | } |
17284 | 17212 | ||
@@ -17356,13 +17284,11 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, | |||
17356 | return 0; | 17284 | return 0; |
17357 | nid = alc662_look_for_dac(codec, pin); | 17285 | nid = alc662_look_for_dac(codec, pin); |
17358 | if (!nid) { | 17286 | if (!nid) { |
17359 | char name[32]; | ||
17360 | /* the corresponding DAC is already occupied */ | 17287 | /* the corresponding DAC is already occupied */ |
17361 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) | 17288 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
17362 | return 0; /* no way */ | 17289 | return 0; /* no way */ |
17363 | /* create a switch only */ | 17290 | /* create a switch only */ |
17364 | sprintf(name, "%s Playback Switch", pfx); | 17291 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17365 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17366 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 17292 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
17367 | } | 17293 | } |
17368 | 17294 | ||
@@ -17538,6 +17464,15 @@ static int patch_alc662(struct hda_codec *codec) | |||
17538 | 17464 | ||
17539 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 17465 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
17540 | 17466 | ||
17467 | if (alc_read_coef_idx(codec, 0)==0x8020){ | ||
17468 | kfree(codec->chip_name); | ||
17469 | codec->chip_name = kstrdup("ALC661", GFP_KERNEL); | ||
17470 | if (!codec->chip_name) { | ||
17471 | alc_free(codec); | ||
17472 | return -ENOMEM; | ||
17473 | } | ||
17474 | } | ||
17475 | |||
17541 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | 17476 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
17542 | alc662_models, | 17477 | alc662_models, |
17543 | alc662_cfg_tbl); | 17478 | alc662_cfg_tbl); |
@@ -17604,6 +17539,20 @@ static int patch_alc662(struct hda_codec *codec) | |||
17604 | return 0; | 17539 | return 0; |
17605 | } | 17540 | } |
17606 | 17541 | ||
17542 | static int patch_alc888(struct hda_codec *codec) | ||
17543 | { | ||
17544 | if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){ | ||
17545 | kfree(codec->chip_name); | ||
17546 | codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL); | ||
17547 | if (!codec->chip_name) { | ||
17548 | alc_free(codec); | ||
17549 | return -ENOMEM; | ||
17550 | } | ||
17551 | return patch_alc662(codec); | ||
17552 | } | ||
17553 | return patch_alc882(codec); | ||
17554 | } | ||
17555 | |||
17607 | /* | 17556 | /* |
17608 | * patch entries | 17557 | * patch entries |
17609 | */ | 17558 | */ |
@@ -17635,8 +17584,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17635 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, | 17584 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
17636 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 17585 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
17637 | .patch = patch_alc882 }, | 17586 | .patch = patch_alc882 }, |
17638 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, | 17587 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 }, |
17639 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, | 17588 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
17589 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, | ||
17640 | {} /* terminator */ | 17590 | {} /* terminator */ |
17641 | }; | 17591 | }; |
17642 | 17592 | ||