Commit 054d867e authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Check power-state before changing in patch_via.c

Instead of always writing AC_VERB_SET_POWER_STATE, check the current
power-state and don't write again if the value is already set.
This may reduce the click noise upon the dynamic power-state change
(e.g. in analog-input mixer).
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 54c2a89f
...@@ -687,6 +687,15 @@ static void via_auto_init_analog_input(struct hda_codec *codec) ...@@ -687,6 +687,15 @@ static void via_auto_init_analog_input(struct hda_codec *codec)
} }
} }
static void update_power_state(struct hda_codec *codec, hda_nid_t nid,
unsigned int parm)
{
if (snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_POWER_STATE, 0) == parm)
return;
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm);
}
static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid,
unsigned int *affected_parm) unsigned int *affected_parm)
{ {
...@@ -709,7 +718,7 @@ static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, ...@@ -709,7 +718,7 @@ static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid,
} else } else
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, nid, parm);
} }
static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol, static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol,
...@@ -2295,10 +2304,7 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -2295,10 +2304,7 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
if (mux) { if (mux) {
/* switch to D0 beofre change index */ /* switch to D0 beofre change index */
if (snd_hda_codec_read(codec, mux, 0, update_power_state(codec, mux, AC_PWRST_D0);
AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0)
snd_hda_codec_write(codec, mux, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
snd_hda_codec_write(codec, mux, 0, snd_hda_codec_write(codec, mux, 0,
AC_VERB_SET_CONNECT_SEL, AC_VERB_SET_CONNECT_SEL,
spec->inputs[cur].mux_idx); spec->inputs[cur].mux_idx);
...@@ -2922,9 +2928,9 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec) ...@@ -2922,9 +2928,9 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec)
if (imux_is_smixer) if (imux_is_smixer)
parm = AC_PWRST_D0; parm = AC_PWRST_D0;
/* SW0 (17h), AIW 0/1 (13h/14h) */ /* SW0 (17h), AIW 0/1 (13h/14h) */
snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x17, parm);
snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x13, parm);
snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x14, parm);
/* outputs */ /* outputs */
/* PW0 (19h), SW1 (18h), AOW1 (11h) */ /* PW0 (19h), SW1 (18h), AOW1 (11h) */
...@@ -2932,8 +2938,8 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec) ...@@ -2932,8 +2938,8 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec)
set_pin_power_state(codec, 0x19, &parm); set_pin_power_state(codec, 0x19, &parm);
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1b, &parm); set_pin_power_state(codec, 0x1b, &parm);
snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x18, parm);
snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x11, parm);
/* PW6 (22h), SW2 (26h), AOW2 (24h) */ /* PW6 (22h), SW2 (26h), AOW2 (24h) */
if (is_8ch) { if (is_8ch) {
...@@ -2941,20 +2947,16 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec) ...@@ -2941,20 +2947,16 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec)
set_pin_power_state(codec, 0x22, &parm); set_pin_power_state(codec, 0x22, &parm);
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1a, &parm); set_pin_power_state(codec, 0x1a, &parm);
snd_hda_codec_write(codec, 0x26, 0, update_power_state(codec, 0x26, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x24, parm);
snd_hda_codec_write(codec, 0x24, 0,
AC_VERB_SET_POWER_STATE, parm);
} else if (codec->vendor_id == 0x11064397) { } else if (codec->vendor_id == 0x11064397) {
/* PW7(23h), SW2(27h), AOW2(25h) */ /* PW7(23h), SW2(27h), AOW2(25h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x23, &parm); set_pin_power_state(codec, 0x23, &parm);
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1a, &parm); set_pin_power_state(codec, 0x1a, &parm);
snd_hda_codec_write(codec, 0x27, 0, update_power_state(codec, 0x27, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x25, parm);
snd_hda_codec_write(codec, 0x25, 0,
AC_VERB_SET_POWER_STATE, parm);
} }
/* PW 3/4/7 (1ch/1dh/23h) */ /* PW 3/4/7 (1ch/1dh/23h) */
...@@ -2966,17 +2968,13 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec) ...@@ -2966,17 +2968,13 @@ static void set_widgets_power_state_vt1708B(struct hda_codec *codec)
set_pin_power_state(codec, 0x23, &parm); set_pin_power_state(codec, 0x23, &parm);
/* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */ /* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */
snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, update_power_state(codec, 0x16, imux_is_smixer ? AC_PWRST_D0 : parm);
imux_is_smixer ? AC_PWRST_D0 : parm); update_power_state(codec, 0x10, parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm);
if (is_8ch) { if (is_8ch) {
snd_hda_codec_write(codec, 0x25, 0, update_power_state(codec, 0x25, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x27, parm);
snd_hda_codec_write(codec, 0x27, 0,
AC_VERB_SET_POWER_STATE, parm);
} else if (codec->vendor_id == 0x11064397 && spec->hp_independent_mode) } else if (codec->vendor_id == 0x11064397 && spec->hp_independent_mode)
snd_hda_codec_write(codec, 0x25, 0, update_power_state(codec, 0x25, parm);
AC_VERB_SET_POWER_STATE, parm);
} }
static int patch_vt1708S(struct hda_codec *codec); static int patch_vt1708S(struct hda_codec *codec);
...@@ -3149,10 +3147,10 @@ static void set_widgets_power_state_vt1702(struct hda_codec *codec) ...@@ -3149,10 +3147,10 @@ static void set_widgets_power_state_vt1702(struct hda_codec *codec)
if (imux_is_smixer) if (imux_is_smixer)
parm = AC_PWRST_D0; /* SW0 (13h) = stereo mixer (idx 3) */ parm = AC_PWRST_D0; /* SW0 (13h) = stereo mixer (idx 3) */
/* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */ /* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */
snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x13, parm);
snd_hda_codec_write(codec, 0x12, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x12, parm);
snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1f, parm);
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x20, parm);
/* outputs */ /* outputs */
/* PW 3/4 (16h/17h) */ /* PW 3/4 (16h/17h) */
...@@ -3160,10 +3158,9 @@ static void set_widgets_power_state_vt1702(struct hda_codec *codec) ...@@ -3160,10 +3158,9 @@ static void set_widgets_power_state_vt1702(struct hda_codec *codec)
set_pin_power_state(codec, 0x17, &parm); set_pin_power_state(codec, 0x17, &parm);
set_pin_power_state(codec, 0x16, &parm); set_pin_power_state(codec, 0x16, &parm);
/* MW0 (1ah), AOW 0/1 (10h/1dh) */ /* MW0 (1ah), AOW 0/1 (10h/1dh) */
snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, update_power_state(codec, 0x1a, imux_is_smixer ? AC_PWRST_D0 : parm);
imux_is_smixer ? AC_PWRST_D0 : parm); update_power_state(codec, 0x10, parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1d, parm);
snd_hda_codec_write(codec, 0x1d, 0, AC_VERB_SET_POWER_STATE, parm);
} }
static int patch_vt1702(struct hda_codec *codec) static int patch_vt1702(struct hda_codec *codec)
...@@ -3228,52 +3225,48 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec) ...@@ -3228,52 +3225,48 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec)
if (imux_is_smixer) if (imux_is_smixer)
parm = AC_PWRST_D0; parm = AC_PWRST_D0;
/* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */ /* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */
snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1e, parm);
snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1f, parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x10, parm);
snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x11, parm);
/* outputs */ /* outputs */
/* PW3 (27h), MW2 (1ah), AOW3 (bh) */ /* PW3 (27h), MW2 (1ah), AOW3 (bh) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x27, &parm); set_pin_power_state(codec, 0x27, &parm);
snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1a, parm);
snd_hda_codec_write(codec, 0xb, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0xb, parm);
/* PW2 (26h), AOW2 (ah) */ /* PW2 (26h), AOW2 (ah) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x26, &parm); set_pin_power_state(codec, 0x26, &parm);
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x2b, &parm); set_pin_power_state(codec, 0x2b, &parm);
snd_hda_codec_write(codec, 0xa, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0xa, parm);
/* PW0 (24h), AOW0 (8h) */ /* PW0 (24h), AOW0 (8h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x24, &parm); set_pin_power_state(codec, 0x24, &parm);
if (!spec->hp_independent_mode) /* check for redirected HP */ if (!spec->hp_independent_mode) /* check for redirected HP */
set_pin_power_state(codec, 0x28, &parm); set_pin_power_state(codec, 0x28, &parm);
snd_hda_codec_write(codec, 0x8, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x8, parm);
/* MW9 (21h), Mw2 (1ah), AOW0 (8h) */ /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */
snd_hda_codec_write(codec, 0x21, 0, AC_VERB_SET_POWER_STATE, update_power_state(codec, 0x21, imux_is_smixer ? AC_PWRST_D0 : parm);
imux_is_smixer ? AC_PWRST_D0 : parm);
/* PW1 (25h), AOW1 (9h) */ /* PW1 (25h), AOW1 (9h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x25, &parm); set_pin_power_state(codec, 0x25, &parm);
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x2a, &parm); set_pin_power_state(codec, 0x2a, &parm);
snd_hda_codec_write(codec, 0x9, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x9, parm);
if (spec->hp_independent_mode) { if (spec->hp_independent_mode) {
/* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */ /* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x28, &parm); set_pin_power_state(codec, 0x28, &parm);
snd_hda_codec_write(codec, 0x1b, 0, update_power_state(codec, 0x1b, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x34, parm);
snd_hda_codec_write(codec, 0x34, 0, update_power_state(codec, 0xc, parm);
AC_VERB_SET_POWER_STATE, parm);
snd_hda_codec_write(codec, 0xc, 0,
AC_VERB_SET_POWER_STATE, parm);
} }
} }
...@@ -3433,8 +3426,8 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3433,8 +3426,8 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
if (imux_is_smixer) if (imux_is_smixer)
parm = AC_PWRST_D0; parm = AC_PWRST_D0;
/* SW0 (17h), AIW0(13h) */ /* SW0 (17h), AIW0(13h) */
snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x17, parm);
snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x13, parm);
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x1e, &parm); set_pin_power_state(codec, 0x1e, &parm);
...@@ -3442,12 +3435,11 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3442,12 +3435,11 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
if (spec->dmic_enabled) if (spec->dmic_enabled)
set_pin_power_state(codec, 0x22, &parm); set_pin_power_state(codec, 0x22, &parm);
else else
snd_hda_codec_write(codec, 0x22, 0, update_power_state(codec, 0x22, AC_PWRST_D3);
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
/* SW2(26h), AIW1(14h) */ /* SW2(26h), AIW1(14h) */
snd_hda_codec_write(codec, 0x26, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x26, parm);
snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x14, parm);
/* outputs */ /* outputs */
/* PW0 (19h), SW1 (18h), AOW1 (11h) */ /* PW0 (19h), SW1 (18h), AOW1 (11h) */
...@@ -3456,8 +3448,8 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3456,8 +3448,8 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
/* Smart 5.1 PW2(1bh) */ /* Smart 5.1 PW2(1bh) */
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1b, &parm); set_pin_power_state(codec, 0x1b, &parm);
snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x18, parm);
snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x11, parm);
/* PW7 (23h), SW3 (27h), AOW3 (25h) */ /* PW7 (23h), SW3 (27h), AOW3 (25h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
...@@ -3465,12 +3457,12 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3465,12 +3457,12 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
/* Smart 5.1 PW1(1ah) */ /* Smart 5.1 PW1(1ah) */
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1a, &parm); set_pin_power_state(codec, 0x1a, &parm);
snd_hda_codec_write(codec, 0x27, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x27, parm);
/* Smart 5.1 PW5(1eh) */ /* Smart 5.1 PW5(1eh) */
if (spec->smart51_enabled) if (spec->smart51_enabled)
set_pin_power_state(codec, 0x1e, &parm); set_pin_power_state(codec, 0x1e, &parm);
snd_hda_codec_write(codec, 0x25, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x25, parm);
/* Mono out */ /* Mono out */
/* SW4(28h)->MW1(29h)-> PW12 (2ah)*/ /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/
...@@ -3486,9 +3478,9 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3486,9 +3478,9 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
mono_out = 1; mono_out = 1;
} }
parm = mono_out ? AC_PWRST_D0 : AC_PWRST_D3; parm = mono_out ? AC_PWRST_D0 : AC_PWRST_D3;
snd_hda_codec_write(codec, 0x28, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x28, parm);
snd_hda_codec_write(codec, 0x29, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x29, parm);
snd_hda_codec_write(codec, 0x2a, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x2a, parm);
/* PW 3/4 (1ch/1dh) */ /* PW 3/4 (1ch/1dh) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
...@@ -3496,15 +3488,12 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec) ...@@ -3496,15 +3488,12 @@ static void set_widgets_power_state_vt1716S(struct hda_codec *codec)
set_pin_power_state(codec, 0x1d, &parm); set_pin_power_state(codec, 0x1d, &parm);
/* HP Independent Mode, power on AOW3 */ /* HP Independent Mode, power on AOW3 */
if (spec->hp_independent_mode) if (spec->hp_independent_mode)
snd_hda_codec_write(codec, 0x25, 0, update_power_state(codec, 0x25, parm);
AC_VERB_SET_POWER_STATE, parm);
/* force to D0 for internal Speaker */ /* force to D0 for internal Speaker */
/* MW0 (16h), AOW0 (10h) */ /* MW0 (16h), AOW0 (10h) */
snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, update_power_state(codec, 0x16, imux_is_smixer ? AC_PWRST_D0 : parm);
imux_is_smixer ? AC_PWRST_D0 : parm); update_power_state(codec, 0x10, mono_out ? AC_PWRST_D0 : parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE,
mono_out ? AC_PWRST_D0 : parm);
} }
static int patch_vt1716S(struct hda_codec *codec) static int patch_vt1716S(struct hda_codec *codec)
...@@ -3580,54 +3569,45 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec) ...@@ -3580,54 +3569,45 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec)
set_pin_power_state(codec, 0x2b, &parm); set_pin_power_state(codec, 0x2b, &parm);
parm = AC_PWRST_D0; parm = AC_PWRST_D0;
/* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */ /* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */
snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1e, parm);
snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1f, parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x10, parm);
snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x11, parm);
/* outputs */ /* outputs */
/* AOW0 (8h)*/ /* AOW0 (8h)*/
snd_hda_codec_write(codec, 0x8, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x8, parm);
if (spec->codec_type == VT1802) { if (spec->codec_type == VT1802) {
/* PW4 (28h), MW4 (18h), MUX4(38h) */ /* PW4 (28h), MW4 (18h), MUX4(38h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x28, &parm); set_pin_power_state(codec, 0x28, &parm);
snd_hda_codec_write(codec, 0x18, 0, update_power_state(codec, 0x18, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x38, parm);
snd_hda_codec_write(codec, 0x38, 0,
AC_VERB_SET_POWER_STATE, parm);
} else { } else {
/* PW4 (26h), MW4 (1ch), MUX4(37h) */ /* PW4 (26h), MW4 (1ch), MUX4(37h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x26, &parm); set_pin_power_state(codec, 0x26, &parm);
snd_hda_codec_write(codec, 0x1c, 0, update_power_state(codec, 0x1c, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x37, parm);
snd_hda_codec_write(codec, 0x37, 0,
AC_VERB_SET_POWER_STATE, parm);
} }
if (spec->codec_type == VT1802) { if (spec->codec_type == VT1802) {
/* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */ /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x25, &parm); set_pin_power_state(codec, 0x25, &parm);
snd_hda_codec_write(codec, 0x15, 0, update_power_state(codec, 0x15, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x35, parm);
snd_hda_codec_write(codec, 0x35, 0,
AC_VERB_SET_POWER_STATE, parm);
} else { } else {
/* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */ /* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x25, &parm); set_pin_power_state(codec, 0x25, &parm);
snd_hda_codec_write(codec, 0x19, 0, update_power_state(codec, 0x19, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x35, parm);
snd_hda_codec_write(codec, 0x35, 0,
AC_VERB_SET_POWER_STATE, parm);
} }
if (spec->hp_independent_mode) if (spec->hp_independent_mode)
snd_hda_codec_write(codec, 0x9, 0, update_power_state(codec, 0x9, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
/* Class-D */ /* Class-D */
/* PW0 (24h), MW0(18h/14h), MUX0(34h) */ /* PW0 (24h), MW0(18h/14h), MUX0(34h) */
...@@ -3637,12 +3617,10 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec) ...@@ -3637,12 +3617,10 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec)
set_pin_power_state(codec, 0x24, &parm); set_pin_power_state(codec, 0x24, &parm);
parm = present ? AC_PWRST_D3 : AC_PWRST_D0; parm = present ? AC_PWRST_D3 : AC_PWRST_D0;
if (spec->codec_type == VT1802) if (spec->codec_type == VT1802)
snd_hda_codec_write(codec, 0x14, 0, update_power_state(codec, 0x14, parm);
AC_VERB_SET_POWER_STATE, parm);
else else
snd_hda_codec_write(codec, 0x18, 0, update_power_state(codec, 0x18, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x34, parm);
snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_POWER_STATE, parm);
/* Mono Out */ /* Mono Out */
present = snd_hda_jack_detect(codec, 0x26); present = snd_hda_jack_detect(codec, 0x26);
...@@ -3650,28 +3628,20 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec) ...@@ -3650,28 +3628,20 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec)
parm = present ? AC_PWRST_D3 : AC_PWRST_D0; parm = present ? AC_PWRST_D3 : AC_PWRST_D0;
if (spec->codec_type == VT1802) { if (spec->codec_type == VT1802) {
/* PW15 (33h), MW8(1ch), MUX8(3ch) */ /* PW15 (33h), MW8(1ch), MUX8(3ch) */
snd_hda_codec_write(codec, 0x33, 0, update_power_state(codec, 0x33, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1c, parm);
snd_hda_codec_write(codec, 0x1c, 0, update_power_state(codec, 0x3c, parm);
AC_VERB_SET_POWER_STATE, parm);
snd_hda_codec_write(codec, 0x3c, 0,
AC_VERB_SET_POWER_STATE, parm);
} else { } else {
/* PW15 (31h), MW8(17h), MUX8(3bh) */ /* PW15 (31h), MW8(17h), MUX8(3bh) */
snd_hda_codec_write(codec, 0x31, 0, update_power_state(codec, 0x31, parm);
AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x17, parm);
snd_hda_codec_write(codec, 0x17, 0, update_power_state(codec, 0x3b, parm);
AC_VERB_SET_POWER_STATE, parm);
snd_hda_codec_write(codec, 0x3b, 0,
AC_VERB_SET_POWER_STATE, parm);
} }
/* MW9 (21h) */ /* MW9 (21h) */
if (imux_is_smixer || !is_aa_path_mute(codec)) if (imux_is_smixer || !is_aa_path_mute(codec))
snd_hda_codec_write(codec, 0x21, 0, update_power_state(codec, 0x21, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
else else
snd_hda_codec_write(codec, 0x21, 0, update_power_state(codec, 0x21, AC_PWRST_D3);
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
} }
/* patch for vt2002P */ /* patch for vt2002P */
...@@ -3731,30 +3701,28 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec) ...@@ -3731,30 +3701,28 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec)
set_pin_power_state(codec, 0x2b, &parm); set_pin_power_state(codec, 0x2b, &parm);
parm = AC_PWRST_D0; parm = AC_PWRST_D0;
/* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */ /* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */
snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1e, parm);
snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1f, parm);
snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x10, parm);
snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x11, parm);
/* outputs */ /* outputs */
/* AOW0 (8h)*/ /* AOW0 (8h)*/
snd_hda_codec_write(codec, 0x8, 0, update_power_state(codec, 0x8, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
/* PW4 (28h), MW4 (18h), MUX4(38h) */ /* PW4 (28h), MW4 (18h), MUX4(38h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x28, &parm); set_pin_power_state(codec, 0x28, &parm);
snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x18, parm);
snd_hda_codec_write(codec, 0x38, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x38, parm);
/* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */ /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x25, &parm); set_pin_power_state(codec, 0x25, &parm);
snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x15, parm);
snd_hda_codec_write(codec, 0x35, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x35, parm);
if (spec->hp_independent_mode) if (spec->hp_independent_mode)
snd_hda_codec_write(codec, 0x9, 0, update_power_state(codec, 0x9, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
/* Internal Speaker */ /* Internal Speaker */
/* PW0 (24h), MW0(14h), MUX0(34h) */ /* PW0 (24h), MW0(14h), MUX0(34h) */
...@@ -3763,15 +3731,11 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec) ...@@ -3763,15 +3731,11 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec)
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x24, &parm); set_pin_power_state(codec, 0x24, &parm);
if (present) { if (present) {
snd_hda_codec_write(codec, 0x14, 0, update_power_state(codec, 0x14, AC_PWRST_D3);
AC_VERB_SET_POWER_STATE, AC_PWRST_D3); update_power_state(codec, 0x34, AC_PWRST_D3);
snd_hda_codec_write(codec, 0x34, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
} else { } else {
snd_hda_codec_write(codec, 0x14, 0, update_power_state(codec, 0x14, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0); update_power_state(codec, 0x34, AC_PWRST_D0);
snd_hda_codec_write(codec, 0x34, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
} }
...@@ -3782,26 +3746,20 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec) ...@@ -3782,26 +3746,20 @@ static void set_widgets_power_state_vt1812(struct hda_codec *codec)
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x31, &parm); set_pin_power_state(codec, 0x31, &parm);
if (present) { if (present) {
snd_hda_codec_write(codec, 0x1c, 0, update_power_state(codec, 0x1c, AC_PWRST_D3);
AC_VERB_SET_POWER_STATE, AC_PWRST_D3); update_power_state(codec, 0x3c, AC_PWRST_D3);
snd_hda_codec_write(codec, 0x3c, 0, update_power_state(codec, 0x3e, AC_PWRST_D3);
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
snd_hda_codec_write(codec, 0x3e, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
} else { } else {
snd_hda_codec_write(codec, 0x1c, 0, update_power_state(codec, 0x1c, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0); update_power_state(codec, 0x3c, AC_PWRST_D0);
snd_hda_codec_write(codec, 0x3c, 0, update_power_state(codec, 0x3e, AC_PWRST_D0);
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
snd_hda_codec_write(codec, 0x3e, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
} }
/* PW15 (33h), MW15 (1dh), MUX15(3dh) */ /* PW15 (33h), MW15 (1dh), MUX15(3dh) */
parm = AC_PWRST_D3; parm = AC_PWRST_D3;
set_pin_power_state(codec, 0x33, &parm); set_pin_power_state(codec, 0x33, &parm);
snd_hda_codec_write(codec, 0x1d, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x1d, parm);
snd_hda_codec_write(codec, 0x3d, 0, AC_VERB_SET_POWER_STATE, parm); update_power_state(codec, 0x3d, parm);
} }
......
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