* [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs
@ 2008-05-19 0:00 Tony Vroon
2008-05-19 10:23 ` Takashi Iwai
0 siblings, 1 reply; 6+ messages in thread
From: Tony Vroon @ 2008-05-19 0:00 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
[-- Attachment #1.1.1: Type: text/plain, Size: 667 bytes --]
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
[-- Attachment #1.1.2: alc262-fujitsu-autosense.patch --]
[-- Type: text/x-patch, Size: 2715 bytes --]
--- 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@linx.net>
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs
2008-05-19 0:00 [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs Tony Vroon
@ 2008-05-19 10:23 ` Takashi Iwai
2008-05-19 10:31 ` Tony Vroon
0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2008-05-19 10:23 UTC (permalink / raw)
To: Tony Vroon; +Cc: alsa-devel
At Mon, 19 May 2008 01:00:19 +0100,
Tony Vroon wrote:
>
> --- 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;
I get a compile warning, "unused variable mute". Could you fix it?
> @@ -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);
Any reason to remove this?
Otherwise the internal speaker won't react together with the Master volume.
Maybe a cleaner fix is to remove the bind_sw and bind_vol hacks and
use vmaster instead.
thanks,
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs
2008-05-19 10:23 ` Takashi Iwai
@ 2008-05-19 10:31 ` Tony Vroon
2008-05-19 10:37 ` Takashi Iwai
0 siblings, 1 reply; 6+ messages in thread
From: Tony Vroon @ 2008-05-19 10:31 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 707 bytes --]
On Mon, 2008-05-19 at 12:23 +0200, Takashi Iwai wrote:
> Any reason to remove this?
> Otherwise the internal speaker won't react together with the Master volume.
It seemed to only take the internal headphone output into account, not
the dock headphone output. But if it's just to link the two volumes
together I'll add it back. It will fix the compile warning as well.
Its purpose was unclear to me.
Will the existing mechanism cope if 0x14 (internal HP output) is muted
and 0x1B (dock HP output) is not?
> Maybe a cleaner fix is to remove the bind_sw and bind_vol hacks and
> use vmaster instead.
Is there example code I can look at please?
> thanks,
> Takashi
Regards,
Tony V.
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs
2008-05-19 10:31 ` Tony Vroon
@ 2008-05-19 10:37 ` Takashi Iwai
2008-05-19 10:56 ` Takashi Iwai
0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2008-05-19 10:37 UTC (permalink / raw)
To: Tony Vroon; +Cc: alsa-devel
At Mon, 19 May 2008 11:31:09 +0100,
Tony Vroon wrote:
>
> On Mon, 2008-05-19 at 12:23 +0200, Takashi Iwai wrote:
> > Any reason to remove this?
> > Otherwise the internal speaker won't react together with the Master volume.
>
> It seemed to only take the internal headphone output into account, not
> the dock headphone output. But if it's just to link the two volumes
> together I'll add it back. It will fix the compile warning as well.
> Its purpose was unclear to me.
>
> Will the existing mechanism cope if 0x14 (internal HP output) is muted
> and 0x1B (dock HP output) is not?
The code there was to synchronize both HP and speaker outputs with the
master switch. The master switch changes 0x14 mute status and calls
automute. When no HP is plugged, the internal speaker is unmuted only
when master switch is on -- that is, 0x14 is also unmuted.
The logic is a bit complex, and thus I suggested to replace with
vmaster.
> > Maybe a cleaner fix is to remove the bind_sw and bind_vol hacks and
> > use vmaster instead.
>
> Is there example code I can look at please?
Add the individual mixer elements corresponding to HP, dock and
PC-speaker switches instead of hackish master switch. Then a virtual
master switch will be automatically created.
I'll create a test patch soon later...
thanks,
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs
2008-05-19 10:37 ` Takashi Iwai
@ 2008-05-19 10:56 ` Takashi Iwai
2008-05-19 11:33 ` Tony Vroon
0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2008-05-19 10:56 UTC (permalink / raw)
To: Tony Vroon; +Cc: alsa-devel
At Mon, 19 May 2008 12:37:10 +0200,
I wrote:
>
> At Mon, 19 May 2008 11:31:09 +0100,
> Tony Vroon wrote:
> >
> > On Mon, 2008-05-19 at 12:23 +0200, Takashi Iwai wrote:
> > > Any reason to remove this?
> > > Otherwise the internal speaker won't react together with the Master volume.
> >
> > It seemed to only take the internal headphone output into account, not
> > the dock headphone output. But if it's just to link the two volumes
> > together I'll add it back. It will fix the compile warning as well.
> > Its purpose was unclear to me.
> >
> > Will the existing mechanism cope if 0x14 (internal HP output) is muted
> > and 0x1B (dock HP output) is not?
>
> The code there was to synchronize both HP and speaker outputs with the
> master switch. The master switch changes 0x14 mute status and calls
> automute. When no HP is plugged, the internal speaker is unmuted only
> when master switch is on -- that is, 0x14 is also unmuted.
>
> The logic is a bit complex, and thus I suggested to replace with
> vmaster.
>
> > > Maybe a cleaner fix is to remove the bind_sw and bind_vol hacks and
> > > use vmaster instead.
> >
> > Is there example code I can look at please?
>
> Add the individual mixer elements corresponding to HP, dock and
> PC-speaker switches instead of hackish master switch. Then a virtual
> master switch will be automatically created.
>
> I'll create a test patch soon later...
On the second thought, it's also not so trivial in this case because
of the combination with the jack detection code.
How about the patch below?
Note that the mute bits of 0x14 and 0x1b follow only to the state of
master switch. It's on/off regardless of jack detection. Only the
internal speaker is affected via jack-detection.
Takashi
---
diff -r e2b60934d1c8 pci/hda/patch_realtek.c
--- a/pci/hda/patch_realtek.c Mon May 19 12:32:25 2008 +0200
+++ b/pci/hda/patch_realtek.c Mon May 19 12:54:26 2008 +0200
@@ -8757,35 +8757,39 @@
},
};
-/* 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;
unsigned int mute;
if (force || !spec->sense_updated) {
- unsigned int present_int_hp, present_dock_hp;
+ unsigned int present;
/* need to execute and sync at first */
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);
- 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);
- spec->jack_present = (present_int_hp & 0x80000000) != 0;
- spec->jack_present |= (present_dock_hp & 0x80000000) != 0;
+ /* check laptop HP jack */
+ present = snd_hda_codec_read(codec, 0x14, 0,
+ AC_VERB_GET_PIN_SENSE, 0);
+ /* need to execute and sync at first */
+ snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
+ /* check docking HP jack */
+ present |= snd_hda_codec_read(codec, 0x1b, 0,
+ AC_VERB_GET_PIN_SENSE, 0);
+ if (present & AC_PINSENSE_PRESENCE)
+ spec->jack_present = 1;
+ else
+ spec->jack_present = 0;
spec->sense_updated = 1;
}
- if (spec->jack_present) {
- /* mute internal speaker */
- snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
- HDA_AMP_MUTE, HDA_AMP_MUTE);
- } else {
- /* unmute internal speaker if necessary */
+ /* unmute internal speaker only if both HPs are unplugged and
+ * master switch is on
+ */
+ if (spec->jack_present)
+ mute = HDA_AMP_MUTE;
+ else
mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
- snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
- HDA_AMP_MUTE, mute);
- }
+ snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
+ HDA_AMP_MUTE, mute);
}
/* unsolicited event for HP jack sensing */
@@ -8794,6 +8798,11 @@
{
if ((res >> 26) != ALC_HP_EVENT)
return;
+ alc262_fujitsu_automute(codec, 1);
+}
+
+static void alc262_fujitsu_init_hook(struct hda_codec *codec)
+{
alc262_fujitsu_automute(codec, 1);
}
@@ -9570,6 +9579,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 },
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-05-19 11:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-19 0:00 [ALC262_FUJITSU patch_realtek.c] Use jack sense for both headphone outputs Tony Vroon
2008-05-19 10:23 ` Takashi Iwai
2008-05-19 10:31 ` Tony Vroon
2008-05-19 10:37 ` Takashi Iwai
2008-05-19 10:56 ` Takashi Iwai
2008-05-19 11:33 ` Tony Vroon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.