Skip to contentSkip to conversation

1.0.15rc3 patch_analog.s bug + fix

DISCUSSION Peter Skensved 4 participants 14 messages Oct 15, 2007 – Oct 17, 2007

lore
Share & tools
lore
#0 lore raw
     Hi,

I've come across a problem with the 1.0.15rc3 alsa driver on my Lenovo 3000 N100 laptop using
the auto mute feature - it appears to work backwards ! Plugging in the headphones unmutes the external speakers and unplugging the heaphones mutes them ...

Changing the if statement in line ~600 in patch_analog.c in ad1986a_update_hp to

    if (!spec->jack_preset)

makes it work the intended way. ( spec->jack_present changes state _before_ the call to ad1986a_hp_automute )

peter

----

Peter Skensved Email : [email protected]
Dept. of Physics,
Queen's University,
Kingston, Ontario,
Canada

#1 lore raw

At Sun, 14 Oct 2007 22:53:03 -0400,

Quoted 6 lines · Peter Skensved
     Hi,

I've come across a problem with the 1.0.15rc3 alsa driver on my Lenovo 3000 N100 laptop using
the auto mute feature - it appears to work backwards ! Plugging in the headphones unmutes the external speakers and unplugging the heaphones mutes them ...

Quoted 6 lines

Changing the if statement in line ~600 in patch_analog.c in ad1986a_update_hp to

    if (!spec->jack_preset)

makes it work the intended way. ( spec->jack_present changes state _before_ the call to ad1986a_hp_automute )

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Is jack_present set/reset correctly when HP jack is plugged/unplugged at all? Or, the pin NID is swapped, or any other reason?

Thanks,

Takashi

#2 lore raw
Quoted 10 lines · Takashi Iwai

At Sun, 14 Oct 2007 22:53:03 -0400,

Quoted 8 lines · Peter Skensved
     Hi,

I've come across a problem with the 1.0.15rc3 alsa driver on my Lenovo 3000 N100 laptop using
the auto mute feature - it appears to work backwards ! Plugging in the headphones unmutes the external speakers and unplugging the heaphones mutes them ...

Changing the if statement in line ~600 in patch_analog.c in ad1986a_update_hp to

Quoted 9 lines
Quoted 4 lines
    if (!spec->jack_preset)

makes it work the intended way. ( spec->jack_present changes state _before_ the call to ad1986a_hp_automute )

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Well - in the default mode the jack is present and the internal speakers are permanently
muted until I plug in a set of headphones no matter how I toggle the speaker mute in the mixer.

With headphones plugged in I can mute and unmute the internal speakers in alsa mixer

Surely the default cannot be that I have to carry a set of headphones with my
laptop all the time ???!!???

Quoted 3 lines

Is jack_present set/reset correctly when HP jack is plugged/unplugged at all? Or, the pin NID is swapped, or any other reason?

I sprinkled some printk's in the driver :
On entry to ad1986a_update_hp : plugging headphones into jack : spec->jack_present = 0

                                     removing headphones from jack : spec->jack_present = 1
Quoted 8 lines

Thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 3 lines · On Monday 15 October 2007 23:34:21 Peter Skensved wrote:
Quoted 3 lines

Hmm, the code logic looks correct to me.  If HP jack is present, the internal speaker should be muted.  Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch)

Code logic is broken.
Internal speakers muted while jack unplugged and unmuted while it's plugged.

See attached original patch.

alsa-kernel/pci/hda/patch_analog.c +56 -2
@@ -497,6 +497,7 @@
 /*
  * mixers
  */
+
 static struct snd_kcontrol_new ad1986a_mixers[] = {
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -628,18 +629,65 @@
 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 	long *valp = ucontrol->value.integer.value;
 	int change;
+	unsigned int present;
+
+	present = snd_hda_codec_read(codec, 0x1a, 0,
+				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
 
+	/* HP (0x1a) */
 	change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
 					  0x80, valp[0] ? 0 : 0x80);
 	change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
 					   0x80, valp[1] ? 0 : 0x80);
+
+	/* Line-Out (0x1b) */
 	snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
-				 0x80, valp[0] ? 0 : 0x80);
+				 0x80, (valp[0] && present) ? 0 : 0x80);
 	snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
