[ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good morning,

Could you please consider the following patch for 2.6.27.
The driver starts up with the jacks in an inconsistent state (speakers on, 
laptop headphone output enabled, dock headphone output enabled) and does not 
consider their state until the first unsolicited event arrives. In some cases 
it takes *headphone insert* *headphone removal* *headphone insert* to get the 
driver to mute the speakers successfully.

Also, both HP outputs are enabled together, rather then individually enabled based 
on jack sense results.

This patch addresses both problems. Open to comments as usual & sign-off in diff.

Regards,
Tony V.
LINX sysadmin
--- sound/pci/hda/patch_realtek.c.orig	2008-05-17 15:07:35.000000000 +0100
+++ sound/pci/hda/patch_realtek.c	2008-05-19 00:43:35.000000000 +0100
@@ -8757,7 +8757,7 @@
 	},
 };
 
-/* mute/unmute internal speaker according to the hp jack and mute state */
+/* mute/unmute internal speaker according to the hp jacks and mute state */
 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
 {
 	struct alc_spec *spec = codec->spec;
@@ -8765,13 +8765,28 @@
 
 	if (force || !spec->sense_updated) {
 		unsigned int present_int_hp, present_dock_hp;
-		/* need to execute and sync at first */
+		/* sense laptop headphone jack, enable amp if required */
 		snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
 		present_int_hp = snd_hda_codec_read(codec, 0x14, 0,
 					AC_VERB_GET_PIN_SENSE, 0);
+		if ((present_int_hp & 0x80000000) != 0)
+			snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
+						 HDA_AMP_MUTE, 0);
+		else
+			snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
+						 HDA_AMP_MUTE, HDA_AMP_MUTE);
+
+		/* sense dock headphone jack, enable amp if required */
 		snd_hda_codec_read(codec, 0x1B, 0, AC_VERB_SET_PIN_SENSE, 0);
 		present_dock_hp = snd_hda_codec_read(codec, 0x1b, 0,
 					AC_VERB_GET_PIN_SENSE, 0);
+		if ((present_dock_hp & 0x80000000) != 0)
+			snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
+						 HDA_AMP_MUTE, 0);
+		else
+			snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
+						 HDA_AMP_MUTE, HDA_AMP_MUTE);
+
 		spec->jack_present = (present_int_hp & 0x80000000) != 0;
 		spec->jack_present |= (present_dock_hp & 0x80000000) != 0;
 		spec->sense_updated = 1;
@@ -8781,10 +8796,9 @@
 		snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
 					 HDA_AMP_MUTE, HDA_AMP_MUTE);
 	} else {
-		/* unmute internal speaker if necessary */
-		mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
+		/* unmute internal speaker */
 		snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
-					 HDA_AMP_MUTE, mute);
+					 HDA_AMP_MUTE, 0);
 	}
 }
 
@@ -8797,6 +8811,11 @@
 	alc262_fujitsu_automute(codec, 1);
 }
 
+static void alc262_fujitsu_init_hook(struct hda_codec *codec)
+{
+	alc262_fujitsu_automute(codec, 1);
+}
+
 /* bind volumes of both NID 0x0c and 0x0d */
 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
 	.ops = &snd_hda_bind_vol,
@@ -9570,6 +9590,7 @@
 		.channel_mode = alc262_modes,
 		.input_mux = &alc262_fujitsu_capture_source,
 		.unsol_event = alc262_fujitsu_unsol_event,
+		.init_hook = alc262_fujitsu_init_hook,
 	},
 	[ALC262_HP_BPC] = {
 		.mixers = { alc262_HP_BPC_mixer },

Signed-off-by: Tony Vroon <tony@xxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux