Skip to contentSkip to conversation

ALSA: hda - Fix jack gating when auto_{mute, mic} is suppressed.

PATCH In review Chih-Chung Chang 3 participants 3 messages Aug 5, 2013 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - Fix jack gating when auto_{mute, mic} is suppressed.

The snd_hda_jack_set_gating_jack() call didn't work when auto_{mute,mic} is suppressed because (1) am_entry is not filled with nid of the mic pin. (2) The jacks are not created (by snd_hda_jack_detect_enable_callback) before the snd_hda_jack_set_gating_jack call.

Now we use the first input pin nid directly, and create the jack if it doesn't exist yet.

sound/pci/hda/hda_jack.c +2 -2
index 3fd2973..aa02c0f 100644
@@ -247,8 +247,8 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
 				 hda_nid_t gating_nid)
 {
-	struct hda_jack_tbl *gated = snd_hda_jack_tbl_get(codec, gated_nid);
-	struct hda_jack_tbl *gating = snd_hda_jack_tbl_get(codec, gating_nid);
+	struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid);
+	struct hda_jack_tbl *gating = snd_hda_jack_tbl_new(codec, gating_nid);
 
 	if (!gated || !gating)
 		return -EINVAL;
sound/pci/hda/patch_realtek.c +5 -4
index 8bd2261..2b64de5 100644
@@ -3258,11 +3258,12 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
 	struct alc_spec *spec = codec->spec;
 
 	if (action == HDA_FIXUP_ACT_PROBE) {
-		if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
-			       !spec->gen.autocfg.hp_pins[0]))
+		int mic_pin = spec->gen.autocfg.inputs[0].pin;
+		int hp_pin = spec->gen.autocfg.hp_pins[0];
+
+		if (snd_BUG_ON(!mic_pin || !hp_pin))
 			return;
-		snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
-					     spec->gen.autocfg.hp_pins[0]);
+		snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
 	}
 }
 
Signature · 1 line
1.8.3
#1 lore raw

At Mon, 5 Aug 2013 12:09:21 +0800,

Quoted 11 lines · Chih-Chung Chang

The snd_hda_jack_set_gating_jack() call didn't work when auto_{mute,mic} is suppressed because (1) am_entry is not filled with nid of the mic pin. (2) The jacks are not created (by snd_hda_jack_detect_enable_callback) before the snd_hda_jack_set_gating_jack call.

Now we use the first input pin nid directly, and create the jack if it doesn't exist yet.

Where we need this kind of fix, the choice of the mic pin via autocfg.inputs[0].pin doesn't look right. For example, an internal mic pin with a smaller NID than an external mic pin would screw it up.

thanks,

Takashi

Quoted 40 lines
sound/pci/hda/hda_jack.c +2 -2
index 3fd2973..aa02c0f 100644
@@ -247,8 +247,8 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
 				 hda_nid_t gating_nid)
 {
-	struct hda_jack_tbl *gated = snd_hda_jack_tbl_get(codec, gated_nid);
-	struct hda_jack_tbl *gating = snd_hda_jack_tbl_get(codec, gating_nid);
+	struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid);
+	struct hda_jack_tbl *gating = snd_hda_jack_tbl_new(codec, gating_nid);
 
 	if (!gated || !gating)
 		return -EINVAL;
sound/pci/hda/patch_realtek.c +5 -4
index 8bd2261..2b64de5 100644
@@ -3258,11 +3258,12 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
 	struct alc_spec *spec = codec->spec;
 
 	if (action == HDA_FIXUP_ACT_PROBE) {
-		if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
-			       !spec->gen.autocfg.hp_pins[0]))
+		int mic_pin = spec->gen.autocfg.inputs[0].pin;
+		int hp_pin = spec->gen.autocfg.hp_pins[0];
+
+		if (snd_BUG_ON(!mic_pin || !hp_pin))
 			return;
-		snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
-					     spec->gen.autocfg.hp_pins[0]);
+		snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
 	}
 }
 
Signature · 1 line
1.8.3
#2 lore raw
Quoted 12 lines · Takashi Iwai

At Mon, 5 Aug 2013 12:09:21 +0800,

Quoted 10 lines · Chih-Chung Chang

The snd_hda_jack_set_gating_jack() call didn't work when auto_{mute,mic} is suppressed because (1) am_entry is not filled with nid of the mic pin. (2) The jacks are not created (by snd_hda_jack_detect_enable_callback) before the snd_hda_jack_set_gating_jack call.

Now we use the first input pin nid directly, and create the jack if it doesn't exist yet.

Quoted 7 lines
Quoted 1 line

Where we need this kind of fix, the choice of the mic pin via autocfg.inputs[0].pin doesn't look right. For example, an internal mic pin with a smaller NID than an external mic pin would screw it up.

Thanks for review. I will send a revised patch.

Quoted 56 lines

thanks,

Takashi

sound/pci/hda/hda_jack.c EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); · line 247

Quoted 7 lines
sound/pci/hda/hda_jack.c +0 -0
index 3fd2973..aa02c0f 100644
@@ -247,8 +247,8 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t

gated_nid,

sound/pci/hda/hda_jack.c EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);

Quoted 3 lines
sound/pci/hda/hda_jack.c +0 -1
                               hda_nid_t gating_nid)
 {
-     struct hda_jack_tbl *gated = snd_hda_jack_tbl_get(codec,

gated_nid);

sound/pci/hda/hda_jack.c EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); · line 251

Quoted 1 line
sound/pci/hda/hda_jack.c +0 -1
-     struct hda_jack_tbl *gating = snd_hda_jack_tbl_get(codec,

gating_nid);

sound/pci/hda/hda_jack.c EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); · line 250

Quoted 1 line
sound/pci/hda/hda_jack.c +1 -0
+     struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec,

gated_nid);

sound/pci/hda/hda_jack.c EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); · line 251

Quoted 1 line
sound/pci/hda/hda_jack.c +1 -0
+     struct hda_jack_tbl *gating = snd_hda_jack_tbl_new(codec,

gating_nid);

Review

Quoted 4 lines
sound/pci/hda/hda_jack.c +0 -0
      if (!gated || !gating)
              return -EINVAL;
(quoted diff) +0 -0

b/sound/pci/hda/patch_realtek.c

sound/pci/hda/patch_realtek.c static void alc271_hp_gate_mic_jack(struct

Quoted 4 lines

index 8bd2261..2b64de5 100644

sound/pci/hda/patch_realtek.c +0 -0
@@ -3258,11 +3258,12 @@ static void alc271_hp_gate_mic_jack(struct

hda_codec *codec,

sound/pci/hda/patch_realtek.c static void alc271_hp_gate_mic_jack(struct hda_codec *codec,

Quoted 11 lines
sound/pci/hda/patch_realtek.c +4 -3
      struct alc_spec *spec = codec->spec;
 
      if (action == HDA_FIXUP_ACT_PROBE) {
-             if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
-                            !spec->gen.autocfg.hp_pins[0]))
+             int mic_pin = spec->gen.autocfg.inputs[0].pin;
+             int hp_pin = spec->gen.autocfg.hp_pins[0];
+
+             if (snd_BUG_ON(!mic_pin || !hp_pin))
                      return;
-             snd_hda_jack_set_gating_jack(codec,

spec->gen.am_entry[1].pin,

Quoted 8 lines
sound/pci/hda/patch_realtek.c +1 -2
-                                          spec->gen.autocfg.hp_pins[0]);
+             snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
      }
 }
 
--

1.8.3