Page MenuHomeFreeBSD

VCHIQ HDMI AUDIO 64 bits BCM2835, BCM2711 Raspberry Pi 4B; correct minor compile errors. bcm2835_audio.c
Needs ReviewPublic

Authored by fred_thegalacticzoo.com on Jan 11 2024, 10:32 AM.
Referenced Files
Unknown Object (File)
Sat, Dec 14, 9:07 AM
Unknown Object (File)
Wed, Dec 4, 3:40 PM
Unknown Object (File)
Wed, Dec 4, 3:40 PM
Unknown Object (File)
Thu, Nov 28, 4:50 AM
Unknown Object (File)
Thu, Nov 28, 4:50 AM
Unknown Object (File)
Thu, Nov 28, 4:50 AM
Unknown Object (File)
Thu, Nov 28, 4:50 AM
Unknown Object (File)
Thu, Nov 28, 4:27 AM

Details

Summary

change %lld -----> to %uld to comply with clang --warning checking errors

I was working to get files to compile with "make buildkernel KERNCONF=GENERIC-VCHIQ -DNO_CLEAN" but the clang --warning_cast_int_to_unsigned errors would appear. I have not been able to physically get sound out from the HDMI Audio speakers on the HDMI TV input. So just corrected errors for compile to complete and build a working FreeBSD ARM64 kernel.

Looking forward to enable Raspberry Pi 64bit Audio to function correctly on Raspberry Pi 3B,4B BCM2711,400 Keyboard, and new Raspberry Pi 5 BCM2712

Test Plan

Visual Review, Test compile.
VCHIQ BCM2835 Audio Marcos Devesas Campos Audio code patch files worked beautifully on Raspberry Pi 4B running FreeBSD 14.0-CURRENT back in September 7, 2022.
Compiling FreeBSD 14.0 Kernel
Patch KERNCONF=GENERIC-VCHIQ enable HDMI AUDIO on Raspberry Pi 4B,400,3B

https://reviews.freebsd.org/D36431 Marcos Devesas Campos Audio code patch Sept 3 2022

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

add file vchiq_2835_arm_.c.patch to diff section

I do not know how to add the 5 other patch files to be included in this diff comparision. Seems like 132598, got over written with this "update diff" instead of being added. Time for me to read and study hand book. okay

Concatenated 7 git diff -u patch files into one_large_vchiq_freebsd_patch_file.patch and updated this diff. I see that the FreeBSD (src) does not yet contain Marcos Devesas Campos VCHIQ revision D378378 https://reviews.freebsd.org/D37878. So make a decision to use or not use that code before incorporating this D43399 revision.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274804

My Aim here is to have working HDMI sound on the Raspberry Pi 3B,4B,400 Single Board Computers to support a desktop environment and play YouTube videos and have stereo sound come out the HDMI TV / Monitor speakers. This should also work for VLC application playing videos and mp3 audios. I hope that USB Headsets like Logitech H390 get tested to work with this Raspberry Pi Hardware. Also test the 3.5mm analog output audio source to be working. Why? To compete with Debian Raspberry Pi OS functioning software. How do you answer FreeBSD.org/where snapshot works great for networking and command lines but there is NO SUPPORT for audio on that Raspberry Pi 64 bit hardware, 3B,4B,400,5 Okay good to know that Audio is not supported, I will stay with Raspberry Pi O/S FreeBSD is just not there yet for Desktop Use on Arm 64 bit hardware. That is why.
https://ghostbsd-arm64.blogspot.com/2023/12/how-to-install-ghostbsd-arm64-into-usb.html Install GhostBSD Arm64 into a USB Flash drive. based on FreeBSD 14.0-STABLE

Okay here is the set of steps to have VCHIQ Audio compiled into your FreeBSD Kernel.

su - # setup to be root user
cd /usr/ghost14 ; mkdir Patches
cd Patches
wget -c https://reviews.freebsd.org/D36431?download=true
wget -c https://reviews.freebsd.org/D37878?download=true
wget -c https://reviews.freebsd.org/D37879?download=true

patch <../Patches/D36431.diff
patch <../Patches/D37878.diff
patch <../Patches/D37879.diff

Now compile with line make buildkernel
su root
cd /usr/ghost14/ghostbsd-src

previously completed patch -v <HDMI_VCHIQ_sound_patch.txt

time make -j4 buildkernel KERNCONF=GENERIC-VCHIQ -DNO_CLEAN
Compiling to see if errors show up.
No compile errors showed up.

Update Src Installing Kernel 26.6.5. Installing the Compiled Code

make installkernel KERNCONF=GENERIC-VCHIQ
If a custom kernel was built, KERNCONF must also be set to use the new custom kernel:

  1. cd /usr/src
  2. make installkernel KERNCONF=GENERIC-VCHIQ
  3. shutdown -r now
  4. cd /usr/src
  5. make installworld
  6. shutdown -r now

Is this patch based on the three preceding patches? Were there compilation warnings (or errors) encountered when applying those three patches, leading to the creation of this patch to address those issues?

image.png (128×848 px, 36 KB)

I have tested the three patches by applying the diff from this link on my RPI4B running FreeBSD CURRENT. I successfully compiled the kernel and verified that sound can be produced through the 3.5mm headphone jack. However, it appears that sound is still not being produced through HDMI? In my device, only one PCM device (3.5mm) is visible.

kola@generic:~ $ cat /dev/sndstat 
Installed devices:
pcm0: <VCHIQ audio> (play) default
No devices installed from userspace.
In D43399#991801, @bses30074_gmail.com wrote:

Is this patch based on the three preceding patches? Were there compilation warnings (or errors) encountered when applying those three patches, leading to the creation of this patch to address those issues?

image.png (128×848 px, 36 KB)

