|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
LCD backend (ra8_glcdc) implementation for the display PAL. More...
#include "ra8_display_pal_lcd.h"#include <stddef.h>#include <stdint.h>#include <string.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_cache.h"#include "ra8_check.h"#include "ra8_display_pal.h"#include "ra8_display_pal_internal.h"#include "ra8_err.h"#include "ra8_glcdc.h"#include "ra8_log.h"#include "ra8_time.h"Go to the source code of this file.
Data Structures | |
| struct | lcd_ctx_t |
| LCD backend private context attached to the PAL handle. More... | |
Enumerations | |
| enum | disp_lcd_mask_t : uint32_t { k_rgb565_mask = 0xFFFFU } |
| RGB565 pixel mask. More... | |
| enum | ra8_display_pal_lcd_const_t : uint32_t { k_lcd_bringup_settle_ms = 200U , k_lcd_bg_color_black = 0U , k_lcd_fb_align_bytes = 64U , k_lcd_rgb565_bpp = 2U } |
| Numeric constants used by the LCD backend bring-up. More... | |
Functions | |
| static void | internal_lcd_dsb (void) |
| DSB memory barrier on Cortex-M, no-op on the host test build. | |
| static ra8_err_t | internal_lcd_validate_cfg (const display_cfg_t *cfg) |
| Validate the caller's display_cfg_t against the LCD backend's expectations. | |
| static ra8_err_t | internal_lcd_bringup_panel (const display_cfg_t *cfg) |
| Drive the GPIO + GLCDC sequence that powers the panel up and starts scan-out. | |
| static void | internal_lcd_snapshot (const display_cfg_t *cfg) |
| Populate s_lcd_ctx from the validated cfg. | |
| static ra8_err_t | internal_lcd_check_rect (const display_caps_t *caps, display_rect_t r) |
| Confirm a rectangle stays inside the active framebuffer. | |
| static ra8_err_t | internal_lcd_init (const display_cfg_t *cfg, void **out_ctx) |
| LCD backend init – validate, panel bring-up, snapshot. | |
| static ra8_err_t | internal_lcd_get_caps (const void *ctx, display_caps_t *out) |
| Vtable get_caps – O(1) copy from s_lcd_ctx.caps. | |
| static ra8_err_t | internal_lcd_get_framebuffer (void *ctx, display_fb_t *out) |
| Vtable get_framebuffer – hand back the FB descriptor. | |
| static ra8_err_t | internal_lcd_flush (void *ctx, display_rect_t rect, display_refresh_hint_t hint) |
| Vtable flush – DSB barrier, validate rect. | |
| static ra8_err_t | internal_lcd_clear (void *ctx, uint32_t color) |
| Vtable clear – fill the framebuffer with a uniform RGB565 value. | |
| static ra8_err_t | internal_lcd_deinit (void *ctx) |
| Vtable deinit – tear the GLCDC down and drop state. | |
Variables | |
| static const char *const | s_tag = "ra8_display_pal_lcd" |
| Module log tag. | |
| static lcd_ctx_t | s_lcd_ctx |
| Single LCD backend context – one display per board. | |
| const display_backend_iface_t | k_display_backend_lcd_ra8_glcdc |
| LCD backend vtable – pass its address through display_cfg_t.iface to drive the EK-RA8D2 panel. | |
LCD backend (ra8_glcdc) implementation for the display PAL.
Wraps the existing libs/ra8_hal/src/ra8_glcdc.c HAL plus the EK-RA8D2 panel power-on sequence into the display_backend_iface_t shape the PAL dispatcher consumes. The 6-step bring-up that used to be duplicated in every LCD-using app's lcd_bringup_panel collapses into a single display_init call.
Definition in file ra8_display_pal_lcd.c.
| enum disp_lcd_mask_t : uint32_t |
RGB565 pixel mask.
| Enumerator | |
|---|---|
| k_rgb565_mask | Rgb565 mask. |
Definition at line 46 of file ra8_display_pal_lcd.c.
| enum ra8_display_pal_lcd_const_t : uint32_t |
Numeric constants used by the LCD backend bring-up.
Definition at line 56 of file ra8_display_pal_lcd.c.
|
static |
Drive the GPIO + GLCDC sequence that powers the panel up and starts scan-out.
Mirrors the lcd_bringup_panel helper that used to live in every LCD-using app: panel power-on, board GLCDC routing, settle, GLCDC init, BG clear, start(true), layer1_show. Returns on the first error – callers must treat a non-ok return as "panel may be in any state" and not call deinit.
| [in] | cfg | Caller configuration (validated upstream). |
| k_ra8_ok | Panel is up and GR1 is visible. |
| (from | ra8_board_*) Forwarded from the board helpers. |
| (from | ra8_glcdc_*) Forwarded from the GLCDC HAL. |
Definition at line 190 of file ra8_display_pal_lcd.c.
References display_cfg_t::framebuffer, display_cfg_t::height_px, k_lcd_bg_color_black, k_lcd_bringup_settle_ms, k_ra8_board_glcdc_fmt_rgb888, k_ra8_glcdc_fmt_rgb565, k_ra8_ok, display_cfg_t::panel_timing, ra8_board_glcdc_init(), ra8_board_lcd_panel_power_on(), ra8_delay_ms(), ra8_glcdc_init(), ra8_glcdc_layer1_show(), ra8_glcdc_set_background_color(), ra8_glcdc_start(), and display_cfg_t::width_px.
|
static |
Confirm a rectangle stays inside the active framebuffer.
Compound boolean intentionally split into four sequential checks so MC/DC vectors are trivial.
| [in] | caps | Backend capabilities. |
| [in] | r | Candidate rectangle. |
| k_ra8_ok | Rectangle fits. |
| k_ra8_err_invalid_arg | Rectangle would step out of bounds. |
Definition at line 287 of file ra8_display_pal_lcd.c.
References display_rect_t::h, display_caps_t::height_px, k_ra8_err_invalid_arg, k_ra8_ok, display_rect_t::w, display_caps_t::width_px, display_rect_t::x, and display_rect_t::y.
Referenced by internal_lcd_flush().
|
static |
Vtable clear – fill the framebuffer with a uniform RGB565 value.
Tight CPU loop; not the fastest possible (DMA would beat this) but the simplest correct implementation.
| [in] | ctx | Backend context. |
| [in] | color | Pixel value (low 16 bits used). |
| k_ra8_ok | Buffer cleared. |
| k_ra8_err_null_ptr | ctx was NULL. |
Definition at line 504 of file ra8_display_pal_lcd.c.
References lcd_ctx_t::fb, display_fb_t::height_px, internal_lcd_dsb(), k_ra8_ok, k_rgb565_mask, display_fb_t::pixels, ra8_cache_dcache_clean_by_addr(), RA8_CHECK_NULL_PTR, s_tag, display_fb_t::stride_bytes, and display_fb_t::width_px.
|
static |
Vtable deinit – tear the GLCDC down and drop state.
Forwards to ra8_glcdc_deinit which disables scan-out and clears the registers. GPIO pins claimed during ra8_board_lcd_panel_power_on are left claimed (a follow-up init either does a chip reset first or stays bound).
| [in] | ctx | Backend context. |
| k_ra8_ok | Tear-down succeeded. |
| k_ra8_err_null_ptr | ctx was NULL. |
Definition at line 551 of file ra8_display_pal_lcd.c.
References lcd_ctx_t::fb, display_fb_t::pixels, RA8_CHECK_NULL_PTR, ra8_glcdc_deinit(), s_tag, and lcd_ctx_t::started.
|
inlinestatic |
DSB memory barrier on Cortex-M, no-op on the host test build.
Guarded with RA8_OFF_TARGET so the host x86 build does not try to assemble the ARMv8-M dsb instruction. Matches the pattern used by ra8_reset.c and ra8_lpm.c.
Definition at line 100 of file ra8_display_pal_lcd.c.
Referenced by internal_lcd_clear(), and internal_lcd_flush().
|
static |
Vtable flush – DSB barrier, validate rect.
LCD scans continuously so flush is essentially a no-op (the caller's writes will land on the next scan). We still validate rect so callers writing backend-agnostic code learn about out-of-bounds rectangles at the LCD path rather than first discovering them on e-ink. hint is ignored.
| [in] | ctx | Backend context. |
| [in] | rect | Region the caller painted. |
| [in] | hint | Refresh-mode intent (ignored for LCD). |
| k_ra8_ok | Barrier issued. |
| k_ra8_err_null_ptr | ctx was NULL. |
| k_ra8_err_invalid_arg | rect leaves the framebuffer. |
Definition at line 451 of file ra8_display_pal_lcd.c.
References lcd_ctx_t::caps, lcd_ctx_t::fb, display_rect_t::h, internal_lcd_check_rect(), internal_lcd_dsb(), k_ra8_ok, display_fb_t::pixels, ra8_cache_dcache_clean_by_addr(), RA8_CHECK_NULL_PTR, s_tag, display_fb_t::stride_bytes, and display_rect_t::y.
|
static |
Vtable get_caps – O(1) copy from s_lcd_ctx.caps.
The caps were snapshotted from cfg at init time.
| [in] | ctx | Backend context. |
| [out] | out | Capabilities snapshot. |
| k_ra8_ok | Caps written. |
| k_ra8_err_null_ptr | Either argument was NULL. |
Definition at line 381 of file ra8_display_pal_lcd.c.
References lcd_ctx_t::caps, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
|
static |
Vtable get_framebuffer – hand back the FB descriptor.
Returns the same buffer the caller passed in via cfg.
| [in] | ctx | Backend context. |
| [out] | out | Framebuffer descriptor. |
| k_ra8_ok | Descriptor written. |
| k_ra8_err_null_ptr | Either argument was NULL. |
Definition at line 413 of file ra8_display_pal_lcd.c.
References lcd_ctx_t::fb, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
|
static |
LCD backend init – validate, panel bring-up, snapshot.
Vtable entry for k_display_backend_lcd_ra8_glcdc. The body is short because the heavy lifting is in the two internal helpers above; this matches the NASA P10 Rule 4 per-function size budget.
| [in] | cfg | Caller configuration. |
| [out] | out_ctx | Filled with the backend context pointer. |
| k_ra8_ok | Backend ready. |
| k_ra8_err_null_ptr | Required pointer was NULL. |
| k_ra8_err_invalid_arg | Dimensions / buffer size invalid. |
| k_ra8_err_not_supported | Pixel format other than RGB565. |
| k_ra8_err_busy | Backend already started. |
Definition at line 337 of file ra8_display_pal_lcd.c.
References internal_lcd_bringup_panel(), internal_lcd_snapshot(), internal_lcd_validate_cfg(), k_ra8_err_busy, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, s_lcd_ctx, and s_tag.
|
static |
Populate s_lcd_ctx from the validated cfg.
Snapshotting cfg into the context lets get_caps / get_framebuffer answer without touching the cfg pointer again – the caller may free its cfg after init returns.
| [in] | cfg | Validated caller configuration. |
Definition at line 244 of file ra8_display_pal_lcd.c.
References display_cfg_t::framebuffer, display_cfg_t::height_px, k_display_pixfmt_rgb565, k_lcd_rgb565_bpp, s_lcd_ctx, and display_cfg_t::width_px.
Referenced by internal_lcd_init().
|
static |
Validate the caller's display_cfg_t against the LCD backend's expectations.
Rejects NULL framebuffer, zero / negative dimensions, undersized buffer, and any non-RGB565 pixel format. Run before any hardware call so a failure leaves the panel untouched.
| [in] | cfg | Caller configuration. |
| k_ra8_ok | Configuration accepted. |
| k_ra8_err_null_ptr | Framebuffer pointer was NULL. |
| k_ra8_err_invalid_arg | Dimensions or buffer size out of range. |
| k_ra8_err_not_supported | Pixel format other than RGB565. |
Definition at line 139 of file ra8_display_pal_lcd.c.
References display_cfg_t::framebuffer, display_cfg_t::framebuffer_bytes, display_cfg_t::height_px, k_display_pixfmt_rgb565, k_lcd_rgb565_bpp, k_ra8_err_invalid_arg, k_ra8_err_not_supported, k_ra8_ok, display_cfg_t::panel_timing, display_cfg_t::pixfmt, RA8_CHECK_NULL_PTR, s_tag, and display_cfg_t::width_px.
Referenced by internal_lcd_init().
| const display_backend_iface_t k_display_backend_lcd_ra8_glcdc |
LCD backend vtable – pass its address through display_cfg_t.iface to drive the EK-RA8D2 panel.
The vtable's init callback runs the full GLCDC bring-up:
The matching deinit callback turns the panel back off.
Definition at line 566 of file ra8_display_pal_lcd.c.
|
static |
Single LCD backend context – one display per board.
Definition at line 80 of file ra8_display_pal_lcd.c.
Referenced by internal_lcd_init(), and internal_lcd_snapshot().
|
static |
Module log tag.
Definition at line 43 of file ra8_display_pal_lcd.c.