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:lenbytes atptr, streamedrepstimes before the driver advances to the next segment. - Sequence — the repeating period of the scan:
BCM_SEQUENCE_LENconsecutive segments whoselenandrepsare given byBCM_SEQUENCE. One complete panel refresh consists of this sequence repeatedBCM_SEQUENCE_COUNTtimes. - Group — an optional driver hint:
BCM_SEGMENTS_PER_GROUPconsecutive 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| Layout | One sequence is… | BCM_SEQUENCE_LEN | BCM_SEQUENCE_COUNT |
|---|---|---|---|
| Frame-major bitplane | the whole frame | PLANES | 1 |
| Row-major bitplane | one row’s BCM cycle | PLANES + has_gap + has_tail | NROWS |
Threshold (plain / latched) | the whole frame | 1 | 1 |
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)) // MSBRow-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§
Sourceconst BCM_SEQUENCE: [BcmLenReps; 10]
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).
Sourceconst BCM_SEQUENCE_LEN: usize
const BCM_SEQUENCE_LEN: usize
Number of BCM segments in one sequence, i.e. the number of
meaningful entries in BCM_SEQUENCE.
Sourceconst BCM_SEQUENCE_COUNT: usize
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§
Sourceconst BCM_SEGMENT_COUNT: usize = _
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.
Sourceconst BCM_SEGMENTS_PER_GROUP: usize = 1
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§
Required Methods§
Sourcefn bcm_segment_ptr(&self, index: usize) -> *const u8
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:
selfstays borrowed and is not mutated for the whole time the pointer is used by the peripheral (hold the borrow — e.g. an embassyMutex<StaticCell<_>>guarding a&mut— across the transfer);- the framebuffer is not moved while the transfer is live, so it
must live in
static/StaticCellmemory, never on a task stack; - the pointer is aligned to
align_of::<Self::Word>()before casting to*const Self::Word(a framebuffer instaticmemory satisfies this), and at mostlenbytes 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§
Sourcefn bcm_segment_count(&self) -> usize
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.
Sourcefn bcm_segment(&self, index: usize) -> BcmSegment
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.
Sourcefn bcm_segments_per_group(&self) -> usize
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".