diff options
author | Daniel T Chen <crimsun@ubuntu.com> | 2009-12-27 18:52:08 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-28 06:15:47 -0500 |
commit | c97259df3f2e163c72f4d0685c61fb2e026dc989 (patch) | |
tree | 7b491c760b404724c3a6f37b247a428f89ca8323 /sound | |
parent | ea52bf260ecbb175339af3178c15788df21b7516 (diff) |
ALSA: hda: Refactor powerdown for Realtek HDA codecs
This patch converts the alc889 Aspire-specific powerdown to a generic
one. Like the previous effort, it currently only handles Front and PCM
but can be easily extended to cover other nids. The existing hook for
alc889 Aspire-specific remains enabled. Upon further testing, I've added
its use for ALC861_AUTO as well. Following patches will enable them for
other quirks.
Tested-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Daniel T Chen <crimsun@ubuntu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cd6d139b4fd5..141ff446104a 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -338,7 +338,7 @@ struct alc_spec { | |||
338 | void (*init_hook)(struct hda_codec *codec); | 338 | void (*init_hook)(struct hda_codec *codec); |
339 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | 339 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
340 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 340 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
341 | void (*power_hook)(struct hda_codec *codec, int power); | 341 | void (*power_hook)(struct hda_codec *codec); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | /* for pin sensing */ | 344 | /* for pin sensing */ |
@@ -391,7 +391,7 @@ struct alc_config_preset { | |||
391 | void (*init_hook)(struct hda_codec *); | 391 | void (*init_hook)(struct hda_codec *); |
392 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 392 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
393 | struct hda_amp_list *loopbacks; | 393 | struct hda_amp_list *loopbacks; |
394 | void (*power_hook)(struct hda_codec *codec, int power); | 394 | void (*power_hook)(struct hda_codec *codec); |
395 | #endif | 395 | #endif |
396 | }; | 396 | }; |
397 | 397 | ||
@@ -1835,16 +1835,6 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) | |||
1835 | spec->autocfg.speaker_pins[2] = 0x1b; | 1835 | spec->autocfg.speaker_pins[2] = 0x1b; |
1836 | } | 1836 | } |
1837 | 1837 | ||
1838 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
1839 | static void alc889_power_eapd(struct hda_codec *codec, int power) | ||
1840 | { | ||
1841 | snd_hda_codec_write(codec, 0x14, 0, | ||
1842 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1843 | snd_hda_codec_write(codec, 0x15, 0, | ||
1844 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1845 | } | ||
1846 | #endif | ||
1847 | |||
1848 | /* | 1838 | /* |
1849 | * ALC880 3-stack model | 1839 | * ALC880 3-stack model |
1850 | * | 1840 | * |
@@ -3725,12 +3715,40 @@ static void alc_free(struct hda_codec *codec) | |||
3725 | } | 3715 | } |
3726 | 3716 | ||
3727 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3717 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3718 | static void alc_power_eapd(struct hda_codec *codec) | ||
3719 | { | ||
3720 | /* We currently only handle front, HP */ | ||
3721 | switch (codec->vendor_id) { | ||
3722 | case 0x10ec0260: | ||
3723 | snd_hda_codec_write(codec, 0x0f, 0, | ||
3724 | AC_VERB_SET_EAPD_BTLENABLE, 0x00); | ||
3725 | snd_hda_codec_write(codec, 0x10, 0, | ||
3726 | AC_VERB_SET_EAPD_BTLENABLE, 0x00); | ||
3727 | break; | ||
3728 | case 0x10ec0262: | ||
3729 | case 0x10ec0267: | ||
3730 | case 0x10ec0268: | ||
3731 | case 0x10ec0269: | ||
3732 | case 0x10ec0272: | ||
3733 | case 0x10ec0660: | ||
3734 | case 0x10ec0662: | ||
3735 | case 0x10ec0663: | ||
3736 | case 0x10ec0862: | ||
3737 | case 0x10ec0889: | ||
3738 | snd_hda_codec_write(codec, 0x14, 0, | ||
3739 | AC_VERB_SET_EAPD_BTLENABLE, 0x00); | ||
3740 | snd_hda_codec_write(codec, 0x15, 0, | ||
3741 | AC_VERB_SET_EAPD_BTLENABLE, 0x00); | ||
3742 | break; | ||
3743 | } | ||
3744 | } | ||
3745 | |||
3728 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) | 3746 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
3729 | { | 3747 | { |
3730 | struct alc_spec *spec = codec->spec; | 3748 | struct alc_spec *spec = codec->spec; |
3731 | alc_shutup(codec); | 3749 | alc_shutup(codec); |
3732 | if (spec && spec->power_hook) | 3750 | if (spec && spec->power_hook) |
3733 | spec->power_hook(codec, 0); | 3751 | spec->power_hook(codec); |
3734 | return 0; | 3752 | return 0; |
3735 | } | 3753 | } |
3736 | #endif | 3754 | #endif |
@@ -3738,16 +3756,9 @@ static int alc_suspend(struct hda_codec *codec, pm_message_t state) | |||
3738 | #ifdef SND_HDA_NEEDS_RESUME | 3756 | #ifdef SND_HDA_NEEDS_RESUME |
3739 | static int alc_resume(struct hda_codec *codec) | 3757 | static int alc_resume(struct hda_codec *codec) |
3740 | { | 3758 | { |
3741 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3742 | struct alc_spec *spec = codec->spec; | ||
3743 | #endif | ||
3744 | codec->patch_ops.init(codec); | 3759 | codec->patch_ops.init(codec); |
3745 | snd_hda_codec_resume_amp(codec); | 3760 | snd_hda_codec_resume_amp(codec); |
3746 | snd_hda_codec_resume_cache(codec); | 3761 | snd_hda_codec_resume_cache(codec); |
3747 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3748 | if (spec && spec->power_hook) | ||
3749 | spec->power_hook(codec, 1); | ||
3750 | #endif | ||
3751 | return 0; | 3762 | return 0; |
3752 | } | 3763 | } |
3753 | #endif | 3764 | #endif |
@@ -3767,6 +3778,7 @@ static struct hda_codec_ops alc_patch_ops = { | |||
3767 | .suspend = alc_suspend, | 3778 | .suspend = alc_suspend, |
3768 | .check_power_status = alc_check_power_status, | 3779 | .check_power_status = alc_check_power_status, |
3769 | #endif | 3780 | #endif |
3781 | .reboot_notify = alc_shutup, | ||
3770 | }; | 3782 | }; |
3771 | 3783 | ||
3772 | 3784 | ||
@@ -9547,7 +9559,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9547 | .setup = alc889_acer_aspire_8930g_setup, | 9559 | .setup = alc889_acer_aspire_8930g_setup, |
9548 | .init_hook = alc_automute_amp, | 9560 | .init_hook = alc_automute_amp, |
9549 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 9561 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9550 | .power_hook = alc889_power_eapd, | 9562 | .power_hook = alc_power_eapd, |
9551 | #endif | 9563 | #endif |
9552 | }, | 9564 | }, |
9553 | [ALC888_ACER_ASPIRE_7730G] = { | 9565 | [ALC888_ACER_ASPIRE_7730G] = { |
@@ -14984,9 +14996,13 @@ static int patch_alc861(struct hda_codec *codec) | |||
14984 | spec->vmaster_nid = 0x03; | 14996 | spec->vmaster_nid = 0x03; |
14985 | 14997 | ||
14986 | codec->patch_ops = alc_patch_ops; | 14998 | codec->patch_ops = alc_patch_ops; |
14987 | if (board_config == ALC861_AUTO) | 14999 | if (board_config == ALC861_AUTO) { |
14988 | spec->init_hook = alc861_auto_init; | 15000 | spec->init_hook = alc861_auto_init; |
14989 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 15001 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15002 | spec->power_hook = alc_power_eapd; | ||
15003 | #endif | ||
15004 | } | ||
15005 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
14990 | if (!spec->loopback.amplist) | 15006 | if (!spec->loopback.amplist) |
14991 | spec->loopback.amplist = alc861_loopbacks; | 15007 | spec->loopback.amplist = alc861_loopbacks; |
14992 | #endif | 15008 | #endif |