rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
gfx_turn.c File Reference

Screen rotation 180° in the flush. See include/gfx_turn.h. More...

#include "gfx_turn.h"
#include <stdatomic.h>
#include <stddef.h>
#include <string.h>

Functions

void gfx_turn_init (gfx_turn_t *t, int width, int height)
 NORMAL, nothing failed, for a width x height picture; the shown flag NORMAL too.
void gfx_turn_request (gfx_turn_t *t, bool turned)
 What the setting asks for; taken at the next gfx_turn_next().
void gfx_turn_fail (gfx_turn_t *t, gfx_turn_fail_t why)
 Fall back to NORMAL until the next start.
bool gfx_turn_drawing (const gfx_turn_t *t)
 Whether the frame being drawn goes into a logical buffer.
void gfx_turn_begin (gfx_turn_t *t, const gfx_canvas_t *logical)
 Start a frame: drawing turned, the damage record bound to logical, empty and attached; NORMAL, no record attached.
static gfx_turn_show_t fall_back (gfx_turn_t *t, const gfx_color_t *logical, gfx_color_t *fb, gfx_turn_fail_t why)
 Fall back for this frame: logical into fb as drawn.
gfx_turn_show_t gfx_turn_flush (gfx_turn_t *t, const gfx_color_t *logical, gfx_color_t *fb, const gfx_turn_ops_t *ops)
 End a frame: copy what it drew into fb, turned.
bool gfx_turn_presented (gfx_turn_t *t, gfx_turn_show_t show)
 The frame of the last flush is on the glass: set the shown flag.
void gfx_turn_next (gfx_turn_t *t)
 After a flip: take the request for the next frame.
bool gfx_turn_take_repaint (gfx_turn_t *t)
 Whether the UI must repaint everything before the next frame; clears it.
bool gfx_turn_take_alert (gfx_turn_t *t)
 Whether the fallback's alert is due; clears it.
bool gfx_turn_shown (void)
 What the panel shows: the one flag picture and touch turn by. Read from any task.
gfx_turn_copy_t gfx_turn_engine_copy (const gfx_turn_engine_t *e, const gfx_color_t *src, gfx_color_t *dst, gfx_rect_t r, int width, int height, uint32_t budget_us)
 One block through e: the job built from r with e->done_ctx as its user_data, submitted and waited for. The copy function of a gfx_turn_ops_t calls it.
uint32_t gfx_turn_stray_dones (void)
 Done callbacks that came with a NULL context since start-up.

Variables

static atomic_bool s_shown
 What the panel shows (gfx_turn_shown()): written by the task that flips, read by the touch task.
atomic_uint gfx_turn_stray
 Done callbacks that came with a NULL context; gfx_turn.c.

Detailed Description

Screen rotation 180° in the flush. See include/gfx_turn.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ fall_back()

gfx_turn_show_t fall_back ( gfx_turn_t * t,
const gfx_color_t * logical,
gfx_color_t * fb,
gfx_turn_fail_t why )
static

Fall back for this frame: logical into fb as drawn.

Parameters
tthe state
logicalthe logical buffer
fbthe frame buffer
whythe reason
Returns
GFX_TURN_SHOW_FALLBACK

◆ gfx_turn_begin()

void gfx_turn_begin ( gfx_turn_t * t,
const gfx_canvas_t * logical )

Start a frame: drawing turned, the damage record bound to logical, empty and attached; NORMAL, no record attached.

Parameters
tthe state
logicalthe canvas the frame is drawn on

◆ gfx_turn_drawing()

bool gfx_turn_drawing ( const gfx_turn_t * t)

Whether the frame being drawn goes into a logical buffer.

Parameters
tthe state
Returns
true while turned and not fallen back

◆ gfx_turn_engine_copy()

gfx_turn_copy_t gfx_turn_engine_copy ( const gfx_turn_engine_t * e,
const gfx_color_t * src,
gfx_color_t * dst,
gfx_rect_t r,
int width,
int height,
uint32_t budget_us )

One block through e: the job built from r with e->done_ctx as its user_data, submitted and waited for. The copy function of a gfx_turn_ops_t calls it.

Parameters
ethe engine
srcthe logical buffer
dstthe frame buffer of the same index
rthe block, in src's coordinates
widthboth pictures' width, pixels
heighttheir height, rows
budget_usthe longest wait, us
Returns
GFX_TURN_COPY_ERROR when e, its done_ctx or a callback is missing or the engine refuses the job; GFX_TURN_COPY_TIMEOUT when the done callback does not come in time

◆ gfx_turn_fail()

void gfx_turn_fail ( gfx_turn_t * t,
gfx_turn_fail_t why )

Fall back to NORMAL until the next start.

Parameters
tthe state
whythe reason, not GFX_TURN_FAIL_NONE

◆ gfx_turn_flush()

gfx_turn_show_t gfx_turn_flush ( gfx_turn_t * t,
const gfx_color_t * logical,
gfx_color_t * fb,
const gfx_turn_ops_t * ops )

End a frame: copy what it drew into fb, turned.

Detaches the damage record. NORMAL copies nothing. Turned, the record's rectangles, or the whole picture while full flips are left, go through ops within GFX_TURN_BUDGET_US; a copy that times out or fails makes the frame the logical buffer as drawn, unturned, and the state fallen back.

Parameters
tthe state
logicalthe logical buffer the frame was drawn into
fbthe frame buffer of the same index
opsthe copy engine
Returns
what fb now holds

◆ gfx_turn_init()

void gfx_turn_init ( gfx_turn_t * t,
int width,
int height )

NORMAL, nothing failed, for a width x height picture; the shown flag NORMAL too.

Parameters
tthe state
widththe picture's width, pixels
heightits height, rows

◆ gfx_turn_next()

void gfx_turn_next ( gfx_turn_t * t)

After a flip: take the request for the next frame.

A switch asks the UI for a whole repaint (gfx_turn_take_repaint()), and a switch to 180° copies the whole picture for GFX_TURN_FULL_FLIPS flips. A request for 180° that meets a fallback asks for its alert once.

Parameters
tthe state

◆ gfx_turn_presented()

bool gfx_turn_presented ( gfx_turn_t * t,
gfx_turn_show_t show )

The frame of the last flush is on the glass: set the shown flag.

Parameters
tthe state
showwhat that flush returned
Returns
true when the shown flag changed

◆ gfx_turn_request()

void gfx_turn_request ( gfx_turn_t * t,
bool turned )

What the setting asks for; taken at the next gfx_turn_next().

Parameters
tthe state
turnedtrue for 180°

◆ gfx_turn_shown()

bool gfx_turn_shown ( void )

What the panel shows: the one flag picture and touch turn by. Read from any task.

Returns
true while the picture on the glass is turned by 180°

◆ gfx_turn_stray_dones()

uint32_t gfx_turn_stray_dones ( void )

Done callbacks that came with a NULL context since start-up.

Returns
the count; it wraps at 2^32

◆ gfx_turn_take_alert()

bool gfx_turn_take_alert ( gfx_turn_t * t)

Whether the fallback's alert is due; clears it.

Parameters
tthe state
Returns
true once per start that falls back while 180° is asked for

◆ gfx_turn_take_repaint()

bool gfx_turn_take_repaint ( gfx_turn_t * t)

Whether the UI must repaint everything before the next frame; clears it.

Parameters
tthe state
Returns
true once per switch