Commit 0ec33d1f authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarTakashi Iwai <tiwai@suse.de>
parent f3550d1b
...@@ -4128,10 +4128,8 @@ static int alc_resume(struct hda_codec *codec) ...@@ -4128,10 +4128,8 @@ static int alc_resume(struct hda_codec *codec)
codec->patch_ops.init(codec); codec->patch_ops.init(codec);
snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_amp(codec);
snd_hda_codec_resume_cache(codec); snd_hda_codec_resume_cache(codec);
#ifdef CONFIG_SND_HDA_POWER_SAVE
if (codec->patch_ops.check_power_status) if (codec->patch_ops.check_power_status)
codec->patch_ops.check_power_status(codec, 0x01); codec->patch_ops.check_power_status(codec, 0x01);
#endif
return 0; return 0;
} }
#endif #endif
...@@ -14656,22 +14654,26 @@ static void alc269_auto_init(struct hda_codec *codec) ...@@ -14656,22 +14654,26 @@ static void alc269_auto_init(struct hda_codec *codec)
alc_inithook(codec); alc_inithook(codec);
} }
#ifdef SND_HDA_NEEDS_RESUME
static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
{
int val = alc_read_coef_idx(codec, 0x04);
if (power_up)
val |= 1 << 11;
else
val &= ~(1 << 11);
alc_write_coef_idx(codec, 0x04, val);
}
#ifdef CONFIG_SND_HDA_POWER_SAVE #ifdef CONFIG_SND_HDA_POWER_SAVE
static int alc269_suspend(struct hda_codec *codec, pm_message_t state) static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
int val;
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
val = alc_read_coef_idx(codec, 0x04);
/* Power down output pin */
alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
}
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
alc269_toggle_power_output(codec, 0);
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
val = alc_read_coef_idx(codec, 0x04); alc269_toggle_power_output(codec, 0);
/* Power down output pin */
alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
msleep(150); msleep(150);
} }
...@@ -14680,43 +14682,32 @@ static int alc269_suspend(struct hda_codec *codec, pm_message_t state) ...@@ -14680,43 +14682,32 @@ static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
spec->power_hook(codec); spec->power_hook(codec);
return 0; return 0;
} }
#endif #endif /* CONFIG_SND_HDA_POWER_SAVE */
#ifdef SND_HDA_NEEDS_RESUME
static int alc269_resume(struct hda_codec *codec) static int alc269_resume(struct hda_codec *codec)
{ {
int val;
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
val = alc_read_coef_idx(codec, 0x04); alc269_toggle_power_output(codec, 0);
/* Power down output pin */
alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
msleep(150); msleep(150);
} }
codec->patch_ops.init(codec); codec->patch_ops.init(codec);
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
val = alc_read_coef_idx(codec, 0x04); alc269_toggle_power_output(codec, 1);
/* Power up output pin */
alc_write_coef_idx(codec, 0x04, val | (1<<11));
msleep(200); msleep(200);
} }
if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
val = alc_read_coef_idx(codec, 0x04); alc269_toggle_power_output(codec, 1);
/* Power up output pin */
alc_write_coef_idx(codec, 0x04, val | (1<<11));
}
snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_amp(codec);
snd_hda_codec_resume_cache(codec); snd_hda_codec_resume_cache(codec);
#ifdef CONFIG_SND_HDA_POWER_SAVE
if (codec->patch_ops.check_power_status) if (codec->patch_ops.check_power_status)
codec->patch_ops.check_power_status(codec, 0x01); codec->patch_ops.check_power_status(codec, 0x01);
#endif
return 0; return 0;
} }
#endif #endif /* SND_HDA_NEEDS_RESUME */
enum { enum {
ALC269_FIXUP_SONY_VAIO, ALC269_FIXUP_SONY_VAIO,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment