motorola-harpia: no speaker/mic audio in phosh. Race condition suspected.
Describe your issue
What's the expected behaviour?
When I restart my device, I would like to have speakers and mic audio working, as well as modem.
What's the current behaviour?
PMOS installs fine in my Moto G4 Play device ("motorola-harpia").
At the first boot, I need to change the selected pulseaudio device in order to get sound working, because the default selected device is a headset that is not connected: I change it to "speaker" for output, and "primary mic" for input, and audio works fine. This is the case for both phosh and plasma-mobile.
However, when using phosh (the UI I want to use), after restarting the phone, speaker/mic audio is gone, even with the proper pulseaudio device selected. This is not the case in plasma-mobile, where audio survives restarts. So, first suspect: something phosh related. But there are more details.
First of all, I insist with stating "speaker/mic", as I can actually connect a bluetooth headset and it works normally: while this problem is live, I do have audio using other audio devices. I believe this, added to the plasma-mobile detail, means pulseaudio is not part of the problem.
Secondly, there's a previous problem. During my first attemps at using pmos, I had no modem. I went to the matrix channels for help, and somebody there told me to restart modemmanager, which actually worked. Right now, I have to run sudo rc-service modemmanager restart
after every reboot to get my modem online. That happens on both phosh and plasma-mobile. I don't understand the details, but as I have a quick workaround, I can live with that.
That modemmanager things seems unrelated, until other details are involved. This device uses some kernel modules that passes audio through modem. During pmbootstrap
installation, the proccess asks me for some "providers", where I select the "all" option; other options are "no modem", and more restrictions like "also no wifi". With the "all" selection, the file /boot/lk2nd_rproc_mode
in the resulting system has the all
value. But if I change that to the no-modem
value and reboot, I actually have audio working without having to do anything else. Of course, I also have no modem, which is not acceptable. But this shows a strong relationship between the modem and the audio, and that's where the other modemmanager problems becomes relevant.
So, to recap:
- For some reason, I have to restart modemmanager service. After restarting it, stays stable until next reboot.
- First boot after fresh install, I have "speaker/mic" audio in phosh, right after selecting the proper pulseaudio device in system configurations. But after restarting the device, even with that pulseaudio configuration, there's no "speaker/mic" audio anymore. And this is not the case in plasma-mobile.
- If I set
no-modem
in the/boot/lk2nd_rproc_mode
file, and then restart the device, phosh has "speaker/mic" audio without any other action required.
My analysis:
- Given that it doesn't happen on plasma-mobile, I must conclude it's related to some phosh architecture detail.
- Given that the audio device and module actually works, looks like some kind of boot-related configuration.
- Given that disabling modem in lk2nd restores audio, seems like the modem is strongly related.
- Given that other modemmanager issue (first time it runs at boot it stops, but then I restart it and works fine) looks like some kind of race condition where modemmanager needs some other stuff running before being able to be stable.
- With all this in mind, I suspect there's a second race condition between audio and the modem status, present only in phosh (or at least not present in plasma-mobile).
I lack knowledge of the involved systems in order to debug more. But I suspect some timing or relationship between services starts could be part of a workaround or even a fix.
You can see some chat about the issue, here: https://matrix.to/#/!zpvMifoucHSiUsVFgl:postmarketos.org/$r39F9PMi8bY2jHTLX7_OTdkhUnQkSjaLF2TvmcTb47w?via=matrix.org&via=kde.org&via=tchncs.de In there, you will also find dmesg logs and other details.
How to reproduce your issue?
- Install pmos with phosh and the
all
provider in a motorola-harpia device. - After it boots the first time, restart modemmanager to get modem online, and configure the selected pulseaudio device in system settings to "speaker" instead of "headset". Test the audio (using the option in system settings), and should be working (only one side, as the speaker is mono).
- Restart the system. After that, audio is gone, no matter if you restart or not modemmanager.
What device are you using?
motorola-harpia ("Moto G4 Play")
On what postmarketOS version did you encounter the issue?
-
edge ( master
branch) -
v22.06
(supported until 2023-01-18) -
v22.12
-
I confirm that the issue still is present after running sudo apk upgrade -a
On what environment did you encounter the issue?
Environments
-
Phosh -
Plasma Mobile (partially: modem problem is there, audio problem is not) -
Sxmo (Wayland/Sway) Please post the output of sxmo_version.sh
-
Other: Please fill out
How did you get postmarketOS image?
-
from https://images.postmarketos.org -
I built it using pmbootstrap -
It was preinstalled on my device
What's the build date of the image? (in yyyy-mm-dd format)
2023-02-20 (or later, can't remeber exactly the last install date; but it was a week ago from now at max)
Additional information
Here are several logs: 4 of them are dmesgs in different situations that I collected about a week ago, and the other 3 are audio related and collected today while receiving help on the matrix channel. The file names should be self descriptive.
20230220.dmesg.after_installing_with_audio_and_modemmanager_off.log
20230220.dmesg.after_installing_with_audio_and_modemmanager_on.log
20230220.dmesg.after_restart_with_no_audio_and_modemmanager_off.log
20230220.dmesg.after_restart_with_no_audio_and_modemmanager_on.log