-				 0x80, valp[1] ? 0 : 0x80);
+				 0x80, (valp[1] && present) ? 0 : 0x80);
+
 	return change;
 }
 
+/* mute internal speakers if HP is plugged */
+static void ad1986a_laptop_eapd_automute(struct hda_codec *codec)
+{
+	unsigned int present, sw;
+
+	present = snd_hda_codec_read(codec, 0x1a, 0,
+				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+
+	/*
+	 * TODO: get kcontrol value for "Master Playback Switch" and
+	 * enable Line-Out only if (present && sw), where sw means "unmute"
+	 *
+	 * Currently the Line-Out is unmuted when we unplug HP jack, even if we
+	 * asked to mute Master Volume.
+	 */
+	sw = 1;
+
+	/* Line-Out */
+	snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
+				 0x80, (present && sw) ? 0 : 0x80);
+	snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
+				 0x80, (present && sw) ? 0 : 0x80);
+}
+
+/* unsolicited event for HP jack sensing */
+static void ad1986a_laptop_eapd_unsol_event(struct hda_codec *codec,
+					    unsigned int res)
+{
+	ad1986a_laptop_eapd_automute(codec);
+}
+
+/* initialize jack-sensing, too */
+static int ad1986a_laptop_eapd_init(struct hda_codec *codec)
+{
+	ad198x_init(codec);
+	ad1986a_laptop_eapd_automute(codec);
+	return 0;
+}
+
 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
 	.num_items = 3,
 	.items = {
@@ -749,6 +797,8 @@
 	{0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
 	{0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
 	{0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+	/* HP pin event */
+	{0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN},
 	{ } /* end */
 };
 
@@ -913,6 +963,10 @@
 		spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
 		spec->multiout.dig_out_nid = 0;
 		spec->input_mux = &ad1986a_laptop_eapd_capture_source;
+
+		/* add some ad1986a specific operations */
+		codec->patch_ops.init = ad1986a_laptop_eapd_init;
+		codec->patch_ops.unsol_event = ad1986a_laptop_eapd_unsol_event;
 		break;
 	case AD1986A_ULTRA:
 		spec->mixers[0] = ad1986a_laptop_eapd_mixers;

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw

At Tue, 16 Oct 2007 10:39:55 +0300,

Quoted 9 lines · Vasily Khoruzhick

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 3 lines · On Monday 15 October 2007 23:34:21 Peter Skensved wrote:
Quoted 3 lines

Hmm, the code logic looks correct to me.  If HP jack is present, the internal speaker should be muted.  Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch)

Code logic is broken.
Internal speakers muted while jack unplugged and unmuted while it's plugged.

No, it's the wrong logic. The internal speaker should be unmuted when HP is unplugged, and muted when plugged. You don't want to hear from both at the same time.

Quoted 1 line

See attached original patch.

And if that patch works, then it simply means that the HP jack detection is reversed, not about the code logic.

Takashi

Quoted 106 lines

[2 hdaintel-laptop-eapd-updated.patch <text/x-diff; iso-8859-1 (7bit)>]

alsa-kernel/pci/hda/patch_analog.c +56 -2
@@ -497,6 +497,7 @@
 /*
  * mixers
  */
+
 static struct snd_kcontrol_new ad1986a_mixers[] = {
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -628,18 +629,65 @@
 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 	long *valp = ucontrol->value.integer.value;
 	int change;
+	unsigned int present;
+
+	present = snd_hda_codec_read(codec, 0x1a, 0,
+				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
 
+	/* HP (0x1a) */
 	change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
 					  0x80, valp[0] ? 0 : 0x80);
 	change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
 					   0x80, valp[1] ? 0 : 0x80);
+
+	/* Line-Out (0x1b) */
 	snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
-				 0x80, valp[0] ? 0 : 0x80);
+				 0x80, (valp[0] && present) ? 0 : 0x80);
 	snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
-				 0x80, valp[1] ? 0 : 0x80);
+				 0x80, (valp[1] && present) ? 0 : 0x80);
+
 	return change;
 }
 
