A Go module for opening a display on a Raspberry Pi and blitting image.RGBA frames onto it.
No CGO, no libdrm, no X11 — just raw Linux ioctls and mmap.
| Backend | Path | Speed (800×480, Pi 2) | Requirements |
|---|---|---|---|
| DRM/KMS | /dev/dri/card* |
~1.66 ms/frame | DRM master (console, no display server) |
| fbdev | /dev/fb0 |
~53 ms/frame (16 bpp) | Read/write on /dev/fb0 |
Open tries DRM first (card0, card1, card2) and falls back to fbdev automatically.
import "github.com/amnonbc/pidisp"
d, err := pidisp.Open(pidisp.Options{Rotate: true})
if err != nil {
log.Fatal(err)
}
defer d.Close()
img := image.NewRGBA(image.Rect(0, 0, d.Width(), d.Height()))
// draw into img ...
d.Blit(img)# Pi 2/3 (ARMv7)
GOOS=linux GOARCH=arm GOARM=7 go build ./...
# Pi 1 (ARMv6)
GOOS=linux GOARCH=arm GOARM=6 go build ./...
# Pi 4/5 (ARM64)
GOOS=linux GOARCH=arm64 go build ./...
Add to /boot/config.txt:
dtoverlay=vc4-kms-v3d
Run the process on the console with no display server active (DRM requires DRM master).
Other Go framebuffer libraries exist, but pidisp fills a specific niche:
| Feature | pidisp | Others (gonutz/different55/etc) |
|---|---|---|
| DRM/KMS support | ✓ (with hardware rotation) | ✗ fbdev only |
| Auto-fallback | ✓ tries DRM, falls back to fbdev | ✗ single backend |
| Hardware acceleration | ✓ ABGR8888 zero-copy, plane rotation | ✗ per-pixel software operations |
| Performance (Pi 2) | 1.66 ms/frame | ~53 ms/frame |
| CGO-free | ✓ raw ioctls only | varies |
| Modern Pi OS support | ✓ (DRM default) |
When to use pidisp:
- Raspberry Pi graphics without a display server
- Any Linux system with DRM/KMS display hardware
- High-performance graphics (~32× faster than fbdev on DRM-capable hardware)
- Simple API that abstracts away backend selection
Limitations:
- Linux only (DRM/fbdev not available on other platforms)
- Requires DRM master for DRM backend (console-only, no display server)
image.RGBAformat only (no color space conversion)
drm— DRM/KMS backend; ABGR8888 + hardware rotation for maximum performancefb— fbdev fallback; supports 16 bpp (RGB565 with Bayer dithering) and 32 bpp
- https://github.com/gonutz/framebuffer - cgo based library, without DRM acceleration.
- https://github.com/gogpu/gg - enterprise grade 2D graphics library for Go.