linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887
@ 2020-10-06  7:53 Jian-Hong Pan
  2020-10-06 12:24 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Jian-Hong Pan @ 2020-10-06  7:53 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Kailang Yang, alsa-devel, linux-kernel, linux, Jian-Hong Pan

The ASUS D700SA desktop's audio (1043:2390) with ALC887 cannot detect
the headset microphone and another headphone jack until
ALC887_FIXUP_ASUS_HMIC and ALC887_FIXUP_ASUS_AUDIO quirks are applied.
The NID 0x15 maps as the headset microphone and NID 0x19 maps as another
headphone jack. Also need the function like alc887_fixup_asus_jack to
enable the audio jacks.

Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
Signed-off-by: Kailang Yang <kailang@realtek.com>
---
 sound/pci/hda/patch_realtek.c | 41 +++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d4f17b465892..8d0928bdc9ff 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1929,6 +1929,8 @@ enum {
 	ALC1220_FIXUP_CLEVO_P950,
 	ALC1220_FIXUP_CLEVO_PB51ED,
 	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
+	ALC887_FIXUP_ASUS_AUDIO,
+	ALC887_FIXUP_ASUS_HMIC,
 };
 
 static void alc889_fixup_coef(struct hda_codec *codec,
@@ -2141,6 +2143,30 @@ static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
 }
 
+static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
+					 struct hda_jack_callback *jack)
+{
+	struct alc_spec *spec = codec->spec;
+	int vref;
+
+	snd_hda_gen_hp_automute(codec, jack);
+
+	vref = spec->gen.hp_jack_present ? 0xc4 : 0xc0;
+	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+			    vref);
+}
+
+static void alc887_fixup_asus_jack(struct hda_codec *codec,
+				     const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+	if (action != HDA_FIXUP_ACT_PROBE)
+		return;
+	snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+			    0xc0);
+	spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
+}
+
 static const struct hda_fixup alc882_fixups[] = {
 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
 		.type = HDA_FIXUP_PINS,
@@ -2398,6 +2424,20 @@ static const struct hda_fixup alc882_fixups[] = {
 		.chained = true,
 		.chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
 	},
+	[ALC887_FIXUP_ASUS_AUDIO] = {
+		.type = HDA_FIXUP_PINS,
+		.v.pins = (const struct hda_pintbl[]) {
+			{ 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
+			{ 0x19, 0x22219420 },
+			{}
+		},
+	},
+	[ALC887_FIXUP_ASUS_HMIC] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc887_fixup_asus_jack,
+		.chained = true,
+		.chain_id = ALC887_FIXUP_ASUS_AUDIO,
+	},
 };
 
 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
@@ -2431,6 +2471,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
+	SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887
  2020-10-06  7:53 [PATCH] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887 Jian-Hong Pan
@ 2020-10-06 12:24 ` Takashi Iwai
  2020-10-07  5:22   ` [PATCH v2] " Jian-Hong Pan
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2020-10-06 12:24 UTC (permalink / raw)
  To: Jian-Hong Pan; +Cc: Takashi Iwai, Kailang Yang, alsa-devel, linux-kernel, linux

On Tue, 06 Oct 2020 09:53:35 +0200,
Jian-Hong Pan wrote:
> 
> The ASUS D700SA desktop's audio (1043:2390) with ALC887 cannot detect
> the headset microphone and another headphone jack until
> ALC887_FIXUP_ASUS_HMIC and ALC887_FIXUP_ASUS_AUDIO quirks are applied.
> The NID 0x15 maps as the headset microphone and NID 0x19 maps as another
> headphone jack. Also need the function like alc887_fixup_asus_jack to
> enable the audio jacks.
> 
> Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
> Signed-off-by: Kailang Yang <kailang@realtek.com>
> ---
>  sound/pci/hda/patch_realtek.c | 41 +++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index d4f17b465892..8d0928bdc9ff 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -1929,6 +1929,8 @@ enum {
>  	ALC1220_FIXUP_CLEVO_P950,
>  	ALC1220_FIXUP_CLEVO_PB51ED,
>  	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
> +	ALC887_FIXUP_ASUS_AUDIO,
> +	ALC887_FIXUP_ASUS_HMIC,
>  };
>  
>  static void alc889_fixup_coef(struct hda_codec *codec,
> @@ -2141,6 +2143,30 @@ static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
>  	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
>  }
>  
> +static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
> +					 struct hda_jack_callback *jack)
> +{
> +	struct alc_spec *spec = codec->spec;
> +	int vref;
> +
> +	snd_hda_gen_hp_automute(codec, jack);
> +
> +	vref = spec->gen.hp_jack_present ? 0xc4 : 0xc0;

Use the AC_PINCTL_* instead of the raw numbers.  Some values are
shortened form in hda_local.h, too (e.g. 0xc0 = PIN_HP).


> +	snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
> +			    vref);

Better to use snd_hda_set_pin_ctl().

