Skip to main content

FrameBuffer

Trait FrameBuffer 

Source
pub trait FrameBuffer {
    type Word;

    const BCM_SEQUENCE: [BcmLenReps; 10];
    const BCM_SEQUENCE_LEN: usize;
    const BCM_SEQUENCE_COUNT: usize;
    const BCM_SEGMENT_COUNT: usize = _;
    const BCM_SEGMENTS_PER_GROUP: usize = 1;

    // Required method
    fn bcm_segment_ptr(&self, index: usize) -> *const u8;

    // Provided methods
    fn bcm_segment_count(&self) -> usize { ... }
    fn bcm_segment(&self, index: usize) -> BcmSegment { ... }
    fn bcm_segments_per_group(&self) -> usize { ... }
}
Expand description

Framebuffer that exposes its BCM scan sequence as an ordered series of segments.

§Terminology

  • Segment — the atomic unit, a BcmSegment: len bytes at ptr, streamed reps times before the driver advances to the next segment.
  • Sequence — the repeating period of the scan: BCM_SEQUENCE_LEN consecutive segments whose len and reps are given by BCM_SEQUENCE. One complete panel refresh consists of this sequence repeated BCM_SEQUENCE_COUNT times.
  • Group — an optional driver hint: BCM_SEGMENTS_PER_GROUP consecutive segments that a driver may chain into a single DMA transfer. Groups never straddle a sequence boundary.
one refresh  = BCM_SEGMENT_COUNT segments
             = BCM_SEQUENCE_COUNT repetitions of one sequence
one sequence = BCM_SEQUENCE_LEN segments (BCM_SEQUENCE)
one segment  = len bytes, streamed reps times
LayoutOne sequence is…BCM_SEQUENCE_LENBCM_SEQUENCE_COUNT
Frame-major bitplanethe whole framePLANES1
Row-major bitplaneone row’s BCM cyclePLANES + has_gap + has_tailNROWS
Threshold (plain / latched)the whole frame11

Row-major framebuffers repeat the same (len, reps) pattern NROWS times, so BCM_SEQUENCE holds one row’s worth of entries instead of the whole frame’s.

§Segment Ordering

Frame-major (bitplane) framebuffers describe the whole frame in a single sequence of PLANES segments (BCM_SEQUENCE_LEN == PLANES, BCM_SEQUENCE_COUNT == 1). Planes are LSB-first and stored contiguously, so each segment streams a whole suffix of planes: the segment for plane k starts at plane k, covers the remaining planes, and is repeated just enough times to bring plane k’s total coverage to 2^k:

segment 0: (plane0_ptr, PLANES*plane_bytes, 1)      // LSB; all planes
segment 1: (plane1_ptr, (PLANES-1)*plane_bytes, 1)
segment 2: (plane2_ptr, (PLANES-2)*plane_bytes, 2)
…
segment N: (planeN_ptr, plane_bytes, 2^(PLANES-2))  // MSB

Row-major framebuffers repeat one sequence per row (BCM_SEQUENCE_COUNT == NROWS). Planes are LSB-first within each row and stored contiguously. The inter-row gap segment sits between plane 0 and plane 1 — the point where the row address changes; with a gap enabled, plane 0 stands alone and plane 1’s segment gets 2 reps:

sequence 0 (row 0):
  (row0_plane0_ptr, PLANES*pixel_bytes, 1)
  (row0_gap_ptr, gap_bytes, 1)                    // if enabled
  (row0_plane1_ptr, (PLANES-1)*pixel_bytes, 1|2)  // 2 reps if gap
  …
  (row0_planeN_ptr, pixel_bytes, 2^(PLANES-2))
  (row0_trailer_ptr, trailer_bytes, 1)            // if enabled
sequence 1 (row 1):
  …

Threshold-based framebuffers produce a single segment with reps = 1 covering the entire buffer.

Required Associated Constants§

Source

const BCM_SEQUENCE: [BcmLenReps; 10]

Static (len, reps) of the segments in one sequence, in scan order.

This is instance-free data: len is the byte length of a segment and reps is how many times it is streamed before advancing to the next one. Drivers can use it at compile time to size transfer resources (for example DMA descriptor tables) without needing a framebuffer instance.

Only the first BCM_SEQUENCE_LEN entries are meaningful; the remaining entries are BcmLenReps::ZERO padding (stable Rust does not allow the array length to be computed from the implementor’s const generics).

Source

const BCM_SEQUENCE_LEN: usize

Number of BCM segments in one sequence, i.e. the number of meaningful entries in BCM_SEQUENCE.

Source

const BCM_SEQUENCE_COUNT: usize

Number of times the sequence repeats in one complete panel refresh: NROWS for row-major framebuffers (one sequence per row), 1 for frame-major and threshold framebuffers (the sequence covers the whole frame).

Provided Associated Constants§

Source

const BCM_SEGMENT_COUNT: usize = _

Total number of BCM segments streamed for one complete panel refresh (all rows, all planes).

The default implementation is BCM_SEQUENCE_LEN * BCM_SEQUENCE_COUNT.

