diff options
| -rw-r--r-- | sound/pci/hda/patch_via.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 430cb33c0e4c..eae466a6a987 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
| @@ -1684,23 +1684,6 @@ static void via_hp_automute(struct hda_codec *codec) | |||
| 1684 | via_line_automute(codec, present); | 1684 | via_line_automute(codec, present); |
| 1685 | } | 1685 | } |
| 1686 | 1686 | ||
| 1687 | /* unsolicited event for jack sensing */ | ||
| 1688 | static void via_unsol_event(struct hda_codec *codec, | ||
| 1689 | unsigned int res) | ||
| 1690 | { | ||
| 1691 | res >>= 26; | ||
| 1692 | res = snd_hda_jack_get_action(codec, res); | ||
| 1693 | |||
| 1694 | if (res & VIA_JACK_EVENT) | ||
| 1695 | set_widgets_power_state(codec); | ||
| 1696 | |||
| 1697 | res &= ~VIA_JACK_EVENT; | ||
| 1698 | |||
| 1699 | if (res == VIA_HP_EVENT || res == VIA_LINE_EVENT) | ||
| 1700 | via_hp_automute(codec); | ||
| 1701 | snd_hda_jack_report_sync(codec); | ||
| 1702 | } | ||
| 1703 | |||
| 1704 | #ifdef CONFIG_PM | 1687 | #ifdef CONFIG_PM |
| 1705 | static int via_suspend(struct hda_codec *codec) | 1688 | static int via_suspend(struct hda_codec *codec) |
| 1706 | { | 1689 | { |
| @@ -1736,7 +1719,7 @@ static const struct hda_codec_ops via_patch_ops = { | |||
| 1736 | .build_pcms = via_build_pcms, | 1719 | .build_pcms = via_build_pcms, |
| 1737 | .init = via_init, | 1720 | .init = via_init, |
| 1738 | .free = via_free, | 1721 | .free = via_free, |
| 1739 | .unsol_event = via_unsol_event, | 1722 | .unsol_event = snd_hda_jack_unsol_event, |
| 1740 | #ifdef CONFIG_PM | 1723 | #ifdef CONFIG_PM |
| 1741 | .suspend = via_suspend, | 1724 | .suspend = via_suspend, |
| 1742 | .check_power_status = via_check_power_status, | 1725 | .check_power_status = via_check_power_status, |
| @@ -2714,6 +2697,17 @@ static void via_auto_init_dig_in(struct hda_codec *codec) | |||
| 2714 | snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); | 2697 | snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); |
| 2715 | } | 2698 | } |
| 2716 | 2699 | ||
| 2700 | static void via_jack_output_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) | ||
| 2701 | { | ||
| 2702 | set_widgets_power_state(codec); | ||
| 2703 | via_hp_automute(codec); | ||
| 2704 | } | ||
| 2705 | |||
| 2706 | static void via_jack_powerstate_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) | ||
| 2707 | { | ||
| 2708 | set_widgets_power_state(codec); | ||
| 2709 | } | ||
| 2710 | |||
| 2717 | /* initialize the unsolicited events */ | 2711 | /* initialize the unsolicited events */ |
| 2718 | static void via_auto_init_unsol_event(struct hda_codec *codec) | 2712 | static void via_auto_init_unsol_event(struct hda_codec *codec) |
| 2719 | { | 2713 | { |
| @@ -2721,26 +2715,31 @@ static void via_auto_init_unsol_event(struct hda_codec *codec) | |||
| 2721 | struct auto_pin_cfg *cfg = &spec->autocfg; | 2715 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2722 | unsigned int ev; | 2716 | unsigned int ev; |
| 2723 | int i; | 2717 | int i; |
| 2718 | hda_jack_callback cb; | ||
| 2724 | 2719 | ||
| 2725 | if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0])) | 2720 | if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0])) |
| 2726 | snd_hda_jack_detect_enable(codec, cfg->hp_pins[0], | 2721 | snd_hda_jack_detect_enable_callback(codec, cfg->hp_pins[0], |
| 2727 | VIA_HP_EVENT | VIA_JACK_EVENT); | 2722 | VIA_HP_EVENT | VIA_JACK_EVENT, |
| 2723 | via_jack_output_event); | ||
| 2728 | 2724 | ||
| 2729 | if (cfg->speaker_pins[0]) | 2725 | if (cfg->speaker_pins[0]) |
| 2730 | ev = VIA_LINE_EVENT; | 2726 | ev = VIA_LINE_EVENT; |
| 2731 | else | 2727 | else |
| 2732 | ev = 0; | 2728 | ev = 0; |
| 2729 | cb = ev ? via_jack_output_event : via_jack_powerstate_event; | ||
| 2730 | |||
| 2733 | for (i = 0; i < cfg->line_outs; i++) { | 2731 | for (i = 0; i < cfg->line_outs; i++) { |
| 2734 | if (cfg->line_out_pins[i] && | 2732 | if (cfg->line_out_pins[i] && |
| 2735 | is_jack_detectable(codec, cfg->line_out_pins[i])) | 2733 | is_jack_detectable(codec, cfg->line_out_pins[i])) |
| 2736 | snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i], | 2734 | snd_hda_jack_detect_enable_callback(codec, cfg->line_out_pins[i], |
| 2737 | ev | VIA_JACK_EVENT); | 2735 | ev | VIA_JACK_EVENT, cb); |
| 2738 | } | 2736 | } |
| 2739 | 2737 | ||
| 2740 | for (i = 0; i < cfg->num_inputs; i++) { | 2738 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2741 | if (is_jack_detectable(codec, cfg->inputs[i].pin)) | 2739 | if (is_jack_detectable(codec, cfg->inputs[i].pin)) |
| 2742 | snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin, | 2740 | snd_hda_jack_detect_enable_callback(codec, cfg->inputs[i].pin, |
| 2743 | VIA_JACK_EVENT); | 2741 | VIA_JACK_EVENT, |
| 2742 | via_jack_powerstate_event); | ||
| 2744 | } | 2743 | } |
| 2745 | } | 2744 | } |
| 2746 | 2745 | ||
