diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-12-20 09:42:57 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-12-20 09:42:57 -0500 |
commit | 78c058df6a120044455b5635daefdc515bf9d899 (patch) | |
tree | d349e70e384404a9a2d9860feb0219e9f8acb212 /sound/pci/hda/patch_realtek.c | |
parent | db9c6f842fa957b41984cd8ceea1f07c53fb3fbf (diff) | |
parent | 31ef22579302ac42054bebecb528710f46580925 (diff) |
Merge branch 'test/hda-jack' into topic/hda
Conflicts:
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_via.c
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 84 |
1 files changed, 19 insertions, 65 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 690f2a2a4595..d24adbd023ee 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | #include "hda_beep.h" | 35 | #include "hda_beep.h" |
36 | #include "hda_jack.h" | ||
36 | 37 | ||
37 | /* unsol event tags */ | 38 | /* unsol event tags */ |
38 | #define ALC_FRONT_EVENT 0x01 | 39 | #define ALC_FRONT_EVENT 0x01 |
@@ -184,6 +185,7 @@ struct alc_spec { | |||
184 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ | 185 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ |
185 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ | 186 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
186 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ | 187 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
188 | unsigned int use_jack_tbl:1; /* 1 for model=auto */ | ||
187 | 189 | ||
188 | /* auto-mute control */ | 190 | /* auto-mute control */ |
189 | int automute_mode; | 191 | int automute_mode; |
@@ -466,46 +468,6 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
466 | } | 468 | } |
467 | 469 | ||
468 | /* | 470 | /* |
469 | * Jack-reporting via input-jack layer | ||
470 | */ | ||
471 | |||
472 | /* initialization of jacks; currently checks only a few known pins */ | ||
473 | static int alc_init_jacks(struct hda_codec *codec) | ||
474 | { | ||
475 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
476 | struct alc_spec *spec = codec->spec; | ||
477 | int err; | ||
478 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | ||
479 | unsigned int mic_nid = spec->ext_mic_pin; | ||
480 | unsigned int dock_nid = spec->dock_mic_pin; | ||
481 | |||
482 | if (hp_nid) { | ||
483 | err = snd_hda_input_jack_add(codec, hp_nid, | ||
484 | SND_JACK_HEADPHONE, NULL); | ||
485 | if (err < 0) | ||
486 | return err; | ||
487 | snd_hda_input_jack_report(codec, hp_nid); | ||
488 | } | ||
489 | |||
490 | if (mic_nid) { | ||
491 | err = snd_hda_input_jack_add(codec, mic_nid, | ||
492 | SND_JACK_MICROPHONE, NULL); | ||
493 | if (err < 0) | ||
494 | return err; | ||
495 | snd_hda_input_jack_report(codec, mic_nid); | ||
496 | } | ||
497 | if (dock_nid) { | ||
498 | err = snd_hda_input_jack_add(codec, dock_nid, | ||
499 | SND_JACK_MICROPHONE, NULL); | ||
500 | if (err < 0) | ||
501 | return err; | ||
502 | snd_hda_input_jack_report(codec, dock_nid); | ||
503 | } | ||
504 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | /* | ||
509 | * Jack detections for HP auto-mute and mic-switch | 471 | * Jack detections for HP auto-mute and mic-switch |
510 | */ | 472 | */ |
511 | 473 | ||
@@ -518,7 +480,6 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) | |||
518 | hda_nid_t nid = pins[i]; | 480 | hda_nid_t nid = pins[i]; |
519 | if (!nid) | 481 | if (!nid) |
520 | break; | 482 | break; |
521 | snd_hda_input_jack_report(codec, nid); | ||
522 | present |= snd_hda_jack_detect(codec, nid); | 483 | present |= snd_hda_jack_detect(codec, nid); |
523 | } | 484 | } |
524 | return present; | 485 | return present; |
@@ -658,19 +619,18 @@ static void alc_mic_automute(struct hda_codec *codec) | |||
658 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); | 619 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
659 | else | 620 | else |
660 | alc_mux_select(codec, 0, spec->int_mic_idx, false); | 621 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
661 | |||
662 | snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]); | ||
663 | if (spec->dock_mic_idx >= 0) | ||
664 | snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]); | ||
665 | } | 622 | } |
666 | 623 | ||
667 | /* unsolicited event for HP jack sensing */ | 624 | /* unsolicited event for HP jack sensing */ |
668 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | 625 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
669 | { | 626 | { |
627 | struct alc_spec *spec = codec->spec; | ||
670 | if (codec->vendor_id == 0x10ec0880) | 628 | if (codec->vendor_id == 0x10ec0880) |
671 | res >>= 28; | 629 | res >>= 28; |
672 | else | 630 | else |
673 | res >>= 26; | 631 | res >>= 26; |
632 | if (spec->use_jack_tbl) | ||
633 | res = snd_hda_jack_get_action(codec, res); | ||
674 | switch (res) { | 634 | switch (res) { |
675 | case ALC_HP_EVENT: | 635 | case ALC_HP_EVENT: |
676 | alc_hp_automute(codec); | 636 | alc_hp_automute(codec); |
@@ -682,6 +642,7 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |||
682 | alc_mic_automute(codec); | 642 | alc_mic_automute(codec); |
683 | break; | 643 | break; |
684 | } | 644 | } |
645 | snd_hda_jack_report_sync(codec); | ||
685 | } | 646 | } |
686 | 647 | ||
687 | /* call init functions of standard auto-mute helpers */ | 648 | /* call init functions of standard auto-mute helpers */ |
@@ -971,9 +932,7 @@ static void alc_init_automute(struct hda_codec *codec) | |||
971 | continue; | 932 | continue; |
972 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", | 933 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
973 | nid); | 934 | nid); |
974 | snd_hda_codec_write_cache(codec, nid, 0, | 935 | snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); |
975 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
976 | AC_USRSP_EN | ALC_HP_EVENT); | ||
977 | spec->detect_hp = 1; | 936 | spec->detect_hp = 1; |
978 | } | 937 | } |
979 | 938 | ||
@@ -985,9 +944,8 @@ static void alc_init_automute(struct hda_codec *codec) | |||
985 | continue; | 944 | continue; |
986 | snd_printdd("realtek: Enable Line-Out " | 945 | snd_printdd("realtek: Enable Line-Out " |
987 | "auto-muting on NID 0x%x\n", nid); | 946 | "auto-muting on NID 0x%x\n", nid); |
988 | snd_hda_codec_write_cache(codec, nid, 0, | 947 | snd_hda_jack_detect_enable(codec, nid, |
989 | AC_VERB_SET_UNSOLICITED_ENABLE, | 948 | ALC_FRONT_EVENT); |
990 | AC_USRSP_EN | ALC_FRONT_EVENT); | ||
991 | spec->detect_lo = 1; | 949 | spec->detect_lo = 1; |
992 | } | 950 | } |
993 | spec->automute_lo_possible = spec->detect_hp; | 951 | spec->automute_lo_possible = spec->detect_hp; |
@@ -1126,13 +1084,10 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec) | |||
1126 | return false; /* no corresponding imux */ | 1084 | return false; /* no corresponding imux */ |
1127 | } | 1085 | } |
1128 | 1086 | ||
1129 | snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0, | 1087 | snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); |
1130 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1131 | AC_USRSP_EN | ALC_MIC_EVENT); | ||
1132 | if (spec->dock_mic_pin) | 1088 | if (spec->dock_mic_pin) |
1133 | snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0, | 1089 | snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, |
1134 | AC_VERB_SET_UNSOLICITED_ENABLE, | 1090 | ALC_MIC_EVENT); |
1135 | AC_USRSP_EN | ALC_MIC_EVENT); | ||
1136 | 1091 | ||
1137 | spec->auto_mic_valid_imux = 1; | 1092 | spec->auto_mic_valid_imux = 1; |
1138 | spec->auto_mic = 1; | 1093 | spec->auto_mic = 1; |
@@ -2074,6 +2029,10 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2074 | 2029 | ||
2075 | alc_free_kctls(codec); /* no longer needed */ | 2030 | alc_free_kctls(codec); /* no longer needed */ |
2076 | 2031 | ||
2032 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); | ||
2033 | if (err < 0) | ||
2034 | return err; | ||
2035 | |||
2077 | return 0; | 2036 | return 0; |
2078 | } | 2037 | } |
2079 | 2038 | ||
@@ -2101,6 +2060,8 @@ static int alc_init(struct hda_codec *codec) | |||
2101 | 2060 | ||
2102 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); | 2061 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
2103 | 2062 | ||
2063 | snd_hda_jack_report_sync(codec); | ||
2064 | |||
2104 | hda_call_check_power_status(codec, 0x01); | 2065 | hda_call_check_power_status(codec, 0x01); |
2105 | return 0; | 2066 | return 0; |
2106 | } | 2067 | } |
@@ -2484,7 +2445,6 @@ static void alc_free(struct hda_codec *codec) | |||
2484 | return; | 2445 | return; |
2485 | 2446 | ||
2486 | alc_shutup(codec); | 2447 | alc_shutup(codec); |
2487 | snd_hda_input_jack_free(codec); | ||
2488 | alc_free_kctls(codec); | 2448 | alc_free_kctls(codec); |
2489 | alc_free_bind_ctls(codec); | 2449 | alc_free_bind_ctls(codec); |
2490 | kfree(spec); | 2450 | kfree(spec); |
@@ -3944,6 +3904,7 @@ static void set_capture_mixer(struct hda_codec *codec) | |||
3944 | static void alc_auto_init_std(struct hda_codec *codec) | 3904 | static void alc_auto_init_std(struct hda_codec *codec) |
3945 | { | 3905 | { |
3946 | struct alc_spec *spec = codec->spec; | 3906 | struct alc_spec *spec = codec->spec; |
3907 | spec->use_jack_tbl = 1; | ||
3947 | alc_auto_init_multi_out(codec); | 3908 | alc_auto_init_multi_out(codec); |
3948 | alc_auto_init_extra_out(codec); | 3909 | alc_auto_init_extra_out(codec); |
3949 | alc_auto_init_analog_input(codec); | 3910 | alc_auto_init_analog_input(codec); |
@@ -4731,7 +4692,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
4731 | if (board_config == ALC_MODEL_AUTO) | 4692 | if (board_config == ALC_MODEL_AUTO) |
4732 | spec->init_hook = alc_auto_init_std; | 4693 | spec->init_hook = alc_auto_init_std; |
4733 | 4694 | ||
4734 | alc_init_jacks(codec); | ||
4735 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4695 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4736 | if (!spec->loopback.amplist) | 4696 | if (!spec->loopback.amplist) |
4737 | spec->loopback.amplist = alc882_loopbacks; | 4697 | spec->loopback.amplist = alc882_loopbacks; |
@@ -4909,7 +4869,6 @@ static int patch_alc262(struct hda_codec *codec) | |||
4909 | spec->init_hook = alc_auto_init_std; | 4869 | spec->init_hook = alc_auto_init_std; |
4910 | spec->shutup = alc_eapd_shutup; | 4870 | spec->shutup = alc_eapd_shutup; |
4911 | 4871 | ||
4912 | alc_init_jacks(codec); | ||
4913 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4872 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4914 | if (!spec->loopback.amplist) | 4873 | if (!spec->loopback.amplist) |
4915 | spec->loopback.amplist = alc262_loopbacks; | 4874 | spec->loopback.amplist = alc262_loopbacks; |
@@ -5020,8 +4979,6 @@ static int patch_alc268(struct hda_codec *codec) | |||
5020 | spec->init_hook = alc_auto_init_std; | 4979 | spec->init_hook = alc_auto_init_std; |
5021 | spec->shutup = alc_eapd_shutup; | 4980 | spec->shutup = alc_eapd_shutup; |
5022 | 4981 | ||
5023 | alc_init_jacks(codec); | ||
5024 | |||
5025 | return 0; | 4982 | return 0; |
5026 | 4983 | ||
5027 | error: | 4984 | error: |
@@ -5577,7 +5534,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
5577 | spec->init_hook = alc_auto_init_std; | 5534 | spec->init_hook = alc_auto_init_std; |
5578 | spec->shutup = alc269_shutup; | 5535 | spec->shutup = alc269_shutup; |
5579 | 5536 | ||
5580 | alc_init_jacks(codec); | ||
5581 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 5537 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5582 | if (!spec->loopback.amplist) | 5538 | if (!spec->loopback.amplist) |
5583 | spec->loopback.amplist = alc269_loopbacks; | 5539 | spec->loopback.amplist = alc269_loopbacks; |
@@ -6187,8 +6143,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
6187 | spec->init_hook = alc_auto_init_std; | 6143 | spec->init_hook = alc_auto_init_std; |
6188 | spec->shutup = alc_eapd_shutup; | 6144 | spec->shutup = alc_eapd_shutup; |
6189 | 6145 | ||
6190 | alc_init_jacks(codec); | ||
6191 | |||
6192 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 6146 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6193 | if (!spec->loopback.amplist) | 6147 | if (!spec->loopback.amplist) |
6194 | spec->loopback.amplist = alc662_loopbacks; | 6148 | spec->loopback.amplist = alc662_loopbacks; |