You are not logged in.

#1 2013-03-23 23:12:06

fax
Member
Registered: 2013-01-07
Posts: 16

[SOLVED] Alsa: How to disable auto-mute when plugging in headphones?

I have a set of headphones plugged into my workstation permanently (the headphone jack is hard to reach so I don't want to plug those headphones in and out) as well as some speakers. Jack sensing works perfectly - when I unplug the headphones, the speakers are unmuted and when I plug the headphones back in the speakers are muted. Now as I said, my headphones are plugged in permanently and occasionally I want to have sound on the speakers at the same time. So far I have not found a way to have both headphones and speakers unmuted simultaneously.

I originally thought this was a problem with Pulseaudio (I am using Cinnamon as my desktop) but when I directly go to the Alsa hw device I get exactly the same behavior. The sound chip is a built-in VIA VT1818S and aplay displays the correct cards and devices:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: VT1818S Analog [VT1818S Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: VT1818S Digital [VT1818S Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 2: VT1818S HP [VT1818S HP]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
...

I verified with "mpg123 -a hw:0,0" that I get no sound on the speakers when the headphones are plugged in and vice versa. I tried a lot of different settings with alsamixer and amixer to no avail. These are my current settings:

$ amixer -c 0 contents
numid=42,iface=CARD,name='Front Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=44,iface=CARD,name='Front Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=46,iface=CARD,name='HDMI Phantom Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=45,iface=CARD,name='Line Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=40,iface=CARD,name='Line Out CLFE Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=38,iface=CARD,name='Line Out Front Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=41,iface=CARD,name='Line Out Side Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=39,iface=CARD,name='Line Out Surround Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=43,iface=CARD,name='Rear Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=47,iface=CARD,name='SPDIF Phantom Jack',index=1
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=37,iface=MIXER,name='Master Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=36,iface=MIXER,name='Master Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=42,step=0
  : values=23
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=13,iface=MIXER,name='Headphone Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=12,iface=MIXER,name='PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=11,iface=MIXER,name='PCM Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=31,31
  | dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=28,iface=MIXER,name='Front Mic Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=0,0
  | dBscale-min=0.00dB,step=10.25dB,mute=0
numid=24,iface=MIXER,name='Front Mic Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=23,iface=MIXER,name='Front Mic Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=31,31
  | dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=2,iface=MIXER,name='Front Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Front Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=42,step=0
  : values=42,42
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=4,iface=MIXER,name='Surround Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=3,iface=MIXER,name='Surround Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=42,step=0
  : values=42,42
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=6,iface=MIXER,name='Center Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=5,iface=MIXER,name='Center Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=42,step=0
  : values=42
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=8,iface=MIXER,name='LFE Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=7,iface=MIXER,name='LFE Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=42,step=0
  : values=42
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=26,iface=MIXER,name='Line Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=25,iface=MIXER,name='Line Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=31,31
  | dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=16,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=18,iface=MIXER,name='Capture Switch',index=1
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=15,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=0,0
  | dBscale-min=-16.50dB,step=1.50dB,mute=0
numid=17,iface=MIXER,name='Capture Volume',index=1
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=0,0
  | dBscale-min=-16.50dB,step=1.50dB,mute=0
numid=14,iface=MIXER,name='Loopback Mixing'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'Disabled'
  ; Item #1 'Enabled'
  : values=0
numid=35,iface=MIXER,name='IEC958 Default PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=31,iface=MIXER,name='IEC958 Playback Con Mask'
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=32,iface=MIXER,name='IEC958 Playback Pro Mask'
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=33,iface=MIXER,name='IEC958 Playback Default'
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=34,iface=MIXER,name='IEC958 Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=30,iface=MIXER,name='Dynamic Power-Control'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'Disabled'
  ; Item #1 'Enabled'
  : values=0
numid=29,iface=MIXER,name='Independent HP'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'OFF'
  ; Item #1 'ON'
  : values=0
numid=19,iface=MIXER,name='Input Source'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Rear Mic'
  ; Item #1 'Front Mic'
  ; Item #2 'Line'
  ; Item #3 'Stereo Mixer'
  : values=1
numid=20,iface=MIXER,name='Input Source',index=1
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Rear Mic'
  ; Item #1 'Front Mic'
  ; Item #2 'Line'
  ; Item #3 'Stereo Mixer'
  : values=0
numid=27,iface=MIXER,name='Rear Mic Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=0,0
  | dBscale-min=0.00dB,step=10.25dB,mute=0
numid=22,iface=MIXER,name='Rear Mic Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=off,off
numid=21,iface=MIXER,name='Rear Mic Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=23,23
  | dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=10,iface=MIXER,name='Side Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=9,iface=MIXER,name='Side Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=42,step=0
  : values=42,42
  | dBscale-min=-63.00dB,step=1.50dB,mute=0
numid=49,iface=PCM,name='Capture Channel Map'
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

numid=50,iface=PCM,name='Capture Channel Map',index=1
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

numid=48,iface=PCM,name='Playback Channel Map'
  ; type=INTEGER,access=r----R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (257, 8, 0)!

numid=51,iface=PCM,name='Playback Channel Map',device=1
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

numid=52,iface=PCM,name='Playback Channel Map',device=2
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

If I read the Alsa kernel docs right, the VIA driver simply does not provide any option to disable auto-muting: http://git.alsa-project.org/?p=alsa-ker … xt;hb=HEAD.

I would be glad if I had misread/misunderstood something or there were any other means of achieving what I am after? All I found so far is lots of posts where auto-muting did not work but very few people seem to want the opposite. FWIW, my old installation of Ubuntu 11.10 was working fine in that regard, i.e. it probably did not support auto-muting for my hardware.

Last edited by fax (2013-03-24 20:20:19)

Offline

#2 2013-03-24 20:20:01

fax
Member
Registered: 2013-01-07
Posts: 16

Re: [SOLVED] Alsa: How to disable auto-mute when plugging in headphones?

Solved, well, good enough for me anyway. In alsamixer, I enabled "Independent HP". Independent HP means that two of the six surround channels get diverted to the headphones. Alsa creates a second device, one for line out and the other one for the headphones. It is a very neat feature that is meant to allow you to e.g. do a voice call with your headphones while you play music through the speakers at the same time. I can now choose in PulseAudio whether I want output to my headphones or the speakers. It required that in /etc/pulse/default.pa, I added the line "load-module module-alsa-sink device=hw:0,2" after this paragraph:

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

# Take Independent HP into use.
load-module module-alsa-sink device=hw:0,2

All this really is a work-around for two bugs:

  • Call it a bug or a missing feature, but it does not look like the Alsa snd_hda_codec_via driver allows to disable auto-muting.

  • Before the change to default.pa, PulseAudio already allows me to switch between two output devices - "analog output" and "analog headphones". "Analog headphones" however does the same thing as "analog output" and plays sound on the external speakers and not the headphones. I suspect that the PulseAudio module-udev-detect detects both Alsa devices but wires them wrongly.

The above still doesn't give me what I originally asked, i.e. sound on both speakers and headphones at the same time, but I realized that I don't really need that. I just need a way to switch on speakers occasionally while my headphones are plugged in.

Last edited by fax (2013-03-24 23:06:27)

Offline

#3 2013-03-24 20:40:05

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Alsa: How to disable auto-mute when plugging in headphones?

Try poking around with hda-verb.

Offline

#4 2013-03-26 12:17:20

fax
Member
Registered: 2013-01-07
Posts: 16

Re: [SOLVED] Alsa: How to disable auto-mute when plugging in headphones?

Thanks, that is a tool I wasn't aware of. I had looked at a similar tool, whose name evades me right now, and discarded it because my PulseAudio hack has the added benefit that I can use all the usual Gnome/Cinnamon knobs and buttons to configure and switch audio devices.

Offline

Board footer

Powered by FluxBB