You are not logged in.

#1 2024-07-01 20:58:48

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 326

Dell Latitude 5400 switch to headset mic when plugged

Pulseaudio doesn't switch Built-in Audio Analog Stereo input port to "Headset microphone" when headset is plugged in.
I've read many topics regarding similar problem here and in other forums, but no solution worked for me.

The mic itself works fine and i can use it by switching from "Internal Microphone" to "Headset Microphone" in pavucontrol Input Devices manually (of course, with pactl as well). But i'd like it to be switched automatically after headset is plugged in.
Output Device is switched from "Speakers" to "Headphones", as desired.

I'm not sure whether this is ALSA or pulseaudio issue. When headset is not plugged, Port in pavucontrol Input Devices tab dropdown list is named "Headset Microphone (unplugged)", also there is "Microphone (unplugged)".
When headset is plugged, it is immediately renamed to "Headset Microphone" (and also "Microphone") right in dropdown list. So pulseaudio detects microphone presence, but doesn't switch to it.

Difference in `pactl list` output ('-': unplugged, '+': plugged):

        Ports:
                analog-output-speaker: Speakers (type: Speaker, priority: 10000, availability unknown)
-               analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 2, not available)
-       Active Port: analog-output-speaker
+               analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 2, availability unknown)
+       Active Port: analog-output-headphones
...
        Ports:
                analog-input-internal-mic: Internal Microphone (type: Mic, priority: 8900, availability unknown)
-               analog-input-headphone-mic: Microphone (type: Mic, priority: 8700, availability group: Legacy 2, not available)
-               analog-input-headset-mic: Headset Microphone (type: Headset, priority: 8800, availability group: Legacy 2, not available)
+               analog-input-headphone-mic: Microphone (type: Mic, priority: 8700, availability group: Legacy 2, availability unknown)
+               analog-input-headset-mic: Headset Microphone (type: Headset, priority: 8800, availability group: Legacy 2, availability unknown)
...
        Ports:
                analog-input-internal-mic: Internal Microphone (type: Mic, priority: 8900, latency offset: 0 usec, availability unknown)
                        Properties:
                                device.icon_name = "audio-input-microphone"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-surround+input:analog-stereo, output:hdmi-surround71+input:analog-stereo, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1+input:analog-stereo, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2+input:analog-stereo
-               analog-input-headphone-mic: Microphone (type: Mic, priority: 8700, latency offset: 0 usec, availability group: Legacy 2, not available)
+               analog-input-headphone-mic: Microphone (type: Mic, priority: 8700, latency offset: 0 usec, availability group: Legacy 2, availability unknown)
                        Properties:
                                device.icon_name = "audio-input-microphone"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-surround+input:analog-stereo, output:hdmi-surround71+input:analog-stereo, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1+input:analog-stereo, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2+input:analog-stereo
-               analog-input-headset-mic: Headset Microphone (type: Headset, priority: 8800, latency offset: 0 usec, availability group: Legacy 2, not available)
+               analog-input-headset-mic: Headset Microphone (type: Headset, priority: 8800, latency offset: 0 usec, availability group: Legacy 2, availability unknown)
                        Properties:
                                device.icon_name = "audio-input-microphone"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-surround+input:analog-stereo, output:hdmi-surround71+input:analog-stereo, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1+input:analog-stereo, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2+input:analog-stereo
                analog-output-speaker: Speakers (type: Speaker, priority: 10000, latency offset: 0 usec, availability unknown)
                        Properties:
                                device.icon_name = "audio-speakers"
                        Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo
-               analog-output-headphones: Headphones (type: Headphones, priority: 9900, latency offset: 0 usec, availability group: Legacy 2, not available)
+               analog-output-headphones: Headphones (type: Headphones, priority: 9900, latency offset: 0 usec, availability group: Legacy 2, availability unknown)
                        Properties:
                                device.icon_name = "audio-headphones"

The same for `pacmd list sources`:

        ports:
                analog-input-internal-mic: Internal Microphone (priority 8900, latency offset 0 usec, available: unknown)
                        properties:
                                device.icon_name = "audio-input-microphone"
-               analog-input-headphone-mic: Microphone (priority 8700, latency offset 0 usec, available: no)
+               analog-input-headphone-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
                        properties:
                                device.icon_name = "audio-input-microphone"
