alsa-mixer: enable the alsa auto-mute if headphone is the active port

After applying the commit 19e34d8d5b, the speakers could be set to
active port and could output sound when headphone is plugging in. But
it introduced a regression on some old machines, on them there are
only one mute and one volume control shared between speakers and
headphone, pulseaudio can't mute the speaker standalone when the
headphone is playing sound. In such a case, it needs to count on
alsa auto-mute to mute the speaker by setting pinctl to 0x0.

To fix this regression and meanwhile not to impact the fix of the
commit 19e34d8d5b, Boris proposed a good idea in the issues#1297,
based on that idea, I wrote this patch and validated it on a physical
machine:
 - After booting up, the speaker is the active output port, in this
   case, the auto-mute is disabled and speakers' Pin-ctls: 0x40: OUT
 - plugging a headphone, the headphone is the active output port, in
   this case, the auto-mute is enabled and speakers' Pin-ctls: 0x00:
 - keeping headphone plugged, use pacmd to change the active port to
   speaker, the auto-mute becomes disabled and speakers' Pin-ctls:
   0x40: OUT

BTW, the patch will not bring any impact to the systems using the ucm
in pulseaudio, that is to say, it will not impact most modern laptops.

Thanks to Boris Gjenero to propose the idea of the fix.

Fixes: 19e34d8d5b ("alsa-mixer: disable the Auto-Mute once the system has speaker")
Closes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1297
Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
Hui Wang 2024-04-17 09:25:56 +08:00
parent 6c77b0191a
commit 749d5960a5
2 changed files with 8 additions and 1 deletions

View file

@ -177,4 +177,11 @@ volume = off
switch = off
volume = off
; Make sure the auto-mute becomes enabled if headphone is selected to be the active output port
[Element Auto-Mute Mode]
enumeration = select
[Option Auto-Mute Mode:Enabled]
name = analog-output-headphones
.include analog-output.conf.common

View file

@ -88,7 +88,7 @@ override-map.2 = all-left,all-right
switch = off
volume = off
; Make sure the internal speakers are not auto-muted once the system has speakers
; Make sure the auto-mute is disabled if the speakers are selected to be the active output port
[Element Auto-Mute Mode]
enumeration = select