raspberry-vanilla / android_local_manifest

105 stars 48 forks source link

No audio through HifiBerry DAC+ ADC Pro card on Raspberry Pi 5 #95

Closed jsln closed 1 month ago

jsln commented 1 month ago

Hi, I get no audio using one of the Oboe samples (compiled with NDK), with the HifiBerry DAC+ ADC Pro, anybody has had success with that hardware? I guess this has something to do with my configuration as this is what the logcat shows:

05-29 21:45:01.179  1078  2026 E AudioSystem: Function: listAudioPorts Line: 1582 Failed
05-29 21:45:01.179  1078  2026 E AudioSystem-JNI: AudioSystem::listAudioPorts error -19
05-29 21:45:01.179  1078  2026 W AudioManager: updateAudioPortCache: listAudioPorts failed
05-29 21:45:01.249   745   971 E AudioSystem: Function: listAudioPorts Line: 1582 Failed
05-29 21:45:01.249   745   971 E AudioSystem-JNI: AudioSystem::listAudioPorts error -19
05-29 21:45:01.249   745   971 W AudioManager: updateAudioPortCache: listAudioPorts failed
05-29 21:45:01.279  1078  2026 E AudioSystem: Function: listAudioPorts Line: 1582 Failed
05-29 21:45:01.279  1078  2026 E AudioSystem-JNI: AudioSystem::listAudioPorts error -19

I have the following lines in device/brcm/rpi5/vendor.prop

# Audio
persist.audio.pcm.card=3
ro.hardware.audio.primary=rpi

And I can see those properties set with getproc.

Furthermore, these are the relevant parts of my boot/config.txt:

dtoverlay=vc4-kms-v32,noaudio

# Audio DAC
#dtparam=audio=on
dtoverlay=hifiberry-dacplusadcpro,slave
force_eeprom_read=0

# I2C
dtparam=i2c_arm=on

# I2S
dtparam=i2s=on

I see the driver being enabled:

$ cat /proc/asound/cards
 0 [sndrpihifiberry]: HifiberryDacpAd - snd_rpi_hifiberry_dacplusadcpro
                      snd_rpi_hifiberry_dacplusadcpro

I have another previously built aosp image with unmodified vendor.prop, and hdmi audio enabled in boot/config.txt, and hdmi audio works there.

Any ideas with what might be happening?

skanda-coder commented 1 month ago

Hello,

Usually the first two audio output slots are taken by HDMI output as shown below.

0 [vc4hdmi0 ]: vc4-hdmi - vc4-hdmi-0 vc4-hdmi-0 1 [vc4hdmi1 ]: vc4-hdmi - vc4-hdmi-1 vc4-hdmi-1

However in your case seems like HDMI is not showing up in /proc/asound/cards and 0 ist he fist Alsa output entry.

Try pointing persist.audio.pcm.card to 0 instead: persist.audio.pcm.card=0

KonstaT commented 1 month ago

Yes, as @skanda-coder mentioned above, you don't have the HDMI output devices because you've set dtoverlay=vc4-kms-v3d,noaudio and you would need to set persist.audio.pcm.card=0. The relevant wiki page (https://github.com/raspberry-vanilla/android_local_manifest/wiki/Audio) is slightly out of date. On Pi 5 with dtoverlay=vc4-kms-v3d (i.e. no change in that regard), you would set persist.audio.pcm.card=2.

I'm not sure if adding the slave parameter to the DAC driver is still needed or has it been fixed upstream since.

jsln commented 1 month ago

Thanks @skanda-coder , @KonstaT , I got it working by setting persist.audio.pcm.card.

Furthermore, it turns out the slave parameter is not needed.