Skip to content

AkarinServer/disp-adapter-g2d-integration

Repository files navigation

Allwinner D1 G2D Hardware Acceleration Integration

This project enables G2D (Graphics 2D) hardware acceleration on Allwinner D1 (Lichee RV Dock) systems using DRM by providing compatibility layers and driver adaptations.

Overview

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:

  1. G2D Kernel Driver: Adapted G2D driver for D1 with device tree support
  2. DISP Adapter: /dev/disp compatibility layer for applications expecting traditional Allwinner display interfaces
  3. fbturbo Patch: Patches to make fbturbo Xorg driver work with DRM-based systems

Features

  • ✅ G2D hardware acceleration enabled
  • ✅ Compatible with DRM-based systems
  • ✅ Device tree support for D1
  • ✅ fbturbo Xorg driver integration
  • ✅ Minimal performance overhead

Components

1. G2D Driver (g2d-driver/)

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

2. DISP Adapter (disp-adapter/)

Kernel module providing /dev/disp compatibility layer.

Features:

  • Provides /dev/disp device node
  • Handles DISP ioctl calls
  • Stub implementation (sufficient for fbturbo initialization)

3. fbturbo Patch (fbturbo-patch/)

Patches for fbturbo Xorg driver to work with DRM systems.

Changes:

  • Makes /dev/disp optional
  • Handles FBIOGET_LAYER_HDL failure gracefully
  • Allows G2D acceleration without traditional display framework

Requirements

  • 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)

Installation

On Target System (D1)

1. Build and Install G2D Driver

cd g2d-driver
make
sudo insmod g2d_23.ko

2. Add Device Tree Node

Add 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.

3. Build and Install DISP Adapter

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/disp

4. Patch and Build fbturbo

cd 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/

5. Configure X Server

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 acceleration

Verification

Check 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"

Project Structure

.
├── 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

Performance

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.

Troubleshooting

G2D driver not loading

  • 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

DISP adapter not creating device

  • Check module loaded: lsmod | grep disp_adapter
  • Manually create device: sudo mknod /dev/disp c 504 0
  • Check permissions: ls -l /dev/disp

fbturbo not using G2D

  • Check X server logs: tail /var/log/Xorg.0.log
  • Verify /dev/g2d exists: ls -l /dev/g2d
  • Check fbturbo is patched: strings /usr/lib/xorg/modules/drivers/fbturbo_drv.so | grep "FBIOGET_LAYER_HDL"

License

GPL v2 (kernel modules) - See LICENSE file for details

Contributing

Contributions are welcome! Please ensure:

  • Code follows kernel coding style
  • Device tree changes are tested
  • Patches are well-documented

Acknowledgments

  • Allwinner for G2D hardware and initial driver
  • fbturbo project for Xorg driver
  • Linux DRM community

References

About

G2D hardware acceleration integration for Allwinner D1 (Lichee RV Dock) with DRM compatibility

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors