Can't get h/w video acceleration on rpi4

Bug #1905272 reported by Sergey Borovkov
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
New
High
Unassigned
linux-raspi (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Hi, we've run into an issue where we can't get h/w video acceleration working on rpi4 on ubuntu core 18 (and 20).

Our snap is using the following stack:
Qt 5 eglfs + gstreamer + mesa.

Raspberry's config txt has: dt_overlay=vc4-fkms-v3d, gpu_mem=256.

I've enabled all video/opengl related interfaces:
- opengl
- hardware-observe
- framebuffer.

Gstreamer can't detect that it has support for h264 h/w decoding using v4l2 plugin. The very same snap unpacked on the raspbian and that is running in a pretty same way it is on the core immediately detects that h264 decoding is available (i.e. I unsquashfs it there, set the LD_LIBRARY_PATH, WEBGL_DRIVERS_PATH, and all other environment variables that are returned from `env` command when running snap run --shell my_snap).

Because of that Qt falls back to the GStreamer pipeline with s/w decoder (avdec) and outputs like 0.5 frames per second (I am not sure if OpenGL actually works with h/w acceleration because even then it's so slow).

Running on core 20 did not help - I tried running it in devmode as well without any differences.

Raspbian, where it works, has 5.5 version of Linux kernel, I did try the beta version of core 20 which had 5.4 kernel version but it made no difference.

lsmod on raspbian shows some extra modules related to vc4 not present on the core (not sure how relevant they are though):

- v4l2_mem2mem
- bcm2835_codec

Revision history for this message
Oliver Grawert (ogra) wrote :

while v4l2_mem2mem is a rather old module from the mainline kernel (and is shiped in our kernels, bcm2835_codec is pi4 specific and should essentially provide access to the decoder, this seems to be missing in our kernel ...

Revision history for this message
Oliver Grawert (ogra) wrote :

the config option seems to be:

CONFIG_VIDEO_CODEC_BCM2835=m

Revision history for this message
Oliver Grawert (ogra) wrote :

talking to juerg (our kernel maintainer) it seems the codec module should be available in 5.4 in UC20, did you try to manually modprobe it ?

Revision history for this message
Sergey Borovkov (serge-borovkov) wrote :

Hi Oliver, sorry, did not mention that the difference in codecs is with core 18 - I only tried the snap on 20 to make sure it does not work there as well. I will check it.

Michael Vogt (mvo)
Changed in snapd:
importance: Undecided → High
Revision history for this message
Sergey Borovkov (serge-borovkov) wrote :

On Core 20:
root@ubuntu:/home/pi# modprobe bcm2835_codec
modprobe: FATAL: Module bcm2835_codec not found in directory /lib/modules/5.4.0-1011-raspi

On raspbian:

sudo modprobe bcm2835_codec
pi@raspberrypi:~ $

Google seems to be telling me that it's an element that provides video encode, decode, and transform functions via V4L2 M2M devices.

Is that a root of this issue?

Revision history for this message
Oliver Grawert (ogra) wrote :

this could surely be part of it

Revision history for this message
Juerg Haefliger (juergh) wrote :

5.4.0-1011-raspi is an ancient kernel from May. How did you end up using that? Current is 5.4.0-1022.25. With that kernel, I still had to copy the DTBs from the kernel to make it work. So it looks like another DTB/kernel mismatch.

Revision history for this message
Sergey Borovkov (serge-borovkov) wrote :

For UC 20 I downloaded the image from here: https://cdimage.ubuntu.com/ubuntu-core/20/beta/current/
I tried refreshing to the edge kernel but then an image would not boot.

For 18 I had built an image from an assertion containing kernel: pi-kernel=18-pi

Juerg Haefliger (juergh)
Changed in linux-raspi (Ubuntu):
status: New → Invalid
Revision history for this message
Sergey Borovkov (serge-borovkov) wrote :

I guess I will have to build an image with my own assertion, as ubuntu's images are in fact from May and image does not boot if I refresh the kernel. Will update if it does not work once I make it myself.

Revision history for this message
Juerg Haefliger (juergh) wrote :

You can try to copy the DTBs (and overlays) from /lib/firmware/5.4.0-<xyz>-raspi/device-tree/broadcom/ to /run/mnt/ubuntu-seed after refreshing the kernel snap.

Revision history for this message
Sergey Borovkov (serge-borovkov) wrote :

Thanks, ogra pointed me to the /pending subdirectory for images. I installed the latest one and gstreamer can actually detect v4l2h264 decoding capabilities there.
Unfortunate that it does not work on 18 though.

Revision history for this message
Juerg Haefliger (juergh) wrote :

We will fix 18 eventually (when we move the kernel to 5.4). But that requires some snap changes that are currently in the works.

Revision history for this message
Viktor Petersson (vpetersson) wrote :

@Juerg - Do you have a timeline for this?

Revision history for this message
Juerg Haefliger (juergh) wrote :

This is gated by snapd work. I don't have visibility into the snap team's schedule.

Revision history for this message
Maciej Borzecki (maciek-borzecki) wrote :

@juergh do I understand it correctly that this is blocked on snapd pulling dtbs from the kernel snap?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers