|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
2D Drawing Engine (DRW / D/AVE 2D) geometry primitives More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_drw.h"#include "ra8_drw_dlist.h"#include "ra8_drw_internal.h"#include "ra8_drw_regs.h"#include "ra8_err.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_drw_dlist_span_t : uint8_t { k_ra8_drw_dlist_entry_words = 2U , k_ra8_drw_dlist_special_words = 1U , k_ra8_drw_dlist_fill_regs = 4U , k_ra8_drw_dlist_fill_words = 9U } |
| Word spans of the display-list entries the builder emits. More... | |
Functions | |
| ra8_err_t | ra8_drw_fill_rect (const ra8_drw_rect_t *rect) |
| Issue a solid-fill rectangle blit into the framebuffer. | |
| ra8_err_t | ra8_drw_blit_textured_rect (const ra8_drw_rect_t *rect) |
| Blit a textured rectangle (texture must be programmed first). | |
| static void | internal_program_line_limiters (const ra8_drw_line_t *line) |
| Program L1..L4 START/XADD/YADD for a stroked line. | |
| ra8_err_t | ra8_drw_draw_line (const ra8_drw_line_t *line) |
| Issue an anti-aliased line stroke between two points. | |
| ra8_err_t | ra8_drw_draw_triangle (const ra8_drw_triangle_t *tri) |
| Issue an anti-aliased filled triangle. | |
| ra8_err_t | ra8_drw_run_dlist (const uint32_t *dlist_addr) |
| Trigger execution of a display list. | |
| static void | internal_dlist_put_reg (ra8_drw_dlist_t *dl, ra8_drw_dlr_index_t idx, uint32_t val) |
| Append a single-register display-list entry to the builder buffer. | |
| static void | internal_dlist_put_special (ra8_drw_dlist_t *dl, uint32_t arg) |
| Append a display-list special word (wait or terminate). | |
| ra8_err_t | ra8_drw_dlist_begin (ra8_drw_dlist_t *dl, uint32_t *buf, uint32_t cap_words) |
| Bind a display-list builder to a caller-owned word buffer. | |
| ra8_err_t | ra8_drw_dlist_add_fill (ra8_drw_dlist_t *dl, const ra8_drw_rect_t *rect) |
| Append one solid-rectangle fill primitive to a display list. | |
| ra8_err_t | ra8_drw_dlist_end (ra8_drw_dlist_t *dl) |
| Close a display list with its terminator word. | |
| ra8_err_t | ra8_drw_dlist_run (const ra8_drw_dlist_t *dl) |
| Trigger a built display list (writes DLISTSTART). | |
| ra8_err_t | ra8_drw_perf_arm (ra8_drw_perftrigger_t event_ctr1, ra8_drw_perftrigger_t event_ctr2) |
| Programme PERFTRIGGER for the two performance counters and reset both PERFCOUNTk registers. | |
| ra8_err_t | ra8_drw_perf_read (ra8_drw_perfcounter_id_t id, uint32_t *out) |
| Read one PERFCOUNTk register. | |
| ra8_err_t | ra8_drw_perf_reset (ra8_drw_perfcounter_id_t id) |
| Reset one PERFCOUNTk register to zero. | |
Variables | |
| static const char * | s_tag = "DRW" |
| Logging tag for the DRW driver. | |
2D Drawing Engine (DRW / D/AVE 2D) geometry primitives
Geometry-primitive half of the RA8D2 D/AVE 2D driver, split out of ra8_drw.c to keep each translation unit under the file-size cap. This TU owns the drawing primitives (fill / textured-blit / line / triangle), display-list submission and the performance counters. The surface-setup, lifecycle, IRQ and cache helpers remain in ra8_drw.c. This TU keeps its own read-only copy of the s_tag logging tag and reuses the shared limiter helper internal_program_rect_limiters declared in ra8_drw_internal.h.
Every register access carries a HUM Ch 62 citation immediately above it so cite_check.py can validate provenance.
Definition in file ra8_drw_draw.c.
| enum ra8_drw_dlist_span_t : uint8_t |
Word spans of the display-list entries the builder emits.
A single-register entry is a tag word plus one value word; a special word (wait / terminate) is one word. A solid-fill primitive programs COLOR1, SIZE, CONTROL and ORIGIN and appends one wait word.
Definition at line 345 of file ra8_drw_draw.c.
|
static |
Append a single-register display-list entry to the builder buffer.
Writes a one-index tag (register index OR k_ra8_drw_dlr_tag_one_index) followed by the value word. The caller (ra8_drw_dlist_add_fill) reserves the whole primitive's span up front, so this writer never bounds-checks – it is a plain memory append to the caller buffer, never MMIO.
| [in,out] | dl | Bound builder with at least two free words. |
| [in] | idx | Register index (ra8_drw_dlr_index_t). |
| [in] | val | Value word to program. |
val at the reserved slot. Definition at line 374 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::buf, ra8_drw_dlist_t::count, k_ra8_drw_dlist_entry_words, and k_ra8_drw_dlr_tag_one_index.
Referenced by ra8_drw_dlist_add_fill().
|
static |
Append a display-list special word (wait or terminate).
Encodes k_ra8_drw_dlr_eol_byte with arg in byte 1. The caller reserves the word up front, so this writer never bounds-checks.
| [in,out] | dl | Bound builder with at least one free word. |
| [in] | arg | End-of-list argument (wait / terminate). |
Definition at line 400 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::buf, ra8_drw_dlist_t::count, k_ra8_drw_dlist_special_words, k_ra8_drw_dlr_eol_arg_pos, and k_ra8_drw_dlr_eol_byte.
Referenced by ra8_drw_dlist_add_fill(), and ra8_drw_dlist_end().
|
static |
Program L1..L4 START/XADD/YADD for a stroked line.
HUM Ch 62.2.10-62.2.12 (LnSTART/LnXADD/LnYADD pp 3698-3699). The line is encoded as four perpendicular limiters per HUM Ch 62.4.4 "Lines" p 3725.
| [in] | line | Validated line descriptor. |
Definition at line 174 of file ra8_drw_draw.c.
References internal_iabs(), internal_to_subpixel(), k_ra8_drw_off_l1band, k_ra8_drw_off_l1start, k_ra8_drw_off_l1xadd, k_ra8_drw_off_l1yadd, k_ra8_drw_off_l2band, k_ra8_drw_off_l2start, k_ra8_drw_off_l2xadd, k_ra8_drw_off_l2yadd, k_ra8_drw_off_l3start, k_ra8_drw_off_l3xadd, k_ra8_drw_off_l3yadd, k_ra8_drw_off_l4start, k_ra8_drw_off_l4xadd, k_ra8_drw_off_l4yadd, k_ra8_drw_subpixel_unit, ra8_drw_reg32(), ra8_drw_line_t::width_px, ra8_drw_line_t::x0, ra8_drw_line_t::x1, ra8_drw_line_t::y0, and ra8_drw_line_t::y1.
Referenced by ra8_drw_draw_line().
|
nodiscard |
Blit a textured rectangle (texture must be programmed first).
The caller programmes the texture state via ra8_drw_set_texture (which also enables CONTROL2.TEXTUREENABLE). This function then writes the rectangle limiter set + SIZE and starts the engine via a write to CONTROL.
| [in] | rect | Destination rectangle. Must not be nullptr. |
| k_ra8_ok | Blit issued. |
| k_ra8_err_null_ptr | rect was nullptr. |
| k_ra8_err_invalid_arg | width/height out of range. |
Definition at line 98 of file ra8_drw_draw.c.
References ra8_drw_rect_t::height_px, k_ra8_drw_cachectl_cflushtx, k_ra8_drw_max_height_px, k_ra8_drw_max_width_px, k_ra8_drw_min_dim_px, k_ra8_drw_off_cachectl, k_ra8_drw_off_control, k_ra8_drw_off_lustart, k_ra8_drw_off_luxadd, k_ra8_drw_off_luyadd, k_ra8_drw_off_lvstartf, k_ra8_drw_off_lvstarti, k_ra8_drw_off_lvxaddi, k_ra8_drw_off_lvyaddi, k_ra8_drw_off_lvyxaddf, k_ra8_drw_off_origin, k_ra8_drw_subpixel_unit, k_ra8_err_invalid_arg, k_ra8_ok, priv_program_rect_bbox(), priv_ra8_drw_internal_rect_above_max(), priv_ra8_drw_internal_rect_below_min(), priv_ra8_drw_internal_rect_off_surface(), priv_ra8_drw_internal_rect_origin(), RA8_CHECK_NULL_PTR, ra8_drw_reg32(), s_tag, and ra8_drw_rect_t::width_px.
|
nodiscard |
Append one solid-rectangle fill primitive to a display list.
Emits the display-list entries the DRW needs to paint an axis-aligned solid rectangle – COLOR1, SIZE, CONTROL (limiters off, the bounding-box scan is the rectangle, HUM Ch 62.6.2 p 3716) and ORIGIN, the write that triggers the render – followed by a "wait for pipeline and cache" word so the primitive fully drains before the next one begins. This is the same geometry the register-mode ra8_drw_fill_rect uses; the surface format (CONTROL2, PITCH, cache) stays as ra8_drw_init programmed it. A full-surface rectangle with colour 0 is how a display list clears the framebuffer.
| [in,out] | dl | Bound builder (ra8_drw_dlist_begin succeeded). |
| [in] | rect | Rectangle in pixels; color_argb8888 is 0xAARRGGBB. |
| k_ra8_ok | Primitive appended. |
| k_ra8_err_null_ptr | dl or rect was nullptr. |
| k_ra8_err_invalid_arg | Dimensions out of range or off the surface. |
| k_ra8_err_no_mem | The buffer cannot hold this primitive. |
dl was bound by ra8_drw_dlist_begin and not yet ended. Definition at line 425 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::cap_words, ra8_drw_rect_t::color_argb8888, ra8_drw_dlist_t::count, ra8_drw_rect_t::height_px, internal_dlist_put_reg(), internal_dlist_put_special(), k_ra8_drw_dlist_fill_words, k_ra8_drw_dlr_arg_wait, k_ra8_drw_dlr_idx_color1, k_ra8_drw_dlr_idx_control, k_ra8_drw_dlr_idx_origin, k_ra8_drw_dlr_idx_size, k_ra8_drw_max_height_px, k_ra8_drw_max_width_px, k_ra8_drw_min_dim_px, k_ra8_drw_size_height_pos, k_ra8_err_invalid_arg, k_ra8_err_no_mem, k_ra8_ok, ra8_drw_dlist_t::overflow, priv_ra8_drw_internal_rect_above_max(), priv_ra8_drw_internal_rect_below_min(), priv_ra8_drw_internal_rect_off_surface(), priv_ra8_drw_internal_rect_origin(), RA8_CHECK_NULL_PTR, s_tag, and ra8_drw_rect_t::width_px.
Referenced by demo_build_dlist().
|
nodiscard |
Bind a display-list builder to a caller-owned word buffer.
Resets the builder to empty and records the target buffer. The buffer must be 4-byte aligned and live in a region the DRW bus initiator can read (SRAM). No words are written yet.
| [out] | dl | Builder to initialize. |
| [in] | buf | 4-byte-aligned word buffer in DRW-readable memory. |
| [in] | cap_words | Capacity of buf in 32-bit words (>= 1). |
| k_ra8_ok | Builder bound and cleared. |
| k_ra8_err_null_ptr | dl or buf was nullptr. |
| k_ra8_err_invalid_arg | buf not 4-byte aligned or cap_words 0. |
dl and buf are non-null. buf is 4-byte aligned and cap_words >= 1. Definition at line 407 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::buf, ra8_drw_dlist_t::cap_words, ra8_drw_dlist_t::count, k_ra8_drw_internal_align_mask, k_ra8_err_invalid_arg, k_ra8_ok, ra8_drw_dlist_t::overflow, RA8_CHECK_NULL_PTR, s_tag, and ra8_drw_dlist_t::terminated.
Referenced by demo_build_dlist().
|
nodiscard |
Close a display list with its terminator word.
Appends the end-of-list marker so the DLR stops fetching after the last primitive. Must be called before ra8_drw_dlist_run.
| [in,out] | dl | Bound builder holding at least one primitive. |
| k_ra8_ok | Terminator appended; the list is runnable. |
| k_ra8_err_null_ptr | dl was nullptr. |
| k_ra8_err_no_mem | The buffer cannot hold the terminator. |
| k_ra8_err_invalid_arg | The builder already overflowed. |
dl is non-null and was bound by ra8_drw_dlist_begin. dl has not overflowed. Definition at line 467 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::cap_words, ra8_drw_dlist_t::count, internal_dlist_put_special(), k_ra8_drw_dlist_special_words, k_ra8_drw_dlr_arg_terminate, k_ra8_err_invalid_arg, k_ra8_err_no_mem, k_ra8_ok, ra8_drw_dlist_t::overflow, RA8_CHECK_NULL_PTR, s_tag, and ra8_drw_dlist_t::terminated.
Referenced by demo_build_dlist().
|
nodiscard |
Trigger a built display list (writes DLISTSTART).
Convenience wrapper over ra8_drw_run_dlist that first checks the builder closed cleanly. It flushes the DRW caches and writes DLISTSTART with the buffer address; the DLR then clears and repaints the framebuffer with no CPU framebuffer writes. Poll ra8_drw_wait_idle (or STATUS.DLISTACTIVE) for completion before reading the framebuffer.
| [in] | dl | Terminated builder (ra8_drw_dlist_end succeeded). |
| k_ra8_ok | Display list triggered. |
| k_ra8_err_null_ptr | dl was nullptr. |
| k_ra8_err_invalid_arg | Builder overflowed, empty or not terminated. |
dl is non-null, terminated and did not overflow. Definition at line 482 of file ra8_drw_draw.c.
References ra8_drw_dlist_t::buf, ra8_drw_dlist_t::count, k_ra8_err_invalid_arg, ra8_drw_dlist_t::overflow, RA8_CHECK_NULL_PTR, ra8_drw_run_dlist(), s_tag, and ra8_drw_dlist_t::terminated.
Referenced by main().
|
nodiscard |
Issue an anti-aliased line stroke between two points.
Pre-computes the four perpendicular limiters bounding the stroke, programmes COLOR1, then enables LIM1..LIM4 with the standard intersect topology. HUM Ch 62.4.4 "Lines" p 3725.
| [in] | line | Line parameters. Must not be nullptr. |
| k_ra8_ok | Line issued. |
| k_ra8_err_null_ptr | line was nullptr. |
| k_ra8_err_invalid_arg | width_px == 0 or > 1024. |
Definition at line 206 of file ra8_drw_draw.c.
References ra8_drw_line_t::color_argb8888, internal_program_line_limiters(), k_ra8_drw_cachectl_all_en, k_ra8_drw_cachectl_cflushfx, k_ra8_drw_control_line_quad, k_ra8_drw_max_width_px, k_ra8_drw_off_cachectl, k_ra8_drw_off_control, k_ra8_drw_off_origin, k_ra8_drw_off_size, k_ra8_drw_size_height_pos, k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_drw_internal_color1_write(), priv_ra8_drw_internal_origin(), RA8_CHECK_NULL_PTR, ra8_drw_reg32(), s_tag, ra8_drw_line_t::width_px, ra8_drw_line_t::x0, ra8_drw_line_t::x1, ra8_drw_line_t::y0, and ra8_drw_line_t::y1.
|
nodiscard |
Issue an anti-aliased filled triangle.
Computes the three edge limiters and writes CONTROL with LIM1..LIM3 enabled. HUM Ch 62.4.5 "Triangles" p 3726.
| [in] | tri | Triangle parameters. Must not be nullptr. |
| k_ra8_ok | Triangle issued. |
| k_ra8_err_null_ptr | tri was nullptr. |
Definition at line 245 of file ra8_drw_draw.c.
References ra8_drw_triangle_t::color_argb8888, internal_to_subpixel(), k_ra8_drw_cachectl_all_en, k_ra8_drw_cachectl_cflushfx, k_ra8_drw_control_triangle, k_ra8_drw_off_cachectl, k_ra8_drw_off_control, k_ra8_drw_off_l1start, k_ra8_drw_off_l1xadd, k_ra8_drw_off_l1yadd, k_ra8_drw_off_l2start, k_ra8_drw_off_l2xadd, k_ra8_drw_off_l2yadd, k_ra8_drw_off_l3start, k_ra8_drw_off_l3xadd, k_ra8_drw_off_l3yadd, k_ra8_drw_off_origin, k_ra8_drw_off_size, k_ra8_drw_size_height_pos, k_ra8_ok, priv_ra8_drw_internal_color1_write(), priv_ra8_drw_internal_origin(), RA8_CHECK_NULL_PTR, ra8_drw_reg32(), s_tag, ra8_drw_triangle_t::x0, ra8_drw_triangle_t::x1, ra8_drw_triangle_t::x2, ra8_drw_triangle_t::y0, ra8_drw_triangle_t::y1, and ra8_drw_triangle_t::y2.
|
nodiscard |
Issue a solid-fill rectangle blit into the framebuffer.
Programmes the DRW limiters to bound a rectangle, sets COLOR1 to the requested ARGB colour, then writes CONTROL with the four limiter-enable bits set to kick the engine.
| [in] | rect | Rectangle parameters. Must not be nullptr. |
| k_ra8_ok | Blit issued (engine may still be busy). |
| k_ra8_err_null_ptr | rect was nullptr. |
| k_ra8_err_invalid_arg | width/height was 0 or > 1024. |
Definition at line 59 of file ra8_drw_draw.c.
References ra8_drw_rect_t::color_argb8888, ra8_drw_rect_t::height_px, k_ra8_drw_max_height_px, k_ra8_drw_max_width_px, k_ra8_drw_min_dim_px, k_ra8_drw_off_control, k_ra8_drw_off_origin, k_ra8_err_invalid_arg, k_ra8_ok, priv_program_rect_bbox(), priv_ra8_drw_internal_color1_write(), priv_ra8_drw_internal_rect_off_surface(), priv_ra8_drw_internal_rect_origin(), RA8_CHECK_NULL_PTR, ra8_drw_reg32(), s_tag, and ra8_drw_rect_t::width_px.
Referenced by drw_blend_fill(), and drw_demo_fill_and_check().
|
nodiscard |
Programme PERFTRIGGER for the two performance counters and reset both PERFCOUNTk registers.
| [in] | event_ctr1 | Trigger event for PERFCOUNT1. |
| [in] | event_ctr2 | Trigger event for PERFCOUNT2. |
| k_ra8_ok | Counters armed. |
| k_ra8_err_invalid_arg | Either event > 0x1F. |
Definition at line 496 of file ra8_drw_draw.c.
References k_ra8_drw_internal_perfev_max, k_ra8_drw_off_perfcount1, k_ra8_drw_off_perfcount2, k_ra8_drw_off_perftrigger, k_ra8_drw_perftrigger2_pos, k_ra8_err_invalid_arg, k_ra8_ok, and ra8_drw_reg32().
|
nodiscard |
Read one PERFCOUNTk register.
| [in] | id | Counter identifier. |
| [out] | out | Receives the 32-bit count. |
| k_ra8_ok | Count read. |
| k_ra8_err_null_ptr | out was nullptr. |
| k_ra8_err_invalid_arg | id outside enum. |
Definition at line 515 of file ra8_drw_draw.c.
References k_ra8_drw_off_perfcount1, k_ra8_drw_off_perfcount2, k_ra8_drw_perfctr_1, k_ra8_drw_perfctr_2, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_drw_reg32(), and s_tag.
|
nodiscard |
Reset one PERFCOUNTk register to zero.
| [in] | id | Counter identifier. |
| k_ra8_ok | Counter cleared. |
| k_ra8_err_invalid_arg | id outside enum. |
Definition at line 532 of file ra8_drw_draw.c.
References k_ra8_drw_off_perfcount1, k_ra8_drw_off_perfcount2, k_ra8_drw_perfctr_1, k_ra8_drw_perfctr_2, k_ra8_err_invalid_arg, k_ra8_ok, and ra8_drw_reg32().
|
nodiscard |
Trigger execution of a display list.
Writes DLISTSTART with the supplied address. The DRW pulls one 32-bit word at a time from RAM and decodes it as (register index, value) pairs until it hits a terminator. HUM Ch 62.6 "Display List Mode" p 3724-3725.
| [in] | dlist_addr | Pointer to the first display-list word in memory; must be 4-byte aligned and reside in a region the DRW bus initiator can read. |
| k_ra8_ok | Display list trigger written. |
| k_ra8_err_invalid_arg | Address null or unaligned. |
Definition at line 312 of file ra8_drw_draw.c.
References k_ra8_drw_cachectl_all_flush, k_ra8_drw_internal_align_mask, k_ra8_drw_off_cachectl, k_ra8_drw_off_dliststart, k_ra8_err_invalid_arg, k_ra8_ok, and ra8_drw_reg32().
Referenced by ra8_drw_dlist_run().
|
static |
Logging tag for the DRW driver.
TU-local read-only copy. ra8_drw.c keeps its own identical copy so both TUs log under the same "DRW" tag without sharing linkage.
Definition at line 52 of file ra8_drw_draw.c.