New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hdmi audio: switch audio HAL module from tinyalsa to alsa #1
fix hdmi audio: switch audio HAL module from tinyalsa to alsa #1
Conversation
Thank you for this PR. :) This is actually one of the few options I've considered. This looks fine for most parts. Few quick thoughts/ideas:
I have some other things going on so it might take a while until get around to all this but I'm sure I will eventually. Thanks again for your contribution! |
I'll look into that if I find time in the next days. Thanks for the pointer to
Yes that's the part that scared me off. In alsa-lib the No idea how one would port that so soong. Soong does support generated headers somehow: see
Either you do that yourself when merging this PR or you need give me a pointer to where that happens. Sometimes it's really hard to find all these inter-dependencies... |
Yeah, it will require a reboot. I don't consider that too much of an issue as I don't think people generally need to switch between audio devices that often.
Also probably not too much of an issue to generate it once and just stick the generated header somewhere in the source. I doubt I'll be updating the alsa-lib anytime soon so it won't be changing either.
https://github.com/raspberry-vanilla/android_kernel_brcm_rpi4/blob/android-13.0/arch/arm64/configs/lineageos_rpi4_defconfig#L4030 to |
I tried using a
Implemented that now. Here are the properties (like in the wiki) you would need to set (in your settings app) when switching audio outputs: audio jack:
HDMI0:
HDMI1:
DAC:
To set the ro properties I used:
As you said requires a reboot afterwards... Also you still need to toggle that |
Thank you. :) I updated the PR with few of my nitpicks:
I tested this and this seems to work well. If this still looks fine for you, I'll merge this sometime next week. Still some TODOs but I can manage this:
|
Just tested it - LGTM |
Hi @KonstaT
I read what you said about, why HDMI audio was not properly working, so I started digging a bit.
The current
alsa_loop
solution uses alsa-lib to do the IEC958 subframe conversion (via pcm_iec958.c).However, the audio HAL module in
audio_hw.c
already uses tinyalsa, so I though why not do it directly.The reason why android seems to use tinyalsa instead of full alsa seems to be GPL license stuff and maybe size(?).
But thanks to raspberry-vanilla/android_external_alsa-lib we already have alsa-lib in our build.
The only big task was to port
audio_hw.c
from tinyalsa to alsa.I had to revert the
audio_hw.c
from soong back to a makefile, because the alsa-lib is also still makefile and a soong module cannot depend on a makefile one.Of course a few things are still hacked together like the fixed channels and rates. If someone with more time and knowledge comes along he/she might be able to add surround sound and passthrough (if raspberry drivers even support that, but LibreELEC seems to be able to) like here.
Also on your original vendor image
/vendor/lib/libasound.so
does not exits cause all alsa_utils are 64 bit, but now it is needed and thus created.So to test this on an existing vendor image you need to update both
/vendor/lib/libasound.so
and/vendor/lib/hw/audio.primary.rpi.so
And also remove the
asla_loop
from/vendor/etc/init/hw/init.rpi4.rc
.TODO: remove the
alsa_loop
frominit.rpi4.rc
otherwise multiple processes try to open the alsa device and fail...