-               analog-input-headset-mic: Headset Microphone (priority 8800, latency offset 0 usec, available: no)
+               analog-input-headset-mic: Headset Microphone (priority 8800, latency offset 0 usec, available: unknown)
                        properties:
                                device.icon_name = "audio-input-microphone"
        active port: <analog-input-internal-mic>

Codec detection in dmesg:

$ dmesg | grep snd_hda
[   26.163839] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[   26.164100] snd_hda_intel 0000:00:1f.3: enabling device (0000 -> 0002)
[   26.164575] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[   26.272376] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC3204: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[   26.272383] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   26.272385] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[   26.272387] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[   26.272388] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[   26.272389] snd_hda_codec_realtek hdaudioC0D0:      Headset Mic=0x19
[   26.272390] snd_hda_codec_realtek hdaudioC0D0:      Headphone Mic=0x1a
[   26.272392] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12

/etc/pulse/default.pa:

.fail
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
load-module module-augment-properties
load-module module-switch-on-port-available

.ifexists module-udev-detect.so
load-module module-udev-detect
.else
load-module module-detect
.endif

.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy auto_switch=0
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

load-module module-dbus-protocol
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif

load-module module-default-device-restore
load-module module-always-sink
load-module module-intended-roles
load-module module-suspend-on-idle

.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

load-module module-position-event-sounds
load-module module-role-cork
load-module module-filter-heuristics
load-module module-filter-apply

.nofail
.include /etc/pulse/default.pa.d

/etc/pulse/system.pa:

load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

.ifexists module-udev-detect.so
load-module module-udev-detect
.else
load-module module-detect
.endif

.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

load-module module-default-device-restore
load-module module-always-sink
load-module module-suspend-on-idle
load-module module-position-event-sounds

.nofail
.include /etc/pulse/system.pa.d

`alsactl monitor` output during plug-in:

node hw:0, #15 (0,0,0,Headphone Mic Jack,0) VALUE
node hw:0, #3 (2,0,0,Speaker Playback Volume,0) VALUE
node hw:0, #3 (2,0,0,Speaker Playback Volume,0) VALUE
node hw:0, #1 (2,0,0,Headphone Playback Volume,0) VALUE
node hw:0, #1 (2,0,0,Headphone Playback Volume,0) VALUE
node hw:0, #13 (2,0,0,Master Playback Switch,0) VALUE
node hw:0, #2 (2,0,0,Headphone Playback Switch,0) VALUE
node hw:0, #2 (2,0,0,Headphone Playback Switch,0) VALUE
node hw:0, #12 (2,0,0,Master Playback Volume,0) VALUE
node hw:0, #41 (2,0,0,PCM Playback Volume,0) VALUE

and during plug-out:

node hw:0, #15 (0,0,0,Headphone Mic Jack,0) VALUE
node hw:0, #2 (2,0,0,Headphone Playback Switch,0) VALUE
node hw:0, #2 (2,0,0,Headphone Playback Switch,0) VALUE
node hw:0, #1 (2,0,0,Headphone Playback Volume,0) VALUE
node hw:0, #1 (2,0,0,Headphone Playback Volume,0) VALUE
node hw:0, #4 (2,0,0,Speaker Playback Switch,0) VALUE
node hw:0, #4 (2,0,0,Speaker Playback Switch,0) VALUE
node hw:0, #3 (2,0,0,Speaker Playback Volume,0) VALUE
node hw:0, #3 (2,0,0,Speaker Playback Volume,0) VALUE
node hw:0, #12 (2,0,0,Master Playback Volume,0) VALUE
node hw:0, #41 (2,0,0,PCM Playback Volume,0) VALUE
node hw:0, #13 (2,0,0,Master Playback Switch,0) VALUE
node hw:0, #4 (2,0,0,Speaker Playback Switch,0) VALUE

I tried tons of fixups and their combinations for snd_intel_hda model parameter found in sound/pci/hda/patch_realtek.c, none worked. Unfortunatelly, it's quite hard to try all of them.

Offline

#2 2024-07-02 14:15:58

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,120

Re: Dell Latitude 5400 switch to headset mic when plugged

What are your relevant ALSA controls?

aplay -lL
amixer -c0

sometimes this is a driver level switch, assuming you are currently not loading a custom model parameter so we get the default view.

