aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-09-20 09:20:52 -0400
committerTakashi Iwai <tiwai@suse.de>2010-09-20 09:36:07 -0400
commit0ec33d1f952934ea3251cefc6d108b47818eedd0 (patch)
tree78a8ba489440e192f40fcfd7d7ea8f5885f1650d /sound/pci/hda/patch_realtek.c
parentf3550d1b052a8acf4159b407dbdd1def47f223f9 (diff)
ALSA: hda - Refactor ALC269 power-ups/downs in PM callbacks
Create a helper function to simplify the code. Also, cleaned up the ifdef SND_HDA_NEEDS_RESUME and CONFIG_SND_HDA_POWER_SAVE. The former is always defined when the latter is set. 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.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 4abe3da1240c..8689216fdcce 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4128,10 +4128,8 @@ static int alc_resume(struct hda_codec *codec)
4128 codec->patch_ops.init(codec); 4128 codec->patch_ops.init(codec);
4129 snd_hda_codec_resume_amp(codec); 4129 snd_hda_codec_resume_amp(codec);
4130 snd_hda_codec_resume_cache(codec); 4130 snd_hda_codec_resume_cache(codec);
4131#ifdef CONFIG_SND_HDA_POWER_SAVE
4132 if (codec->patch_ops.check_power_status) 4131 if (codec->patch_ops.check_power_status)
4133 codec->patch_ops.check_power_status(codec, 0x01); 4132 codec->patch_ops.check_power_status(codec, 0x01);
4134#endif
4135 return 0; 4133 return 0;
4136} 4134}
4137#endif 4135#endif
@@ -14656,22 +14654,26 @@ static void alc269_auto_init(struct hda_codec *codec)
14656 alc_inithook(codec); 14654 alc_inithook(codec);
14657} 14655}
14658 14656
14657#ifdef SND_HDA_NEEDS_RESUME
14658static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14659{
14660 int val = alc_read_coef_idx(codec, 0x04);
14661 if (power_up)
14662 val |= 1 << 11;
14663 else
14664 val &= ~(1 << 11);
14665 alc_write_coef_idx(codec, 0x04, val);
14666}
14667
14659#ifdef CONFIG_SND_HDA_POWER_SAVE 14668#ifdef CONFIG_SND_HDA_POWER_SAVE
14660static int alc269_suspend(struct hda_codec *codec, pm_message_t state) 14669static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14661{ 14670{
14662 struct alc_spec *spec = codec->spec; 14671 struct alc_spec *spec = codec->spec;
14663 int val;
14664
14665 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14666 val = alc_read_coef_idx(codec, 0x04);
14667 /* Power down output pin */
14668 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14669 }
14670 14672
14673 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14674 alc269_toggle_power_output(codec, 0);
14671 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14675 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14672 val = alc_read_coef_idx(codec, 0x04); 14676 alc269_toggle_power_output(codec, 0);
14673 /* Power down output pin */
14674 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14675 msleep(150); 14677 msleep(150);
14676 } 14678 }
14677 14679
@@ -14680,43 +14682,32 @@ static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14680 spec->power_hook(codec); 14682 spec->power_hook(codec);
14681 return 0; 14683 return 0;
14682} 14684}
14683#endif 14685#endif /* CONFIG_SND_HDA_POWER_SAVE */
14684#ifdef SND_HDA_NEEDS_RESUME 14686
14685static int alc269_resume(struct hda_codec *codec) 14687static int alc269_resume(struct hda_codec *codec)
14686{ 14688{
14687 int val;
14688
14689 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14689 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14690 val = alc_read_coef_idx(codec, 0x04); 14690 alc269_toggle_power_output(codec, 0);
14691 /* Power down output pin */
14692 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14693 msleep(150); 14691 msleep(150);
14694 } 14692 }
14695 14693
14696 codec->patch_ops.init(codec); 14694 codec->patch_ops.init(codec);
14697 14695
14698 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { 14696 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14699 val = alc_read_coef_idx(codec, 0x04); 14697 alc269_toggle_power_output(codec, 1);
14700 /* Power up output pin */
14701 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14702 msleep(200); 14698 msleep(200);
14703 } 14699 }
14704 14700
14705 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14701 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14706 val = alc_read_coef_idx(codec, 0x04); 14702 alc269_toggle_power_output(codec, 1);
14707 /* Power up output pin */
14708 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14709 }
14710 14703
14711 snd_hda_codec_resume_amp(codec); 14704 snd_hda_codec_resume_amp(codec);
14712 snd_hda_codec_resume_cache(codec); 14705 snd_hda_codec_resume_cache(codec);
14713#ifdef CONFIG_SND_HDA_POWER_SAVE
14714 if (codec->patch_ops.check_power_status) 14706 if (codec->patch_ops.check_power_status)
14715 codec->patch_ops.check_power_status(codec, 0x01); 14707 codec->patch_ops.check_power_status(codec, 0x01);
14716#endif
14717 return 0; 14708 return 0;
14718} 14709}
14719#endif 14710#endif /* SND_HDA_NEEDS_RESUME */
14720 14711
14721enum { 14712enum {
14722 ALC269_FIXUP_SONY_VAIO, 14713 ALC269_FIXUP_SONY_VAIO,