Add mali driver to rockpi

This gives us opencl access to the GPU.  Not fast, but it is good
enough to start testing and developing.

Change-Id: I3cc68e28a6db26ecce552b3fadd4662acb9f75f5
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/rockpi/build_kernel.sh b/frc971/rockpi/build_kernel.sh
index f3cadd4..a230ecf 100755
--- a/frc971/rockpi/build_kernel.sh
+++ b/frc971/rockpi/build_kernel.sh
@@ -8,6 +8,10 @@
   ln -s ../.config linux/.config
 fi
 
+if [[ ! -e mali-driver ]]; then
+  git clone --branch master https://github.com/bootlin/mali-driver
+fi
+
 (
 cd linux
 
@@ -44,7 +48,13 @@
   make rockpi
 )
 
+(
+  cd mali-driver
+  make KDIR=$(realpath ../linux) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- all
+)
+
 cp ../../y2022/localizer/kernel/adis16505.ko "kernel-install/lib/modules/${VERSION}/kernel/"
+cp mali-driver/r8p0/drivers/gpu/arm/midgard/mali_kbase.ko "kernel-install/lib/modules/${VERSION}/kernel/"
 
 /sbin/depmod -b ./kernel-install ${VERSION}
 
diff --git a/frc971/rockpi/build_rootfs.sh b/frc971/rockpi/build_rootfs.sh
index e5706fc..f7abbd5 100755
--- a/frc971/rockpi/build_rootfs.sh
+++ b/frc971/rockpi/build_rootfs.sh
@@ -156,7 +156,10 @@
 target "apt-get -y install -t bullseye-backports systemd"
 target "apt-get -y install -t bullseye-backports bpfcc-tools"
 
-target "apt-get install -y sudo openssh-server python3 bash-completion git v4l-utils cpufrequtils pmount rsync vim-nox chrony libopencv-calib3d4.5 libopencv-contrib4.5 libopencv-core4.5 libopencv-features2d4.5 libopencv-flann4.5 libopencv-highgui4.5 libopencv-imgcodecs4.5 libopencv-imgproc4.5 libopencv-ml4.5 libopencv-objdetect4.5 libopencv-photo4.5 libopencv-shape4.5 libopencv-stitching4.5 libopencv-superres4.5 libopencv-video4.5 libopencv-videoio4.5 libopencv-videostab4.5 libopencv-viz4.5 libnice10 pmount libnice-dev feh libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-nice usbutils locales trace-cmd"
+target "apt-get install -y sudo openssh-server python3 bash-completion git v4l-utils cpufrequtils pmount rsync vim-nox chrony libopencv-calib3d4.5 libopencv-contrib4.5 libopencv-core4.5 libopencv-features2d4.5 libopencv-flann4.5 libopencv-highgui4.5 libopencv-imgcodecs4.5 libopencv-imgproc4.5 libopencv-ml4.5 libopencv-objdetect4.5 libopencv-photo4.5 libopencv-shape4.5 libopencv-stitching4.5 libopencv-superres4.5 libopencv-video4.5 libopencv-videoio4.5 libopencv-videostab4.5 libopencv-viz4.5 libnice10 pmount libnice-dev feh libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-nice usbutils locales trace-cmd clinfo"
+target "cd /tmp && wget https://software.frc971.org/Build-Dependencies/libmali-midgard-t86x-r14p0-x11_1.9-1_arm64.deb && sudo dpkg -i libmali-midgard-t86x-r14p0-x11_1.9-1_arm64.deb && rm libmali-midgard-t86x-r14p0-x11_1.9-1_arm64.deb"
+
+target "apt-get clean"
 
 target "usermod -a -G sudo pi"
 target "usermod -a -G video pi"
@@ -184,6 +187,7 @@
 copyfile root.root 644 etc/systemd/system/usb-mount@.service
 copyfile root.root 644 etc/udev/rules.d/99-usb-mount.rules
 copyfile root.root 644 etc/udev/rules.d/99-adis16505.rules
+copyfile root.root 644 etc/udev/rules.d/99-mali.rules
 
 target "apt-get update"
 target "apt-get -y install -t bullseye-backports systemd"
diff --git a/frc971/rockpi/contents/etc/udev/rules.d/99-mali.rules b/frc971/rockpi/contents/etc/udev/rules.d/99-mali.rules
new file mode 100644
index 0000000..2c8d63a
--- /dev/null
+++ b/frc971/rockpi/contents/etc/udev/rules.d/99-mali.rules
@@ -0,0 +1 @@
+KERNEL=="mali0", MODE="0660", GROUP="render"