diff options
Diffstat (limited to 'sound/pci/hda/patch_via.c')
-rw-r--r-- | sound/pci/hda/patch_via.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index d374e8cfdcc8..b9bd4d1cc860 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -1606,6 +1606,17 @@ static void via_free(struct hda_codec *codec) | |||
1606 | kfree(codec->spec); | 1606 | kfree(codec->spec); |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | /* mute/unmute outputs */ | ||
1610 | static void toggle_output_mutes(struct hda_codec *codec, int num_pins, | ||
1611 | hda_nid_t *pins, bool mute) | ||
1612 | { | ||
1613 | int i; | ||
1614 | for (i = 0; i < num_pins; i++) | ||
1615 | snd_hda_codec_write(codec, pins[i], 0, | ||
1616 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1617 | mute ? 0 : PIN_OUT); | ||
1618 | } | ||
1619 | |||
1609 | /* mute internal speaker if HP is plugged */ | 1620 | /* mute internal speaker if HP is plugged */ |
1610 | static void via_hp_automute(struct hda_codec *codec) | 1621 | static void via_hp_automute(struct hda_codec *codec) |
1611 | { | 1622 | { |
@@ -1614,12 +1625,10 @@ static void via_hp_automute(struct hda_codec *codec) | |||
1614 | 1625 | ||
1615 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | 1626 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
1616 | 1627 | ||
1617 | if (!spec->hp_independent_mode) { | 1628 | if (!spec->hp_independent_mode) |
1618 | /* auto mute */ | 1629 | toggle_output_mutes(codec, spec->autocfg.line_outs, |
1619 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, | 1630 | spec->autocfg.line_out_pins, |
1620 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1631 | present); |
1621 | present ? 0 : PIN_OUT); | ||
1622 | } | ||
1623 | } | 1632 | } |
1624 | 1633 | ||
1625 | /* mute mono out if HP or Line out is plugged */ | 1634 | /* mute mono out if HP or Line out is plugged */ |
@@ -1708,45 +1717,35 @@ static void via_speaker_automute(struct hda_codec *codec) | |||
1708 | 1717 | ||
1709 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | 1718 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
1710 | 1719 | ||
1711 | if (!spec->hp_independent_mode) { | 1720 | if (!spec->hp_independent_mode) |
1712 | snd_hda_codec_write(codec, spec->autocfg.speaker_pins[0], 0, | 1721 | toggle_output_mutes(codec, spec->autocfg.speaker_outs, |
1713 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1722 | spec->autocfg.speaker_pins, |
1714 | hp_present ? 0 : PIN_OUT); | 1723 | hp_present); |
1715 | } | ||
1716 | } | 1724 | } |
1717 | 1725 | ||
1718 | /* mute line-out and internal speaker if HP is plugged */ | 1726 | /* mute line-out and internal speaker if HP is plugged */ |
1719 | static void via_hp_bind_automute(struct hda_codec *codec) | 1727 | static void via_hp_bind_automute(struct hda_codec *codec) |
1720 | { | 1728 | { |
1721 | /* use long instead of int below just to avoid an internal compiler | 1729 | int present; |
1722 | * error with gcc 4.0.x | ||
1723 | */ | ||
1724 | unsigned long hp_present, present = 0; | ||
1725 | struct via_spec *spec = codec->spec; | 1730 | struct via_spec *spec = codec->spec; |
1726 | int i; | ||
1727 | 1731 | ||
1728 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) | 1732 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) |
1729 | return; | 1733 | return; |
1730 | 1734 | ||
1731 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | 1735 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
1736 | if (!spec->hp_independent_mode) | ||
1737 | toggle_output_mutes(codec, spec->autocfg.line_outs, | ||
1738 | spec->autocfg.line_out_pins, | ||
1739 | present); | ||
1732 | 1740 | ||
1733 | present = snd_hda_jack_detect(codec, spec->autocfg.line_out_pins[0]); | 1741 | if (!present) |
1742 | present = snd_hda_jack_detect(codec, | ||
1743 | spec->autocfg.line_out_pins[0]); | ||
1734 | 1744 | ||
1735 | if (!spec->hp_independent_mode) { | ||
1736 | /* Mute Line-Outs */ | ||
1737 | for (i = 0; i < spec->autocfg.line_outs; i++) | ||
1738 | snd_hda_codec_write(codec, | ||
1739 | spec->autocfg.line_out_pins[i], 0, | ||
1740 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1741 | hp_present ? 0 : PIN_OUT); | ||
1742 | if (hp_present) | ||
1743 | present = hp_present; | ||
1744 | } | ||
1745 | /* Speakers */ | 1745 | /* Speakers */ |
1746 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | 1746 | toggle_output_mutes(codec, spec->autocfg.speaker_outs, |
1747 | snd_hda_codec_write(codec, spec->autocfg.speaker_pins[i], 0, | 1747 | spec->autocfg.speaker_pins, |
1748 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1748 | present); |
1749 | present ? 0 : PIN_OUT); | ||
1750 | } | 1749 | } |
1751 | 1750 | ||
1752 | 1751 | ||