diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-03-16 09:48:05 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-03-16 09:48:05 -0400 |
commit | 34e72afe73c40d9974c1f230c3b62fc43f5c5b28 (patch) | |
tree | fee2be2e3453e246ee55ffb711a36a8ec053361a /sound/pci/hda/hda_generic.c | |
parent | e79d74ab25339437447478e4dfe2b35c5b560512 (diff) | |
parent | cc261738add93947d138d2fabad9f4dbed4e5c00 (diff) |
Merge branch 'for-linus' into for-next
Diffstat (limited to 'sound/pci/hda/hda_generic.c')
-rw-r--r-- | sound/pci/hda/hda_generic.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index b680b4ec6331..8ec5289f8e05 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -687,12 +687,45 @@ static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, | |||
687 | return val; | 687 | return val; |
688 | } | 688 | } |
689 | 689 | ||
690 | /* is this a stereo widget or a stereo-to-mono mix? */ | ||
691 | static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid, int dir) | ||
692 | { | ||
693 | unsigned int wcaps = get_wcaps(codec, nid); | ||
694 | hda_nid_t conn; | ||
695 | |||
696 | if (wcaps & AC_WCAP_STEREO) | ||
697 | return true; | ||
698 | if (dir != HDA_INPUT || get_wcaps_type(wcaps) != AC_WID_AUD_MIX) | ||
699 | return false; | ||
700 | if (snd_hda_get_num_conns(codec, nid) != 1) | ||
701 | return false; | ||
702 | if (snd_hda_get_connections(codec, nid, &conn, 1) < 0) | ||
703 | return false; | ||
704 | return !!(get_wcaps(codec, conn) & AC_WCAP_STEREO); | ||
705 | } | ||
706 | |||
690 | /* initialize the amp value (only at the first time) */ | 707 | /* initialize the amp value (only at the first time) */ |
691 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) | 708 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
692 | { | 709 | { |
693 | unsigned int caps = query_amp_caps(codec, nid, dir); | 710 | unsigned int caps = query_amp_caps(codec, nid, dir); |
694 | int val = get_amp_val_to_activate(codec, nid, dir, caps, false); | 711 | int val = get_amp_val_to_activate(codec, nid, dir, caps, false); |
695 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); | 712 | |
713 | if (is_stereo_amps(codec, nid, dir)) | ||
714 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); | ||
715 | else | ||
716 | snd_hda_codec_amp_init(codec, nid, 0, dir, idx, 0xff, val); | ||
717 | } | ||
718 | |||
719 | /* update the amp, doing in stereo or mono depending on NID */ | ||
720 | static int update_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx, | ||
721 | unsigned int mask, unsigned int val) | ||
722 | { | ||
723 | if (is_stereo_amps(codec, nid, dir)) | ||
724 | return snd_hda_codec_amp_stereo(codec, nid, dir, idx, | ||
725 | mask, val); | ||
726 | else | ||
727 | return snd_hda_codec_amp_update(codec, nid, 0, dir, idx, | ||
728 | mask, val); | ||
696 | } | 729 | } |
697 | 730 | ||
698 | /* calculate amp value mask we can modify; | 731 | /* calculate amp value mask we can modify; |
@@ -732,7 +765,7 @@ static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, | |||
732 | return; | 765 | return; |
733 | 766 | ||
734 | val &= mask; | 767 | val &= mask; |
735 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, mask, val); | 768 | update_amp(codec, nid, dir, idx, mask, val); |
736 | } | 769 | } |
737 | 770 | ||
738 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, | 771 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
@@ -4424,13 +4457,11 @@ static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix) | |||
4424 | has_amp = nid_has_mute(codec, mix, HDA_INPUT); | 4457 | has_amp = nid_has_mute(codec, mix, HDA_INPUT); |
4425 | for (i = 0; i < nums; i++) { | 4458 | for (i = 0; i < nums; i++) { |
4426 | if (has_amp) | 4459 | if (has_amp) |
4427 | snd_hda_codec_amp_stereo(codec, mix, | 4460 | update_amp(codec, mix, HDA_INPUT, i, |
4428 | HDA_INPUT, i, | 4461 | 0xff, HDA_AMP_MUTE); |
4429 | 0xff, HDA_AMP_MUTE); | ||
4430 | else if (nid_has_volume(codec, conn[i], HDA_OUTPUT)) | 4462 | else if (nid_has_volume(codec, conn[i], HDA_OUTPUT)) |
4431 | snd_hda_codec_amp_stereo(codec, conn[i], | 4463 | update_amp(codec, conn[i], HDA_OUTPUT, 0, |
4432 | HDA_OUTPUT, 0, | 4464 | 0xff, HDA_AMP_MUTE); |
4433 | 0xff, HDA_AMP_MUTE); | ||
4434 | } | 4465 | } |
4435 | } | 4466 | } |
4436 | 4467 | ||