diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-07-06 08:02:55 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-07-07 03:31:15 -0400 |
commit | 97aaab7b493d9e22a9c0a125a501920354e67846 (patch) | |
tree | ffa9e80f67a161b18e95fd16d341d79d37521e27 /sound/pci/hda/patch_realtek.c | |
parent | cd51155676b1c0f44604e304109cb9739a54ea7e (diff) |
ALSA: hda - Create bind-mutes appropriately for ALC662 auto-parser
When multiple inputs are present on the mixer widget (typically a DAC
and a loopback), mute/unmute both inputs with the corresponding mixer
element.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 62853e3bda83..236200963b02 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -18855,28 +18855,38 @@ static int alc662_auto_fill_dac_nids(struct hda_codec *codec) | |||
18855 | return 0; | 18855 | return 0; |
18856 | } | 18856 | } |
18857 | 18857 | ||
18858 | static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, | 18858 | static int alc662_add_vol_ctl(struct hda_codec *codec, |
18859 | hda_nid_t nid, int idx, unsigned int chs) | 18859 | const char *pfx, int cidx, |
18860 | hda_nid_t nid, unsigned int chs) | ||
18860 | { | 18861 | { |
18861 | return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, | 18862 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
18862 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 18863 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
18863 | } | 18864 | } |
18864 | 18865 | ||
18865 | static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, | 18866 | #define alc662_add_stereo_vol(codec, pfx, cidx, nid) \ |
18866 | hda_nid_t nid, int idx, unsigned int chs) | 18867 | alc662_add_vol_ctl(codec, pfx, cidx, nid, 3) |
18868 | |||
18869 | /* create a mute-switch for the given mixer widget; | ||
18870 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute | ||
18871 | */ | ||
18872 | static int alc662_add_sw_ctl(struct hda_codec *codec, | ||
18873 | const char *pfx, int cidx, | ||
18874 | hda_nid_t nid, unsigned int chs) | ||
18867 | { | 18875 | { |
18868 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, | 18876 | int type; |
18869 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); | 18877 | unsigned long val; |
18878 | if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { | ||
18879 | type = ALC_CTL_WIDGET_MUTE; | ||
18880 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); | ||
18881 | } else { | ||
18882 | type = ALC_CTL_BIND_MUTE; | ||
18883 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); | ||
18884 | } | ||
18885 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); | ||
18870 | } | 18886 | } |
18871 | 18887 | ||
18872 | #define alc662_add_vol_ctl(spec, pfx, nid, chs) \ | 18888 | #define alc662_add_stereo_sw(codec, pfx, cidx, nid) \ |
18873 | __alc662_add_vol_ctl(spec, pfx, nid, 0, chs) | 18889 | alc662_add_sw_ctl(codec, pfx, cidx, nid, 3) |
18874 | #define alc662_add_sw_ctl(spec, pfx, nid, chs) \ | ||
18875 | __alc662_add_sw_ctl(spec, pfx, nid, 0, chs) | ||
18876 | #define alc662_add_stereo_vol(spec, pfx, nid) \ | ||
18877 | alc662_add_vol_ctl(spec, pfx, nid, 3) | ||
18878 | #define alc662_add_stereo_sw(spec, pfx, nid) \ | ||
18879 | alc662_add_sw_ctl(spec, pfx, nid, 3) | ||
18880 | 18890 | ||
18881 | /* add playback controls from the parsed DAC table */ | 18891 | /* add playback controls from the parsed DAC table */ |
18882 | static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec, | 18892 | static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec, |
@@ -18906,23 +18916,23 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
18906 | name = alc_get_line_out_pfx(spec, i, true, &index); | 18916 | name = alc_get_line_out_pfx(spec, i, true, &index); |
18907 | if (!name) { | 18917 | if (!name) { |
18908 | /* Center/LFE */ | 18918 | /* Center/LFE */ |
18909 | err = alc662_add_vol_ctl(spec, "Center", nid, 1); | 18919 | err = alc662_add_vol_ctl(codec, "Center", 0, nid, 1); |
18910 | if (err < 0) | 18920 | if (err < 0) |
18911 | return err; | 18921 | return err; |
18912 | err = alc662_add_vol_ctl(spec, "LFE", nid, 2); | 18922 | err = alc662_add_vol_ctl(codec, "LFE", 0, nid, 2); |
18913 | if (err < 0) | 18923 | if (err < 0) |
18914 | return err; | 18924 | return err; |
18915 | err = alc662_add_sw_ctl(spec, "Center", mix, 1); | 18925 | err = alc662_add_sw_ctl(codec, "Center", 0, mix, 1); |
18916 | if (err < 0) | 18926 | if (err < 0) |
18917 | return err; | 18927 | return err; |
18918 | err = alc662_add_sw_ctl(spec, "LFE", mix, 2); | 18928 | err = alc662_add_sw_ctl(codec, "LFE", 0, mix, 2); |
18919 | if (err < 0) | 18929 | if (err < 0) |
18920 | return err; | 18930 | return err; |
18921 | } else { | 18931 | } else { |
18922 | err = __alc662_add_vol_ctl(spec, name, nid, index, 3); | 18932 | err = alc662_add_stereo_vol(codec, name, index, nid); |
18923 | if (err < 0) | 18933 | if (err < 0) |
18924 | return err; | 18934 | return err; |
18925 | err = __alc662_add_sw_ctl(spec, name, mix, index, 3); | 18935 | err = alc662_add_stereo_sw(codec, name, index, mix); |
18926 | if (err < 0) | 18936 | if (err < 0) |
18927 | return err; | 18937 | return err; |
18928 | } | 18938 | } |
@@ -18952,10 +18962,10 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, | |||
18952 | mix = alc_auto_dac_to_mix(codec, pin, dac); | 18962 | mix = alc_auto_dac_to_mix(codec, pin, dac); |
18953 | if (!mix) | 18963 | if (!mix) |
18954 | return 0; | 18964 | return 0; |
18955 | err = alc662_add_vol_ctl(spec, pfx, dac, 3); | 18965 | err = alc662_add_stereo_vol(codec, pfx, 0, dac); |
18956 | if (err < 0) | 18966 | if (err < 0) |
18957 | return err; | 18967 | return err; |
18958 | err = alc662_add_sw_ctl(spec, pfx, mix, 3); | 18968 | err = alc662_add_stereo_sw(codec, pfx, 0, mix); |
18959 | if (err < 0) | 18969 | if (err < 0) |
18960 | return err; | 18970 | return err; |
18961 | return 0; | 18971 | return 0; |