diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 498 |
1 files changed, 232 insertions, 266 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index b7b419691803..6b7eeba656ed 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -157,8 +157,6 @@ struct sigmatel_spec { | |||
157 | int board_config; | 157 | int board_config; |
158 | unsigned int eapd_switch: 1; | 158 | unsigned int eapd_switch: 1; |
159 | unsigned int surr_switch: 1; | 159 | unsigned int surr_switch: 1; |
160 | unsigned int line_switch: 1; | ||
161 | unsigned int mic_switch: 1; | ||
162 | unsigned int alt_switch: 1; | 160 | unsigned int alt_switch: 1; |
163 | unsigned int hp_detect: 1; | 161 | unsigned int hp_detect: 1; |
164 | unsigned int spdif_mute: 1; | 162 | unsigned int spdif_mute: 1; |
@@ -195,6 +193,8 @@ struct sigmatel_spec { | |||
195 | unsigned int cur_mmux; | 193 | unsigned int cur_mmux; |
196 | struct hda_multi_out multiout; | 194 | struct hda_multi_out multiout; |
197 | hda_nid_t dac_nids[5]; | 195 | hda_nid_t dac_nids[5]; |
196 | hda_nid_t hp_dacs[5]; | ||
197 | hda_nid_t speaker_dacs[5]; | ||
198 | 198 | ||
199 | /* capture */ | 199 | /* capture */ |
200 | hda_nid_t *adc_nids; | 200 | hda_nid_t *adc_nids; |
@@ -238,7 +238,9 @@ struct sigmatel_spec { | |||
238 | /* i/o switches */ | 238 | /* i/o switches */ |
239 | unsigned int io_switch[2]; | 239 | unsigned int io_switch[2]; |
240 | unsigned int clfe_swap; | 240 | unsigned int clfe_swap; |
241 | unsigned int hp_switch; /* NID of HP as line-out */ | 241 | hda_nid_t line_switch; /* shared line-in for input and output */ |
242 | hda_nid_t mic_switch; /* shared mic-in for input and output */ | ||
243 | hda_nid_t hp_switch; /* NID of HP as line-out */ | ||
242 | unsigned int aloopback; | 244 | unsigned int aloopback; |
243 | 245 | ||
244 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 246 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
@@ -289,9 +291,6 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | |||
289 | }; | 291 | }; |
290 | 292 | ||
291 | #define STAC92HD73_DAC_COUNT 5 | 293 | #define STAC92HD73_DAC_COUNT 5 |
292 | static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = { | ||
293 | 0x15, 0x16, 0x17, 0x18, 0x19, | ||
294 | }; | ||
295 | 294 | ||
296 | static hda_nid_t stac92hd73xx_mux_nids[4] = { | 295 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
297 | 0x28, 0x29, 0x2a, 0x2b, | 296 | 0x28, 0x29, 0x2a, 0x2b, |
@@ -310,11 +309,7 @@ static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | |||
310 | 0x11, 0x12, 0 | 309 | 0x11, 0x12, 0 |
311 | }; | 310 | }; |
312 | 311 | ||
313 | #define STAC92HD81_DAC_COUNT 2 | ||
314 | #define STAC92HD83_DAC_COUNT 3 | 312 | #define STAC92HD83_DAC_COUNT 3 |
315 | static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = { | ||
316 | 0x13, 0x14, 0x22, | ||
317 | }; | ||
318 | 313 | ||
319 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { | 314 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
320 | 0x17, 0x18, | 315 | 0x17, 0x18, |
@@ -356,10 +351,6 @@ static hda_nid_t stac92hd71bxx_smux_nids[2] = { | |||
356 | 0x24, 0x25, | 351 | 0x24, 0x25, |
357 | }; | 352 | }; |
358 | 353 | ||
359 | static hda_nid_t stac92hd71bxx_dac_nids[1] = { | ||
360 | 0x10, /*0x11, */ | ||
361 | }; | ||
362 | |||
363 | #define STAC92HD71BXX_NUM_DMICS 2 | 354 | #define STAC92HD71BXX_NUM_DMICS 2 |
364 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { | 355 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
365 | 0x18, 0x19, 0 | 356 | 0x18, 0x19, 0 |
@@ -761,10 +752,6 @@ static struct hda_verb stac9200_eapd_init[] = { | |||
761 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { | 752 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
762 | /* set master volume and direct control */ | 753 | /* set master volume and direct control */ |
763 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 754 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
764 | /* setup audio connections */ | ||
765 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
766 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
767 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
768 | /* setup adcs to point to mixer */ | 755 | /* setup adcs to point to mixer */ |
769 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 756 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
770 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 757 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -783,10 +770,6 @@ static struct hda_verb dell_eq_core_init[] = { | |||
783 | /* set master volume to max value without distortion | 770 | /* set master volume to max value without distortion |
784 | * and direct control */ | 771 | * and direct control */ |
785 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | 772 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
786 | /* setup audio connections */ | ||
787 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
788 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
789 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
790 | /* setup adcs to point to mixer */ | 773 | /* setup adcs to point to mixer */ |
791 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 774 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
792 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 775 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -800,10 +783,6 @@ static struct hda_verb dell_eq_core_init[] = { | |||
800 | 783 | ||
801 | static struct hda_verb dell_m6_core_init[] = { | 784 | static struct hda_verb dell_m6_core_init[] = { |
802 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 785 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
803 | /* setup audio connections */ | ||
804 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
805 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
806 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
807 | /* setup adcs to point to mixer */ | 786 | /* setup adcs to point to mixer */ |
808 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 787 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
809 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 788 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -818,13 +797,6 @@ static struct hda_verb dell_m6_core_init[] = { | |||
818 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { | 797 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
819 | /* set master volume and direct control */ | 798 | /* set master volume and direct control */ |
820 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 799 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
821 | /* setup audio connections */ | ||
822 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
823 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
824 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
825 | /* connect hp ports to dac3 */ | ||
826 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
827 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
828 | /* setup adcs to point to mixer */ | 800 | /* setup adcs to point to mixer */ |
829 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 801 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
830 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 802 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -842,15 +814,8 @@ static struct hda_verb stac92hd73xx_8ch_core_init[] = { | |||
842 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { | 814 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
843 | /* set master volume and direct control */ | 815 | /* set master volume and direct control */ |
844 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 816 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
845 | /* setup audio connections */ | ||
846 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
847 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
848 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
849 | /* dac3 is connected to import3 mux */ | 817 | /* dac3 is connected to import3 mux */ |
850 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, | 818 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
851 | /* connect hp ports to dac4 */ | ||
852 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04}, | ||
853 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04}, | ||
854 | /* setup adcs to point to mixer */ | 819 | /* setup adcs to point to mixer */ |
855 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 820 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
856 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 821 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -881,8 +846,6 @@ static struct hda_verb stac92hd83xxx_core_init[] = { | |||
881 | static struct hda_verb stac92hd71bxx_core_init[] = { | 846 | static struct hda_verb stac92hd71bxx_core_init[] = { |
882 | /* set master volume and direct control */ | 847 | /* set master volume and direct control */ |
883 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 848 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
884 | /* connect headphone jack to dac1 */ | ||
885 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
886 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ | 849 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
887 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 850 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
888 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 851 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -901,8 +864,6 @@ static struct hda_verb stac92hd71bxx_analog_core_init[] = { | |||
901 | 864 | ||
902 | /* set master volume and direct control */ | 865 | /* set master volume and direct control */ |
903 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 866 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
904 | /* connect headphone jack to dac1 */ | ||
905 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
906 | /* unmute right and left channels for nodes 0x0a, 0xd */ | 867 | /* unmute right and left channels for nodes 0x0a, 0xd */ |
907 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 868 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
908 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 869 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -2747,70 +2708,53 @@ static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, | |||
2747 | return stac92xx_add_control_idx(spec, type, 0, name, val); | 2708 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
2748 | } | 2709 | } |
2749 | 2710 | ||
2750 | /* flag inputs as additional dynamic lineouts */ | 2711 | /* check whether the line-input can be used as line-out */ |
2751 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) | 2712 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
2752 | { | 2713 | { |
2753 | struct sigmatel_spec *spec = codec->spec; | 2714 | struct sigmatel_spec *spec = codec->spec; |
2754 | unsigned int wcaps, wtype; | 2715 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2755 | int i, num_dacs = 0; | 2716 | hda_nid_t nid; |
2756 | 2717 | unsigned int pincap; | |
2757 | /* use the wcaps cache to count all DACs available for line-outs */ | ||
2758 | for (i = 0; i < codec->num_nodes; i++) { | ||
2759 | wcaps = codec->wcaps[i]; | ||
2760 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2761 | 2718 | ||
2762 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) | 2719 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
2763 | num_dacs++; | 2720 | return 0; |
2764 | } | 2721 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
2722 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
2723 | if (pincap & AC_PINCAP_OUT) | ||
2724 | return nid; | ||
2725 | return 0; | ||
2726 | } | ||
2765 | 2727 | ||
2766 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); | 2728 | /* check whether the mic-input can be used as line-out */ |
2767 | 2729 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) | |
2768 | switch (cfg->line_outs) { | 2730 | { |
2769 | case 3: | 2731 | struct sigmatel_spec *spec = codec->spec; |
2770 | /* add line-in as side */ | 2732 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2771 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { | 2733 | unsigned int def_conf, pincap; |
2772 | cfg->line_out_pins[cfg->line_outs] = | 2734 | unsigned int mic_pin; |
2773 | cfg->input_pins[AUTO_PIN_LINE]; | 2735 | |
2774 | spec->line_switch = 1; | 2736 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
2775 | cfg->line_outs++; | 2737 | return 0; |
2776 | } | 2738 | mic_pin = AUTO_PIN_MIC; |
2777 | break; | 2739 | for (;;) { |
2778 | case 2: | 2740 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
2779 | /* add line-in as clfe and mic as side */ | 2741 | def_conf = snd_hda_codec_read(codec, nid, 0, |
2780 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { | 2742 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
2781 | cfg->line_out_pins[cfg->line_outs] = | 2743 | /* some laptops have an internal analog microphone |
2782 | cfg->input_pins[AUTO_PIN_LINE]; | 2744 | * which can't be used as a output */ |
2783 | spec->line_switch = 1; | 2745 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
2784 | cfg->line_outs++; | 2746 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
2785 | } | 2747 | if (pincap & AC_PINCAP_OUT) |
2786 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { | 2748 | return nid; |
2787 | cfg->line_out_pins[cfg->line_outs] = | ||
2788 | cfg->input_pins[AUTO_PIN_MIC]; | ||
2789 | spec->mic_switch = 1; | ||
2790 | cfg->line_outs++; | ||
2791 | } | ||
2792 | break; | ||
2793 | case 1: | ||
2794 | /* add line-in as surr and mic as clfe */ | ||
2795 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { | ||
2796 | cfg->line_out_pins[cfg->line_outs] = | ||
2797 | cfg->input_pins[AUTO_PIN_LINE]; | ||
2798 | spec->line_switch = 1; | ||
2799 | cfg->line_outs++; | ||
2800 | } | ||
2801 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { | ||
2802 | cfg->line_out_pins[cfg->line_outs] = | ||
2803 | cfg->input_pins[AUTO_PIN_MIC]; | ||
2804 | spec->mic_switch = 1; | ||
2805 | cfg->line_outs++; | ||
2806 | } | 2749 | } |
2807 | break; | 2750 | if (mic_pin == AUTO_PIN_MIC) |
2751 | mic_pin = AUTO_PIN_FRONT_MIC; | ||
2752 | else | ||
2753 | break; | ||
2808 | } | 2754 | } |
2809 | |||
2810 | return 0; | 2755 | return 0; |
2811 | } | 2756 | } |
2812 | 2757 | ||
2813 | |||
2814 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 2758 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
2815 | { | 2759 | { |
2816 | int i; | 2760 | int i; |
@@ -2823,6 +2767,52 @@ static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2823 | return 0; | 2767 | return 0; |
2824 | } | 2768 | } |
2825 | 2769 | ||
2770 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | ||
2771 | { | ||
2772 | int i; | ||
2773 | if (is_in_dac_nids(spec, nid)) | ||
2774 | return 1; | ||
2775 | for (i = 0; i < spec->autocfg.hp_outs; i++) | ||
2776 | if (spec->hp_dacs[i] == nid) | ||
2777 | return 1; | ||
2778 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
2779 | if (spec->speaker_dacs[i] == nid) | ||
2780 | return 1; | ||
2781 | return 0; | ||
2782 | } | ||
2783 | |||
2784 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | ||
2785 | { | ||
2786 | struct sigmatel_spec *spec = codec->spec; | ||
2787 | int j, conn_len; | ||
2788 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | ||
2789 | unsigned int wcaps, wtype; | ||
2790 | |||
2791 | conn_len = snd_hda_get_connections(codec, nid, conn, | ||
2792 | HDA_MAX_CONNECTIONS); | ||
2793 | for (j = 0; j < conn_len; j++) { | ||
2794 | wcaps = snd_hda_param_read(codec, conn[j], | ||
2795 | AC_PAR_AUDIO_WIDGET_CAP); | ||
2796 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2797 | /* we check only analog outputs */ | ||
2798 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | ||
2799 | continue; | ||
2800 | /* if this route has a free DAC, assign it */ | ||
2801 | if (!check_all_dac_nids(spec, conn[j])) { | ||
2802 | if (conn_len > 1) { | ||
2803 | /* select this DAC in the pin's input mux */ | ||
2804 | snd_hda_codec_write_cache(codec, nid, 0, | ||
2805 | AC_VERB_SET_CONNECT_SEL, j); | ||
2806 | } | ||
2807 | return conn[j]; | ||
2808 | } | ||
2809 | } | ||
2810 | return 0; | ||
2811 | } | ||
2812 | |||
2813 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | ||
2814 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | ||
2815 | |||
2826 | /* | 2816 | /* |
2827 | * Fill in the dac_nids table from the parsed pin configuration | 2817 | * Fill in the dac_nids table from the parsed pin configuration |
2828 | * This function only works when every pin in line_out_pins[] | 2818 | * This function only works when every pin in line_out_pins[] |
@@ -2830,31 +2820,17 @@ static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2830 | * codecs are not connected directly to a DAC, such as the 9200 | 2820 | * codecs are not connected directly to a DAC, such as the 9200 |
2831 | * and 9202/925x. For those, dac_nids[] must be hard-coded. | 2821 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
2832 | */ | 2822 | */ |
2833 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, | 2823 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
2834 | struct auto_pin_cfg *cfg) | ||
2835 | { | 2824 | { |
2836 | struct sigmatel_spec *spec = codec->spec; | 2825 | struct sigmatel_spec *spec = codec->spec; |
2837 | int i, j, conn_len = 0; | 2826 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2838 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; | 2827 | int i; |
2839 | unsigned int wcaps, wtype; | 2828 | hda_nid_t nid, dac; |
2840 | 2829 | ||
2841 | for (i = 0; i < cfg->line_outs; i++) { | 2830 | for (i = 0; i < cfg->line_outs; i++) { |
2842 | nid = cfg->line_out_pins[i]; | 2831 | nid = cfg->line_out_pins[i]; |
2843 | conn_len = snd_hda_get_connections(codec, nid, conn, | 2832 | dac = get_unassigned_dac(codec, nid); |
2844 | HDA_MAX_CONNECTIONS); | 2833 | if (!dac) { |
2845 | for (j = 0; j < conn_len; j++) { | ||
2846 | wcaps = snd_hda_param_read(codec, conn[j], | ||
2847 | AC_PAR_AUDIO_WIDGET_CAP); | ||
2848 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2849 | if (wtype != AC_WID_AUD_OUT || | ||
2850 | (wcaps & AC_WCAP_DIGITAL)) | ||
2851 | continue; | ||
2852 | /* conn[j] is a DAC routed to this line-out */ | ||
2853 | if (!is_in_dac_nids(spec, conn[j])) | ||
2854 | break; | ||
2855 | } | ||
2856 | |||
2857 | if (j == conn_len) { | ||
2858 | if (spec->multiout.num_dacs > 0) { | 2834 | if (spec->multiout.num_dacs > 0) { |
2859 | /* we have already working output pins, | 2835 | /* we have already working output pins, |
2860 | * so let's drop the broken ones again | 2836 | * so let's drop the broken ones again |
@@ -2868,24 +2844,64 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, | |||
2868 | __func__, nid); | 2844 | __func__, nid); |
2869 | return -ENODEV; | 2845 | return -ENODEV; |
2870 | } | 2846 | } |
2847 | add_spec_dacs(spec, dac); | ||
2848 | } | ||
2871 | 2849 | ||
2872 | spec->multiout.dac_nids[i] = conn[j]; | 2850 | /* add line-in as output */ |
2873 | spec->multiout.num_dacs++; | 2851 | nid = check_line_out_switch(codec); |
2874 | if (conn_len > 1) { | 2852 | if (nid) { |
2875 | /* select this DAC in the pin's input mux */ | 2853 | dac = get_unassigned_dac(codec, nid); |
2876 | snd_hda_codec_write_cache(codec, nid, 0, | 2854 | if (dac) { |
2877 | AC_VERB_SET_CONNECT_SEL, j); | 2855 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
2856 | nid, cfg->line_outs); | ||
2857 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
2858 | cfg->line_outs++; | ||
2859 | spec->line_switch = nid; | ||
2860 | add_spec_dacs(spec, dac); | ||
2861 | } | ||
2862 | } | ||
2863 | /* add mic as output */ | ||
2864 | nid = check_mic_out_switch(codec); | ||
2865 | if (nid) { | ||
2866 | dac = get_unassigned_dac(codec, nid); | ||
2867 | if (dac) { | ||
2868 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", | ||
2869 | nid, cfg->line_outs); | ||
2870 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
2871 | cfg->line_outs++; | ||
2872 | spec->mic_switch = nid; | ||
2873 | add_spec_dacs(spec, dac); | ||
2874 | } | ||
2875 | } | ||
2878 | 2876 | ||
2877 | for (i = 0; i < cfg->hp_outs; i++) { | ||
2878 | nid = cfg->hp_pins[i]; | ||
2879 | dac = get_unassigned_dac(codec, nid); | ||
2880 | if (dac) { | ||
2881 | if (!spec->multiout.hp_nid) | ||
2882 | spec->multiout.hp_nid = dac; | ||
2883 | else | ||
2884 | add_spec_extra_dacs(spec, dac); | ||
2879 | } | 2885 | } |
2886 | spec->hp_dacs[i] = dac; | ||
2880 | } | 2887 | } |
2881 | 2888 | ||
2882 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | 2889 | for (i = 0; i < cfg->speaker_outs; i++) { |
2890 | nid = cfg->speaker_pins[i]; | ||
2891 | dac = get_unassigned_dac(codec, nid); | ||
2892 | if (dac) | ||
2893 | add_spec_extra_dacs(spec, dac); | ||
2894 | spec->speaker_dacs[i] = dac; | ||
2895 | } | ||
2896 | |||
2897 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
2883 | spec->multiout.num_dacs, | 2898 | spec->multiout.num_dacs, |
2884 | spec->multiout.dac_nids[0], | 2899 | spec->multiout.dac_nids[0], |
2885 | spec->multiout.dac_nids[1], | 2900 | spec->multiout.dac_nids[1], |
2886 | spec->multiout.dac_nids[2], | 2901 | spec->multiout.dac_nids[2], |
2887 | spec->multiout.dac_nids[3], | 2902 | spec->multiout.dac_nids[3], |
2888 | spec->multiout.dac_nids[4]); | 2903 | spec->multiout.dac_nids[4]); |
2904 | |||
2889 | return 0; | 2905 | return 0; |
2890 | } | 2906 | } |
2891 | 2907 | ||
@@ -2910,9 +2926,7 @@ static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_ | |||
2910 | 2926 | ||
2911 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) | 2927 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
2912 | { | 2928 | { |
2913 | if (!spec->multiout.hp_nid) | 2929 | if (spec->multiout.num_dacs > 4) { |
2914 | spec->multiout.hp_nid = nid; | ||
2915 | else if (spec->multiout.num_dacs > 4) { | ||
2916 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); | 2930 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
2917 | return 1; | 2931 | return 1; |
2918 | } else { | 2932 | } else { |
@@ -2922,35 +2936,47 @@ static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2922 | return 0; | 2936 | return 0; |
2923 | } | 2937 | } |
2924 | 2938 | ||
2925 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 2939 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
2926 | { | 2940 | { |
2927 | if (is_in_dac_nids(spec, nid)) | 2941 | int i; |
2928 | return 1; | 2942 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
2943 | if (!spec->multiout.extra_out_nid[i]) { | ||
2944 | spec->multiout.extra_out_nid[i] = nid; | ||
2945 | return 0; | ||
2946 | } | ||
2947 | } | ||
2948 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); | ||
2949 | return 1; | ||
2950 | } | ||
2951 | |||
2952 | static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) | ||
2953 | { | ||
2954 | int i; | ||
2955 | |||
2956 | if (spec->autocfg.line_outs != 1) | ||
2957 | return 0; | ||
2929 | if (spec->multiout.hp_nid == nid) | 2958 | if (spec->multiout.hp_nid == nid) |
2930 | return 1; | 2959 | return 0; |
2931 | return 0; | 2960 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) |
2961 | if (spec->multiout.extra_out_nid[i] == nid) | ||
2962 | return 0; | ||
2963 | return 1; | ||
2932 | } | 2964 | } |
2933 | 2965 | ||
2934 | /* add playback controls from the parsed DAC table */ | 2966 | /* add playback controls from the parsed DAC table */ |
2935 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | 2967 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
2936 | const struct auto_pin_cfg *cfg) | 2968 | const struct auto_pin_cfg *cfg) |
2937 | { | 2969 | { |
2970 | struct sigmatel_spec *spec = codec->spec; | ||
2938 | static const char *chname[4] = { | 2971 | static const char *chname[4] = { |
2939 | "Front", "Surround", NULL /*CLFE*/, "Side" | 2972 | "Front", "Surround", NULL /*CLFE*/, "Side" |
2940 | }; | 2973 | }; |
2941 | hda_nid_t nid = 0; | 2974 | hda_nid_t nid = 0; |
2942 | int i, err; | 2975 | int i, err, num_dacs; |
2943 | |||
2944 | struct sigmatel_spec *spec = codec->spec; | ||
2945 | unsigned int wid_caps, pincap; | 2976 | unsigned int wid_caps, pincap; |
2946 | 2977 | ||
2947 | 2978 | for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { | |
2948 | for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) { | ||
2949 | if (!spec->multiout.dac_nids[i]) | ||
2950 | continue; | ||
2951 | |||
2952 | nid = spec->multiout.dac_nids[i]; | 2979 | nid = spec->multiout.dac_nids[i]; |
2953 | |||
2954 | if (i == 2) { | 2980 | if (i == 2) { |
2955 | /* Center/LFE */ | 2981 | /* Center/LFE */ |
2956 | err = create_controls(spec, "Center", nid, 1); | 2982 | err = create_controls(spec, "Center", nid, 1); |
@@ -2972,16 +2998,24 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
2972 | } | 2998 | } |
2973 | 2999 | ||
2974 | } else { | 3000 | } else { |
2975 | err = create_controls(spec, chname[i], nid, 3); | 3001 | const char *name = chname[i]; |
3002 | /* if it's a single DAC, assign a better name */ | ||
3003 | if (!i && is_unique_dac(spec, nid)) { | ||
3004 | switch (cfg->line_out_type) { | ||
3005 | case AUTO_PIN_HP_OUT: | ||
3006 | name = "Headphone"; | ||
3007 | break; | ||
3008 | case AUTO_PIN_SPEAKER_OUT: | ||
3009 | name = "Speaker"; | ||
3010 | break; | ||
3011 | } | ||
3012 | } | ||
3013 | err = create_controls(spec, name, nid, 3); | ||
2976 | if (err < 0) | 3014 | if (err < 0) |
2977 | return err; | 3015 | return err; |
2978 | } | 3016 | } |
2979 | } | 3017 | } |
2980 | 3018 | ||
2981 | if ((spec->multiout.num_dacs - cfg->line_outs) > 0 && | ||
2982 | cfg->hp_outs == 1 && !spec->multiout.hp_nid) | ||
2983 | spec->multiout.hp_nid = nid; | ||
2984 | |||
2985 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { | 3019 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
2986 | err = stac92xx_add_control(spec, | 3020 | err = stac92xx_add_control(spec, |
2987 | STAC_CTL_WIDGET_HP_SWITCH, | 3021 | STAC_CTL_WIDGET_HP_SWITCH, |
@@ -2992,45 +3026,19 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
2992 | } | 3026 | } |
2993 | 3027 | ||
2994 | if (spec->line_switch) { | 3028 | if (spec->line_switch) { |
2995 | nid = cfg->input_pins[AUTO_PIN_LINE]; | 3029 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
2996 | pincap = snd_hda_param_read(codec, nid, | 3030 | "Line In as Output Switch", |
2997 | AC_PAR_PIN_CAP); | 3031 | spec->line_switch << 8); |
2998 | if (pincap & AC_PINCAP_OUT) { | 3032 | if (err < 0) |
2999 | err = stac92xx_add_control(spec, | 3033 | return err; |
3000 | STAC_CTL_WIDGET_IO_SWITCH, | ||
3001 | "Line In as Output Switch", nid << 8); | ||
3002 | if (err < 0) | ||
3003 | return err; | ||
3004 | } | ||
3005 | } | 3034 | } |
3006 | 3035 | ||
3007 | if (spec->mic_switch) { | 3036 | if (spec->mic_switch) { |
3008 | unsigned int def_conf; | 3037 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
3009 | unsigned int mic_pin = AUTO_PIN_MIC; | 3038 | "Mic as Output Switch", |
3010 | again: | 3039 | (spec->mic_switch << 8) | 1); |
3011 | nid = cfg->input_pins[mic_pin]; | 3040 | if (err < 0) |
3012 | def_conf = snd_hda_codec_read(codec, nid, 0, | 3041 | return err; |
3013 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3014 | /* some laptops have an internal analog microphone | ||
3015 | * which can't be used as a output */ | ||
3016 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { | ||
3017 | pincap = snd_hda_param_read(codec, nid, | ||
3018 | AC_PAR_PIN_CAP); | ||
3019 | if (pincap & AC_PINCAP_OUT) { | ||
3020 | err = stac92xx_add_control(spec, | ||
3021 | STAC_CTL_WIDGET_IO_SWITCH, | ||
3022 | "Mic as Output Switch", (nid << 8) | 1); | ||
3023 | nid = snd_hda_codec_read(codec, nid, 0, | ||
3024 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3025 | if (!check_in_dac_nids(spec, nid)) | ||
3026 | add_spec_dacs(spec, nid); | ||
3027 | if (err < 0) | ||
3028 | return err; | ||
3029 | } | ||
3030 | } else if (mic_pin == AUTO_PIN_MIC) { | ||
3031 | mic_pin = AUTO_PIN_FRONT_MIC; | ||
3032 | goto again; | ||
3033 | } | ||
3034 | } | 3042 | } |
3035 | 3043 | ||
3036 | return 0; | 3044 | return 0; |
@@ -3042,55 +3050,39 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, | |||
3042 | { | 3050 | { |
3043 | struct sigmatel_spec *spec = codec->spec; | 3051 | struct sigmatel_spec *spec = codec->spec; |
3044 | hda_nid_t nid; | 3052 | hda_nid_t nid; |
3045 | int i, old_num_dacs, err; | 3053 | int i, err, nums; |
3046 | 3054 | ||
3047 | old_num_dacs = spec->multiout.num_dacs; | 3055 | nums = 0; |
3048 | for (i = 0; i < cfg->hp_outs; i++) { | 3056 | for (i = 0; i < cfg->hp_outs; i++) { |
3057 | static const char *pfxs[] = { | ||
3058 | "Headphone", "Headphone2", "Headphone3", | ||
3059 | }; | ||
3049 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); | 3060 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
3050 | if (wid_caps & AC_WCAP_UNSOL_CAP) | 3061 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
3051 | spec->hp_detect = 1; | 3062 | spec->hp_detect = 1; |
3052 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, | 3063 | if (nums >= ARRAY_SIZE(pfxs)) |
3053 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3054 | if (check_in_dac_nids(spec, nid)) | ||
3055 | nid = 0; | ||
3056 | if (! nid) | ||
3057 | continue; | ||
3058 | add_spec_dacs(spec, nid); | ||
3059 | } | ||
3060 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
3061 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, | ||
3062 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3063 | if (check_in_dac_nids(spec, nid)) | ||
3064 | nid = 0; | ||
3065 | if (! nid) | ||
3066 | continue; | 3064 | continue; |
3067 | add_spec_dacs(spec, nid); | 3065 | nid = spec->hp_dacs[i]; |
3068 | } | 3066 | if (!nid) |
3069 | for (i = 0; i < cfg->line_outs; i++) { | ||
3070 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, | ||
3071 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3072 | if (check_in_dac_nids(spec, nid)) | ||
3073 | nid = 0; | ||
3074 | if (! nid) | ||
3075 | continue; | 3067 | continue; |
3076 | add_spec_dacs(spec, nid); | 3068 | err = create_controls(spec, pfxs[nums++], nid, 3); |
3069 | if (err < 0) | ||
3070 | return err; | ||
3077 | } | 3071 | } |
3078 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { | 3072 | nums = 0; |
3073 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
3079 | static const char *pfxs[] = { | 3074 | static const char *pfxs[] = { |
3080 | "Speaker", "External Speaker", "Speaker2", | 3075 | "Speaker", "External Speaker", "Speaker2", |
3081 | }; | 3076 | }; |
3082 | err = create_controls(spec, pfxs[i - old_num_dacs], | 3077 | if (nums >= ARRAY_SIZE(pfxs)) |
3083 | spec->multiout.dac_nids[i], 3); | 3078 | continue; |
3084 | if (err < 0) | 3079 | nid = spec->speaker_dacs[i]; |
3085 | return err; | 3080 | if (!nid) |
3086 | } | 3081 | continue; |
3087 | if (spec->multiout.hp_nid) { | 3082 | err = create_controls(spec, pfxs[nums++], nid, 3); |
3088 | err = create_controls(spec, "Headphone", | ||
3089 | spec->multiout.hp_nid, 3); | ||
3090 | if (err < 0) | 3083 | if (err < 0) |
3091 | return err; | 3084 | return err; |
3092 | } | 3085 | } |
3093 | |||
3094 | return 0; | 3086 | return 0; |
3095 | } | 3087 | } |
3096 | 3088 | ||
@@ -3428,7 +3420,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3428 | { | 3420 | { |
3429 | struct sigmatel_spec *spec = codec->spec; | 3421 | struct sigmatel_spec *spec = codec->spec; |
3430 | int err; | 3422 | int err; |
3431 | int hp_speaker_swap = 0; | ||
3432 | 3423 | ||
3433 | if ((err = snd_hda_parse_pin_def_config(codec, | 3424 | if ((err = snd_hda_parse_pin_def_config(codec, |
3434 | &spec->autocfg, | 3425 | &spec->autocfg, |
@@ -3446,13 +3437,15 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3446 | * speaker_outs so that the following routines can handle | 3437 | * speaker_outs so that the following routines can handle |
3447 | * HP pins as primary outputs. | 3438 | * HP pins as primary outputs. |
3448 | */ | 3439 | */ |
3440 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); | ||
3449 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, | 3441 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
3450 | sizeof(spec->autocfg.line_out_pins)); | 3442 | sizeof(spec->autocfg.line_out_pins)); |
3451 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; | 3443 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
3452 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, | 3444 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
3453 | sizeof(spec->autocfg.hp_pins)); | 3445 | sizeof(spec->autocfg.hp_pins)); |
3454 | spec->autocfg.line_outs = spec->autocfg.hp_outs; | 3446 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
3455 | hp_speaker_swap = 1; | 3447 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
3448 | spec->autocfg.hp_outs = 0; | ||
3456 | } | 3449 | } |
3457 | if (spec->autocfg.mono_out_pin) { | 3450 | if (spec->autocfg.mono_out_pin) { |
3458 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & | 3451 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
@@ -3504,11 +3497,11 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3504 | AC_PINCTL_OUT_EN); | 3497 | AC_PINCTL_OUT_EN); |
3505 | } | 3498 | } |
3506 | 3499 | ||
3507 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) | 3500 | if (!spec->multiout.num_dacs) { |
3508 | return err; | 3501 | err = stac92xx_auto_fill_dac_nids(codec); |
3509 | if (spec->multiout.num_dacs == 0) | 3502 | if (err < 0) |
3510 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) | ||
3511 | return err; | 3503 | return err; |
3504 | } | ||
3512 | 3505 | ||
3513 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); | 3506 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); |
3514 | 3507 | ||
@@ -3546,19 +3539,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3546 | } | 3539 | } |
3547 | #endif | 3540 | #endif |
3548 | 3541 | ||
3549 | if (hp_speaker_swap == 1) { | ||
3550 | /* Restore the hp_outs and line_outs */ | ||
3551 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, | ||
3552 | sizeof(spec->autocfg.line_out_pins)); | ||
3553 | spec->autocfg.hp_outs = spec->autocfg.line_outs; | ||
3554 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins, | ||
3555 | sizeof(spec->autocfg.speaker_pins)); | ||
3556 | spec->autocfg.line_outs = spec->autocfg.speaker_outs; | ||
3557 | memset(spec->autocfg.speaker_pins, 0, | ||
3558 | sizeof(spec->autocfg.speaker_pins)); | ||
3559 | spec->autocfg.speaker_outs = 0; | ||
3560 | } | ||
3561 | |||
3562 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); | 3542 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
3563 | 3543 | ||
3564 | if (err < 0) | 3544 | if (err < 0) |
@@ -3870,8 +3850,7 @@ static void stac92xx_power_down(struct hda_codec *codec) | |||
3870 | /* power down inactive DACs */ | 3850 | /* power down inactive DACs */ |
3871 | hda_nid_t *dac; | 3851 | hda_nid_t *dac; |
3872 | for (dac = spec->dac_list; *dac; dac++) | 3852 | for (dac = spec->dac_list; *dac; dac++) |
3873 | if (!is_in_dac_nids(spec, *dac) && | 3853 | if (!check_all_dac_nids(spec, *dac)) |
3874 | spec->multiout.hp_nid != *dac) | ||
3875 | snd_hda_codec_write(codec, *dac, 0, | 3854 | snd_hda_codec_write(codec, *dac, 0, |
3876 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 3855 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
3877 | } | 3856 | } |
@@ -4055,10 +4034,7 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4055 | */ | 4034 | */ |
4056 | struct sigmatel_spec *spec = codec->spec; | 4035 | struct sigmatel_spec *spec = codec->spec; |
4057 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4036 | struct auto_pin_cfg *cfg = &spec->autocfg; |
4058 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && | 4037 | if (nid == spec->line_switch || nid == spec->mic_switch) |
4059 | spec->line_switch) || | ||
4060 | (nid == cfg->input_pins[AUTO_PIN_MIC] && | ||
4061 | spec->mic_switch)) | ||
4062 | return; | 4038 | return; |
4063 | } | 4039 | } |
4064 | 4040 | ||
@@ -4100,11 +4076,9 @@ static int no_hp_sensing(struct sigmatel_spec *spec, int i) | |||
4100 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4076 | struct auto_pin_cfg *cfg = &spec->autocfg; |
4101 | 4077 | ||
4102 | /* ignore sensing of shared line and mic jacks */ | 4078 | /* ignore sensing of shared line and mic jacks */ |
4103 | if (spec->line_switch && | 4079 | if (cfg->hp_pins[i] == spec->line_switch) |
4104 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE]) | ||
4105 | return 1; | 4080 | return 1; |
4106 | if (spec->mic_switch && | 4081 | if (cfg->hp_pins[i] == spec->mic_switch) |
4107 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC]) | ||
4108 | return 1; | 4082 | return 1; |
4109 | /* ignore if the pin is set as line-out */ | 4083 | /* ignore if the pin is set as line-out */ |
4110 | if (cfg->hp_pins[i] == spec->hp_switch) | 4084 | if (cfg->hp_pins[i] == spec->hp_switch) |
@@ -4515,6 +4489,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
4515 | struct sigmatel_spec *spec; | 4489 | struct sigmatel_spec *spec; |
4516 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; | 4490 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
4517 | int err = 0; | 4491 | int err = 0; |
4492 | int num_dacs; | ||
4518 | 4493 | ||
4519 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4494 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
4520 | if (spec == NULL) | 4495 | if (spec == NULL) |
@@ -4541,33 +4516,29 @@ again: | |||
4541 | return err; | 4516 | return err; |
4542 | } | 4517 | } |
4543 | 4518 | ||
4544 | spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, | 4519 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
4545 | conn, STAC92HD73_DAC_COUNT + 2) - 1; | 4520 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
4546 | 4521 | ||
4547 | if (spec->multiout.num_dacs < 0) { | 4522 | if (num_dacs < 3 || num_dacs > 5) { |
4548 | printk(KERN_WARNING "hda_codec: Could not determine " | 4523 | printk(KERN_WARNING "hda_codec: Could not determine " |
4549 | "number of channels defaulting to DAC count\n"); | 4524 | "number of channels defaulting to DAC count\n"); |
4550 | spec->multiout.num_dacs = STAC92HD73_DAC_COUNT; | 4525 | num_dacs = STAC92HD73_DAC_COUNT; |
4551 | } | 4526 | } |
4552 | 4527 | switch (num_dacs) { | |
4553 | switch (spec->multiout.num_dacs) { | ||
4554 | case 0x3: /* 6 Channel */ | 4528 | case 0x3: /* 6 Channel */ |
4555 | spec->multiout.hp_nid = 0x17; | ||
4556 | spec->mixer = stac92hd73xx_6ch_mixer; | 4529 | spec->mixer = stac92hd73xx_6ch_mixer; |
4557 | spec->init = stac92hd73xx_6ch_core_init; | 4530 | spec->init = stac92hd73xx_6ch_core_init; |
4558 | break; | 4531 | break; |
4559 | case 0x4: /* 8 Channel */ | 4532 | case 0x4: /* 8 Channel */ |
4560 | spec->multiout.hp_nid = 0x18; | ||
4561 | spec->mixer = stac92hd73xx_8ch_mixer; | 4533 | spec->mixer = stac92hd73xx_8ch_mixer; |
4562 | spec->init = stac92hd73xx_8ch_core_init; | 4534 | spec->init = stac92hd73xx_8ch_core_init; |
4563 | break; | 4535 | break; |
4564 | case 0x5: /* 10 Channel */ | 4536 | case 0x5: /* 10 Channel */ |
4565 | spec->multiout.hp_nid = 0x19; | ||
4566 | spec->mixer = stac92hd73xx_10ch_mixer; | 4537 | spec->mixer = stac92hd73xx_10ch_mixer; |
4567 | spec->init = stac92hd73xx_10ch_core_init; | 4538 | spec->init = stac92hd73xx_10ch_core_init; |
4568 | }; | 4539 | } |
4540 | spec->multiout.dac_nids = spec->dac_nids; | ||
4569 | 4541 | ||
4570 | spec->multiout.dac_nids = stac92hd73xx_dac_nids; | ||
4571 | spec->aloopback_mask = 0x01; | 4542 | spec->aloopback_mask = 0x01; |
4572 | spec->aloopback_shift = 8; | 4543 | spec->aloopback_shift = 8; |
4573 | 4544 | ||
@@ -4598,9 +4569,8 @@ again: | |||
4598 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; | 4569 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
4599 | spec->eapd_switch = 0; | 4570 | spec->eapd_switch = 0; |
4600 | spec->num_amps = 1; | 4571 | spec->num_amps = 1; |
4601 | spec->multiout.hp_nid = 0; /* dual HPs */ | ||
4602 | 4572 | ||
4603 | if (!spec->init) | 4573 | if (spec->board_config != STAC_DELL_EQ) |
4604 | spec->init = dell_m6_core_init; | 4574 | spec->init = dell_m6_core_init; |
4605 | switch (spec->board_config) { | 4575 | switch (spec->board_config) { |
4606 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | 4576 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
@@ -4691,17 +4661,15 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
4691 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 4661 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
4692 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 4662 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
4693 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 4663 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
4694 | spec->multiout.dac_nids = stac92hd83xxx_dac_nids; | 4664 | spec->multiout.dac_nids = spec->dac_nids; |
4695 | 4665 | ||
4696 | spec->init = stac92hd83xxx_core_init; | 4666 | spec->init = stac92hd83xxx_core_init; |
4697 | switch (codec->vendor_id) { | 4667 | switch (codec->vendor_id) { |
4698 | case 0x111d7605: | 4668 | case 0x111d7605: |
4699 | spec->multiout.num_dacs = STAC92HD81_DAC_COUNT; | ||
4700 | break; | 4669 | break; |
4701 | default: | 4670 | default: |
4702 | spec->num_pwrs--; | 4671 | spec->num_pwrs--; |
4703 | spec->init++; /* switch to config #2 */ | 4672 | spec->init++; /* switch to config #2 */ |
4704 | spec->multiout.num_dacs = STAC92HD83_DAC_COUNT; | ||
4705 | } | 4673 | } |
4706 | 4674 | ||
4707 | spec->mixer = stac92hd83xxx_mixer; | 4675 | spec->mixer = stac92hd83xxx_mixer; |
@@ -4892,9 +4860,7 @@ again: | |||
4892 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | 4860 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
4893 | }; | 4861 | }; |
4894 | 4862 | ||
4895 | spec->multiout.num_dacs = 1; | 4863 | spec->multiout.dac_nids = spec->dac_nids; |
4896 | spec->multiout.hp_nid = 0x11; | ||
4897 | spec->multiout.dac_nids = stac92hd71bxx_dac_nids; | ||
4898 | if (spec->dinput_mux) | 4864 | if (spec->dinput_mux) |
4899 | spec->private_dimux.num_items += | 4865 | spec->private_dimux.num_items += |
4900 | spec->num_dmics - | 4866 | spec->num_dmics - |