Happy to have your testing and participation in getting Marcos VCHIQ HDMI audio sound patch reviewed. I post many URL links below to share ideas for further reading and learning.. YES, this is first a FreeBSD code review and not related to other BSD and URL links. So the point is to specifically comment about using FreeBSD source code. Sorry for the overload, but I wanted a good post to answer your question and share links for the background information.

No, this patch is based on git clone FreeBSD-src source code and getting it to simply compile (yes, I encountered warnings, errors) with cd /usr/src ; make buildworld -DNO_CLEAN ; make buildkernel KERNCONF=GENERIC-VCHIQ -DNO_CLEAN
I assumed after a years time 22 to 23, Marcos code was included in the git clone FreeBSD-src code and buildkernel KERNCONF=GENERIC-VCHIQ Later, I realized after creating this patch to get FreeBSD to compile, that Marcos patch code review D37878 & D37879 was not included there. D37878 review & D37878 review
I am hitting submit to not lose text entry. Will see if I can edit after submit.
[[ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274804 |[PATCH] KERNCONF=GENERIC-VCHIQ enable HDMI AUDIO on Raspberry Pi 4B,400,3B October 30 2023 ]]
Do you have a patch diff file that you can share some where?
Arm Open-Source Telegram group that I use. Arm Open-Source Telegram group
GhostBSD Development Arm64 Development Arm64 Development
Fred Finsters Blog post https://ghostbsd-arm64.blogspot.com/ GhostBSD Arm64 Blog
January 19, 2024 Howto Download a Raspberry Pi 4B bootable image from http://ghostbsdarm64.hopto.org/packages/

What would you like to see working on Raspberry Pi. I know that the 43455 Wifi device driver is important. I would like to see support for Raspi4B extra serial ports UARTs 2,3,4,5

I have tested the three patches by applying the diff from this link on my RPI4B running FreeBSD CURRENT. I successfully compiled the kernel and verified that sound can be produced through the 3.5mm headphone jack. However, it appears that sound is still not being produced through HDMI? In my device, only one PCM device (3.5mm) is visible.

kola@generic:~ $ cat /dev/sndstat 
Installed devices:
pcm0: <VCHIQ audio> (play) default
No devices installed from userspace.

Marcos reply on howto use VCHIQ Audio sysctl dev.pcm.0.dest

Marco's Reply with simple test outputs https://lists.freebsd.org/archives/freebsd-arm/2022-September/001711.html

stock config.txt and dtb-s.

dmesg should then show

vchiq0: <BCM2835 VCHIQ> mem 0x7e00b840-0x7e00b87b irq 72 on simplebus0
vchiq: local ver 8 (min 3), remote ver 8.
pcm0: <VCHIQ audio> on vchiq0

and

cat /dev/random > /dev/dsp

should play static

If nothing’s playing, flipping the sysctl dev.pcm.0.dest through

  • 0: both hdmi and headphones
  • 1: headphones
  • 2: hdmi

usually brings the audio back to life.
sysctl dev.pcm.0.dest=0
sysctl dev.pcm.0.dest=1
sysctl dev.pcm.0.dest=2

Best,
Marco
~~~~~~~~~~~~~~~~~~~~~~~~~~

Patch & Compile FreeBSD source code September 7 2022 blogpost
https://lists.freebsd.org/archives/freebsd-arm/2022-May/001342.html Marcos improved Patchfile source

Booted the patched 14-CURRENT on the RPI3B+. Ronald Klop's comment and test

dmesg diff:
+vchiq0: <BCM2835 VCHIQ> mem 0x7e00b840-0x7e00b87b irq 54 on simplebus0
+vchiq: local ver 8 (min 3), remote ver 8.
+pcm0: <VCHIQ audio> on vchiq0

[root@rpi3 ~]# cat /dev/sndstat
Installed devices:
pcm0: <VCHIQ audio> (play) default
No devices installed from userspace.

[root@rpi3 ~]# sysctl dev.pcm
dev.pcm.0.trace: 0
dev.pcm.0.starved: 0
dev.pcm.0.freebuffer: 40000
dev.pcm.0.underruns: 0
dev.pcm.0.retrieved: 0
dev.pcm.0.submitted: 0
dev.pcm.0.callbacks: 0
dev.pcm.0.dest: 0
dev.pcm.0.mode: 3
dev.pcm.0.bitperfect: 0
dev.pcm.0.buffersize: 0
dev.pcm.0.play.vchanformat: s16le:2.0
dev.pcm.0.play.vchanrate: 48000
dev.pcm.0.play.vchanmode: fixed
dev.pcm.0.play.vchans: 1
dev.pcm.0.%parent: vchiq0
dev.pcm.0.%pnpinfo:
dev.pcm.0.%location:
dev.pcm.0.%driver: pcm
dev.pcm.0.%desc: VCHIQ audio
dev.pcm.%parent:

To play some audio I need to search some headphones first. :-)

Ronald.

pkg install mpg123 Use this software for playing mp3 files as a test setup. I welcome other simple ideas build/create a VCHIQ audio test setup on the Raspberry Pi 3B,4B,400 Keyboard, ?5?

Where is Marcos Test setup omxplayer? Here is a google URL to Freebsd comment, that shows very recent activity of removing omxplayer from freebsd ports multimedia Seems like it is incoporated into VLC player.
So maybe use VLC player for testing.

[[ https://cgit.freebsd.org/ports/commit/?id=78deb945ebe418c3734fcf6438e05b8b5c3adc32 | December 31 2023 freebsd omxplayer commit  ]]

OMXPlayer - why it's no longer there ? Raspberry Pi dot com comment

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marcos comment:
Tested on zero, zero2 and 4+ with ping, functional, bulk
and control vchiq_test-s, and omxplayer