axdisplay/
lib.rs

1//! [ArceOS](https://github.com/arceos-org/arceos) graphics module.
2//!
3//! Currently only supports direct writing to the framebuffer.
4
5#![no_std]
6
7#[macro_use]
8extern crate log;
9
10#[doc(no_inline)]
11pub use axdriver_display::DisplayInfo;
12
13use axdriver::{AxDeviceContainer, prelude::*};
14use axsync::Mutex;
15use lazyinit::LazyInit;
16
17static MAIN_DISPLAY: LazyInit<Mutex<AxDisplayDevice>> = LazyInit::new();
18
19/// Initializes the graphics subsystem by underlayer devices.
20pub fn init_display(mut display_devs: AxDeviceContainer<AxDisplayDevice>) {
21    info!("Initialize graphics subsystem...");
22
23    let dev = display_devs.take_one().expect("No graphics device found!");
24    info!("  use graphics device 0: {:?}", dev.device_name());
25    MAIN_DISPLAY.init_once(Mutex::new(dev));
26}
27
28/// Gets the framebuffer information.
29pub fn framebuffer_info() -> DisplayInfo {
30    MAIN_DISPLAY.lock().info()
31}
32
33/// Flushes the framebuffer, i.e. show on the screen.
34pub fn framebuffer_flush() {
35    MAIN_DISPLAY.lock().flush().unwrap();
36}