Initialize alsaucm to support Atom tablets

25 views
Skip to first unread message

Huy Minh Bùi (HMTheBoy154)

unread,
May 28, 2024, 4:47:29 PMMay 28
to Android-x86
Recently on BlissOS chat some people feedback about their audio on their Intel Atom tablets doesn't work. More specifically 2 cases of different tablets with bytcr-rt5651. While I don't have this audio card, I have an ASUS T100TA which uses bytcr-rt5640 instead.

I can be able to replicate the error that they sent me, something like:
dpcm_fe_dai_prepare() failed (-22)
no backend DAIs enabled for Audio Port

by removing all alsa state in /system/etc/alsa. But that made me realize that saving alsa state is not a good idea as you need to gather hardware in order to get these alsa state. So I decided to find a better solution.

Thankfully, I've found out about alsaucm, a program that both us here on BlissOS and also Android-x86 already included in the source but left unused. I've found out that the ucm configuration we copied serve a purpose. Apparently you can use it to activate a "verb"

alsaucm -c $d set _verb HiFi

This verb then provide audio devices like Speaker/Headphones/Internal Mic/Headset Mic which you can enable

For example, in my case with the T100TA, I can use this command to enable Speaker on my device

alsaucm -c bytcr-5640 set _verb HiFi set _enadev Speaker

It works, the speaker is actually working. I don't have to rely on pre-configured state anymore. And with that knowledge & a little bit of extra work, I wanna present the final patches

First, we need to bypass parsing "ConflictDevices" to enable multiple devices at the same time:
https://github.com/android-generic/external_alsa-lib/commit/160af5c84184003f525df73b9f54aa2e1a210279

Then here's the commit
https://github.com/BlissOS/device_generic_common/commit/2f8441797c9bdb2800d8fc969588980bf1aa1b75
https://github.com/BlissOS/device_generic_common/commit/0c9222d901071633e7b890716e9e85bbe00eaeb5

This patch contain an extra function to find and enable devices using alsaucm after the usual audio bump to 100. I set it like this because in my case set the audio to 100% for the T100TA is really loud so I'd like to keep it stock. I also give an extra feature which is saving the audio state to /data/vendor/asound.state and restore it at boot so you can edit alsa, save it and then it can restore at the next boot. We already set alsactl to use it too.

And with that, we can be able to completely remove the pre-configured alsa state on our OS. we still leave the init function though in case some people need it. We also make the script looking for extra dir (/data/vendor/alsa) in case the system is not writable.

Currently we've been tested these audio cards and can prove that they are working:
- bytcr-rt5640 
- bytcr-rt5651 (2 of them)
- chtnau8824
- acp5x on the Steam Deck (we can only verify enable HiFi verb work, back then the audio is being handled by a bunch of custom amixer commands + HiFi verb enable)

Huy Minh Bùi (HMTheBoy154)

unread,
May 28, 2024, 4:49:22 PMMay 28
to Android-x86
However, all of the Atom tablets we tested report one same issue, and that is the audio suddenly buzzing and have to stop the media a bit to be able to continue. I still can't be able to find or guess where the culprit is so any help is appreciated 
Vào lúc 03:47:29 UTC+7 ngày Thứ Tư, 29 tháng 5, 2024, Huy Minh Bùi đã viết:
Reply all
Reply to author
Forward
0 new messages