Skip to main content

FrameBuffer

Struct FrameBuffer 

Source
pub struct FrameBuffer { /* private fields */ }
Expand description

An owned physical framebuffer region.

Created once per SDRAM allocation at boot. Owns geometry metadata plus the PhysAddr — no raw pointer, no u32 escape hatch in the public API.

Implementations§

Source§

impl FrameBuffer

Source

pub unsafe fn from_phys( addr: PhysAddr, width: u32, height: u32, stride_bytes: u32, format: PixelFmt, ) -> Self

Construct a FrameBuffer at a physical address.

§Safety

The caller must ensure that:

  • [addr, addr + stride_bytes * height) is a mapped, writable RAM region for the 'static lifetime of the returned value,
  • no other FrameBuffer, &mut [u8], or DMA master references overlapping bytes,
  • addr is appropriately aligned for format (4 bytes for Argb8888, 2 bytes for Rgb565, 1 byte for L8/A8/A4),
  • stride_bytes >= width * pixel_size(format).
Source

pub fn addr(&self) -> PhysAddr

Physical base address.

Source

pub fn dma_addr(&self) -> DmaAddr

DMA bus address for handoff to a DMA master (DMA2D OMAR, LTDC CFBAR, etc.).

The conversion re-asserts pixel-format alignment; a misaligned framebuffer address is a construction-time bug but dma_addr falls back to byte alignment so callers receive a usable value rather than a panic. Wire errors are surfaced via the pixel validator in the DMA engine itself.

Source

pub fn width(&self) -> u32

Width in pixels.

Source

pub fn height(&self) -> u32

Height in pixels.

Source

pub fn stride_bytes(&self) -> u32

Row stride in bytes.

Source

pub fn format(&self) -> PixelFmt

Pixel format.

Source

pub fn bank(&self) -> Option<u8>

SDRAM bank index (0..SDRAM_BANK_COUNT), or None if this framebuffer lives outside the Bank 2 window.

Source

pub fn byte_len(&self) -> usize

Total framebuffer size in bytes (stride_bytes * height).

Trait Implementations§

Source§

impl Debug for FrameBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.