|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Display Platform Abstraction Layer for the RA8D2. More...
Go to the source code of this file.
Data Structures | |
| struct | display_caps_t |
| Capabilities a backend reports after display_init. More... | |
| struct | display_fb_t |
| Framebuffer descriptor returned by display_get_framebuffer. More... | |
| struct | display_rect_t |
| Rectangle in framebuffer coordinates passed into display_flush. More... | |
| struct | display_cfg_t |
| Configuration descriptor passed into display_init. More... | |
Typedefs | |
| typedef struct display_backend_iface | display_backend_iface_t |
| typedef struct display_handle | display_handle_t |
Enumerations | |
| enum | display_pixfmt_t : uint8_t { k_display_pixfmt_rgb565 = 0U , k_display_pixfmt_rgb888 = 1U , k_display_pixfmt_grey4 = 2U , k_display_pixfmt_grey1 = 3U } |
| Canonical pixel formats the PAL understands. More... | |
| enum | display_refresh_hint_t : uint8_t { k_display_refresh_fast = 0U , k_display_refresh_quality = 1U , k_display_refresh_init = 2U } |
| Intent passed into display_flush; backends map this onto whatever waveform/mode their controller offers. More... | |
Functions | |
| ra8_err_t | display_init (const display_cfg_t *cfg, display_handle_t **out_handle) |
| Initialise the display PAL and bring the selected backend up to a state where display_flush succeeds. | |
| ra8_err_t | display_get_caps (const display_handle_t *d, display_caps_t *out) |
| Query the bound backend's runtime capabilities. | |
| ra8_err_t | display_get_framebuffer (const display_handle_t *d, display_fb_t *out) |
| Return the framebuffer descriptor the backend is targeting. | |
| ra8_err_t | display_flush (const display_handle_t *d, display_rect_t rect, display_refresh_hint_t hint) |
| Commit pending framebuffer changes to the panel. | |
| ra8_err_t | display_clear (const display_handle_t *d, uint32_t color) |
| Clear the entire framebuffer to color. | |
| ra8_err_t | display_deinit (const display_handle_t *d) |
| Release the backend and invalidate the PAL handle. | |
| display_rect_t | display_full_rect (const display_handle_t *d) |
| Convenience helper returning the rect covering the whole framebuffer. | |
Display Platform Abstraction Layer for the RA8D2.
Backend-agnostic API that lets applications draw into a framebuffer and push it to a panel without knowing which display controller is on the other end. Today there are three backends:
Apps swap backends by changing the iface field of their display_cfg_t – no other code touches the underlying controller, so a future e-ink port is a single-line change in the app's config.
+-----------------------------+ display_init / get_framebuffer
| application code | display_flush(rect, hint)
| (ra8_gfx / ra8_box chrome) |
+--------------+--------------+
|
v
+-----------------------------+ one vtable per backend.
| ra8_display_pal (this file) |<- dispatches via display_backend_iface_t
+--------------+--------------+
|
+--------+---------+
| |
v v
+------------+ +-------------+
| LCD (glcdc)| | e-ink stub |
+------------+ +-------------+
The caller owns the framebuffer storage and points the PAL at it through cfg->framebuffer. RGB565 is the canonical app-side format; backends that want a different native depth (e.g. e-ink's 4bpp greyscale) convert during display_flush. This keeps app code portable across backends.
Applications that need to control speed-vs-quality on e-ink pass the hint; LCD backends ignore it.
Definition in file ra8_display_pal.h.
| typedef struct display_backend_iface display_backend_iface_t |
Definition at line 208 of file ra8_display_pal.h.
| typedef struct display_handle display_handle_t |
Definition at line 222 of file ra8_display_pal.h.
| enum display_pixfmt_t : uint8_t |
Canonical pixel formats the PAL understands.
RGB565 is the only format LCD apps need today and is the canonical choice for portable code. Greyscale formats are reserved for e-ink backends that paint natively at lower depth – the LCD backend rejects them with k_ra8_err_not_supported.
Definition at line 98 of file ra8_display_pal.h.
| enum display_refresh_hint_t : uint8_t |
Intent passed into display_flush; backends map this onto whatever waveform/mode their controller offers.
Hint values describe the trade-off the caller wants – not a specific waveform name. On LCD backends every hint behaves the same (flush is effectively a no-op). On e-ink the mapping is:
| Enumerator | |
|---|---|
| k_display_refresh_fast | Prioritise latency. |
| k_display_refresh_quality | Prioritise final quality. |
| k_display_refresh_init | Full reset of the panel. |
Definition at line 121 of file ra8_display_pal.h.
|
nodiscard |
Clear the entire framebuffer to color.
Writes color into every pixel of the framebuffer using the backend's native paint loop. Does NOT call display_flush – callers that want the cleared frame visible on e-ink must follow up with a display_flush(d, display_full_rect(d), k_display_refresh_quality).
| [in] | d | PAL handle. |
| [in] | color | Pixel value to write (interpretation depends on caps.pixfmt). |
| k_ra8_ok | Buffer cleared. |
| k_ra8_err_null_ptr | d was NULL. |
Definition at line 148 of file ra8_display_pal.c.
References internal_validate_handle(), k_ra8_ok, and s_handle.
Referenced by main().
|
nodiscard |
Release the backend and invalidate the PAL handle.
Mirrors display_init: tears down the controller, releases the static handle, and leaves the PAL ready to be re-initialised with a different backend.
| [in] | d | PAL handle to release. |
| k_ra8_ok | Backend released; d is now stale. |
| k_ra8_err_null_ptr | d was NULL. |
Definition at line 157 of file ra8_display_pal.c.
References internal_validate_handle(), k_ra8_ok, s_handle, and s_initialized.
Referenced by main().
|
nodiscard |
Commit pending framebuffer changes to the panel.
On scan-out backends (LCD) this is a memory barrier plus an optional cache clean. On e-ink backends this is the real work step: copy rect from the framebuffer into the controller's internal buffer, then trigger a display update with the waveform mapped from hint.
| [in] | d | PAL handle. |
| [in] | rect | Region of the framebuffer to push. Use display_full_rect(d) for a whole-screen update. |
| [in] | hint | Intent driving the waveform/mode selection. |
| k_ra8_ok | Flush completed (or queued for the next scan on continuous-refresh panels). |
| k_ra8_err_null_ptr | d was NULL. |
| k_ra8_err_invalid_arg | rect extends outside the framebuffer. |
| k_ra8_err_not_supported | Backend does not implement flush yet (e-ink stub returns this). |
Definition at line 139 of file ra8_display_pal.c.
References internal_validate_handle(), k_ra8_ok, and s_handle.
Referenced by cm_present(), ep_run_refresh_cycle(), er_flush_event(), ez_flush(), internal_tc_apply_and_measure(), internal_tc_draw_target(), ls_present(), main(), mg_present(), sh_loading_overlay(), sh_present(), sh_present_loupe(), wc_flush_rect(), wd_flush_full(), wd_flush_rect(), and wk_flush_rect().
| display_rect_t display_full_rect | ( | const display_handle_t * | d | ) |
Convenience helper returning the rect covering the whole framebuffer.
Short-hand for the common case where the caller wants to flush the entire framebuffer. Equivalent to {0, 0, caps.width_px, caps.height_px} if the handle is valid, or an all-zero rectangle if it is not.
| [in] | d | PAL handle. |
| Full-screen | rect when d is a live handle. |
| All-zero | rect when d is NULL or stale. |
Definition at line 173 of file ra8_display_pal.c.
References display_caps_t::height_px, internal_validate_handle(), k_ra8_ok, s_handle, and display_caps_t::width_px.
Referenced by cm_present(), ep_run_refresh_cycle(), er_flush_event(), internal_tc_apply_and_measure(), internal_tc_draw_target(), ls_present(), main(), mg_present(), and wd_flush_full().
|
nodiscard |
Query the bound backend's runtime capabilities.
| [in] | d | PAL handle returned by display_init. |
| [out] | out | Capabilities snapshot. |
| k_ra8_ok | Capabilities written to *out. |
| k_ra8_err_null_ptr | Either argument was NULL. |
Definition at line 119 of file ra8_display_pal.c.
References internal_validate_handle(), k_ra8_ok, RA8_CHECK_NULL_PTR, s_handle, and s_tag.
Referenced by app_bringup_display(), and main().
|
nodiscard |
Return the framebuffer descriptor the backend is targeting.
The pointer in out->pixels is the same buffer the caller passed via cfg->framebuffer. The width / height / stride may differ from the values the caller passed if the backend rounded them up to satisfy an alignment requirement.
| [in] | d | PAL handle. |
| [out] | out | Filled with the framebuffer descriptor. |
| k_ra8_ok | Descriptor written. |
| k_ra8_err_null_ptr | Either argument was NULL. |
| k_ra8_err_not_supported | Backend does not expose a CPU-writable framebuffer (e.g. the e-ink stub before it is wired up). |
Definition at line 129 of file ra8_display_pal.c.
References internal_validate_handle(), k_ra8_ok, RA8_CHECK_NULL_PTR, s_handle, and s_tag.
Referenced by app_bringup_display(), app_bringup_panel(), cm_bringup_panel(), ez_bringup_panel(), gh_glcdc_programmed(), internal_tc_glcdc_bringup(), main(), mg_bringup_panel(), sfr_bringup_panel(), sh_panel_or_halt(), wc_panel_up(), wd_panel_up(), and wk_panel_up().
|
nodiscard |
Initialise the display PAL and bring the selected backend up to a state where display_flush succeeds.
Validates cfg, dispatches into the backend's init function (which on the LCD path runs the full GLCDC bring-up sequence: panel power-on, GLCDC pin/clock setup, settle delay, controller init, BG colour clear, start(true), layer1_show), then stores the resulting context inside the module-static handle and returns its address through out_handle.
| [in] | cfg | Backend + geometry descriptor (see struct). |
| [out] | out_handle | Filled with the PAL handle on success. |
| k_ra8_ok | Backend ready; out_handle populated. |
| k_ra8_err_null_ptr | cfg / cfg->iface / cfg->framebuffer / out_handle NULL. |
| k_ra8_err_invalid_arg | Width / height / pixfmt rejected by backend. |
| k_ra8_err_busy | PAL already initialised; deinit first. |
| k_ra8_err_not_supported | Pixel format unsupported by chosen backend. |
Definition at line 93 of file ra8_display_pal.c.
References display_cfg_t::iface, display_backend_iface::init, k_ra8_err_busy, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_log_info, s_handle, s_initialized, and s_tag.
Referenced by app_bringup_display(), app_bringup_panel(), cm_bringup_panel(), ez_bringup_panel(), gh_glcdc_programmed(), internal_tc_glcdc_bringup(), lcd_bringup_panel(), main(), mg_bringup_panel(), sfr_bringup_panel(), sh_panel_or_halt(), wc_panel_up(), wd_panel_up(), and wk_panel_up().