About the driver

This is the Mesa and DRM driver for Broadcom VC4 hardware. It is notably used in the Raspberry Pi hardware, including Raspberry Pi 2, and included as an option in the 2016-02-09 Rasbpian release.

Other information:

Kernel driver status

The V3D kernel driver is now upstream in kernel 4.5, and the devicetree for it is being pulled into kernel 4.7. The merge of everything can be found in linux-next.

The Raspberry Pi Foundation's kernel tree includes the driver in the current rpi-update 4.4 branch, but it's disabled until you choose the "new OpenGL driver" option in raspi-config. Guides here will only cover upstream code; for downstream, the raspi-config is all you need.

3D driver status

The 3D driver can be found at: http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/vc4

  • 93.0% passrate on piglit gpu.py on simulation
  • 92.4% passrate on piglit quick.tests on Raspberry Pi
  • 93.9% passrate on deqp es2 tests in simulation

Bug reporting

Bugs are tracked on my github repositories. The kernel repository covers module probing, display problems, and whole-system crashes. The mesa repository covers graphics rendering bugs, 3D performance, and 3D features.

Feel free to use bare "+1" comments on bugs that impact you, so that I can use participant count as a rough prioritization guide.

Building the upstream kernel (bcm2835 architecture)

This is not a complete guide, just some details you'll definitely need.

Get the kernel from linux-next.

 git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 cd linux
 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
 git fetch linux-next
 git checkout next-TODAYSDATE

You need current firmware (2016-04-19) in order to use a plain upstream kernel without running magic scripts on it. You should reboot after this to make sure that you're fine with the new firmware and your new kernel isn't the problem.

 sudo rpi-update

Build the kernel with:

 make multi_v7_defconfig # if you have rpi2 or 32-bit rpi3
 make bcm2835_defconfig # if you have rpi0/1/cm
 make
 sudo make zinstall modules_install dtbs_install

The kernel will have installed under /boot with some version (make kernelrelease tells you what it was). Update your config.txt to contain:

 avoid_warnings=2     # VPU shouldn't smash our display setup.
 kernel=vmlinuz-KERNELVERSION
 device_tree=dtbs/KERNELVERSION/bcm2836-rpi-2-b.dtb

(but replace bcm2836-rpi-2-b with the appropriate DT for your device present in that directory)

Edit your cmdline.txt to add "cma=256M@256M"

Building mesa

Current Mesa releases include support for vc4, but to build it yourself:

sudo apt-get build-dep libgl1-mesa-dri

# Individual packages for Mesa, if build-dep isn't enough.
sudo apt-get install \
autoconf \
bison \
flex \
gettext \
libdrm-dev \
libexpat1-dev \
libtool \
libudev-dev \
libx11-xcb-dev \
libxcb-dri2-0-dev \
libxcb-glx0-dev \
libxcb-xfixes0-dev \
libxdamage-dev \
libxext-dev \
libxfixes-dev \
python-mako \
x11proto-dri2-dev \
x11proto-gl-dev
# For the X Server
sudo apt-get install \
libgcrypt20-dev \
libpciaccess-dev \
libpixman-1-dev \
libxcb-keysyms1-dev \
libxfont-dev \
libxkbfile-dev \
libxxf86vm-dev \
x11proto-bigreqs-dev \
x11proto-composite-dev \
x11proto-record-dev \
x11proto-render-dev \
x11proto-resource-dev \
x11proto-scrnsaver-dev \
x11proto-video-dev \
x11proto-xcmisc-dev \
x11proto-xf86dri-dev \
x11proto-xinerama-dev \
xutils-dev \

git clone git://anongit.freedesktop.org/mesa/mesa
cd mesa
./autogen.sh \
 --prefix=$HOME/prefix \
 --with-gallium-drivers=vc4 \
 --with-dri-drivers= \
 --with-egl-platforms=x11,drm

Building the X Server

sudo apt-get build-dep xorg

git clone git://anongit.freedesktop.org/xorg/xserver
cd xserver
./autogen.sh \
 --prefix=$HOME/prefix

autogen will repeatedly fail due to various dependencies being missing. Deal with them.

Make $HOME/prefix/etc/X11/xorg.conf to select the modesetting driver:

Section "Files"
        ModulePath   "/home/anholt/prefix/lib/xorg/modules"
        FontPath     "/usr/share/fonts/X11/misc"
        FontPath     "/usr/share/fonts/X11/75dpi"
        FontPath     "/usr/share/fonts/X11/Type1"
EndSection

Section "InputClass"
    Identifier "ev"
    Driver "evdev"
EndSection

Section "InputClass"
    Identifier "syn"
    Driver "synaptics"
    MatchProduct "Synaptics"
EndSection

Section "ServerFlags"
EndSection

Section "Device"
    Identifier  "Configured Video Device"
    Driver "modesetting"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    DefaultDepth    24
    SubSection "Display"
        Depth           24
    EndSubSection
EndSection

Now, you can start the server using startx:

startx -- /home/anholt/prefix/bin/Xorg