Skip to content

Commit 4a219ef

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Add ALC256 HP depop function
Add this functions, it could support ALC256 for HP depop functions. It also can solve some ALC256 machine plug headset cause power off issue. Signed-off-by: Kailang Yang <kailang@realtek.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 15b5ef4 commit 4a219ef

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,6 +3062,74 @@ static void alc283_shutup(struct hda_codec *codec)
30623062
alc_write_coef_idx(codec, 0x43, 0x9614);
30633063
}
30643064

3065+
static void alc256_init(struct hda_codec *codec)
3066+
{
3067+
struct alc_spec *spec = codec->spec;
3068+
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3069+
bool hp_pin_sense;
3070+
3071+
if (!hp_pin)
3072+
return;
3073+
3074+
msleep(30);
3075+
3076+
hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3077+
3078+
if (hp_pin_sense)
3079+
msleep(2);
3080+
3081+
alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3082+
3083+
snd_hda_codec_write(codec, hp_pin, 0,
3084+
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3085+
3086+
if (hp_pin_sense)
3087+
msleep(85);
3088+
3089+
snd_hda_codec_write(codec, hp_pin, 0,
3090+
AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3091+
3092+
if (hp_pin_sense)
3093+
msleep(100);
3094+
3095+
alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3096+
alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3097+
}
3098+
3099+
static void alc256_shutup(struct hda_codec *codec)
3100+
{
3101+
struct alc_spec *spec = codec->spec;
3102+
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3103+
bool hp_pin_sense;
3104+
3105+
if (!hp_pin) {
3106+
alc269_shutup(codec);
3107+
return;
3108+
}
3109+
3110+
hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3111+
3112+
if (hp_pin_sense)
3113+
msleep(2);
3114+
3115+
snd_hda_codec_write(codec, hp_pin, 0,
3116+
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3117+
3118+
if (hp_pin_sense)
3119+
msleep(85);
3120+
3121+
snd_hda_codec_write(codec, hp_pin, 0,
3122+
AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3123+
3124+
alc_update_coef_idx(codec, 0x46, 0, 3 << 12); /* 3k pull low control for Headset jack. */
3125+
3126+
if (hp_pin_sense)
3127+
msleep(100);
3128+
3129+
alc_auto_setup_eapd(codec, false);
3130+
snd_hda_shutup_pins(codec);
3131+
}
3132+
30653133
static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
30663134
unsigned int val)
30673135
{
@@ -6483,6 +6551,8 @@ static int patch_alc269(struct hda_codec *codec)
64836551
break;
64846552
case 0x10ec0256:
64856553
spec->codec_variant = ALC269_TYPE_ALC256;
6554+
spec->shutup = alc256_shutup;
6555+
spec->init_hook = alc256_init;
64866556
spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
64876557
alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
64886558
break;

0 commit comments

Comments
 (0)