> +}
> +
> +static void alc887_fixup_asus_jack(struct hda_codec *codec,
> +				     const struct hda_fixup *fix, int action)
> +{
> +	struct alc_spec *spec = codec->spec;
> +	if (action != HDA_FIXUP_ACT_PROBE)
> +		return;
> +	snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
> +			    0xc0);

This one would be snd_hda_set_pin_ctl_cached(), so that it'll be
restored at resume.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887
  2020-10-06 12:24 ` Takashi Iwai
@ 2020-10-07  5:22   ` Jian-Hong Pan
  2020-10-07 15:31     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Jian-Hong Pan @ 2020-10-07  5:22 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Kailang Yang, alsa-devel, linux-kernel, linux, Jian-Hong Pan

The ASUS D700SA desktop's audio (1043:2390) with ALC887 cannot detect
the headset microphone and another headphone jack until
ALC887_FIXUP_ASUS_HMIC and ALC887_FIXUP_ASUS_AUDIO quirks are applied.
The NID 0x15 maps as the headset microphone and NID 0x19 maps as another
headphone jack. Also need the function like alc887_fixup_asus_jack to
enable the audio jacks.

Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
Signed-off-by: Kailang Yang <kailang@realtek.com>
---
v2:
 - Change the magic numbers to meaningful macros.
 - Change snd_hda_codec_write to snd_hda_set_pin_ctl and
   snd_hda_set_pin_ctl_cache accroding to Takashi's suggestion

 sound/pci/hda/patch_realtek.c | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d4f17b465892..56c3ee95c8d3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1929,6 +1929,8 @@ enum {
 	ALC1220_FIXUP_CLEVO_P950,
 	ALC1220_FIXUP_CLEVO_PB51ED,
 	ALC1220_FIXUP_CLEVO_PB51ED_PINS,
+	ALC887_FIXUP_ASUS_AUDIO,
+	ALC887_FIXUP_ASUS_HMIC,
 };
 
 static void alc889_fixup_coef(struct hda_codec *codec,
@@ -2141,6 +2143,31 @@ static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
 }
 
+static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
+					 struct hda_jack_callback *jack)
+{
+	struct alc_spec *spec = codec->spec;
+	unsigned int vref;
+
+	snd_hda_gen_hp_automute(codec, jack);
+
+	if (spec->gen.hp_jack_present)
+		vref = AC_PINCTL_VREF_80;
+	else
+		vref = AC_PINCTL_VREF_HIZ;
+	snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
+}
+
+static void alc887_fixup_asus_jack(struct hda_codec *codec,
+				     const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+	if (action != HDA_FIXUP_ACT_PROBE)
+		return;
+	snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
+	spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
+}
+
 static const struct hda_fixup alc882_fixups[] = {
 	[ALC882_FIXUP_ABIT_AW9D_MAX] = {
 		.type = HDA_FIXUP_PINS,
@@ -2398,6 +2425,20 @@ static const struct hda_fixup alc882_fixups[] = {
 		.chained = true,
 		.chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
 	},
+	[ALC887_FIXUP_ASUS_AUDIO] = {
+		.type = HDA_FIXUP_PINS,
+		.v.pins = (const struct hda_pintbl[]) {
+			{ 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
+			{ 0x19, 0x22219420 },
+			{}
+		},
+	},
+	[ALC887_FIXUP_ASUS_HMIC] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc887_fixup_asus_jack,
+		.chained = true,
+		.chain_id = ALC887_FIXUP_ASUS_AUDIO,
+	},
 };
 
 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
@@ -2431,6 +2472,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
 	SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
+	SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887
  2020-10-07  5:22   ` [PATCH v2] " Jian-Hong Pan
@ 2020-10-07 15:31     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-10-07 15:31 UTC (permalink / raw)
  To: Jian-Hong Pan; +Cc: Takashi Iwai, Kailang Yang, alsa-devel, linux-kernel, linux

On Wed, 07 Oct 2020 07:22:25 +0200,
Jian-Hong Pan wrote:
> 
> The ASUS D700SA desktop's audio (1043:2390) with ALC887 cannot detect
> the headset microphone and another headphone jack until
> ALC887_FIXUP_ASUS_HMIC and ALC887_FIXUP_ASUS_AUDIO quirks are applied.
> The NID 0x15 maps as the headset microphone and NID 0x19 maps as another
> headphone jack. Also need the function like alc887_fixup_asus_jack to
> enable the audio jacks.
> 
> Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
> Signed-off-by: Kailang Yang <kailang@realtek.com>
> ---
> v2:
>  - Change the magic numbers to meaningful macros.
>  - Change snd_hda_codec_write to snd_hda_set_pin_ctl and
>    snd_hda_set_pin_ctl_cache accroding to Takashi's suggestion

Thanks, applied.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-07 15:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06  7:53 [PATCH] ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887 Jian-Hong Pan
2020-10-06 12:24 ` Takashi Iwai
2020-10-07  5:22   ` [PATCH v2] " Jian-Hong Pan
2020-10-07 15:31     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).