+/* mute internal speakers if HP is plugged */
+static void ad1986a_laptop_eapd_automute(struct hda_codec *codec)
+{
+	unsigned int present, sw;
+
+	present = snd_hda_codec_read(codec, 0x1a, 0,
+				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+
+	/*
+	 * TODO: get kcontrol value for "Master Playback Switch" and
+	 * enable Line-Out only if (present && sw), where sw means "unmute"
+	 *
+	 * Currently the Line-Out is unmuted when we unplug HP jack, even if we
+	 * asked to mute Master Volume.
+	 */
+	sw = 1;
+
+	/* Line-Out */
+	snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
+				 0x80, (present && sw) ? 0 : 0x80);
+	snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
+				 0x80, (present && sw) ? 0 : 0x80);
+}
+
+/* unsolicited event for HP jack sensing */
+static void ad1986a_laptop_eapd_unsol_event(struct hda_codec *codec,
+					    unsigned int res)
+{
+	ad1986a_laptop_eapd_automute(codec);
+}
+
+/* initialize jack-sensing, too */
+static int ad1986a_laptop_eapd_init(struct hda_codec *codec)
+{
+	ad198x_init(codec);
+	ad1986a_laptop_eapd_automute(codec);
+	return 0;
+}
+
 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
 	.num_items = 3,
 	.items = {
@@ -749,6 +797,8 @@
 	{0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
 	{0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
 	{0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+	/* HP pin event */
+	{0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN},
 	{ } /* end */
 };
 
@@ -913,6 +963,10 @@
 		spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
 		spec->multiout.dig_out_nid = 0;
 		spec->input_mux = &ad1986a_laptop_eapd_capture_source;
+
+		/* add some ad1986a specific operations */
+		codec->patch_ops.init = ad1986a_laptop_eapd_init;
+		codec->patch_ops.unsol_event = ad1986a_laptop_eapd_unsol_event;
 		break;
 	case AD1986A_ULTRA:
 		spec->mixers[0] = ad1986a_laptop_eapd_mixers;

[3 <text/plain; us-ascii (7bit)>]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
Quoted 10 lines

At Tue, 16 Oct 2007 10:39:55 +0300,

Quoted 7 lines · Vasily Khoruzhick

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 3 lines · On Monday 15 October 2007 23:34:21 Peter Skensved wrote:
Quoted 3 lines

Hmm, the code logic looks correct to me.  If HP jack is present, the internal speaker should be muted.  Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch)

Quoted 8 lines
Quoted 3 lines

Code logic is broken.
Internal speakers muted while jack unplugged and unmuted while it's plugged.

No, it's the wrong logic. The internal speaker should be unmuted when HP is unplugged, and muted when plugged. You don't want to hear from both at the same time.

Sorry, i've made mistake, of course internal speakers should be muted when jack plugged. Patch that I've attached to previous message has exactly that logic.

Quoted 2 lines

This implies rather that the jack detection itself is reversed from the standard.  Could you try the patch below?

Your patch works.

But it seems that there's another bug - i have loud click when i to play something or change mixer settings after not using audio for ~1min

Thanks.

Regards
Vasily
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#6 lore raw

At Tue, 16 Oct 2007 21:30:50 +0300,

Quoted 15 lines · Vasily Khoruzhick
Quoted 15 lines

At Tue, 16 Oct 2007 10:39:55 +0300,

Quoted 10 lines · Vasily Khoruzhick

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 3 lines · On Monday 15 October 2007 23:34:21 Peter Skensved wrote:
Quoted 3 lines

Hmm, the code logic looks correct to me.  If HP jack is present, the internal speaker should be muted.  Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch)

Code logic is broken.
Internal speakers muted while jack unplugged and unmuted while it's plugged.

Quoted 8 lines
Quoted 4 lines

No, it's the wrong logic. The internal speaker should be unmuted when HP is unplugged, and muted when plugged. You don't want to hear from both at the same time.

Sorry, i've made mistake, of course internal speakers should be muted when jack plugged. Patch that I've attached to previous message has exactly that logic.

Well, the point is that the logic in your patch was a bit confusing. "present" should have been renamed as "not_present" or so...

Quoted 4 lines
Quoted 2 lines

This implies rather that the jack detection itself is reversed from the standard.  Could you try the patch below?

Your patch works.

Thanks for confirmation. Now applied to HG tree.

Quoted 2 lines

But it seems that there's another bug - i have loud click when i to play something or change mixer settings after not using audio for ~1min

I guess it's likely the auto power-saving feature. Could you set the module option power_save=0 for snd-hda-intel?

thanks,

Takashi

#7 lore raw

2007/10/17, Takashi Iwai <[email protected]>:

Quoted 11 lines

At Tue, 16 Oct 2007 21:30:50 +0300,

Quoted 1 line
Quoted 1 line

But it seems that there's another bug - i have loud click when i try to

play

Quoted 4 lines
Quoted 1 line

something or change mixer settings after not using audio for ~1min

I guess it's likely the auto power-saving feature. Could you set the module option power_save=0 for snd-hda-intel?

Thanks, it works. But why such feature is enabled by default?

AFAIK such loud clicks are harmful for speakers or headphones.

Regards
Vasily

#8 lore raw

At Wed, 17 Oct 2007 19:10:45 +0300,

Quoted 9 lines · =?KOI8-R?B?98HTyczJyg==?= wrote:

2007/10/17, Takashi Iwai <[email protected]>:

At Tue, 16 Oct 2007 21:30:50 +0300,

>> But it seems that there's another bug - i have loud click when i try to play
>> something or change mixer settings after not using audio for ~1min

Quoted 5 lines

> I guess it's likely the auto power-saving feature.
> Could you set the module option power_save=0 for snd-hda-intel?

Thanks, it works. But why such feature is enabled by default? AFAIK such loud clicks are harmful for speakers or headphones.

Technically, the option is enabled as default just because of the configure script. In the kernel configuration, you can choose freely as you like. (And this feature will save lots of battery time.)

But, the default power_save value is 0 in the recent version, so passing power_save=0 shouldn't give any difference unless you set other values in somewhere else.

Takashi

#9 lore raw
In reply to Peter Skensved
Quoted 3 lines
Quoted 3 lines

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Original patch:

	present = snd_hda_codec_read(codec, 0x1a, 0,
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;

Code in alsa (patch-analog.c line 614):

	present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
	spec->jack_present = (present & 0x80000000) != 0;

Seems to have quite different logic, don't it?

Should be:

	present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
	spec->jack_present = (present & 0x80000000) == 0;

P.S. It's very sad that you've released 1.0.15 with that bug :(

#10 lore raw

At Tue, 16 Oct 2007 10:58:19 +0300,

Quoted 9 lines · Vasily Khoruzhick
Quoted 4 lines
Quoted 4 lines

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Original patch:

	present = snd_hda_codec_read(codec, 0x1a, 0,
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Quoted 6 lines

Code in alsa (patch-analog.c line 614):

	present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
	spec->jack_present = (present & 0x80000000) != 0;

Seems to have quite different logic, don't it?

I don't see your point. It's the same logic:

If present has bit 0x80000000, spec->jack_present = 1, Otherwise, spec->jack_present = 0.

The problem is that the jack detection of this codec (or specific to the laptop) seems inverse from the standard.

Quoted 6 lines

Should be:

	present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
	spec->jack_present = (present & 0x80000000) == 0;

P.S. It's very sad that you've released 1.0.15 with that bug :(

Yes, it's sad. Too late recognized. We'll likely have 1.0.15a release soon later, though.

Takashi

#11 lore raw

Hi,

sorry for partly OT and interrupting your conversation. is there somewhere a patch which corrects muting for AD1986A when playing 2ch sound when 6ch is selected in the alsamixer?

https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3485

Thanks

M.

2007/10/16, Takashi Iwai <[email protected]>:

Quoted 43 lines

At Tue, 16 Oct 2007 10:58:19 +0300,

Quoted 9 lines · Vasily Khoruzhick
Quoted 4 lines
Quoted 4 lines

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Original patch:

      present = snd_hda_codec_read(codec, 0x1a, 0,
                                   AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Quoted 6 lines

Code in alsa (patch-analog.c line 614):

      present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
      spec->jack_present = (present & 0x80000000) != 0;

Seems to have quite different logic, don't it?

I don't see your point. It's the same logic:

If present has bit 0x80000000, spec->jack_present = 1, Otherwise, spec->jack_present = 0.

The problem is that the jack detection of this codec (or specific to the laptop) seems inverse from the standard.

Quoted 6 lines

Should be:

      present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
      spec->jack_present = (present & 0x80000000) == 0;

P.S. It's very sad that you've released 1.0.15 with that bug :(

Yes, it's sad. Too late recognized. We'll likely have 1.0.15a release soon later, though.

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Signature · 1 line
Glauben heißt nicht wissen wollen, was wahr ist ... Nietzsche
#12 lore raw
In reply to Peter Skensved

At Mon, 15 Oct 2007 16:34:21 -0400,

Quoted 32 lines · Peter Skensved
Quoted 10 lines · Takashi Iwai

At Sun, 14 Oct 2007 22:53:03 -0400,

Quoted 8 lines · Peter Skensved
     Hi,

I've come across a problem with the 1.0.15rc3 alsa driver on my Lenovo 3000 N100 laptop using
the auto mute feature - it appears to work backwards ! Plugging in the headphones unmutes the external speakers and unplugging the heaphones mutes them ...

Changing the if statement in line ~600 in patch_analog.c in ad1986a_update_hp to

Quoted 9 lines
Quoted 4 lines
    if (!spec->jack_preset)

makes it work the intended way. ( spec->jack_present changes state _before_ the call to ad1986a_hp_automute )

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Well - in the default mode the jack is present and the internal speakers are permanently
muted until I plug in a set of headphones no matter how I toggle the speaker mute in the mixer.

With headphones plugged in I can mute and unmute the internal speakers in alsa mixer

Surely the default cannot be that I have to carry a set of headphones with my
laptop all the time ???!!???

Quoted 7 lines
Quoted 3 lines

Is jack_present set/reset correctly when HP jack is plugged/unplugged at all? Or, the pin NID is swapped, or any other reason?

I sprinkled some printk's in the driver :
On entry to ad1986a_update_hp : plugging headphones into jack : spec->jack_present = 0

                                     removing headphones from jack : spec->jack_present = 1

This implies rather that the jack detection itself is reversed from the standard. Could you try the patch below?

thanks,

Takashi

pci/hda/patch_analog.c +2 -1
diff -r 29661bff769f pci/hda/patch_analog.c
@@ -612,7 +612,8 @@ static void ad1986a_hp_automute(struct h
 	unsigned int present;
 
 	present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
-	spec->jack_present = (present & 0x80000000) != 0;
+	/* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
+	spec->jack_present = !(present & 0x80000000);
 	ad1986a_update_hp(codec);
 }
#13 lore raw
Quoted 42 lines · Takashi Iwai

At Mon, 15 Oct 2007 16:34:21 -0400,

Quoted 32 lines · Peter Skensved
Quoted 10 lines · Takashi Iwai

At Sun, 14 Oct 2007 22:53:03 -0400,

Quoted 8 lines · Peter Skensved
     Hi,

I've come across a problem with the 1.0.15rc3 alsa driver on my Lenovo 3000 N100 laptop using
the auto mute feature - it appears to work backwards ! Plugging in the headphones unmutes the external speakers and unplugging the heaphones mutes them ...

Changing the if statement in line ~600 in patch_analog.c in ad1986a_update_hp to

Quoted 9 lines
Quoted 4 lines
    if (!spec->jack_preset)

makes it work the intended way. ( spec->jack_present changes state _before_ the call to ad1986a_hp_automute )

Hmm, the code logic looks correct to me. If HP jack is present, the internal speaker should be muted. Otherwise it follows the state of HP jack (muted/unmuted, that acts as a master switch).

Well - in the default mode the jack is present and the internal speakers are permanently
muted until I plug in a set of headphones no matter how I toggle the speaker mute in the mixer.

With headphones plugged in I can mute and unmute the internal speakers in alsa mixer

Surely the default cannot be that I have to carry a set of headphones with my
laptop all the time ???!!???

Quoted 7 lines
Quoted 3 lines

Is jack_present set/reset correctly when HP jack is plugged/unplugged at all? Or, the pin NID is swapped, or any other reason?

I sprinkled some printk's in the driver :
On entry to ad1986a_update_hp : plugging headphones into jack : spec->jack_present = 0

                                     removing headphones from jack : spec->jack_present = 1
Quoted 8 lines

This implies rather that the jack detection itself is reversed from the standard. Could you try the patch below?

thanks,

Takashi

It works -
peter