diff options
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 152 |
1 files changed, 89 insertions, 63 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 00ed1268f274..407475941fd3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -10790,80 +10790,106 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |||
10790 | { } /* end */ | 10790 | { } /* end */ |
10791 | }; | 10791 | }; |
10792 | 10792 | ||
10793 | /* We use two mixers depending on the output pin; 0x16 is a mono output | ||
10794 | * and thus it's bound with a different mixer. | ||
10795 | * This function returns which mixer amp should be used. | ||
10796 | */ | ||
10797 | static int alc262_check_volbit(hda_nid_t nid) | ||
10798 | { | ||
10799 | if (!nid) | ||
10800 | return 0; | ||
10801 | else if (nid == 0x16) | ||
10802 | return 2; | ||
10803 | else | ||
10804 | return 1; | ||
10805 | } | ||
10806 | |||
10807 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10808 | const char *pfx, int *vbits) | ||
10809 | { | ||
10810 | char name[32]; | ||
10811 | unsigned long val; | ||
10812 | int vbit; | ||
10813 | |||
10814 | vbit = alc262_check_volbit(nid); | ||
10815 | if (!vbit) | ||
10816 | return 0; | ||
10817 | if (*vbits & vbit) /* a volume control for this mixer already there */ | ||
10818 | return 0; | ||
10819 | *vbits |= vbit; | ||
10820 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10821 | if (vbit == 2) | ||
10822 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | ||
10823 | else | ||
10824 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | ||
10825 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | ||
10826 | } | ||
10827 | |||
10828 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10829 | const char *pfx) | ||
10830 | { | ||
10831 | char name[32]; | ||
10832 | unsigned long val; | ||
10833 | |||
10834 | if (!nid) | ||
10835 | return 0; | ||
10836 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10837 | if (nid == 0x16) | ||
10838 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | ||
10839 | else | ||
10840 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | ||
10841 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | ||
10842 | } | ||
10843 | |||
10793 | /* add playback controls from the parsed DAC table */ | 10844 | /* add playback controls from the parsed DAC table */ |
10794 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, | 10845 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10795 | const struct auto_pin_cfg *cfg) | 10846 | const struct auto_pin_cfg *cfg) |
10796 | { | 10847 | { |
10797 | hda_nid_t nid; | 10848 | const char *pfx; |
10849 | int vbits; | ||
10798 | int err; | 10850 | int err; |
10799 | 10851 | ||
10800 | spec->multiout.num_dacs = 1; /* only use one dac */ | 10852 | spec->multiout.num_dacs = 1; /* only use one dac */ |
10801 | spec->multiout.dac_nids = spec->private_dac_nids; | 10853 | spec->multiout.dac_nids = spec->private_dac_nids; |
10802 | spec->multiout.dac_nids[0] = 2; | 10854 | spec->multiout.dac_nids[0] = 2; |
10803 | 10855 | ||
10804 | nid = cfg->line_out_pins[0]; | 10856 | if (!cfg->speaker_pins[0] && !cfg->hp_pins[0]) |
10805 | if (nid) { | 10857 | pfx = "Master"; |
10806 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 10858 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
10807 | "Front Playback Volume", | 10859 | pfx = "Speaker"; |
10808 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | 10860 | else |
10809 | if (err < 0) | 10861 | pfx = "Front"; |
10810 | return err; | 10862 | err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx); |
10811 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 10863 | if (err < 0) |
10812 | "Front Playback Switch", | 10864 | return err; |
10813 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 10865 | err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker"); |
10814 | if (err < 0) | 10866 | if (err < 0) |
10815 | return err; | 10867 | return err; |
10816 | } | 10868 | err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone"); |
10869 | if (err < 0) | ||
10870 | return err; | ||
10817 | 10871 | ||
10818 | nid = cfg->speaker_pins[0]; | 10872 | vbits = alc262_check_volbit(cfg->line_out_pins[0]) | |
10819 | if (nid) { | 10873 | alc262_check_volbit(cfg->speaker_pins[0]) | |
10820 | if (nid == 0x16) { | 10874 | alc262_check_volbit(cfg->hp_pins[0]); |
10821 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 10875 | if (vbits == 1 || vbits == 2) |
10822 | "Speaker Playback Volume", | 10876 | pfx = "Master"; /* only one mixer is used */ |
10823 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | 10877 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
10824 | HDA_OUTPUT)); | 10878 | pfx = "Speaker"; |
10825 | if (err < 0) | 10879 | else |
10826 | return err; | 10880 | pfx = "Front"; |
10827 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 10881 | vbits = 0; |
10828 | "Speaker Playback Switch", | 10882 | err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits); |
10829 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | 10883 | if (err < 0) |
10830 | HDA_OUTPUT)); | 10884 | return err; |
10831 | if (err < 0) | 10885 | err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker", |
10832 | return err; | 10886 | &vbits); |
10833 | } else { | 10887 | if (err < 0) |
10834 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 10888 | return err; |
10835 | "Speaker Playback Switch", | 10889 | err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone", |
10836 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 10890 | &vbits); |
10837 | HDA_OUTPUT)); | 10891 | if (err < 0) |
10838 | if (err < 0) | 10892 | return err; |
10839 | return err; | ||
10840 | } | ||
10841 | } | ||
10842 | nid = cfg->hp_pins[0]; | ||
10843 | if (nid) { | ||
10844 | /* spec->multiout.hp_nid = 2; */ | ||
10845 | if (nid == 0x16) { | ||
10846 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
10847 | "Headphone Playback Volume", | ||
10848 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | ||
10849 | HDA_OUTPUT)); | ||
10850 | if (err < 0) | ||
10851 | return err; | ||
10852 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10853 | "Headphone Playback Switch", | ||
10854 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
10855 | HDA_OUTPUT)); | ||
10856 | if (err < 0) | ||
10857 | return err; | ||
10858 | } else { | ||
10859 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10860 | "Headphone Playback Switch", | ||
10861 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
10862 | HDA_OUTPUT)); | ||
10863 | if (err < 0) | ||
10864 | return err; | ||
10865 | } | ||
10866 | } | ||
10867 | return 0; | 10893 | return 0; |
10868 | } | 10894 | } |
10869 | 10895 | ||