Offline

#3 2024-07-02 15:31:31

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 326

Re: Dell Latitude 5400 switch to headset mic when plugged

V1del wrote:

What are your relevant ALSA controls?

$ aplay -lL
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=PCH
    HDA Intel PCH, ALC3204 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    Front output / input
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3204 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
hdmi:CARD=PCH,DEV=2
    HDA Intel PCH, HDMI 2
    HDMI Audio Output
usbstream:CARD=PCH
    HDA Intel PCH
    USB Stream Output
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3204 Analog [ALC3204 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ amixer -c0
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 55 [63%] [-24.00dB] [off]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 0 [0%] [-65.25dB] [off]
  Front Right: Playback 0 [0%] [-65.25dB] [off]
Simple mixer control 'Headphone Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [off]
Simple mixer control 'Headphone Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 254 [100%] [-0.20dB]
  Front Right: Playback 254 [100%] [-0.20dB]
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'IEC958',1
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',2
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 63
  Front Left: Capture 58 [92%] [26.25dB] [on]
  Front Right: Capture 58 [92%] [26.25dB] [on]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Headset Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [off]
Simple mixer control 'Headset Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Internal Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [on]
Simple mixer control 'Internal Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
V1del wrote:

sometimes this is a driver level switch, assuming you are currently not loading a custom model parameter so we get the default view.

Currently no parameters passed to snd_hda_intel:

$ cd /sys/module/snd_hda_intel/parameters/ && grep -H '' *
align_buffer_size:-1
bdl_pos_adj:-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
beep_mode:N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
ctl_dev_id:N
dmic_detect:Y
enable:Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
enable_msi:-1
id:(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
index:-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
jackpoll_ms:0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
model:(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
patch:(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
pm_blacklist:Y
position_fix:-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
power_save:10
power_save_controller:Y
probe_mask:-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
probe_only:0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
single_cmd:-1
snoop:-1

Offline

#4 2024-07-02 21:34:03

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 326

Re: Dell Latitude 5400 switch to headset mic when plugged

"hdajacksensetest" from alsa-tools for unplugged and plugged states:

# hdajacksensetest
Pin 0x21 (Black Headphone, Front side): present = No
# hdajacksensetest
Pin 0x21 (Black Headphone, Front side): present = Yes

Some output from "pulseaudio --log-level=debug" after plugging in:

D: [pulseaudio] module-switch-on-port-available.c: Not switching to input port analog-input-headphone-mic, its availability is unknown.
D: [pulseaudio] device-port.c: Setting port analog-input-headset-mic to status unknown
...
D: [pulseaudio] module-switch-on-port-available.c: Not switching to input port analog-input-headset-mic, its availability is unknown.

And from module-switch-on-port-available.c:

   case PA_AVAILABLE_UNKNOWN:
        /* If a port availability became unknown, let's see if it's part of
         * some availability group. If it is, it is likely to be a headphone
         * jack that does not have impedance sensing to detect whether what was
         * plugged in was a headphone, headset or microphone. In desktop
         * environments that support it, this will trigger a user choice to
         * select what kind of device was plugged in. However, let's switch to
         * the headphone port at least, so that we have don't break
         * functionality for setups that can't trigger this kind of
         * interaction.
         *
         * For headset or microphone, if they are part of some availability group
         * and they become unknown from off, it needs to check if their source is
         * unlinked or not, if their source is unlinked, let switch_to_port()
         * process them, then with the running of pa_card_set_profile(), their
         * source will be created, otherwise the headset or microphone can't be used
         * to record sound since there is no source for these 2 ports. This issue
         * is observed on Dell machines which have multi-function audio jack but no
         * internal mic.
         *
         * We should make this configurable so that users can optionally
         * override the default to a headset or mic. */
...
        /* Switch the headphone port, the input ports without source and the
         * input ports their source->active_port is part of a group of ports.
         */
        if (port->direction == PA_DIRECTION_INPUT && pp.source && !pp.source->active_port->availability_group) {
            pa_log_debug("Not switching to input port %s, its availability is unknown.", port->name);
            break;
        }

        switch_to_port(port, pp);
...

As i understand, there should be some configurable "availability groups" of ports. Maybe something to customize in /usr/share/pulseaudio/alsa-mixer/ ?

Offline

Board footer

Powered by FluxBB