g2d-sys 1.1.0

Low-level FFI bindings for NXP i.MX G2D 2D graphics accelerator
Documentation

g2d-sys

Crates.io Documentation License MSRV

Low-level FFI bindings for NXP i.MX G2D 2D graphics accelerator.

This crate provides unsafe bindings to libg2d.so for hardware-accelerated 2D graphics operations on NXP i.MX8/i.MX9 platforms.

Features

  • Dynamic loading - Library loaded at runtime via libloading
  • ABI compatibility - Handles G2D library version differences
  • Zero dependencies on NXP SDK - Compiles anywhere, runs on i.MX

Usage

use g2d_sys::{G2D, G2DSurface, G2DFormat, G2DPhysical};

fn main() -> g2d_sys::Result<()> {
    let g2d = G2D::new("/usr/lib/libg2d.so.2")?;
    println!("G2D version: {}", g2d.version());
    Ok(())
}

Supported Operations

Operation Description
blit Copy with format conversion and scaling
clear Fill rectangle with solid color
enable/disable Configure colorspace (BT.601/BT.709)

Library Scope

This is a low-level FFI crate — it provides direct access to libg2d.so functions without safe Rust abstractions. When using DMA-buf buffers, you are responsible for correct cache management, including DRM PRIME attachment for cached heaps. See ARCHITECTURE.md for the complete cache coherency protocol and hardware_tests.rs for working examples.

Requirements

  • Rust 1.75+ (MSRV)
  • NXP i.MX8/i.MX9 platform
  • libg2d.so.2 installed

Tested Platforms

  • i.MX 8M Plus ✅
  • i.MX 95 ✅
  • Other i.MX variants should work but are not tested

License

Apache-2.0