Source

const BCM_SEGMENTS_PER_GROUP: usize = 1

Number of consecutive segments that a driver may chain into a single DMA transfer. Must divide BCM_SEQUENCE_LEN: groups never straddle a sequence boundary.

  • Frame-major framebuffers use 1 (each plane is its own group).
  • Row-major framebuffers use PLANES + has_gap + has_tail (all segments for one row form a single transfer).

Required Associated Types§

Source

type Word

The DMA word type used by this framebuffer (u8 for latched, u16 for direct-drive). Driver implementations can use this to enforce that pin configurations match the framebuffer at compile time.

Required Methods§

Source

fn bcm_segment_ptr(&self, index: usize) -> *const u8

Returns the byte pointer for the index-th BCM segment.

The len and reps for this segment come from BCM_SEQUENCE[index % BCM_SEQUENCE_LEN].

§Pointer validity

The returned pointer borrows from self but escapes as a raw pointer, so the compiler cannot enforce how long it stays valid. The caller must ensure that:

  • self stays borrowed and is not mutated for the whole time the pointer is used by the peripheral (hold the borrow — e.g. an embassy Mutex<StaticCell<_>> guarding a &mut — across the transfer);
  • the framebuffer is not moved while the transfer is live, so it must live in static/StaticCell memory, never on a task stack;
  • the pointer is aligned to align_of::<Self::Word>() before casting to *const Self::Word (a framebuffer in static memory satisfies this), and at most len bytes are read from it.

bcm_segment wraps this together with the static (len, reps) and is the preferred entry point.

§Panics

Panics if index >= BCM_SEGMENT_COUNT.

Provided Methods§

Source

fn bcm_segment_count(&self) -> usize

Total number of BCM segments streamed for one complete panel refresh.

The default implementation returns Self::BCM_SEGMENT_COUNT.

Source

fn bcm_segment(&self, index: usize) -> BcmSegment

Returns the index-th BCM segment.

The provided implementation combines bcm_segment_ptr with the static (len, reps) from BCM_SEQUENCE. The returned BcmSegment inherits the pointer validity contract of bcm_segment_ptr.

§Panics

Panics if index >= BCM_SEGMENT_COUNT.

Source

fn bcm_segments_per_group(&self) -> usize

Number of consecutive segments that form one transfer group.

The default implementation returns Self::BCM_SEGMENTS_PER_GROUP.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F: FrameBuffer, M: PixelRemapper, const PANEL_ROWS: usize, const PANEL_COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize, const TILE_ROWS: usize, const TILE_COLS: usize, const FB_COLS: usize> FrameBuffer for TiledFrameBuffer<F, M, PANEL_ROWS, PANEL_COLS, NROWS, BITS, FRAME_COUNT, TILE_ROWS, TILE_COLS, FB_COLS>

Source§

const BCM_SEQUENCE: [BcmLenReps; 10] = F::BCM_SEQUENCE

Source§

const BCM_SEQUENCE_LEN: usize = F::BCM_SEQUENCE_LEN

Source§

const BCM_SEQUENCE_COUNT: usize = F::BCM_SEQUENCE_COUNT

Source§

const BCM_SEGMENTS_PER_GROUP: usize = F::BCM_SEGMENTS_PER_GROUP

Source§

type Word = <F as FrameBuffer>::Word

Source§

impl<F: FrameBuffer, M: PixelRemapper> FrameBuffer for RemappedFrameBuffer<F, M>

Source§

const BCM_SEQUENCE: [BcmLenReps; 10] = F::BCM_SEQUENCE

Source§

const BCM_SEQUENCE_LEN: usize = F::BCM_SEQUENCE_LEN

Source§

const BCM_SEQUENCE_COUNT: usize = F::BCM_SEQUENCE_COUNT

Source§

const BCM_SEGMENTS_PER_GROUP: usize = F::BCM_SEGMENTS_PER_GROUP

Source§

type Word = <F as FrameBuffer>::Word

Source§

impl<const NROWS: usize, const COLS: usize, const PLANES: usize> FrameBuffer for hub75_framebuffer::bitplane::latched::frame::DmaFrameBuffer<NROWS, COLS, PLANES>

Source§

impl<const NROWS: usize, const COLS: usize, const PLANES: usize> FrameBuffer for hub75_framebuffer::bitplane::latched::row::DmaFrameBuffer<NROWS, COLS, PLANES>

Source§

impl<const NROWS: usize, const COLS: usize, const PLANES: usize> FrameBuffer for hub75_framebuffer::bitplane::plain::frame::DmaFrameBuffer<NROWS, COLS, PLANES>

Source§

impl<const NROWS: usize, const COLS: usize, const PLANES: usize> FrameBuffer for hub75_framebuffer::bitplane::plain::row::DmaFrameBuffer<NROWS, COLS, PLANES>

Source§

impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> FrameBuffer for hub75_framebuffer::latched::DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>

Source§

impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> FrameBuffer for hub75_framebuffer::plain::DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>