Skip to content

Commit

Permalink
ALSA: hda/realtek - Add ALC256 HP depop function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kailangyang authored and tiwai committed Jun 16, 2017
1 parent 15b5ef4 commit 4a219ef
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,74 @@ static void alc283_shutup(struct hda_codec *codec)
alc_write_coef_idx(codec, 0x43, 0x9614);
}

static void alc256_init(struct hda_codec *codec)
{
struct alc_spec *spec = codec->spec;
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
bool hp_pin_sense;

if (!hp_pin)
return;

msleep(30);

hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);

if (hp_pin_sense)
msleep(2);

alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */

snd_hda_codec_write(codec, hp_pin, 0,
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);

if (hp_pin_sense)
msleep(85);

snd_hda_codec_write(codec, hp_pin, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);

if (hp_pin_sense)
msleep(100);

alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
}

static void alc256_shutup(struct hda_codec *codec)
{
struct alc_spec *spec = codec->spec;
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
bool hp_pin_sense;

if (!hp_pin) {
alc269_shutup(codec);
return;
}

hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);

if (hp_pin_sense)
msleep(2);

snd_hda_codec_write(codec, hp_pin, 0,
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);

if (hp_pin_sense)
msleep(85);

snd_hda_codec_write(codec, hp_pin, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);

alc_update_coef_idx(codec, 0x46, 0, 3 << 12); /* 3k pull low control for Headset jack. */

if (hp_pin_sense)
msleep(100);

alc_auto_setup_eapd(codec, false);
snd_hda_shutup_pins(codec);
}

static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
unsigned int val)
{
Expand Down Expand Up @@ -6483,6 +6551,8 @@ static int patch_alc269(struct hda_codec *codec)
break;
case 0x10ec0256:
spec->codec_variant = ALC269_TYPE_ALC256;
spec->shutup = alc256_shutup;
spec->init_hook = alc256_init;
spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
break;
Expand Down

0 comments on commit 4a219ef

Please sign in to comment.