ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_display_pal_policy.c
Go to the documentation of this file.
1
17
19
20#include <stdint.h>
21
22#include "ra8_attributes.h"
23#include "ra8_check.h"
24#include "ra8_err.h"
25
27static const char* const s_tag_policy = "disp_policy";
28
59static uint16_t internal_clamp_clean_every(uint16_t n)
60{
61 if (n < (uint16_t)k_display_policy_clean_every_min) {
62 return (uint16_t)k_display_policy_clean_every_min;
63 }
64 if (n > (uint16_t)k_display_policy_clean_every_max) {
65 return (uint16_t)k_display_policy_clean_every_max;
66 }
67 return n;
68}
69
104{
105 const uint16_t next = (uint16_t)(p->turns_since_clean + 1U);
106 const bool clean = (next >= p->clean_every) || (event == k_display_event_chapter);
107 if (clean) {
109 out->full_update = true;
110 p->turns_since_clean = 0U;
111 } else {
113 out->full_update = false;
114 p->turns_since_clean = next;
115 }
116}
117
119{
120 RA8_CHECK_NULL_PTR(p, s_tag_policy, "init: null policy");
121 if (kind > k_display_policy_fast_clean) {
122 ra8_log_error(s_tag_policy, "init: kind out of range");
124 }
125 p->kind = (uint8_t)kind;
126 p->clean_every = internal_clamp_clean_every(clean_every);
127 p->turns_since_clean = 0U;
128 return k_ra8_ok;
129}
130
134{
135 RA8_CHECK_NULL_PTR(p, s_tag_policy, "decide: null policy");
136 RA8_CHECK_NULL_PTR(out, s_tag_policy, "decide: null out");
137 if (event > k_display_event_chapter) {
138 ra8_log_error(s_tag_policy, "decide: event out of range");
140 }
141
142 /* A fresh open always clears the panel (INIT) regardless of strategy. */
143 if (event == k_display_event_open) {
145 out->full_update = true;
146 p->turns_since_clean = 0U;
147 return k_ra8_ok;
148 }
149
150 switch (p->kind) {
151 case (uint8_t)k_display_policy_fast_only:
153 out->full_update = false;
154 break;
155 case (uint8_t)k_display_policy_quality:
157 out->full_update = true;
158 break;
159 case (uint8_t)k_display_policy_fast_clean:
160 default:
161 internal_decide_fast_clean(p, event, out);
162 break;
163 }
164 return k_ra8_ok;
165}
166
168{
169 RA8_CHECK_NULL_PTR(out, s_tag_policy, "full_rect: null out");
170 if ((w == 0U) || (h == 0U)) {
171 ra8_log_error(s_tag_policy, "full_rect: zero dimension");
173 }
174 out->x = 0U;
175 out->y = 0U;
176 out->w = w;
177 out->h = h;
178 return k_ra8_ok;
179}
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
@ k_display_refresh_fast
Prioritise latency.
@ k_display_refresh_init
Full reset of the panel.
@ k_display_refresh_quality
Prioritise final quality.
ra8_err_t display_policy_init(display_policy_t *p, display_policy_kind_t kind, uint16_t clean_every)
Initialise a refresh-cadence policy.
static void internal_decide_fast_clean(display_policy_t *p, display_turn_event_t event, display_policy_decision_t *out)
Resolve the k_display_policy_fast_clean decision for a non-open turn.
ra8_err_t display_policy_full_rect(uint16_t w, uint16_t h, display_rect_t *out)
Build the full-page damage rectangle for a page turn.
static uint16_t internal_clamp_clean_every(uint16_t n)
Clamp a requested clean cadence to the documented bounds.
static const char *const s_tag_policy
Log tag for the refresh-cadence policy module.
ra8_err_t display_policy_decide(display_policy_t *p, display_turn_event_t event, display_policy_decision_t *out)
Decide the flush parameters for one page-transition event.
Pluggable page-turn refresh-cadence policy for bistable (e-ink) panels.
display_policy_kind_t
Selectable refresh-cadence strategies (chosen at display_policy_init).
@ k_display_policy_quality
Always clean GC16 full – no ghosting, slow.
@ k_display_policy_fast_clean
A2 partial, periodic GC16 clean (default).
@ k_display_policy_fast_only
Always fast A2 partial – snappiest, ghosts.
display_turn_event_t
The page-transition event the policy reacts to.
@ k_display_event_chapter
Chapter-boundary turn – wants a clean refresh.
@ k_display_event_open
Book/first page opened – wants a clean INIT.
@ k_display_policy_clean_every_max
Clamp ceiling.
@ k_display_policy_clean_every_min
Clamp floor (every turn is clean).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
#define ra8_log_error(tag, message)
RA8 log error.
Definition ra8_log.h:335
What the app should pass to display_flush for this event.
display_refresh_hint_t hint
Waveform intent (fast/quality/init).
bool full_update
true => flush the whole page rect.
Caller-owned policy state (zero heap; init once, decide per turn).
uint8_t kind
Active display_policy_kind_t.
uint16_t turns_since_clean
Fast turns since the last clean refresh.
uint16_t clean_every
Fast turns between GC16 cleans (fast_clean).
Rectangle in framebuffer coordinates passed into display_flush.
uint16_t h
Height in pixels.
uint16_t w
Width in pixels.
uint16_t y
Top edge in pixels.
uint16_t x
Left edge in pixels.