Python bindings for Linux DRM/KMS display output via /dev/dri/cardN
Project description
drm-display
Python bindings for Linux DRM/KMS display output — send NumPy image arrays
directly to /dev/dri/cardN without a compositor or X server.
System requirements
- Linux with a KMS-capable GPU (most modern hardware)
libdrmdevelopment headers:apt install libdrm-dev/dnf install libdrm-develgcc- Access to
/dev/dri/cardN(add your user to thevideogroup or run as root)
Install
pip install drm-display
pip install compiles the small C helper (drm_display.c) against your
system's libdrm automatically. pkg-config libdrm is used when available;
otherwise /usr/include/libdrm and -ldrm are assumed.
Usage
import numpy as np
from drm_display import DRMDisplay
display = DRMDisplay(device="/dev/dri/card0", width=1920, height=1080)
# BGRA uint8 NumPy array, shape (height, width, 4)
frame = np.zeros((1080, 1920, 4), dtype=np.uint8)
frame[:, :, 2] = 255 # red screen (B=0, G=0, R=255, A=0)
display.send_full_image(frame)
# Partial update (blit a region at pixel offset x, y)
patch = np.zeros((100, 200, 4), dtype=np.uint8)
patch[:, :, 1] = 255 # green patch
display.send_partial_image(patch, x=50, y=50)
DRMDisplay.__del__ frees DRM resources automatically; call display.cleanup()
explicitly if you need deterministic teardown.
Build from source / editable install
git clone https://github.com/carstenbund/drm_display.git
cd drm_display
pip install -e . # compiles libdrm_display.so in-place
Or compile the shared library manually:
gcc -shared -fPIC -o drm_display/libdrm_display.so \
$(pkg-config --cflags libdrm) \
drm_display/drm_display.c \
$(pkg-config --libs libdrm)
Publishing (maintainer notes)
python -m build
twine upload --repository testpypi dist/* # test first
twine upload dist/* # publish to PyPI
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drm_display-0.1.0.tar.gz.
File metadata
- Download URL: drm_display-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75171f24bb6cc1731985814c4e851a1da504434d27d5a111d18d29c043c1b93e
|
|
| MD5 |
151aca21500616eeabecdc9a4375e472
|
|
| BLAKE2b-256 |
670a27d6b3d5df48d053a1cffed7d95dc80a172af23c3b7778cef7996e1b1280
|
File details
Details for the file drm_display-0.1.0-py3-none-any.whl.
File metadata
- Download URL: drm_display-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b66b98f869cfa0bd75a641667d40baef4447aa54230baaef1626e4152a0a2a97
|
|
| MD5 |
fcda625a4d4aaf4baa5101df6bca74e3
|
|
| BLAKE2b-256 |
789d0a058bb42464ef7d7a52a013ca162dd6ab001eaecbd225bf5a248adc84d4
|