Re: sound on raspberry pi 4

From: Marco Devesas Campos <devesas.campos_at_gmail.com>
Date: Mon, 17 Oct 2022 18:26:43 UTC
Hi Odhiambo, and List,

> On 17 Oct 2022, at 13:50, Odhiambo Washington <odhiambo@gmail.com> wrote:
> 
> 
> Just curious. How do I test this?
> I have a Pi3B+ which I have always wanted to run FreeBSD on, but then getting FreeBSD Desktop is so much pain.
> How would I test accel video and sound on a Pi without getting stressed out? :-)
> 

Oooh boy, I don’t know about that not getting stressed out…

Anyway, the short answer to how you test this is: by using the 32bit compat mode. 
(People with pi4s please read to the end).

64 bit pis can run 32 bit code, and (to simplify) the libraries that connect (via the driver)
to the hardware have not been updated to 64 bits. 

If that hasn’t put you off, this is what i did to play video:

- build the kernel with vchiq support (the patch)

- I had an SD card with a 32 bit installation that had the rpi-userland, rpi-firmware and omxplayer packages. I hooked it up to the pi with a usb card reader and then used chroot
to go into the “32bit world”

# sudo chroot <mount point> /bin/sh

- We need to mount devfs first inside our impromptu jail

# mount -t devfs devfs /dev

- and… that’s it, we’re ready to play some video

# file `which omxplayer.bin`
/usr/local/bin/omxplayer.bin: ELF 32-bit LSB executable, ARM, EABI5 version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, FreeBSD-style, for FreeBSD 13.0 (1300139), stripped

# omxplayer.bin /home/freebsd/f.mp4
Video codec omx-h264 width 464 height 272 profile 578 fps 25.000000
Audio codec aac channels 2 samplerate 48000 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: 464x272@25.00 interlace:0 deinterlace:0 anaglyph:0 par:nan display:0 layer:0 alpha:255 aspectMode:0
Stopped at: 00:00:08
have a nice day ;)

I don’t think I’ve ever tried it but it should be doable to just download an existing arm
(v7?) image, mount it as a memory disk, and use that as a root system on which to install
the needed packages.
 
The bad news: Pi4’s don’t have the 3d/2d acceleration drivers, so that’s out. Unfortunately
even omxplayer from ports is out since it uses openvg, the 2d acceleration framework, for
rendering subtitles — and will crash on start even without them. However, If people get in
touch I can help them compile it on freebsd without subtitle support.

OpenGL applications work (again, on pi3/zero2) provided they worked on 32 bits.
Unfortunately, iirc, lots of ports required mesa-libs which conflicted with the userland
(accelerated) drivers so there aren’t many examples around. Have only tested the
example from https://github.com/raspberrypi/firmware

Any doubts/problems do get in touch,
Marco