diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-05-08 09:57:59 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-05-08 09:57:59 -0400 |
commit | a9fd4f3fcdc7e5757424f7e5888f660cf34bb1a9 (patch) | |
tree | 929dcb7e5a0ffdaaadf94fced6690fa8f145824a /sound | |
parent | b72519b518211ecb7c4c7b5e660ac6235ca7d1b7 (diff) |
ALSA: hda - Clean up Realtek auto-mute unsol routines
Most of unsol handlers defined in patch_realtek.c can be classified to
two types, mute via amp of pins and mute via ctl bits of pins.
Thus there are a big room to generalize each implementation.
This patch creates two generic functions, alc_automute_amp() and
alc_automute_pin(). The latter is actually changed from the previous
alc_sku_automute(). Each caller needs to initialize hp_pins and
speaker_pins properly at own init_hook.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 901 |
1 files changed, 311 insertions, 590 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 7c043b3b81a5..34f6fb72f2bc 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -926,20 +926,26 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
926 | alc_fix_pll(codec); | 926 | alc_fix_pll(codec); |
927 | } | 927 | } |
928 | 928 | ||
929 | static void alc_sku_automute(struct hda_codec *codec) | 929 | static void alc_automute_pin(struct hda_codec *codec) |
930 | { | 930 | { |
931 | struct alc_spec *spec = codec->spec; | 931 | struct alc_spec *spec = codec->spec; |
932 | unsigned int present; | 932 | unsigned int present; |
933 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | 933 | unsigned int nid = spec->autocfg.hp_pins[0]; |
934 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | 934 | int i; |
935 | 935 | ||
936 | /* need to execute and sync at first */ | 936 | /* need to execute and sync at first */ |
937 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | 937 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); |
938 | present = snd_hda_codec_read(codec, hp_nid, 0, | 938 | present = snd_hda_codec_read(codec, nid, 0, |
939 | AC_VERB_GET_PIN_SENSE, 0); | 939 | AC_VERB_GET_PIN_SENSE, 0); |
940 | spec->jack_present = (present & 0x80000000) != 0; | 940 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
941 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 941 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
942 | spec->jack_present ? 0 : PIN_OUT); | 942 | nid = spec->autocfg.speaker_pins[i]; |
943 | if (!nid) | ||
944 | break; | ||
945 | snd_hda_codec_write(codec, nid, 0, | ||
946 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
947 | spec->jack_present ? 0 : PIN_OUT); | ||
948 | } | ||
943 | } | 949 | } |
944 | 950 | ||
945 | #if 0 /* it's broken in some acses -- temporarily disabled */ | 951 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
@@ -974,16 +980,19 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |||
974 | res >>= 28; | 980 | res >>= 28; |
975 | else | 981 | else |
976 | res >>= 26; | 982 | res >>= 26; |
977 | if (res == ALC880_HP_EVENT) | 983 | switch (res) { |
978 | alc_sku_automute(codec); | 984 | case ALC880_HP_EVENT: |
979 | 985 | alc_automute_pin(codec); | |
980 | if (res == ALC880_MIC_EVENT) | 986 | break; |
987 | case ALC880_MIC_EVENT: | ||
981 | alc_mic_automute(codec); | 988 | alc_mic_automute(codec); |
989 | break; | ||
990 | } | ||
982 | } | 991 | } |
983 | 992 | ||
984 | static void alc_inithook(struct hda_codec *codec) | 993 | static void alc_inithook(struct hda_codec *codec) |
985 | { | 994 | { |
986 | alc_sku_automute(codec); | 995 | alc_automute_pin(codec); |
987 | alc_mic_automute(codec); | 996 | alc_mic_automute(codec); |
988 | } | 997 | } |
989 | 998 | ||
@@ -1364,32 +1373,58 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |||
1364 | {} | 1373 | {} |
1365 | }; | 1374 | }; |
1366 | 1375 | ||
1367 | static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) | 1376 | static void alc_automute_amp(struct hda_codec *codec) |
1368 | { | 1377 | { |
1369 | unsigned int present; | 1378 | struct alc_spec *spec = codec->spec; |
1370 | unsigned int bits; | 1379 | unsigned int val, mute; |
1371 | /* Line out presence */ | 1380 | hda_nid_t nid; |
1372 | present = snd_hda_codec_read(codec, 0x17, 0, | 1381 | int i; |
1373 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1382 | |
1374 | /* HP out presence */ | 1383 | spec->jack_present = 0; |
1375 | present = present || snd_hda_codec_read(codec, 0x1b, 0, | 1384 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { |
1376 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1385 | nid = spec->autocfg.hp_pins[i]; |
1377 | bits = present ? HDA_AMP_MUTE : 0; | 1386 | if (!nid) |
1387 | break; | ||
1388 | val = snd_hda_codec_read(codec, nid, 0, | ||
1389 | AC_VERB_GET_PIN_SENSE, 0); | ||
1390 | if (val & AC_PINSENSE_PRESENCE) { | ||
1391 | spec->jack_present = 1; | ||
1392 | break; | ||
1393 | } | ||
1394 | } | ||
1395 | |||
1396 | mute = spec->jack_present ? HDA_AMP_MUTE : 0; | ||
1378 | /* Toggle internal speakers muting */ | 1397 | /* Toggle internal speakers muting */ |
1379 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 1398 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
1380 | HDA_AMP_MUTE, bits); | 1399 | nid = spec->autocfg.speaker_pins[i]; |
1381 | /* Toggle internal bass muting */ | 1400 | if (!nid) |
1382 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 1401 | break; |
1383 | HDA_AMP_MUTE, bits); | 1402 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
1403 | HDA_AMP_MUTE, mute); | ||
1404 | } | ||
1384 | } | 1405 | } |
1385 | 1406 | ||
1386 | static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, | 1407 | static void alc_automute_amp_unsol_event(struct hda_codec *codec, |
1387 | unsigned int res) | 1408 | unsigned int res) |
1388 | { | 1409 | { |
1389 | if (res >> 26 == ALC880_HP_EVENT) | 1410 | if (codec->vendor_id == 0x10ec0880) |
1390 | alc888_fujitsu_xa3530_automute(codec); | 1411 | res >>= 28; |
1412 | else | ||
1413 | res >>= 26; | ||
1414 | if (res == ALC880_HP_EVENT) | ||
1415 | alc_automute_amp(codec); | ||
1391 | } | 1416 | } |
1392 | 1417 | ||
1418 | static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | ||
1419 | { | ||
1420 | struct alc_spec *spec = codec->spec; | ||
1421 | |||
1422 | spec->autocfg.hp_pins[0] = 0x17; /* line-out */ | ||
1423 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ | ||
1424 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ | ||
1425 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ | ||
1426 | alc_automute_amp(codec); | ||
1427 | } | ||
1393 | 1428 | ||
1394 | /* | 1429 | /* |
1395 | * ALC888 Acer Aspire 4930G model | 1430 | * ALC888 Acer Aspire 4930G model |
@@ -1456,22 +1491,13 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1456 | { } /* end */ | 1491 | { } /* end */ |
1457 | }; | 1492 | }; |
1458 | 1493 | ||
1459 | static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) | 1494 | static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) |
1460 | { | 1495 | { |
1461 | unsigned int present; | 1496 | struct alc_spec *spec = codec->spec; |
1462 | unsigned int bits; | ||
1463 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
1464 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1465 | bits = present ? HDA_AMP_MUTE : 0; | ||
1466 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
1467 | HDA_AMP_MUTE, bits); | ||
1468 | } | ||
1469 | 1497 | ||
1470 | static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, | 1498 | spec->autocfg.hp_pins[0] = 0x15; |
1471 | unsigned int res) | 1499 | spec->autocfg.speaker_pins[0] = 0x14; |
1472 | { | 1500 | alc_automute_amp(codec); |
1473 | if (res >> 26 == ALC880_HP_EVENT) | ||
1474 | alc888_acer_aspire_4930g_automute(codec); | ||
1475 | } | 1501 | } |
1476 | 1502 | ||
1477 | /* | 1503 | /* |
@@ -2439,21 +2465,6 @@ static struct hda_verb alc880_beep_init_verbs[] = { | |||
2439 | { } | 2465 | { } |
2440 | }; | 2466 | }; |
2441 | 2467 | ||
2442 | /* toggle speaker-output according to the hp-jack state */ | ||
2443 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) | ||
2444 | { | ||
2445 | unsigned int present; | ||
2446 | unsigned char bits; | ||
2447 | |||
2448 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
2449 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2450 | bits = present ? HDA_AMP_MUTE : 0; | ||
2451 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
2452 | HDA_AMP_MUTE, bits); | ||
2453 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
2454 | HDA_AMP_MUTE, bits); | ||
2455 | } | ||
2456 | |||
2457 | /* auto-toggle front mic */ | 2468 | /* auto-toggle front mic */ |
2458 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | 2469 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) |
2459 | { | 2470 | { |
@@ -2466,9 +2477,14 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2466 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2477 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2467 | } | 2478 | } |
2468 | 2479 | ||
2469 | static void alc880_uniwill_automute(struct hda_codec *codec) | 2480 | static void alc880_uniwill_init_hook(struct hda_codec *codec) |
2470 | { | 2481 | { |
2471 | alc880_uniwill_hp_automute(codec); | 2482 | struct alc_spec *spec = codec->spec; |
2483 | |||
2484 | spec->autocfg.hp_pins[0] = 0x14; | ||
2485 | spec->autocfg.speaker_pins[0] = 0x15; | ||
2486 | spec->autocfg.speaker_pins[0] = 0x16; | ||
2487 | alc_automute_amp(codec); | ||
2472 | alc880_uniwill_mic_automute(codec); | 2488 | alc880_uniwill_mic_automute(codec); |
2473 | } | 2489 | } |
2474 | 2490 | ||
@@ -2479,24 +2495,22 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |||
2479 | * definition. 4bit tag is placed at 28 bit! | 2495 | * definition. 4bit tag is placed at 28 bit! |
2480 | */ | 2496 | */ |
2481 | switch (res >> 28) { | 2497 | switch (res >> 28) { |
2482 | case ALC880_HP_EVENT: | ||
2483 | alc880_uniwill_hp_automute(codec); | ||
2484 | break; | ||
2485 | case ALC880_MIC_EVENT: | 2498 | case ALC880_MIC_EVENT: |
2486 | alc880_uniwill_mic_automute(codec); | 2499 | alc880_uniwill_mic_automute(codec); |
2487 | break; | 2500 | break; |
2501 | default: | ||
2502 | alc_automute_amp_unsol_event(codec, res); | ||
2503 | break; | ||
2488 | } | 2504 | } |
2489 | } | 2505 | } |
2490 | 2506 | ||
2491 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | 2507 | static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) |
2492 | { | 2508 | { |
2493 | unsigned int present; | 2509 | struct alc_spec *spec = codec->spec; |
2494 | unsigned char bits; | ||
2495 | 2510 | ||
2496 | present = snd_hda_codec_read(codec, 0x14, 0, | 2511 | spec->autocfg.hp_pins[0] = 0x14; |
2497 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 2512 | spec->autocfg.speaker_pins[0] = 0x15; |
2498 | bits = present ? HDA_AMP_MUTE : 0; | 2513 | alc_automute_amp(codec); |
2499 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); | ||
2500 | } | 2514 | } |
2501 | 2515 | ||
2502 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | 2516 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) |
@@ -2518,10 +2532,10 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, | |||
2518 | /* Looks like the unsol event is incompatible with the standard | 2532 | /* Looks like the unsol event is incompatible with the standard |
2519 | * definition. 4bit tag is placed at 28 bit! | 2533 | * definition. 4bit tag is placed at 28 bit! |
2520 | */ | 2534 | */ |
2521 | if ((res >> 28) == ALC880_HP_EVENT) | ||
2522 | alc880_uniwill_p53_hp_automute(codec); | ||
2523 | if ((res >> 28) == ALC880_DCVOL_EVENT) | 2535 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
2524 | alc880_uniwill_p53_dcvol_automute(codec); | 2536 | alc880_uniwill_p53_dcvol_automute(codec); |
2537 | else | ||
2538 | alc_automute_amp_unsol_event(codec, res); | ||
2525 | } | 2539 | } |
2526 | 2540 | ||
2527 | /* | 2541 | /* |
@@ -2753,30 +2767,18 @@ static struct hda_verb alc880_lg_init_verbs[] = { | |||
2753 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 2767 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2754 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 2768 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2755 | /* jack sense */ | 2769 | /* jack sense */ |
2756 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | 2770 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
2757 | { } | 2771 | { } |
2758 | }; | 2772 | }; |
2759 | 2773 | ||
2760 | /* toggle speaker-output according to the hp-jack state */ | 2774 | /* toggle speaker-output according to the hp-jack state */ |
2761 | static void alc880_lg_automute(struct hda_codec *codec) | 2775 | static void alc880_lg_init_hook(struct hda_codec *codec) |
2762 | { | 2776 | { |
2763 | unsigned int present; | 2777 | struct alc_spec *spec = codec->spec; |
2764 | unsigned char bits; | ||
2765 | |||
2766 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
2767 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2768 | bits = present ? HDA_AMP_MUTE : 0; | ||
2769 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
2770 | HDA_AMP_MUTE, bits); | ||
2771 | } | ||
2772 | 2778 | ||
2773 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | 2779 | spec->autocfg.hp_pins[0] = 0x1b; |
2774 | { | 2780 | spec->autocfg.speaker_pins[0] = 0x17; |
2775 | /* Looks like the unsol event is incompatible with the standard | 2781 | alc_automute_amp(codec); |
2776 | * definition. 4bit tag is placed at 28 bit! | ||
2777 | */ | ||
2778 | if ((res >> 28) == 0x01) | ||
2779 | alc880_lg_automute(codec); | ||
2780 | } | 2782 | } |
2781 | 2783 | ||
2782 | /* | 2784 | /* |
@@ -2850,30 +2852,18 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = { | |||
2850 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2852 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2851 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 2853 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2852 | /* jack sense */ | 2854 | /* jack sense */ |
2853 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | 2855 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
2854 | { } | 2856 | { } |
2855 | }; | 2857 | }; |
2856 | 2858 | ||
2857 | /* toggle speaker-output according to the hp-jack state */ | 2859 | /* toggle speaker-output according to the hp-jack state */ |
2858 | static void alc880_lg_lw_automute(struct hda_codec *codec) | 2860 | static void alc880_lg_lw_init_hook(struct hda_codec *codec) |
2859 | { | 2861 | { |
2860 | unsigned int present; | 2862 | struct alc_spec *spec = codec->spec; |
2861 | unsigned char bits; | ||
2862 | |||
2863 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
2864 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2865 | bits = present ? HDA_AMP_MUTE : 0; | ||
2866 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
2867 | HDA_AMP_MUTE, bits); | ||
2868 | } | ||
2869 | 2863 | ||
2870 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | 2864 | spec->autocfg.hp_pins[0] = 0x1b; |
2871 | { | 2865 | spec->autocfg.speaker_pins[0] = 0x14; |
2872 | /* Looks like the unsol event is incompatible with the standard | 2866 | alc_automute_amp(codec); |
2873 | * definition. 4bit tag is placed at 28 bit! | ||
2874 | */ | ||
2875 | if ((res >> 28) == 0x01) | ||
2876 | alc880_lg_lw_automute(codec); | ||
2877 | } | 2867 | } |
2878 | 2868 | ||
2879 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { | 2869 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
@@ -2920,16 +2910,10 @@ static struct hda_verb alc880_medion_rim_init_verbs[] = { | |||
2920 | /* toggle speaker-output according to the hp-jack state */ | 2910 | /* toggle speaker-output according to the hp-jack state */ |
2921 | static void alc880_medion_rim_automute(struct hda_codec *codec) | 2911 | static void alc880_medion_rim_automute(struct hda_codec *codec) |
2922 | { | 2912 | { |
2923 | unsigned int present; | 2913 | struct alc_spec *spec = codec->spec; |
2924 | unsigned char bits; | 2914 | alc_automute_amp(codec); |
2925 | 2915 | /* toggle EAPD */ | |
2926 | present = snd_hda_codec_read(codec, 0x14, 0, | 2916 | if (spec->jack_present) |
2927 | AC_VERB_GET_PIN_SENSE, 0) | ||
2928 | & AC_PINSENSE_PRESENCE; | ||
2929 | bits = present ? HDA_AMP_MUTE : 0; | ||
2930 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
2931 | HDA_AMP_MUTE, bits); | ||
2932 | if (present) | ||
2933 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | 2917 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); |
2934 | else | 2918 | else |
2935 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | 2919 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); |
@@ -2945,6 +2929,15 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |||
2945 | alc880_medion_rim_automute(codec); | 2929 | alc880_medion_rim_automute(codec); |
2946 | } | 2930 | } |
2947 | 2931 | ||
2932 | static void alc880_medion_rim_init_hook(struct hda_codec *codec) | ||
2933 | { | ||
2934 | struct alc_spec *spec = codec->spec; | ||
2935 | |||
2936 | spec->autocfg.hp_pins[0] = 0x14; | ||
2937 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
2938 | alc880_medion_rim_automute(codec); | ||
2939 | } | ||
2940 | |||
2948 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2941 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2949 | static struct hda_amp_list alc880_loopbacks[] = { | 2942 | static struct hda_amp_list alc880_loopbacks[] = { |
2950 | { 0x0b, HDA_INPUT, 0 }, | 2943 | { 0x0b, HDA_INPUT, 0 }, |
@@ -3803,7 +3796,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3803 | .channel_mode = alc880_2_jack_modes, | 3796 | .channel_mode = alc880_2_jack_modes, |
3804 | .input_mux = &alc880_f1734_capture_source, | 3797 | .input_mux = &alc880_f1734_capture_source, |
3805 | .unsol_event = alc880_uniwill_p53_unsol_event, | 3798 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3806 | .init_hook = alc880_uniwill_p53_hp_automute, | 3799 | .init_hook = alc880_uniwill_p53_init_hook, |
3807 | }, | 3800 | }, |
3808 | [ALC880_ASUS] = { | 3801 | [ALC880_ASUS] = { |
3809 | .mixers = { alc880_asus_mixer }, | 3802 | .mixers = { alc880_asus_mixer }, |
@@ -3880,7 +3873,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3880 | .need_dac_fix = 1, | 3873 | .need_dac_fix = 1, |
3881 | .input_mux = &alc880_capture_source, | 3874 | .input_mux = &alc880_capture_source, |
3882 | .unsol_event = alc880_uniwill_unsol_event, | 3875 | .unsol_event = alc880_uniwill_unsol_event, |
3883 | .init_hook = alc880_uniwill_automute, | 3876 | .init_hook = alc880_uniwill_init_hook, |
3884 | }, | 3877 | }, |
3885 | [ALC880_UNIWILL_P53] = { | 3878 | [ALC880_UNIWILL_P53] = { |
3886 | .mixers = { alc880_uniwill_p53_mixer }, | 3879 | .mixers = { alc880_uniwill_p53_mixer }, |
@@ -3892,7 +3885,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3892 | .channel_mode = alc880_threestack_modes, | 3885 | .channel_mode = alc880_threestack_modes, |
3893 | .input_mux = &alc880_capture_source, | 3886 | .input_mux = &alc880_capture_source, |
3894 | .unsol_event = alc880_uniwill_p53_unsol_event, | 3887 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3895 | .init_hook = alc880_uniwill_p53_hp_automute, | 3888 | .init_hook = alc880_uniwill_p53_init_hook, |
3896 | }, | 3889 | }, |
3897 | [ALC880_FUJITSU] = { | 3890 | [ALC880_FUJITSU] = { |
3898 | .mixers = { alc880_fujitsu_mixer }, | 3891 | .mixers = { alc880_fujitsu_mixer }, |
@@ -3906,7 +3899,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3906 | .channel_mode = alc880_2_jack_modes, | 3899 | .channel_mode = alc880_2_jack_modes, |
3907 | .input_mux = &alc880_capture_source, | 3900 | .input_mux = &alc880_capture_source, |
3908 | .unsol_event = alc880_uniwill_p53_unsol_event, | 3901 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3909 | .init_hook = alc880_uniwill_p53_hp_automute, | 3902 | .init_hook = alc880_uniwill_p53_init_hook, |
3910 | }, | 3903 | }, |
3911 | [ALC880_CLEVO] = { | 3904 | [ALC880_CLEVO] = { |
3912 | .mixers = { alc880_three_stack_mixer }, | 3905 | .mixers = { alc880_three_stack_mixer }, |
@@ -3931,8 +3924,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3931 | .channel_mode = alc880_lg_ch_modes, | 3924 | .channel_mode = alc880_lg_ch_modes, |
3932 | .need_dac_fix = 1, | 3925 | .need_dac_fix = 1, |
3933 | .input_mux = &alc880_lg_capture_source, | 3926 | .input_mux = &alc880_lg_capture_source, |
3934 | .unsol_event = alc880_lg_unsol_event, | 3927 | .unsol_event = alc_automute_amp_unsol_event, |
3935 | .init_hook = alc880_lg_automute, | 3928 | .init_hook = alc880_lg_init_hook, |
3936 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3929 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3937 | .loopbacks = alc880_lg_loopbacks, | 3930 | .loopbacks = alc880_lg_loopbacks, |
3938 | #endif | 3931 | #endif |
@@ -3947,8 +3940,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3947 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), | 3940 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3948 | .channel_mode = alc880_lg_lw_modes, | 3941 | .channel_mode = alc880_lg_lw_modes, |
3949 | .input_mux = &alc880_lg_lw_capture_source, | 3942 | .input_mux = &alc880_lg_lw_capture_source, |
3950 | .unsol_event = alc880_lg_lw_unsol_event, | 3943 | .unsol_event = alc_automute_amp_unsol_event, |
3951 | .init_hook = alc880_lg_lw_automute, | 3944 | .init_hook = alc880_lg_lw_init_hook, |
3952 | }, | 3945 | }, |
3953 | [ALC880_MEDION_RIM] = { | 3946 | [ALC880_MEDION_RIM] = { |
3954 | .mixers = { alc880_medion_rim_mixer }, | 3947 | .mixers = { alc880_medion_rim_mixer }, |
@@ -3962,7 +3955,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3962 | .channel_mode = alc880_2_jack_modes, | 3955 | .channel_mode = alc880_2_jack_modes, |
3963 | .input_mux = &alc880_medion_rim_capture_source, | 3956 | .input_mux = &alc880_medion_rim_capture_source, |
3964 | .unsol_event = alc880_medion_rim_unsol_event, | 3957 | .unsol_event = alc880_medion_rim_unsol_event, |
3965 | .init_hook = alc880_medion_rim_automute, | 3958 | .init_hook = alc880_medion_rim_init_hook, |
3966 | }, | 3959 | }, |
3967 | #ifdef CONFIG_SND_DEBUG | 3960 | #ifdef CONFIG_SND_DEBUG |
3968 | [ALC880_TEST] = { | 3961 | [ALC880_TEST] = { |
@@ -6666,45 +6659,23 @@ static struct hda_verb alc885_imac24_init_verbs[] = { | |||
6666 | }; | 6659 | }; |
6667 | 6660 | ||
6668 | /* Toggle speaker-output according to the hp-jack state */ | 6661 | /* Toggle speaker-output according to the hp-jack state */ |
6669 | static void alc885_imac24_automute(struct hda_codec *codec) | 6662 | static void alc885_imac24_automute_init_hook(struct hda_codec *codec) |
6670 | { | 6663 | { |
6671 | unsigned int present; | 6664 | struct alc_spec *spec = codec->spec; |
6672 | |||
6673 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
6674 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6675 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, | ||
6676 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6677 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
6678 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6679 | } | ||
6680 | 6665 | ||
6681 | /* Processes unsolicited events. */ | 6666 | spec->autocfg.hp_pins[0] = 0x14; |
6682 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | 6667 | spec->autocfg.speaker_pins[0] = 0x18; |
6683 | unsigned int res) | 6668 | spec->autocfg.speaker_pins[1] = 0x1a; |
6684 | { | 6669 | alc_automute_amp(codec); |
6685 | /* Headphone insertion or removal. */ | ||
6686 | if ((res >> 26) == ALC880_HP_EVENT) | ||
6687 | alc885_imac24_automute(codec); | ||
6688 | } | 6670 | } |
6689 | 6671 | ||
6690 | static void alc885_mbp3_automute(struct hda_codec *codec) | 6672 | static void alc885_mbp3_init_hook(struct hda_codec *codec) |
6691 | { | 6673 | { |
6692 | unsigned int present; | 6674 | struct alc_spec *spec = codec->spec; |
6693 | |||
6694 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
6695 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6696 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
6697 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6698 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
6699 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | ||
6700 | 6675 | ||
6701 | } | 6676 | spec->autocfg.hp_pins[0] = 0x15; |
6702 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | 6677 | spec->autocfg.speaker_pins[0] = 0x14; |
6703 | unsigned int res) | 6678 | alc_automute_amp(codec); |
6704 | { | ||
6705 | /* Headphone insertion or removal. */ | ||
6706 | if ((res >> 26) == ALC880_HP_EVENT) | ||
6707 | alc885_mbp3_automute(codec); | ||
6708 | } | 6679 | } |
6709 | 6680 | ||
6710 | 6681 | ||
@@ -6729,24 +6700,25 @@ static struct hda_verb alc882_targa_verbs[] = { | |||
6729 | /* toggle speaker-output according to the hp-jack state */ | 6700 | /* toggle speaker-output according to the hp-jack state */ |
6730 | static void alc882_targa_automute(struct hda_codec *codec) | 6701 | static void alc882_targa_automute(struct hda_codec *codec) |
6731 | { | 6702 | { |
6732 | unsigned int present; | 6703 | struct alc_spec *spec = codec->spec; |
6733 | 6704 | alc_automute_amp(codec); | |
6734 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
6735 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6736 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
6737 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6738 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | 6705 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6739 | present ? 1 : 3); | 6706 | spec->jack_present ? 1 : 3); |
6707 | } | ||
6708 | |||
6709 | static void alc882_targa_init_hook(struct hda_codec *codec) | ||
6710 | { | ||
6711 | struct alc_spec *spec = codec->spec; | ||
6712 | |||
6713 | spec->autocfg.hp_pins[0] = 0x14; | ||
6714 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
6715 | alc882_targa_automute(codec); | ||
6740 | } | 6716 | } |
6741 | 6717 | ||
6742 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | 6718 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) |
6743 | { | 6719 | { |
6744 | /* Looks like the unsol event is incompatible with the standard | 6720 | if ((res >> 26) == ALC880_HP_EVENT) |
6745 | * definition. 4bit tag is placed at 26 bit! | ||
6746 | */ | ||
6747 | if (((res >> 26) == ALC880_HP_EVENT)) { | ||
6748 | alc882_targa_automute(codec); | 6721 | alc882_targa_automute(codec); |
6749 | } | ||
6750 | } | 6722 | } |
6751 | 6723 | ||
6752 | static struct hda_verb alc882_asus_a7j_verbs[] = { | 6724 | static struct hda_verb alc882_asus_a7j_verbs[] = { |
@@ -6828,7 +6800,7 @@ static void alc885_macpro_init_hook(struct hda_codec *codec) | |||
6828 | static void alc885_imac24_init_hook(struct hda_codec *codec) | 6800 | static void alc885_imac24_init_hook(struct hda_codec *codec) |
6829 | { | 6801 | { |
6830 | alc885_macpro_init_hook(codec); | 6802 | alc885_macpro_init_hook(codec); |
6831 | alc885_imac24_automute(codec); | 6803 | alc885_imac24_automute_init_hook(codec); |
6832 | } | 6804 | } |
6833 | 6805 | ||
6834 | /* | 6806 | /* |
@@ -6999,8 +6971,8 @@ static struct alc_config_preset alc882_presets[] = { | |||
6999 | .input_mux = &alc882_capture_source, | 6971 | .input_mux = &alc882_capture_source, |
7000 | .dig_out_nid = ALC882_DIGOUT_NID, | 6972 | .dig_out_nid = ALC882_DIGOUT_NID, |
7001 | .dig_in_nid = ALC882_DIGIN_NID, | 6973 | .dig_in_nid = ALC882_DIGIN_NID, |
7002 | .unsol_event = alc885_mbp3_unsol_event, | 6974 | .unsol_event = alc_automute_amp_unsol_event, |
7003 | .init_hook = alc885_mbp3_automute, | 6975 | .init_hook = alc885_mbp3_init_hook, |
7004 | }, | 6976 | }, |
7005 | [ALC885_MB5] = { | 6977 | [ALC885_MB5] = { |
7006 | .mixers = { alc885_mb5_mixer }, | 6978 | .mixers = { alc885_mb5_mixer }, |
@@ -7036,7 +7008,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
7036 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | 7008 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), |
7037 | .channel_mode = alc882_ch_modes, | 7009 | .channel_mode = alc882_ch_modes, |
7038 | .input_mux = &alc882_capture_source, | 7010 | .input_mux = &alc882_capture_source, |
7039 | .unsol_event = alc885_imac24_unsol_event, | 7011 | .unsol_event = alc_automute_amp_unsol_event, |
7040 | .init_hook = alc885_imac24_init_hook, | 7012 | .init_hook = alc885_imac24_init_hook, |
7041 | }, | 7013 | }, |
7042 | [ALC882_TARGA] = { | 7014 | [ALC882_TARGA] = { |
@@ -7053,7 +7025,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
7053 | .need_dac_fix = 1, | 7025 | .need_dac_fix = 1, |
7054 | .input_mux = &alc882_capture_source, | 7026 | .input_mux = &alc882_capture_source, |
7055 | .unsol_event = alc882_targa_unsol_event, | 7027 | .unsol_event = alc882_targa_unsol_event, |
7056 | .init_hook = alc882_targa_automute, | 7028 | .init_hook = alc882_targa_init_hook, |
7057 | }, | 7029 | }, |
7058 | [ALC882_ASUS_A7J] = { | 7030 | [ALC882_ASUS_A7J] = { |
7059 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | 7031 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
@@ -7903,8 +7875,6 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { | |||
7903 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | 7875 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), |
7904 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 7876 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
7905 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | 7877 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
7906 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
7907 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | ||
7908 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 7878 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7909 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 7879 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
7910 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 7880 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
@@ -8053,16 +8023,14 @@ static struct hda_verb alc883_init_verbs[] = { | |||
8053 | }; | 8023 | }; |
8054 | 8024 | ||
8055 | /* toggle speaker-output according to the hp-jack state */ | 8025 | /* toggle speaker-output according to the hp-jack state */ |
8056 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | 8026 | static void alc883_mitac_init_hook(struct hda_codec *codec) |
8057 | { | 8027 | { |
8058 | unsigned int present; | 8028 | struct alc_spec *spec = codec->spec; |
8059 | 8029 | ||
8060 | present = snd_hda_codec_read(codec, 0x15, 0, | 8030 | spec->autocfg.hp_pins[0] = 0x15; |
8061 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 8031 | spec->autocfg.speaker_pins[0] = 0x14; |
8062 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8032 | spec->autocfg.speaker_pins[1] = 0x17; |
8063 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8033 | alc_automute_amp(codec); |
8064 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8065 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8066 | } | 8034 | } |
8067 | 8035 | ||
8068 | /* auto-toggle front mic */ | 8036 | /* auto-toggle front mic */ |
@@ -8079,25 +8047,6 @@ static void alc883_mitac_mic_automute(struct hda_codec *codec) | |||
8079 | } | 8047 | } |
8080 | */ | 8048 | */ |
8081 | 8049 | ||
8082 | static void alc883_mitac_automute(struct hda_codec *codec) | ||
8083 | { | ||
8084 | alc883_mitac_hp_automute(codec); | ||
8085 | /* alc883_mitac_mic_automute(codec); */ | ||
8086 | } | ||
8087 | |||
8088 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | ||
8089 | unsigned int res) | ||
8090 | { | ||
8091 | switch (res >> 26) { | ||
8092 | case ALC880_HP_EVENT: | ||
8093 | alc883_mitac_hp_automute(codec); | ||
8094 | break; | ||
8095 | case ALC880_MIC_EVENT: | ||
8096 | /* alc883_mitac_mic_automute(codec); */ | ||
8097 | break; | ||
8098 | } | ||
8099 | } | ||
8100 | |||
8101 | static struct hda_verb alc883_mitac_verbs[] = { | 8050 | static struct hda_verb alc883_mitac_verbs[] = { |
8102 | /* HP */ | 8051 | /* HP */ |
8103 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 8052 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -8215,29 +8164,15 @@ static struct hda_verb alc888_6st_dell_verbs[] = { | |||
8215 | { } | 8164 | { } |
8216 | }; | 8165 | }; |
8217 | 8166 | ||
8218 | static void alc888_3st_hp_front_automute(struct hda_codec *codec) | 8167 | static void alc888_3st_hp_init_hook(struct hda_codec *codec) |
8219 | { | 8168 | { |
8220 | unsigned int present, bits; | 8169 | struct alc_spec *spec = codec->spec; |
8221 | |||
8222 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8223 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8224 | bits = present ? HDA_AMP_MUTE : 0; | ||
8225 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8226 | HDA_AMP_MUTE, bits); | ||
8227 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8228 | HDA_AMP_MUTE, bits); | ||
8229 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, | ||
8230 | HDA_AMP_MUTE, bits); | ||
8231 | } | ||
8232 | 8170 | ||
8233 | static void alc888_3st_hp_unsol_event(struct hda_codec *codec, | 8171 | spec->autocfg.hp_pins[0] = 0x1b; |
8234 | unsigned int res) | 8172 | spec->autocfg.speaker_pins[0] = 0x14; |
8235 | { | 8173 | spec->autocfg.speaker_pins[1] = 0x16; |
8236 | switch (res >> 26) { | 8174 | spec->autocfg.speaker_pins[2] = 0x18; |
8237 | case ALC880_HP_EVENT: | 8175 | alc_automute_amp(codec); |
8238 | alc888_3st_hp_front_automute(codec); | ||
8239 | break; | ||
8240 | } | ||
8241 | } | 8176 | } |
8242 | 8177 | ||
8243 | static struct hda_verb alc888_3st_hp_verbs[] = { | 8178 | static struct hda_verb alc888_3st_hp_verbs[] = { |
@@ -8334,56 +8269,18 @@ static struct hda_verb alc883_medion_md2_verbs[] = { | |||
8334 | }; | 8269 | }; |
8335 | 8270 | ||
8336 | /* toggle speaker-output according to the hp-jack state */ | 8271 | /* toggle speaker-output according to the hp-jack state */ |
8337 | static void alc883_medion_md2_automute(struct hda_codec *codec) | 8272 | static void alc883_medion_md2_init_hook(struct hda_codec *codec) |
8338 | { | 8273 | { |
8339 | unsigned int present; | 8274 | struct alc_spec *spec = codec->spec; |
8340 | |||
8341 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8342 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8343 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8344 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8345 | } | ||
8346 | |||
8347 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | ||
8348 | unsigned int res) | ||
8349 | { | ||
8350 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8351 | alc883_medion_md2_automute(codec); | ||
8352 | } | ||
8353 | |||
8354 | /* toggle speaker-output according to the hp-jack state */ | ||
8355 | static void alc883_tagra_automute(struct hda_codec *codec) | ||
8356 | { | ||
8357 | unsigned int present; | ||
8358 | unsigned char bits; | ||
8359 | |||
8360 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8361 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8362 | bits = present ? HDA_AMP_MUTE : 0; | ||
8363 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
8364 | HDA_AMP_MUTE, bits); | ||
8365 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | ||
8366 | present ? 1 : 3); | ||
8367 | } | ||
8368 | 8275 | ||
8369 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | 8276 | spec->autocfg.hp_pins[0] = 0x14; |
8370 | { | 8277 | spec->autocfg.speaker_pins[0] = 0x15; |
8371 | if ((res >> 26) == ALC880_HP_EVENT) | 8278 | alc_automute_amp(codec); |
8372 | alc883_tagra_automute(codec); | ||
8373 | } | 8279 | } |
8374 | 8280 | ||
8375 | /* toggle speaker-output according to the hp-jack state */ | 8281 | /* toggle speaker-output according to the hp-jack state */ |
8376 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) | 8282 | #define alc883_tagra_init_hook alc882_targa_init_hook |
8377 | { | 8283 | #define alc883_tagra_unsol_event alc882_targa_unsol_event |
8378 | unsigned int present; | ||
8379 | unsigned char bits; | ||
8380 | |||
8381 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8382 | & AC_PINSENSE_PRESENCE; | ||
8383 | bits = present ? HDA_AMP_MUTE : 0; | ||
8384 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8385 | HDA_AMP_MUTE, bits); | ||
8386 | } | ||
8387 | 8284 | ||
8388 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | 8285 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
8389 | { | 8286 | { |
@@ -8395,9 +8292,13 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8395 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8292 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8396 | } | 8293 | } |
8397 | 8294 | ||
8398 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | 8295 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) |
8399 | { | 8296 | { |
8400 | alc883_clevo_m720_hp_automute(codec); | 8297 | struct alc_spec *spec = codec->spec; |
8298 | |||
8299 | spec->autocfg.hp_pins[0] = 0x15; | ||
8300 | spec->autocfg.speaker_pins[0] = 0x14; | ||
8301 | alc_automute_amp(codec); | ||
8401 | alc883_clevo_m720_mic_automute(codec); | 8302 | alc883_clevo_m720_mic_automute(codec); |
8402 | } | 8303 | } |
8403 | 8304 | ||
@@ -8405,52 +8306,32 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |||
8405 | unsigned int res) | 8306 | unsigned int res) |
8406 | { | 8307 | { |
8407 | switch (res >> 26) { | 8308 | switch (res >> 26) { |
8408 | case ALC880_HP_EVENT: | ||
8409 | alc883_clevo_m720_hp_automute(codec); | ||
8410 | break; | ||
8411 | case ALC880_MIC_EVENT: | 8309 | case ALC880_MIC_EVENT: |
8412 | alc883_clevo_m720_mic_automute(codec); | 8310 | alc883_clevo_m720_mic_automute(codec); |
8413 | break; | 8311 | break; |
8312 | default: | ||
8313 | alc_automute_amp_unsol_event(codec, res); | ||
8314 | break; | ||
8414 | } | 8315 | } |
8415 | } | 8316 | } |
8416 | 8317 | ||
8417 | /* toggle speaker-output according to the hp-jack state */ | 8318 | /* toggle speaker-output according to the hp-jack state */ |
8418 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | 8319 | static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) |
8419 | { | 8320 | { |
8420 | unsigned int present; | 8321 | struct alc_spec *spec = codec->spec; |
8421 | unsigned char bits; | ||
8422 | |||
8423 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8424 | & AC_PINSENSE_PRESENCE; | ||
8425 | bits = present ? HDA_AMP_MUTE : 0; | ||
8426 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8427 | HDA_AMP_MUTE, bits); | ||
8428 | } | ||
8429 | 8322 | ||
8430 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | 8323 | spec->autocfg.hp_pins[0] = 0x14; |
8431 | unsigned int res) | 8324 | spec->autocfg.speaker_pins[0] = 0x15; |
8432 | { | 8325 | alc_automute_amp(codec); |
8433 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8434 | alc883_2ch_fujitsu_pi2515_automute(codec); | ||
8435 | } | 8326 | } |
8436 | 8327 | ||
8437 | static void alc883_haier_w66_automute(struct hda_codec *codec) | 8328 | static void alc883_haier_w66_init_hook(struct hda_codec *codec) |
8438 | { | 8329 | { |
8439 | unsigned int present; | 8330 | struct alc_spec *spec = codec->spec; |
8440 | unsigned char bits; | ||
8441 | |||
8442 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8443 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8444 | bits = present ? 0x80 : 0; | ||
8445 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8446 | 0x80, bits); | ||
8447 | } | ||
8448 | 8331 | ||
8449 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | 8332 | spec->autocfg.hp_pins[0] = 0x1b; |
8450 | unsigned int res) | 8333 | spec->autocfg.speaker_pins[0] = 0x14; |
8451 | { | 8334 | alc_automute_amp(codec); |
8452 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8453 | alc883_haier_w66_automute(codec); | ||
8454 | } | 8335 | } |
8455 | 8336 | ||
8456 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8337 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
@@ -8489,23 +8370,14 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
8489 | } | 8370 | } |
8490 | 8371 | ||
8491 | /* toggle speaker-output according to the hp-jack state */ | 8372 | /* toggle speaker-output according to the hp-jack state */ |
8492 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | 8373 | static void alc883_acer_aspire_init_hook(struct hda_codec *codec) |
8493 | { | 8374 | { |
8494 | unsigned int present; | 8375 | struct alc_spec *spec = codec->spec; |
8495 | |||
8496 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8497 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8498 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8499 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8500 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8501 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8502 | } | ||
8503 | 8376 | ||
8504 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | 8377 | spec->autocfg.hp_pins[0] = 0x14; |
8505 | unsigned int res) | 8378 | spec->autocfg.speaker_pins[0] = 0x15; |
8506 | { | 8379 | spec->autocfg.speaker_pins[1] = 0x16; |
8507 | if ((res >> 26) == ALC880_HP_EVENT) | 8380 | alc_automute_amp(codec); |
8508 | alc883_acer_aspire_automute(codec); | ||
8509 | } | 8381 | } |
8510 | 8382 | ||
8511 | static struct hda_verb alc883_acer_eapd_verbs[] = { | 8383 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
@@ -8526,75 +8398,29 @@ static struct hda_verb alc883_acer_eapd_verbs[] = { | |||
8526 | { } | 8398 | { } |
8527 | }; | 8399 | }; |
8528 | 8400 | ||
8529 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) | 8401 | static void alc888_6st_dell_init_hook(struct hda_codec *codec) |
8530 | { | 8402 | { |
8531 | unsigned int present; | 8403 | struct alc_spec *spec = codec->spec; |
8532 | |||
8533 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8534 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8535 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8536 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8537 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8538 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8539 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8540 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8541 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8542 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8543 | } | ||
8544 | 8404 | ||
8545 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | 8405 | spec->autocfg.hp_pins[0] = 0x1b; |
8546 | unsigned int res) | 8406 | spec->autocfg.speaker_pins[0] = 0x14; |
8547 | { | 8407 | spec->autocfg.speaker_pins[1] = 0x15; |
8548 | switch (res >> 26) { | 8408 | spec->autocfg.speaker_pins[2] = 0x16; |
8549 | case ALC880_HP_EVENT: | 8409 | spec->autocfg.speaker_pins[3] = 0x17; |
8550 | /* printk(KERN_DEBUG "hp_event\n"); */ | 8410 | alc_automute_amp(codec); |
8551 | alc888_6st_dell_front_automute(codec); | ||
8552 | break; | ||
8553 | } | ||
8554 | } | 8411 | } |
8555 | 8412 | ||
8556 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) | 8413 | static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) |
8557 | { | 8414 | { |
8558 | unsigned int mute; | 8415 | struct alc_spec *spec = codec->spec; |
8559 | unsigned int present; | ||
8560 | |||
8561 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
8562 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8563 | AC_VERB_GET_PIN_SENSE, 0); | ||
8564 | present = (present & 0x80000000) != 0; | ||
8565 | if (present) { | ||
8566 | /* mute internal speaker */ | ||
8567 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8568 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8569 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8570 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8571 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8572 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8573 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8574 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8575 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
8576 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8577 | } else { | ||
8578 | /* unmute internal speaker if necessary */ | ||
8579 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | ||
8580 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8581 | HDA_AMP_MUTE, mute); | ||
8582 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8583 | HDA_AMP_MUTE, mute); | ||
8584 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8585 | HDA_AMP_MUTE, mute); | ||
8586 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8587 | HDA_AMP_MUTE, mute); | ||
8588 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
8589 | HDA_AMP_MUTE, mute); | ||
8590 | } | ||
8591 | } | ||
8592 | 8416 | ||
8593 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | 8417 | spec->autocfg.hp_pins[0] = 0x1b; |
8594 | unsigned int res) | 8418 | spec->autocfg.speaker_pins[0] = 0x14; |
8595 | { | 8419 | spec->autocfg.speaker_pins[1] = 0x15; |
8596 | if ((res >> 26) == ALC880_HP_EVENT) | 8420 | spec->autocfg.speaker_pins[2] = 0x16; |
8597 | alc888_lenovo_sky_front_automute(codec); | 8421 | spec->autocfg.speaker_pins[3] = 0x17; |
8422 | spec->autocfg.speaker_pins[4] = 0x1a; | ||
8423 | alc_automute_amp(codec); | ||
8598 | } | 8424 | } |
8599 | 8425 | ||
8600 | /* | 8426 | /* |
@@ -8682,39 +8508,33 @@ static void alc883_nb_mic_automute(struct hda_codec *codec) | |||
8682 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | 8508 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
8683 | } | 8509 | } |
8684 | 8510 | ||
8685 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | 8511 | static void alc883_M90V_init_hook(struct hda_codec *codec) |
8686 | { | 8512 | { |
8687 | unsigned int present; | 8513 | struct alc_spec *spec = codec->spec; |
8688 | unsigned char bits; | ||
8689 | 8514 | ||
8690 | present = snd_hda_codec_read(codec, 0x1b, 0, | 8515 | spec->autocfg.hp_pins[0] = 0x1b; |
8691 | AC_VERB_GET_PIN_SENSE, 0) | 8516 | spec->autocfg.speaker_pins[0] = 0x14; |
8692 | & AC_PINSENSE_PRESENCE; | 8517 | spec->autocfg.speaker_pins[1] = 0x15; |
8693 | bits = present ? 0 : PIN_OUT; | 8518 | spec->autocfg.speaker_pins[2] = 0x16; |
8694 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 8519 | alc_automute_pin(codec); |
8695 | bits); | ||
8696 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8697 | bits); | ||
8698 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8699 | bits); | ||
8700 | } | 8520 | } |
8701 | 8521 | ||
8702 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | 8522 | static void alc883_mode2_unsol_event(struct hda_codec *codec, |
8703 | unsigned int res) | 8523 | unsigned int res) |
8704 | { | 8524 | { |
8705 | switch (res >> 26) { | 8525 | switch (res >> 26) { |
8706 | case ALC880_HP_EVENT: | ||
8707 | alc883_M90V_speaker_automute(codec); | ||
8708 | break; | ||
8709 | case ALC880_MIC_EVENT: | 8526 | case ALC880_MIC_EVENT: |
8710 | alc883_nb_mic_automute(codec); | 8527 | alc883_nb_mic_automute(codec); |
8711 | break; | 8528 | break; |
8529 | default: | ||
8530 | alc_sku_unsol_event(codec, res); | ||
8531 | break; | ||
8712 | } | 8532 | } |
8713 | } | 8533 | } |
8714 | 8534 | ||
8715 | static void alc883_mode2_inithook(struct hda_codec *codec) | 8535 | static void alc883_mode2_inithook(struct hda_codec *codec) |
8716 | { | 8536 | { |
8717 | alc883_M90V_speaker_automute(codec); | 8537 | alc883_M90V_init_hook(codec); |
8718 | alc883_nb_mic_automute(codec); | 8538 | alc883_nb_mic_automute(codec); |
8719 | } | 8539 | } |
8720 | 8540 | ||
@@ -8731,32 +8551,13 @@ static struct hda_verb alc888_asus_eee1601_verbs[] = { | |||
8731 | { } /* end */ | 8551 | { } /* end */ |
8732 | }; | 8552 | }; |
8733 | 8553 | ||
8734 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | ||
8735 | { | ||
8736 | unsigned int present; | ||
8737 | unsigned char bits; | ||
8738 | |||
8739 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8740 | AC_VERB_GET_PIN_SENSE, 0) | ||
8741 | & AC_PINSENSE_PRESENCE; | ||
8742 | bits = present ? 0 : PIN_OUT; | ||
8743 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8744 | bits); | ||
8745 | } | ||
8746 | |||
8747 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | ||
8748 | unsigned int res) | ||
8749 | { | ||
8750 | switch (res >> 26) { | ||
8751 | case ALC880_HP_EVENT: | ||
8752 | alc883_eee1601_speaker_automute(codec); | ||
8753 | break; | ||
8754 | } | ||
8755 | } | ||
8756 | |||
8757 | static void alc883_eee1601_inithook(struct hda_codec *codec) | 8554 | static void alc883_eee1601_inithook(struct hda_codec *codec) |
8758 | { | 8555 | { |
8759 | alc883_eee1601_speaker_automute(codec); | 8556 | struct alc_spec *spec = codec->spec; |
8557 | |||
8558 | spec->autocfg.hp_pins[0] = 0x14; | ||
8559 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
8560 | alc_automute_pin(codec); | ||
8760 | } | 8561 | } |
8761 | 8562 | ||
8762 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 8563 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -8969,7 +8770,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
8969 | .need_dac_fix = 1, | 8770 | .need_dac_fix = 1, |
8970 | .input_mux = &alc883_capture_source, | 8771 | .input_mux = &alc883_capture_source, |
8971 | .unsol_event = alc883_tagra_unsol_event, | 8772 | .unsol_event = alc883_tagra_unsol_event, |
8972 | .init_hook = alc883_tagra_automute, | 8773 | .init_hook = alc883_tagra_init_hook, |
8973 | }, | 8774 | }, |
8974 | [ALC883_TARGA_2ch_DIG] = { | 8775 | [ALC883_TARGA_2ch_DIG] = { |
8975 | .mixers = { alc883_tagra_2ch_mixer}, | 8776 | .mixers = { alc883_tagra_2ch_mixer}, |
@@ -8983,7 +8784,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
8983 | .channel_mode = alc883_3ST_2ch_modes, | 8784 | .channel_mode = alc883_3ST_2ch_modes, |
8984 | .input_mux = &alc883_capture_source, | 8785 | .input_mux = &alc883_capture_source, |
8985 | .unsol_event = alc883_tagra_unsol_event, | 8786 | .unsol_event = alc883_tagra_unsol_event, |
8986 | .init_hook = alc883_tagra_automute, | 8787 | .init_hook = alc883_tagra_init_hook, |
8987 | }, | 8788 | }, |
8988 | [ALC883_ACER] = { | 8789 | [ALC883_ACER] = { |
8989 | .mixers = { alc883_base_mixer }, | 8790 | .mixers = { alc883_base_mixer }, |
@@ -9008,8 +8809,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9008 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 8809 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9009 | .channel_mode = alc883_3ST_2ch_modes, | 8810 | .channel_mode = alc883_3ST_2ch_modes, |
9010 | .input_mux = &alc883_capture_source, | 8811 | .input_mux = &alc883_capture_source, |
9011 | .unsol_event = alc883_acer_aspire_unsol_event, | 8812 | .unsol_event = alc_automute_amp_unsol_event, |
9012 | .init_hook = alc883_acer_aspire_automute, | 8813 | .init_hook = alc883_acer_aspire_init_hook, |
9013 | }, | 8814 | }, |
9014 | [ALC888_ACER_ASPIRE_4930G] = { | 8815 | [ALC888_ACER_ASPIRE_4930G] = { |
9015 | .mixers = { alc888_base_mixer, | 8816 | .mixers = { alc888_base_mixer, |
@@ -9028,8 +8829,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9028 | .num_mux_defs = | 8829 | .num_mux_defs = |
9029 | ARRAY_SIZE(alc888_2_capture_sources), | 8830 | ARRAY_SIZE(alc888_2_capture_sources), |
9030 | .input_mux = alc888_2_capture_sources, | 8831 | .input_mux = alc888_2_capture_sources, |
9031 | .unsol_event = alc888_acer_aspire_4930g_unsol_event, | 8832 | .unsol_event = alc_automute_amp_unsol_event, |
9032 | .init_hook = alc888_acer_aspire_4930g_automute, | 8833 | .init_hook = alc888_acer_aspire_4930g_init_hook, |
9033 | }, | 8834 | }, |
9034 | [ALC883_MEDION] = { | 8835 | [ALC883_MEDION] = { |
9035 | .mixers = { alc883_fivestack_mixer, | 8836 | .mixers = { alc883_fivestack_mixer, |
@@ -9053,8 +8854,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9053 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 8854 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9054 | .channel_mode = alc883_3ST_2ch_modes, | 8855 | .channel_mode = alc883_3ST_2ch_modes, |
9055 | .input_mux = &alc883_capture_source, | 8856 | .input_mux = &alc883_capture_source, |
9056 | .unsol_event = alc883_medion_md2_unsol_event, | 8857 | .unsol_event = alc_automute_amp_unsol_event, |
9057 | .init_hook = alc883_medion_md2_automute, | 8858 | .init_hook = alc883_medion_md2_init_hook, |
9058 | }, | 8859 | }, |
9059 | [ALC883_LAPTOP_EAPD] = { | 8860 | [ALC883_LAPTOP_EAPD] = { |
9060 | .mixers = { alc883_base_mixer }, | 8861 | .mixers = { alc883_base_mixer }, |
@@ -9075,7 +8876,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
9075 | .channel_mode = alc883_3ST_2ch_modes, | 8876 | .channel_mode = alc883_3ST_2ch_modes, |
9076 | .input_mux = &alc883_capture_source, | 8877 | .input_mux = &alc883_capture_source, |
9077 | .unsol_event = alc883_clevo_m720_unsol_event, | 8878 | .unsol_event = alc883_clevo_m720_unsol_event, |
9078 | .init_hook = alc883_clevo_m720_automute, | 8879 | .init_hook = alc883_clevo_m720_init_hook, |
9079 | }, | 8880 | }, |
9080 | [ALC883_LENOVO_101E_2ch] = { | 8881 | [ALC883_LENOVO_101E_2ch] = { |
9081 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | 8882 | .mixers = { alc883_lenovo_101e_2ch_mixer}, |
@@ -9099,8 +8900,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9099 | .channel_mode = alc883_3ST_2ch_modes, | 8900 | .channel_mode = alc883_3ST_2ch_modes, |
9100 | .need_dac_fix = 1, | 8901 | .need_dac_fix = 1, |
9101 | .input_mux = &alc883_lenovo_nb0763_capture_source, | 8902 | .input_mux = &alc883_lenovo_nb0763_capture_source, |
9102 | .unsol_event = alc883_medion_md2_unsol_event, | 8903 | .unsol_event = alc_automute_amp_unsol_event, |
9103 | .init_hook = alc883_medion_md2_automute, | 8904 | .init_hook = alc883_medion_md2_init_hook, |
9104 | }, | 8905 | }, |
9105 | [ALC888_LENOVO_MS7195_DIG] = { | 8906 | [ALC888_LENOVO_MS7195_DIG] = { |
9106 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 8907 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9124,8 +8925,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9124 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 8925 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9125 | .channel_mode = alc883_3ST_2ch_modes, | 8926 | .channel_mode = alc883_3ST_2ch_modes, |
9126 | .input_mux = &alc883_capture_source, | 8927 | .input_mux = &alc883_capture_source, |
9127 | .unsol_event = alc883_haier_w66_unsol_event, | 8928 | .unsol_event = alc_automute_amp_unsol_event, |
9128 | .init_hook = alc883_haier_w66_automute, | 8929 | .init_hook = alc883_haier_w66_init_hook, |
9129 | }, | 8930 | }, |
9130 | [ALC888_3ST_HP] = { | 8931 | [ALC888_3ST_HP] = { |
9131 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 8932 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9136,8 +8937,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9136 | .channel_mode = alc888_3st_hp_modes, | 8937 | .channel_mode = alc888_3st_hp_modes, |
9137 | .need_dac_fix = 1, | 8938 | .need_dac_fix = 1, |
9138 | .input_mux = &alc883_capture_source, | 8939 | .input_mux = &alc883_capture_source, |
9139 | .unsol_event = alc888_3st_hp_unsol_event, | 8940 | .unsol_event = alc_automute_amp_unsol_event, |
9140 | .init_hook = alc888_3st_hp_front_automute, | 8941 | .init_hook = alc888_3st_hp_init_hook, |
9141 | }, | 8942 | }, |
9142 | [ALC888_6ST_DELL] = { | 8943 | [ALC888_6ST_DELL] = { |
9143 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 8944 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9149,8 +8950,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9149 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | 8950 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
9150 | .channel_mode = alc883_sixstack_modes, | 8951 | .channel_mode = alc883_sixstack_modes, |
9151 | .input_mux = &alc883_capture_source, | 8952 | .input_mux = &alc883_capture_source, |
9152 | .unsol_event = alc888_6st_dell_unsol_event, | 8953 | .unsol_event = alc_automute_amp_unsol_event, |
9153 | .init_hook = alc888_6st_dell_front_automute, | 8954 | .init_hook = alc888_6st_dell_init_hook, |
9154 | }, | 8955 | }, |
9155 | [ALC883_MITAC] = { | 8956 | [ALC883_MITAC] = { |
9156 | .mixers = { alc883_mitac_mixer }, | 8957 | .mixers = { alc883_mitac_mixer }, |
@@ -9160,8 +8961,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9160 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 8961 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9161 | .channel_mode = alc883_3ST_2ch_modes, | 8962 | .channel_mode = alc883_3ST_2ch_modes, |
9162 | .input_mux = &alc883_capture_source, | 8963 | .input_mux = &alc883_capture_source, |
9163 | .unsol_event = alc883_mitac_unsol_event, | 8964 | .unsol_event = alc_automute_amp_unsol_event, |
9164 | .init_hook = alc883_mitac_automute, | 8965 | .init_hook = alc883_mitac_init_hook, |
9165 | }, | 8966 | }, |
9166 | [ALC883_FUJITSU_PI2515] = { | 8967 | [ALC883_FUJITSU_PI2515] = { |
9167 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | 8968 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, |
@@ -9173,8 +8974,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9173 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 8974 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9174 | .channel_mode = alc883_3ST_2ch_modes, | 8975 | .channel_mode = alc883_3ST_2ch_modes, |
9175 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 8976 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9176 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | 8977 | .unsol_event = alc_automute_amp_unsol_event, |
9177 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | 8978 | .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, |
9178 | }, | 8979 | }, |
9179 | [ALC888_FUJITSU_XA3530] = { | 8980 | [ALC888_FUJITSU_XA3530] = { |
9180 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | 8981 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, |
@@ -9191,8 +8992,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9191 | .num_mux_defs = | 8992 | .num_mux_defs = |
9192 | ARRAY_SIZE(alc888_2_capture_sources), | 8993 | ARRAY_SIZE(alc888_2_capture_sources), |
9193 | .input_mux = alc888_2_capture_sources, | 8994 | .input_mux = alc888_2_capture_sources, |
9194 | .unsol_event = alc888_fujitsu_xa3530_unsol_event, | 8995 | .unsol_event = alc_automute_amp_unsol_event, |
9195 | .init_hook = alc888_fujitsu_xa3530_automute, | 8996 | .init_hook = alc888_fujitsu_xa3530_init_hook, |
9196 | }, | 8997 | }, |
9197 | [ALC888_LENOVO_SKY] = { | 8998 | [ALC888_LENOVO_SKY] = { |
9198 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | 8999 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, |
@@ -9204,8 +9005,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9204 | .channel_mode = alc883_sixstack_modes, | 9005 | .channel_mode = alc883_sixstack_modes, |
9205 | .need_dac_fix = 1, | 9006 | .need_dac_fix = 1, |
9206 | .input_mux = &alc883_lenovo_sky_capture_source, | 9007 | .input_mux = &alc883_lenovo_sky_capture_source, |
9207 | .unsol_event = alc883_lenovo_sky_unsol_event, | 9008 | .unsol_event = alc_automute_amp_unsol_event, |
9208 | .init_hook = alc888_lenovo_sky_front_automute, | 9009 | .init_hook = alc888_lenovo_sky_init_hook, |
9209 | }, | 9010 | }, |
9210 | [ALC888_ASUS_M90V] = { | 9011 | [ALC888_ASUS_M90V] = { |
9211 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9012 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9233,7 +9034,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
9233 | .channel_mode = alc883_3ST_2ch_modes, | 9034 | .channel_mode = alc883_3ST_2ch_modes, |
9234 | .need_dac_fix = 1, | 9035 | .need_dac_fix = 1, |
9235 | .input_mux = &alc883_asus_eee1601_capture_source, | 9036 | .input_mux = &alc883_asus_eee1601_capture_source, |
9236 | .unsol_event = alc883_eee1601_unsol_event, | 9037 | .unsol_event = alc_sku_unsol_event, |
9237 | .init_hook = alc883_eee1601_inithook, | 9038 | .init_hook = alc883_eee1601_inithook, |
9238 | }, | 9039 | }, |
9239 | [ALC1200_ASUS_P5Q] = { | 9040 | [ALC1200_ASUS_P5Q] = { |
@@ -9666,28 +9467,15 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |||
9666 | }; | 9467 | }; |
9667 | 9468 | ||
9668 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 9469 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9669 | static void alc262_hp_t5735_automute(struct hda_codec *codec) | 9470 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) |
9670 | { | 9471 | { |
9671 | struct alc_spec *spec = codec->spec; | 9472 | struct alc_spec *spec = codec->spec; |
9672 | unsigned int present; | ||
9673 | 9473 | ||
9674 | present = snd_hda_codec_read(codec, 0x15, 0, | 9474 | spec->autocfg.hp_pins[0] = 0x15; |
9675 | AC_VERB_GET_PIN_SENSE, 0); | 9475 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ |
9676 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | 9476 | alc_automute_amp(codec); |
9677 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
9678 | spec->jack_present ? HDA_AMP_MUTE : 0); | ||
9679 | } | ||
9680 | |||
9681 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | ||
9682 | unsigned int res) | ||
9683 | { | ||
9684 | if ((res >> 26) != ALC880_HP_EVENT) | ||
9685 | return; | ||
9686 | alc262_hp_t5735_automute(codec); | ||
9687 | } | 9477 | } |
9688 | 9478 | ||
9689 | #define alc262_hp_t5735_init_hook alc262_hp_t5735_automute | ||
9690 | |||
9691 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | 9479 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { |
9692 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 9480 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9693 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 9481 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
@@ -9914,34 +9702,15 @@ static struct hda_verb alc262_tyan_verbs[] = { | |||
9914 | }; | 9702 | }; |
9915 | 9703 | ||
9916 | /* unsolicited event for HP jack sensing */ | 9704 | /* unsolicited event for HP jack sensing */ |
9917 | static void alc262_tyan_automute(struct hda_codec *codec) | 9705 | static void alc262_tyan_init_hook(struct hda_codec *codec) |
9918 | { | 9706 | { |
9919 | unsigned int mute; | 9707 | struct alc_spec *spec = codec->spec; |
9920 | unsigned int present; | ||
9921 | 9708 | ||
9922 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | 9709 | spec->autocfg.hp_pins[0] = 0x1b; |
9923 | present = snd_hda_codec_read(codec, 0x1b, 0, | 9710 | spec->autocfg.speaker_pins[0] = 0x15; |
9924 | AC_VERB_GET_PIN_SENSE, 0); | 9711 | alc_automute_amp(codec); |
9925 | present = (present & 0x80000000) != 0; | ||
9926 | if (present) { | ||
9927 | /* mute line output on ATX panel */ | ||
9928 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
9929 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
9930 | } else { | ||
9931 | /* unmute line output if necessary */ | ||
9932 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | ||
9933 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
9934 | HDA_AMP_MUTE, mute); | ||
9935 | } | ||
9936 | } | 9712 | } |
9937 | 9713 | ||
9938 | static void alc262_tyan_unsol_event(struct hda_codec *codec, | ||
9939 | unsigned int res) | ||
9940 | { | ||
9941 | if ((res >> 26) != ALC880_HP_EVENT) | ||
9942 | return; | ||
9943 | alc262_tyan_automute(codec); | ||
9944 | } | ||
9945 | 9714 | ||
9946 | #define alc262_capture_mixer alc882_capture_mixer | 9715 | #define alc262_capture_mixer alc882_capture_mixer |
9947 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | 9716 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer |
@@ -10096,35 +9865,24 @@ static void alc262_dmic_automute(struct hda_codec *codec) | |||
10096 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | 9865 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); |
10097 | } | 9866 | } |
10098 | 9867 | ||
10099 | /* toggle speaker-output according to the hp-jack state */ | ||
10100 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | ||
10101 | { | ||
10102 | unsigned int present; | ||
10103 | unsigned char bits; | ||
10104 | |||
10105 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
10106 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
10107 | bits = present ? 0 : PIN_OUT; | ||
10108 | snd_hda_codec_write(codec, 0x14, 0, | ||
10109 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | ||
10110 | } | ||
10111 | |||
10112 | |||
10113 | 9868 | ||
10114 | /* unsolicited event for HP jack sensing */ | 9869 | /* unsolicited event for HP jack sensing */ |
10115 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | 9870 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, |
10116 | unsigned int res) | 9871 | unsigned int res) |
10117 | { | 9872 | { |
10118 | if ((res >> 26) == ALC880_HP_EVENT) | ||
10119 | alc262_toshiba_s06_speaker_automute(codec); | ||
10120 | if ((res >> 26) == ALC880_MIC_EVENT) | 9873 | if ((res >> 26) == ALC880_MIC_EVENT) |
10121 | alc262_dmic_automute(codec); | 9874 | alc262_dmic_automute(codec); |
10122 | 9875 | else | |
9876 | alc_sku_unsol_event(codec, res); | ||
10123 | } | 9877 | } |
10124 | 9878 | ||
10125 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | 9879 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) |
10126 | { | 9880 | { |
10127 | alc262_toshiba_s06_speaker_automute(codec); | 9881 | struct alc_spec *spec = codec->spec; |
9882 | |||
9883 | spec->autocfg.hp_pins[0] = 0x15; | ||
9884 | spec->autocfg.speaker_pins[0] = 0x14; | ||
9885 | alc_automute_pin(codec); | ||
10128 | alc262_dmic_automute(codec); | 9886 | alc262_dmic_automute(codec); |
10129 | } | 9887 | } |
10130 | 9888 | ||
@@ -11135,7 +10893,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11135 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 10893 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11136 | .channel_mode = alc262_modes, | 10894 | .channel_mode = alc262_modes, |
11137 | .input_mux = &alc262_capture_source, | 10895 | .input_mux = &alc262_capture_source, |
11138 | .unsol_event = alc262_hp_t5735_unsol_event, | 10896 | .unsol_event = alc_automute_amp_unsol_event, |
11139 | .init_hook = alc262_hp_t5735_init_hook, | 10897 | .init_hook = alc262_hp_t5735_init_hook, |
11140 | }, | 10898 | }, |
11141 | [ALC262_HP_RP5700] = { | 10899 | [ALC262_HP_RP5700] = { |
@@ -11256,8 +11014,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11256 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11014 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11257 | .channel_mode = alc262_modes, | 11015 | .channel_mode = alc262_modes, |
11258 | .input_mux = &alc262_capture_source, | 11016 | .input_mux = &alc262_capture_source, |
11259 | .unsol_event = alc262_tyan_unsol_event, | 11017 | .unsol_event = alc_automute_amp_unsol_event, |
11260 | .init_hook = alc262_tyan_automute, | 11018 | .init_hook = alc262_tyan_init_hook, |
11261 | }, | 11019 | }, |
11262 | }; | 11020 | }; |
11263 | 11021 | ||
@@ -11646,30 +11404,15 @@ static struct hda_verb alc268_dell_verbs[] = { | |||
11646 | }; | 11404 | }; |
11647 | 11405 | ||
11648 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 11406 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
11649 | static void alc268_dell_automute(struct hda_codec *codec) | 11407 | static void alc268_dell_init_hook(struct hda_codec *codec) |
11650 | { | 11408 | { |
11651 | unsigned int present; | 11409 | struct alc_spec *spec = codec->spec; |
11652 | unsigned int mute; | ||
11653 | |||
11654 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | ||
11655 | if (present & 0x80000000) | ||
11656 | mute = HDA_AMP_MUTE; | ||
11657 | else | ||
11658 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | ||
11659 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
11660 | HDA_AMP_MUTE, mute); | ||
11661 | } | ||
11662 | 11410 | ||
11663 | static void alc268_dell_unsol_event(struct hda_codec *codec, | 11411 | spec->autocfg.hp_pins[0] = 0x15; |
11664 | unsigned int res) | 11412 | spec->autocfg.speaker_pins[0] = 0x14; |
11665 | { | 11413 | alc_automute_pin(codec); |
11666 | if ((res >> 26) != ALC880_HP_EVENT) | ||
11667 | return; | ||
11668 | alc268_dell_automute(codec); | ||
11669 | } | 11414 | } |
11670 | 11415 | ||
11671 | #define alc268_dell_init_hook alc268_dell_automute | ||
11672 | |||
11673 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { | 11416 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
11674 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | 11417 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), |
11675 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 11418 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
@@ -11688,16 +11431,6 @@ static struct hda_verb alc267_quanta_il1_verbs[] = { | |||
11688 | { } | 11431 | { } |
11689 | }; | 11432 | }; |
11690 | 11433 | ||
11691 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | ||
11692 | { | ||
11693 | unsigned int present; | ||
11694 | |||
11695 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
11696 | & AC_PINSENSE_PRESENCE; | ||
11697 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
11698 | present ? 0 : PIN_OUT); | ||
11699 | } | ||
11700 | |||
11701 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | 11434 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) |
11702 | { | 11435 | { |
11703 | unsigned int present; | 11436 | unsigned int present; |
@@ -11709,9 +11442,13 @@ static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |||
11709 | present ? 0x00 : 0x01); | 11442 | present ? 0x00 : 0x01); |
11710 | } | 11443 | } |
11711 | 11444 | ||
11712 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | 11445 | static void alc267_quanta_il1_init_hook(struct hda_codec *codec) |
11713 | { | 11446 | { |
11714 | alc267_quanta_il1_hp_automute(codec); | 11447 | struct alc_spec *spec = codec->spec; |
11448 | |||
11449 | spec->autocfg.hp_pins[0] = 0x15; | ||
11450 | spec->autocfg.speaker_pins[0] = 0x14; | ||
11451 | alc_automute_pin(codec); | ||
11715 | alc267_quanta_il1_mic_automute(codec); | 11452 | alc267_quanta_il1_mic_automute(codec); |
11716 | } | 11453 | } |
11717 | 11454 | ||
@@ -11719,12 +11456,12 @@ static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |||
11719 | unsigned int res) | 11456 | unsigned int res) |
11720 | { | 11457 | { |
11721 | switch (res >> 26) { | 11458 | switch (res >> 26) { |
11722 | case ALC880_HP_EVENT: | ||
11723 | alc267_quanta_il1_hp_automute(codec); | ||
11724 | break; | ||
11725 | case ALC880_MIC_EVENT: | 11459 | case ALC880_MIC_EVENT: |
11726 | alc267_quanta_il1_mic_automute(codec); | 11460 | alc267_quanta_il1_mic_automute(codec); |
11727 | break; | 11461 | break; |
11462 | default: | ||
11463 | alc_sku_unsol_event(codec, res); | ||
11464 | break; | ||
11728 | } | 11465 | } |
11729 | } | 11466 | } |
11730 | 11467 | ||
@@ -12198,7 +11935,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12198 | .channel_mode = alc268_modes, | 11935 | .channel_mode = alc268_modes, |
12199 | .input_mux = &alc268_capture_source, | 11936 | .input_mux = &alc268_capture_source, |
12200 | .unsol_event = alc267_quanta_il1_unsol_event, | 11937 | .unsol_event = alc267_quanta_il1_unsol_event, |
12201 | .init_hook = alc267_quanta_il1_automute, | 11938 | .init_hook = alc267_quanta_il1_init_hook, |
12202 | }, | 11939 | }, |
12203 | [ALC268_3ST] = { | 11940 | [ALC268_3ST] = { |
12204 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 11941 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12293,7 +12030,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12293 | .hp_nid = 0x02, | 12030 | .hp_nid = 0x02, |
12294 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12031 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12295 | .channel_mode = alc268_modes, | 12032 | .channel_mode = alc268_modes, |
12296 | .unsol_event = alc268_dell_unsol_event, | 12033 | .unsol_event = alc_sku_unsol_event, |
12297 | .init_hook = alc268_dell_init_hook, | 12034 | .init_hook = alc268_dell_init_hook, |
12298 | .input_mux = &alc268_capture_source, | 12035 | .input_mux = &alc268_capture_source, |
12299 | }, | 12036 | }, |
@@ -14727,19 +14464,6 @@ static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |||
14727 | {} | 14464 | {} |
14728 | }; | 14465 | }; |
14729 | 14466 | ||
14730 | /* toggle speaker-output according to the hp-jack state */ | ||
14731 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | ||
14732 | { | ||
14733 | unsigned int present; | ||
14734 | unsigned char bits; | ||
14735 | |||
14736 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
14737 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14738 | bits = present ? HDA_AMP_MUTE : 0; | ||
14739 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
14740 | HDA_AMP_MUTE, bits); | ||
14741 | } | ||
14742 | |||
14743 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | 14467 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) |
14744 | { | 14468 | { |
14745 | unsigned int present; | 14469 | unsigned int present; |
@@ -14752,9 +14476,13 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
14752 | HDA_AMP_MUTE, bits); | 14476 | HDA_AMP_MUTE, bits); |
14753 | } | 14477 | } |
14754 | 14478 | ||
14755 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | 14479 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) |
14756 | { | 14480 | { |
14757 | alc861vd_lenovo_hp_automute(codec); | 14481 | struct alc_spec *spec = codec->spec; |
14482 | |||
14483 | spec->autocfg.hp_pins[0] = 0x1b; | ||
14484 | spec->autocfg.speaker_pins[0] = 0x14; | ||
14485 | alc_automute_amp(codec); | ||
14758 | alc861vd_lenovo_mic_automute(codec); | 14486 | alc861vd_lenovo_mic_automute(codec); |
14759 | } | 14487 | } |
14760 | 14488 | ||
@@ -14762,12 +14490,12 @@ static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |||
14762 | unsigned int res) | 14490 | unsigned int res) |
14763 | { | 14491 | { |
14764 | switch (res >> 26) { | 14492 | switch (res >> 26) { |
14765 | case ALC880_HP_EVENT: | ||
14766 | alc861vd_lenovo_hp_automute(codec); | ||
14767 | break; | ||
14768 | case ALC880_MIC_EVENT: | 14493 | case ALC880_MIC_EVENT: |
14769 | alc861vd_lenovo_mic_automute(codec); | 14494 | alc861vd_lenovo_mic_automute(codec); |
14770 | break; | 14495 | break; |
14496 | default: | ||
14497 | alc_automute_amp_unsol_event(codec, res); | ||
14498 | break; | ||
14771 | } | 14499 | } |
14772 | } | 14500 | } |
14773 | 14501 | ||
@@ -14817,20 +14545,13 @@ static struct hda_verb alc861vd_dallas_verbs[] = { | |||
14817 | }; | 14545 | }; |
14818 | 14546 | ||
14819 | /* toggle speaker-output according to the hp-jack state */ | 14547 | /* toggle speaker-output according to the hp-jack state */ |
14820 | static void alc861vd_dallas_automute(struct hda_codec *codec) | 14548 | static void alc861vd_dallas_init_hook(struct hda_codec *codec) |
14821 | { | 14549 | { |
14822 | unsigned int present; | 14550 | struct alc_spec *spec = codec->spec; |
14823 | |||
14824 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
14825 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14826 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
14827 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
14828 | } | ||
14829 | 14551 | ||
14830 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | 14552 | spec->autocfg.hp_pins[0] = 0x15; |
14831 | { | 14553 | spec->autocfg.speaker_pins[0] = 0x14; |
14832 | if ((res >> 26) == ALC880_HP_EVENT) | 14554 | alc_automute_amp(codec); |
14833 | alc861vd_dallas_automute(codec); | ||
14834 | } | 14555 | } |
14835 | 14556 | ||
14836 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 14557 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -14944,7 +14665,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14944 | .channel_mode = alc861vd_3stack_2ch_modes, | 14665 | .channel_mode = alc861vd_3stack_2ch_modes, |
14945 | .input_mux = &alc861vd_capture_source, | 14666 | .input_mux = &alc861vd_capture_source, |
14946 | .unsol_event = alc861vd_lenovo_unsol_event, | 14667 | .unsol_event = alc861vd_lenovo_unsol_event, |
14947 | .init_hook = alc861vd_lenovo_automute, | 14668 | .init_hook = alc861vd_lenovo_init_hook, |
14948 | }, | 14669 | }, |
14949 | [ALC861VD_DALLAS] = { | 14670 | [ALC861VD_DALLAS] = { |
14950 | .mixers = { alc861vd_dallas_mixer }, | 14671 | .mixers = { alc861vd_dallas_mixer }, |
@@ -14954,8 +14675,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14954 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | 14675 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14955 | .channel_mode = alc861vd_3stack_2ch_modes, | 14676 | .channel_mode = alc861vd_3stack_2ch_modes, |
14956 | .input_mux = &alc861vd_dallas_capture_source, | 14677 | .input_mux = &alc861vd_dallas_capture_source, |
14957 | .unsol_event = alc861vd_dallas_unsol_event, | 14678 | .unsol_event = alc_automute_amp_unsol_event, |
14958 | .init_hook = alc861vd_dallas_automute, | 14679 | .init_hook = alc861vd_dallas_init_hook, |
14959 | }, | 14680 | }, |
14960 | [ALC861VD_HP] = { | 14681 | [ALC861VD_HP] = { |
14961 | .mixers = { alc861vd_hp_mixer }, | 14682 | .mixers = { alc861vd_hp_mixer }, |
@@ -14966,8 +14687,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14966 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | 14687 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14967 | .channel_mode = alc861vd_3stack_2ch_modes, | 14688 | .channel_mode = alc861vd_3stack_2ch_modes, |
14968 | .input_mux = &alc861vd_hp_capture_source, | 14689 | .input_mux = &alc861vd_hp_capture_source, |
14969 | .unsol_event = alc861vd_dallas_unsol_event, | 14690 | .unsol_event = alc_automute_amp_unsol_event, |
14970 | .init_hook = alc861vd_dallas_automute, | 14691 | .init_hook = alc861vd_dallas_init_hook, |
14971 | }, | 14692 | }, |
14972 | [ALC660VD_ASUS_V1S] = { | 14693 | [ALC660VD_ASUS_V1S] = { |
14973 | .mixers = { alc861vd_lenovo_mixer }, | 14694 | .mixers = { alc861vd_lenovo_mixer }, |
@@ -14982,7 +14703,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14982 | .channel_mode = alc861vd_3stack_2ch_modes, | 14703 | .channel_mode = alc861vd_3stack_2ch_modes, |
14983 | .input_mux = &alc861vd_capture_source, | 14704 | .input_mux = &alc861vd_capture_source, |
14984 | .unsol_event = alc861vd_lenovo_unsol_event, | 14705 | .unsol_event = alc861vd_lenovo_unsol_event, |
14985 | .init_hook = alc861vd_lenovo_automute, | 14706 | .init_hook = alc861vd_lenovo_init_hook, |
14986 | }, | 14707 | }, |
14987 | }; | 14708 | }; |
14988 | 14709 | ||