Raspberry Pi VC4

Using the "VC4" driver on the raspberry pi to enable hardware acceleration (in X, Wayland, opengl applications) presents many challenges. There's plenty of instructions floating around for Raspbian, but for Gentoo, not so much. This page contains a couple of nuggets of wisdom that may help you get there.

Kernel
To have proper GPU acceleration with VideoCore, you need its kernel module loaded. That module has been integrated in v4.5, but it's also present in rpi's kernel v4.4.

I could never manage to compile a kernel that had a functional VC4 module myself, so I piggy-backed on Raspbian pre-compiled v4.4 kernel. To do so, I simply installed Raspbian on an SD card and changed the rootfs kernel argument to point to my gentoo system. Then, I copied  from the Raspbian system into my gentoo system.

Enabling the VC4 kernel module
To enable the kernel module, you have to enable the optional overlay in your  with. It's also recommended to bump your  to 128 (it's what   does when you enable the driver through it).

Make sure that you've copied kernel modules from the Raspbian system, or you'll have a blank screen!

Also, you should know that because that driver is a kernel module, you won't have any HDMI output until it's loaded, which is somewhere in the middle of your init procedure.

Is my module loaded?
Once you're booted up, you can verify that your module is properly loaded with. You're supposed to have a  module in there. Also, it's important to verify that  exists. If you don't have that device, nothing's going to work.

Mesa and friends
If your kernel module is properly loaded, you're halfway there. Now, you need Mesa to use that driver and you need X to enable GPU acceleration.

First, you should edit your  to have. You might be tempted to keep  in there, but I would recommend against it. If  isn't there, then xorg is not going to try to load it over.

Note that media-libs/mesa-12.0.1 is broken for VC4, while media-libs/mesa-12.0.6 appears to work.

Then, it's a matter of having the proper use flags. For me, this was the part that I spent the most time on because I didn't think about enabling  in. Once I got my setup working, I stopped fiddling, so I'm not sure about exactly what use flags you need. Those are mine:

I also have  as global use flags.

Is it working?
To test your setup, you need to install. This provides, which you can run with. If you have something like  in the output, then it's a success! If it's using, you're almost there. If it's using the software rasterizer, you're not there.