This project enables G2D (Graphics 2D) hardware acceleration on Allwinner D1 (Lichee RV Dock) systems using DRM by providing compatibility layers and driver adaptations.
The Allwinner D1 SoC includes a G2D hardware accelerator, but the traditional /dev/disp and /dev/g2d device nodes are not available on systems using DRM (Direct Rendering Manager). This project provides:
- G2D Kernel Driver: Adapted G2D driver for D1 with device tree support
- DISP Adapter:
/dev/dispcompatibility layer for applications expecting traditional Allwinner display interfaces - fbturbo Patch: Patches to make fbturbo Xorg driver work with DRM-based systems
- ✅ G2D hardware acceleration enabled
- ✅ Compatible with DRM-based systems
- ✅ Device tree support for D1
- ✅ fbturbo Xorg driver integration
- ✅ Minimal performance overhead
Kernel module providing /dev/g2d device node for G2D hardware access.
Features:
- Device tree support for D1
- Modern clock and reset APIs
- Compatible with Allwinner official G2D driver interface
Kernel module providing /dev/disp compatibility layer.
Features:
- Provides
/dev/dispdevice node - Handles DISP ioctl calls
- Stub implementation (sufficient for fbturbo initialization)
Patches for fbturbo Xorg driver to work with DRM systems.
Changes:
- Makes
/dev/dispoptional - Handles
FBIOGET_LAYER_HDLfailure gracefully - Allows G2D acceleration without traditional display framework
- Allwinner D1 SoC (tested on Lichee RV Dock)
- Linux kernel 6.8+ with DRM support
- Kernel headers installed
- RISC-V cross-compiler (for building on host) or native gcc (for building on target)
cd g2d-driver
make
sudo insmod g2d_23.koAdd the G2D node to your device tree (see g2d-driver/dts/g2d-d1-active.dtsi for reference):
g2d: g2d@01480000 {
compatible = "allwinner,sunxi-g2d";
reg = <0x0 0x01480000 0x0 0xbffff>;
interrupts = <0x5 0x4>;
clocks = <&ccu CLK_BUS_G2D>, <&ccu CLK_G2D>;
clock-names = "bus", "mod";
resets = <&ccu RST_BUS_G2D>;
status = "okay";
};
Compile and install the device tree, then reboot.
cd disp-adapter
make
sudo insmod disp_adapter.ko
sudo mknod /dev/disp c $(cat /sys/class/disp_adapter/disp/dev | cut -d: -f1) $(cat /sys/class/disp_adapter/disp/dev | cut -d: -f2)
sudo chmod 666 /dev/dispcd fbturbo-source
patch -p1 < ../fbturbo-patch/sunxi_disp.patch
./autogen.sh
./configure
make
sudo make install
sudo cp /usr/local/lib/xorg/modules/drivers/fbturbo_drv.so /usr/lib/xorg/modules/drivers/Create /etc/X11/xorg.conf.d/10-d1.conf:
Section "Device"
Identifier "Allwinner D1"
Driver "fbturbo"
Option "fbdev" "/dev/fb0"
Option "ShadowFB" "false"
EndSection
Restart X server and verify G2D acceleration is enabled:
tail /var/log/Xorg.0.log | grep "G2D acceleration"
# Should show: (II) FBTURBO(0): enabled G2D accelerationCheck that all components are loaded:
# Check kernel modules
lsmod | grep -E "g2d|disp_adapter"
# Check device nodes
ls -l /dev/g2d /dev/disp
# Check X server logs
tail /var/log/Xorg.0.log | grep -i "G2D".
├── README.md # This file
├── INSTALL.md # Installation guide
├── LICENSE # License file
├── CHANGELOG.md # Version history
├── CONTRIBUTING.md # Contribution guidelines
├── .gitignore # Git ignore rules
├── .gitattributes # Git attributes
├── g2d-driver/ # G2D kernel driver
│ ├── g2d_driver.c
│ ├── g2d.c
│ ├── g2d_bsp.c
│ ├── g2d_d1.c # D1-specific clock handling
│ ├── g2d_driver.h
│ ├── g2d.h
│ ├── g2d_bsp.h
│ ├── g2d_driver_i.h
│ ├── g2d_regs.h
│ ├── Makefile
│ ├── Kconfig
│ ├── build_d1.sh # Build script
│ ├── README.md
│ └── dts/ # Device tree files
│ ├── g2d-d1-active.dtsi
│ └── ...
├── disp-adapter/ # DISP compatibility adapter
│ ├── disp_adapter.c
│ ├── disp_types.h
│ ├── Makefile
│ └── README.md
└── fbturbo-patch/ # fbturbo patches
├── sunxi_disp.patch
├── APPLY_PATCH.sh
└── README.md
The current stub implementation of the DISP adapter has minimal performance impact:
- Startup overhead: < 0.5 ms
- Runtime performance: No impact (operations only during initialization)
- G2D acceleration: Fully functional
For detailed performance analysis, see the code comments.
- Check device tree node is present:
ls /proc/device-tree/soc/g2d - Check kernel logs:
dmesg | grep g2d - Verify clock names:
ls /sys/kernel/debug/clk/ | grep g2d
- Check module loaded:
lsmod | grep disp_adapter - Manually create device:
sudo mknod /dev/disp c 504 0 - Check permissions:
ls -l /dev/disp
- Check X server logs:
tail /var/log/Xorg.0.log - Verify
/dev/g2dexists:ls -l /dev/g2d - Check fbturbo is patched:
strings /usr/lib/xorg/modules/drivers/fbturbo_drv.so | grep "FBIOGET_LAYER_HDL"
GPL v2 (kernel modules) - See LICENSE file for details
Contributions are welcome! Please ensure:
- Code follows kernel coding style
- Device tree changes are tested
- Patches are well-documented
- Allwinner for G2D hardware and initial driver
- fbturbo project for Xorg driver
- Linux DRM community