# g2d-sys
[](https://crates.io/crates/g2d-sys)
[](https://docs.rs/g2d-sys)
[](../LICENSE)
[](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
**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
```rust
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
| `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](../../ARCHITECTURE.md#cpu-cache-coherency)
for the complete cache coherency protocol and
[hardware_tests.rs](tests/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