I will try to summarize here all things I had to go through to make this work on Gentoo, but it will be very similar for all other distributions with PulseAudio.
1. Bluetooth adapter model
Not every adapter supports HSP/HFP profiles. Find the model of your bluetooth adapter with lsusb
and search on the internet which profiles it supports. If your bluetooth adapter is very old, it more likely doesn't support HSP/HFP.
2. Kernel configuration and bluetooth service
This is Gentoo and maybe Arch specific. Those things are usually already configured and working fine on common distributions.
Go through a Bluetooth article on Gentoo wiki.
It took me a moment to realize what was happening here. My bluetooth device paired and connected to the computer just fine, but nothing from the audio sharing was working. Not even the basic A2DP profile. Then I found out that some unconfigured and unwanted instance of PipeWire was running and probably stealing bluetooth devices from PulseAudio. In this case either disable PipeWire completely or configure it properly to fully replace the PulseAudio server and skip the next step.
Without ofono only the A2DP profile will work. HSP/HFP profile can maybe appear but it will be marked as unavailable in pavucontrol
.
On other distributions make sure you have installed ofono package and pulseaudio bluetooth modules.
On Gentoo compile PulseAudio with ofono-headset
use-flag. It will install net-misc/ofono
package as a dependency. Then you have to start ofono service.
With OpenRC: rc-service ofono start
To make it persistent: rc-update add ofono default
Make sure your PulseAudio default.pa config contains loading of bluetooth modules:
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
Then restart PulseAudio: pulseaudio -k
5. Bluetooth firmware
This was also my case. My adapter looked like it was working fine, since I could pair it with my phone, play music from the phone, etc. But when I switched to HSP/HFP profile, both audio streams were silent. Then I came across this documentation and noticed my adapter model is mentioned there.
I had to install firmware as described in Broadcom Bluetooth article on Gentoo wiki.