Skip to content

Commit 693abe1

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Fixed hp_pin no value
Fix hp_pin always no value. [More notes on the changes: The hp_pin value that is referred in alc294_hp_init() is always zero at the moment the function gets called, hence this is actually useless as in the current code. And, this kind of init sequence should be called from the codec init callback, instead of the parser function. So, the first fix in this patch to move the call call into its own init_hook. OTOH, this function is needed to be called only once after the boot, and it'd take too long for invoking at each resume (where the init callback gets called). So we add a new flag and invoke this only once as an additional fix. The one case is still not covered, though: S4 resume. But this change itself won't lead to any regression in that regard, so we leave S4 issue as is for now and fix it later. -- tiwai ] Fixes: bde1a74 ("ALSA: hda/realtek - Fixed headphone issue for ALC700") Signed-off-by: Kailang Yang <kailang@realtek.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent e190161 commit 693abe1

File tree

1 file changed

+45
-33
lines changed

1 file changed

+45
-33
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct alc_spec {
117117
int codec_variant; /* flag for other variants */
118118
unsigned int has_alc5505_dsp:1;
119119
unsigned int no_depop_delay:1;
120+
unsigned int done_hp_init:1;
120121

121122
/* for PLL fix */
122123
hda_nid_t pll_nid;
@@ -3372,6 +3373,48 @@ static void alc_default_shutup(struct hda_codec *codec)
33723373
snd_hda_shutup_pins(codec);
33733374
}
33743375

3376+
static void alc294_hp_init(struct hda_codec *codec)
3377+
{
3378+
struct alc_spec *spec = codec->spec;
3379+
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3380+
int i, val;
3381+
3382+
if (!hp_pin)
3383+
return;
3384+
3385+
snd_hda_codec_write(codec, hp_pin, 0,
3386+
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3387+
3388+
msleep(100);
3389+
3390+
snd_hda_codec_write(codec, hp_pin, 0,
3391+
AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3392+
3393+
alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3394+
alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3395+
3396+
/* Wait for depop procedure finish */
3397+
val = alc_read_coefex_idx(codec, 0x58, 0x01);
3398+
for (i = 0; i < 20 && val & 0x0080; i++) {
3399+
msleep(50);
3400+
val = alc_read_coefex_idx(codec, 0x58, 0x01);
3401+
}
3402+
/* Set HP depop to auto mode */
3403+
alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3404+
msleep(50);
3405+
}
3406+
3407+
static void alc294_init(struct hda_codec *codec)
3408+
{
3409+
struct alc_spec *spec = codec->spec;
3410+
3411+
if (!spec->done_hp_init) {
3412+
alc294_hp_init(codec);
3413+
spec->done_hp_init = true;
3414+
}
3415+
alc_default_init(codec);
3416+
}
3417+
33753418
static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
33763419
unsigned int val)
33773420
{
@@ -7373,37 +7416,6 @@ static void alc269_fill_coef(struct hda_codec *codec)
73737416
alc_update_coef_idx(codec, 0x4, 0, 1<<11);
73747417
}
73757418

7376-
static void alc294_hp_init(struct hda_codec *codec)
7377-
{
7378-
struct alc_spec *spec = codec->spec;
7379-
hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
7380-
int i, val;
7381-
7382-
if (!hp_pin)
7383-
return;
7384-
7385-
snd_hda_codec_write(codec, hp_pin, 0,
7386-
AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
7387-
7388-
msleep(100);
7389-
7390-
snd_hda_codec_write(codec, hp_pin, 0,
7391-
AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
7392-
7393-
alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
7394-
alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
7395-
7396-
/* Wait for depop procedure finish */
7397-
val = alc_read_coefex_idx(codec, 0x58, 0x01);
7398-
for (i = 0; i < 20 && val & 0x0080; i++) {
7399-
msleep(50);
7400-
val = alc_read_coefex_idx(codec, 0x58, 0x01);
7401-
}
7402-
/* Set HP depop to auto mode */
7403-
alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
7404-
msleep(50);
7405-
}
7406-
74077419
/*
74087420
*/
74097421
static int patch_alc269(struct hda_codec *codec)
@@ -7529,7 +7541,7 @@ static int patch_alc269(struct hda_codec *codec)
75297541
spec->codec_variant = ALC269_TYPE_ALC294;
75307542
spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
75317543
alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
7532-
alc294_hp_init(codec);
7544+
spec->init_hook = alc294_init;
75337545
break;
75347546
case 0x10ec0300:
75357547
spec->codec_variant = ALC269_TYPE_ALC300;
@@ -7541,7 +7553,7 @@ static int patch_alc269(struct hda_codec *codec)
75417553
spec->codec_variant = ALC269_TYPE_ALC700;
75427554
spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
75437555
alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
7544-
alc294_hp_init(codec);
7556+
spec->init_hook = alc294_init;
75457557
break;
75467558

75477559
}

0 commit comments

Comments
 (0)