[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260126081744.781392-1-pengfuyuan@kylinos.cn>
Date: Mon, 26 Jan 2026 16:17:40 +0800
From: pengfuyuan <pengfuyuan@...inos.cn>
To: Danilo Krummrich <dakr@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Daniel Almeida <daniel.almeida@...labora.com>,
Miguel Ojeda <ojeda@...nel.org>
Cc: Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>,
Helge Deller <deller@....de>,
Hans de Goede <hansg@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Lee Jones <lee@...nel.org>,
Sam Ravnborg <sam@...nborg.org>,
Zsolt Kajtar <soci@....rulez.org>,
Ville Syrjälä <ville.syrjala@...ux.intel.com>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org,
linux-fbdev@...r.kernel.org,
pengfuyuan <pengfuyuan@...inos.cn>
Subject: [PATCH v1 v1 0/4] [RUST] Framebuffer driver support
This patch series adds Rust bindings and safe abstractions for the Linux
framebuffer subsystem, enabling framebuffer drivers to be implemented in Rust.
The series consists of 4 patches:
1. rust: io: mem: add ioremap_wc support
Adds write-combining memory mapping support to the Rust iomem abstraction,
which is essential for framebuffer memory regions that benefit from
write-combining semantics.
2. rust: device: add platdata accessors
Implements generic accessors for platform data, enabling drivers to access
platform-provided configuration. This is needed for framebuffer drivers
that use platform data for configuration.
3. rust: fb: add framebuffer driver support
Adds the core framebuffer framework abstraction, including:
- Device abstraction (`fb::Device`) with reference counting via `AlwaysRefCounted`
- Driver and Operations traits (`fb::Driver`, `fb::Operations`)
- Screen information wrappers (`fb::FixScreenInfo`, `fb::VarScreenInfo`)
- I/O operation helpers (`fb_io_read`, `fb_io_write`, `fb_io_mmap`)
- Blit operation helpers (`cfb_fillrect`, `cfb_copyarea`, `cfb_imageblit`)
4. rust: fb: add simplefb test driver
Adds a test driver that validates the framebuffer framework by porting
the C simplefb driver to Rust. This driver serves as both a validation
tool and a reference implementation for future Rust framebuffer drivers.
The implementation follows the same patterns established in the DRM subsystem
and maintains full compatibility with the existing C framebuffer subsystem.
All C callbacks are properly bridged to Rust trait methods via the `Operations`
trait, memory safety is ensured through proper use of `Opaque<fb_info>`, `ARef`,
and `AlwaysRefCounted` for reference counting, type invariants are documented
and enforced through the type system, and resource cleanup is handled via RAII
with proper cleanup order.
Testing:
--------
This series has been tested on:
- ARM64 platforms with various display configurations
- AMD RX550 graphics card
- Moore Threads S30 graphics card
- Multiple other graphics cards
All tested configurations show normal display functionality with proper
framebuffer initialization, rendering operations (including I/O, color register
management, and blitting), memory mapping, and resource cleanup. The simplefb
test driver successfully demonstrates the usage of all framebuffer framework
APIs and validates the abstraction's correctness.
The simplefb test driver serves as both a validation tool and a reference
implementation for future Rust framebuffer drivers.
pengfuyuan (4):
rust: io: mem: add ioremap_wc support
rust: device: add platdata accessors
rust: fb: add framebuffer driver support
rust: fb: add simplefb test driver
drivers/video/fbdev/Kconfig | 21 +
drivers/video/fbdev/Makefile | 1 +
drivers/video/fbdev/simplefb_rust.rs | 653 +++++++++++++++++++++++++++
rust/bindings/bindings_helper.h | 2 +
rust/helpers/device.c | 5 +
rust/helpers/io.c | 5 +
rust/kernel/device.rs | 31 ++
rust/kernel/fb/blit.rs | 106 +++++
rust/kernel/fb/device.rs | 463 +++++++++++++++++++
rust/kernel/fb/driver.rs | 169 +++++++
rust/kernel/fb/io.rs | 76 ++++
rust/kernel/fb/mod.rs | 23 +
rust/kernel/fb/screeninfo.rs | 318 +++++++++++++
rust/kernel/io/mem.rs | 71 +++
rust/kernel/lib.rs | 2 +
15 files changed, 1946 insertions(+)
create mode 100644 drivers/video/fbdev/simplefb_rust.rs
create mode 100644 rust/kernel/fb/blit.rs
create mode 100644 rust/kernel/fb/device.rs
create mode 100644 rust/kernel/fb/driver.rs
create mode 100644 rust/kernel/fb/io.rs
create mode 100644 rust/kernel/fb/mod.rs
create mode 100644 rust/kernel/fb/screeninfo.rs
--
2.25.1
Powered by blists - more mailing lists