Linux audio - only speakers or microphone available, not both

Updated: January 29, 2021

Here's a rather interesting problem I've encountered recently. I bought myself a new laptop, Lenovo IdeaPad 3, primary for testing different Linux distributions. As part of my initial setup, I encountered a weird issue with the audio system in Kubuntu. Namely, I could play sound, but there was no microphone - or I could record sound with the microphone but there would be no output, either through speakers or headphones.

This infuriated me quite a bit - because there was no such issue in Windows 10 in the laptop's temporary triple-boot configuration. So I started a long and seemingly wild chase, trying to resolve this. The hunt led me into dozens of forums, discussing similar and related problems. Most of them seem to focus on newer Lenovo laptop models. I wanted to use this opportunity to write a little tutorial, which will hopefully help you, should you encounter this problem, get simultaneous playback and microphone in your Linux desktop session(s). After me, Tuxers.

Teaser

Problem in more detail

Anyway. I had Kubuntu running, so far so good. I was able to play music and videos, no issue, either. Then, I clicked on the volume icon in the system area, and I noticed only one device was listed - Speakers. There was no microphone slider, the way I'm typically used to seeing in this or that Linux desktop, regardless of the specific choice of the work environment.

Indeed, this was no fluke. There was no microphone (seemingly). I installed and launched Audacity, and then tried to record myself. There was nothing. At a first glance, the laptop either did not have a microphone, the hardware was busted, or the Linux distro was using a wrong driver, which did not support all the necessary sound card features.

It turned out - none of these were correct.

PulseAudio configuration

I eliminated the hardware issues right away - audio was all good in Windows 10. So I felt, maybe the driver is all wrong. To check this, I launched the PulseAudio utility, and checked the configuration. And then I noticed something rather interesting. For the listed hardware, there were only two profiles available: Stereo Output and Analogue Stereo Input. If I switched them, I'd have either playback or microphone but not both at the same time.

Only input or putput profile

What didn't work

At this point, I spent the whole lot of time searching and searching some more. For your sake, here's a list of several things I tried - so you can consider them, and if needed, discard them:

Solution

The experience above me taught me one primary thing - how wild and complex the audio subsystem is in Linux, and for no good reason. There are tons of configuration files and options, and they are all utterly nerdy in their nature. Eventually, I did find a great resource on the Archlinux Wiki, which finally helped me unblock my problem. So in a way, massive kudos to the forum users for their work.

The idea is to create a new PulseAudio profile, which allows for simultaneous input and output.

Step 1: check the list of your audio devices

There are multiple ways you can do this. You can list your hardware with lspci, and also use the PulseAudio command-line utility pacmd:

sudo lspci -knn | grep Audio -A3
03:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Raven/Raven2/Fenghuang HDMI/DP Audio Controller [1002:15de]
    Subsystem: Lenovo Raven/Raven2/Fenghuang HDMI/DP Audio Controller [17aa:3805]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel
03:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) Platform Security Processor [1022:15df]
--
03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2]
    Subsystem: Lenovo Raven/Raven2/FireFlight/Renoir Audio Processor [17aa:3807]
    Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x
03:00.6 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller [1022:15e3]
    Subsystem: Lenovo Family 17h (Models 10h-1fh) HD Audio Controller [17aa:3809]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '
name: <alsa_output.pci-0000_03_00.6.analog-stereo>
alsa.subdevice = "0"
alsa.device = "0"

The two commands can help you identify the exact PCI bus number and the device number attacked to the bus. We will need this information for the new PulseAudio profile. On my laptop, the audio device we want - the HD Audio Controller (not the HDMI/DP Audio Controller) is located on domain 0000, bus 03, slot 00, function 6.

Step 2: Change the audio configuration

Open /etc/pulse/default.pa in a text editor, as root or sudo. Create a backup of this file first. At the beginning of the file, under the generic file description comments, paste the following snippet of code, so it sits above the other configuration directives:

### Load analog device
load-module module-alsa-sink device=hw:X,Y
load-module module-combine-sink sink_name=combined
set-default-sink combined

Where X is the card and Y is the device. In my case, this maps to X = 0, Y = 3.

### Load analog device
load-module module-alsa-sink device=hw:0,3
load-module module-combine-sink sink_name=combined
set-default-sink combined

At this point, the easiest thing is to simply reboot the system.

Step 3: Check configuration and select new profile

Once the machine restarts, in your Linux distribution, launch the PulseAudio configuration tool, and select the last (Configuration) tab. Expand the drop down list of profiles. You will now notice that there are many more available profiles, in addition to the two default ones. Select Stereo Output + Analogue Stereo Input.

New profile available

Launch an application that can both play sound and record audio - Audacity is a good example. And now, you will notice that you have both functionalities available at the same time, and your problem is resolved.

Audio works correctly now

Conclusion

Here we go. I am happy to have fixed the issue, but I am terribly disappointed that this kind of problem can or should occur in 2021. You might be inclined to blame hardware, and you might even search for specific audio issues with the AMD Raven/Raven2 Audio Processor, which could be a good indicative starting point. But in the end, it's not hardware stuff we ought to blame. I do not know why the PulseAudio configuration should be any different for this particular card on this distro, but in any case, you have this tutorial, so hopefully things will be all jolly from now on.

If you're facing audio issues on your Linux laptop, try to debug your problem methodically. Does the audio work correctly in other operating systems? Does the audio work selectively in your distro? If so, do you have the right kind of configuration in place? Use the lspci and pacmd commands to try to figure out what's wrong, and then, you're far more likely to zero in on the right configuration changes for the audio subsystem. In my case, it was the "simple" matter of creating a new PulseAudio profile. Once again, big thanks to the ArchLinux Wiki folks. Party on, fellas.

Cheers.