ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_glcdc.c
Go to the documentation of this file.
1
41
42#include "ra8_glcdc.h"
43
44#include <stdint.h>
45
46#include "ra8_attributes.h"
47#include "ra8_check.h"
48#include "ra8_err.h"
49#include "ra8_glcdc_regs.h"
50#include "ra8_hw_err.h"
51#include "ra8_log.h"
52#include "ra8_mstp.h"
53
54static const char* s_tag = "GLCDC";
55
56/* =============================================================================
57 * Local constants
58 * =============================================================================
59 */
60
62typedef enum : uint32_t {
63 k_glcdc_clut_size = 0x10000UL,
65
78
79typedef enum : uint16_t {
82
83typedef enum : uint32_t {
87
88/* =============================================================================
89 * Initialisation
90 * =============================================================================
91 */
92
93/* =============================================================================
94 * RA8D2-specific power + clock bring-up that FSP's R_GLCDC_Open expects to
95 * have been done by the BSP before it touches any GLCDC register. Without
96 * these two steps the entire GLCDC register window at 0x40342000 silently
97 * drops reads and writes (the chip's Graphics power domain is off and
98 * LCDCLK is parked on the default MOCO).
99 *
100 * PDCTRGD.PDDE = 0 power on the Graphics power domain
101 * LCDCKCR = PLL2P LCDCLK = 240 MHz on PLL2P
102 *
103 * Both writes are PRCR-protected (LPM and CGC groups respectively).
104 * =============================================================================
105 */
106
126/* HUM Ch 11.2.1 "PRCR : Protect Register" p 440 -- PRC0 (bit 0)
127 * unlocks CGC; PRC1 (bit 1) unlocks LPM. Key = 0xA5xx. */
128enum : uintptr_t {
129 k_addr_prcr = 0x4001E3FAUL,
130 k_addr_pdctrgd = 0x4001E110UL,
131 k_addr_lcdckdivcr = 0x4001E05EUL,
132 k_addr_lcdckcr = 0x4001E05FUL,
133 k_addr_hococr = 0x4001E036UL,
134};
135enum : uint16_t {
138 k_prcr_relock = 0xA500U,
139};
140enum : uint8_t {
141 k_pdctrgd_on = 0x00U,
145 k_lcdck_sreq = 0x40U,
149 k_hococr_run = 0x00U,
150};
151
169static void internal_hoco_enable(void)
170{
171 volatile uint16_t* const prcr = (volatile uint16_t*)k_addr_prcr;
172 volatile uint8_t* const hococr = (volatile uint8_t*)k_addr_hococr;
173 *prcr = (uint16_t)k_prcr_unlock_cgc;
174 *hococr = (uint8_t)k_hococr_run;
175 *prcr = (uint16_t)k_prcr_relock;
176}
177
199{
200 volatile uint16_t* const prcr = (volatile uint16_t*)k_addr_prcr;
201 volatile uint8_t* const pdctrgd = (volatile uint8_t*)k_addr_pdctrgd;
202 *prcr = (uint16_t)k_prcr_unlock_lpm;
203
204 /* Wait for "fully gated" state before issuing the power-on request. */
205 for (uint32_t i = 0U; i < k_glcdc_clut_size; i++) {
206#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
207 /* Host MMIO fault seam: tests drive the retry / exhaustion legs. */
208 const bool pdpgsf_now = (*pdctrgd & (uint8_t)k_pdctrgd_status) == (uint8_t)k_pdctrgd_pdpgsf;
209 if (ra8_fake_mmio_wait_eval(pdctrgd, i, pdpgsf_now)) {
210 break;
211 }
212#else
213 if ((*pdctrgd & (uint8_t)k_pdctrgd_status) == (uint8_t)k_pdctrgd_pdpgsf) {
214 break;
215 }
216#endif
217 }
218 *pdctrgd = (uint8_t)k_pdctrgd_on;
219 /* Wait for "fully on" state -- both PDCSF and PDPGSF must clear. */
220 for (uint32_t i = 0U; i < k_glcdc_clut_size; i++) {
221#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
222 if (ra8_fake_mmio_wait_eval(pdctrgd, i, ((*pdctrgd & (uint8_t)k_pdctrgd_status) == 0U))) {
223 break;
224 }
225#else
226 if ((*pdctrgd & (uint8_t)k_pdctrgd_status) == 0U) {
227 break;
228 }
229#endif
230 }
231 *prcr = (uint16_t)k_prcr_relock;
232}
233
252{
253 volatile uint16_t* const prcr = (volatile uint16_t*)k_addr_prcr;
254 volatile uint8_t* const lcdckdivcr = (volatile uint8_t*)k_addr_lcdckdivcr;
255 volatile uint8_t* const lcdckcr = (volatile uint8_t*)k_addr_lcdckcr;
256
257 *prcr = (uint16_t)k_prcr_unlock_cgc;
258 *lcdckcr = (uint8_t)k_lcdck_sreq;
259 for (uint32_t i = 0U; i < k_glcdc_clut_size; i++) {
260#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
261 /* Host MMIO fault seam: tests drive the retry / exhaustion legs. */
262 if (ra8_fake_mmio_wait_eval(lcdckcr, i, ((*lcdckcr & (uint8_t)k_lcdck_srdy_mask) != 0U))) {
263 break;
264 }
265#else
266 if ((*lcdckcr & (uint8_t)k_lcdck_srdy_mask) != 0U) {
267 break;
268 }
269#endif
270 }
271 *lcdckdivcr = (uint8_t)k_lcdckdivcr_div4;
272 *lcdckcr = (uint8_t)(k_lcdck_sreq | k_lcdck_sel_pll1r);
273 *lcdckcr = (uint8_t)k_lcdck_sel_pll1r;
274 for (uint32_t i = 0U; i < k_glcdc_clut_size; i++) {
275#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
276 if (ra8_fake_mmio_wait_eval(lcdckcr, i, ((*lcdckcr & (uint8_t)k_lcdck_srdy_mask) == 0U))) {
277 break;
278 }
279#else
280 if ((*lcdckcr & (uint8_t)k_lcdck_srdy_mask) == 0U) {
281 break;
282 }
283#endif
284 }
285 *prcr = (uint16_t)k_prcr_relock;
286}
287
317
318/* =============================================================================
319 * Bit positions / shifts that FSP's r_glcdc.c uses verbatim. Pulled from
320 * the FSP private header constants ("GLCDC_PRV_*_SHIFT" / "_MASK") -- not
321 * copied as code, just referenced for the register field layout.
322 *
323 * OUT_SET.FORMAT[13:12] output pixel format
324 * OUT_PDTHA.FORM[17:16] dither output format (must match OUT_SET)
325 * FLM6.FORMAT[30:28] framebuffer pixel format
326 * FLM3.LNOFF[31:16] line stride in bytes
327 * FLM5.LNNUM[26:16] lines per frame minus 1
328 * FLM5.DATANUM[15:0] 64-byte AXI bursts per line minus 1
329 * AB3.GRCHS[26:16]/W[10:0] graphics layer H position + width
330 * AB2.GRCVS[26:16]/W[10:0] graphics layer V position + height
331 * AB7.ARCDEF[23:16] constant alpha for alpha-rect
332 * BG_HSIZE.HP[26:16] BG active-pixel start position
333 * BG_VSIZE.VP[26:16] BG active-line start position
334 * BG_SYNC HP / VP min = 1 (HUM 63 p 3760)
335 * =============================================================================
336 */
347
348/* SEL[2:0] values for TCON_STXx2.SEL (HUM 63 p 3805) */
355
356/* GR.AB1.DISPSEL[1:0] (HUM 63 p 3744 + FSP enum):
357 * 1 = TRANSPARENT -- layer hidden, lower layer (BG) shows through
358 * 2 = NON_TRANSPARENT -- this layer's pixels are output */
363
364/* AB7.ARCDEF[23:16] alpha constants. */
365typedef enum : uint32_t {
368
369/* Panel timing is supplied by the caller via ra8_glcdc_config_t.timing -- it is
370 * accessory data, not a peripheral property, so the panel's values (e.g. the
371 * EK-RA8D2 ER-TFT070-6) live in the board BSP (libs/ra8_board_ek_ra8d2), not in
372 * this driver. */
373
374/* OUT_SET.FORMAT[1:0] codes for output bus. */
380
381/* OUT_PDTHA.FORM[1:0] codes -- must match OUT_SET.FORMAT for non-serial. */
387
396typedef struct {
397 uint32_t h_active;
398 uint32_t h_back;
399 uint32_t h_sync;
400 uint32_t h_total;
401 uint32_t v_active;
402 uint32_t v_back;
403 uint32_t v_sync;
404 uint32_t v_total;
406
427{
428 *ra8_glcdc_reg32(k_ra8_glcdc_off_out_clkphase) = 0U; /* all rising edge */
430
431 /* STVA -> LCD_TCON0 (VSYNC, active-low: INV=1). */
434
435 /* STHA pulse width, DE -> LCD_TCON2 (active-high: INV=0). */
438
439 /* STVB -> LCD_TCON1 (HSYNC routed via STVB2.SEL = STHA, active-low). */
441 ((uint32_t)(t->v_sync + t->v_back) << k_glcdc_shift_high) | t->v_active;
443
444 /* STHB encodes horizontal DE strobe; TCON3 unused on this board. */
446 ((uint32_t)(t->h_sync + t->h_back) << k_glcdc_shift_high) | t->h_active;
449}
450
482
510 uintptr_t fb_addr,
511 uint16_t fb_format,
512 uint16_t fb_w,
513 uint16_t fb_h)
514{
516 *ra8_glcdc_reg32(k_ra8_glcdc_off_gr1_saddr) = (uint32_t)fb_addr;
517
518 /* FLM3.LNOFF (line stride) + FLM5 (active line / AXI-burst count)
519 * track the FRAMEBUFFER dimensions, not the panel. This lets a
520 * small SRAM framebuffer occupy only a portion of the panel
521 * (rest is filled by the BG plane via BG_BGC). */
522 const uint32_t line_bytes = (uint32_t)fb_w * (uint32_t)k_glcdc_bpp_rgb565;
524
525 const uint32_t datanum = (line_bytes / (uint32_t)k_glcdc_axi_burst_bytes) - 1U;
526 const uint32_t lnnum = (uint32_t)fb_h - 1U;
528
529 /* Layer position on the panel: start at the back-porch corner
530 * (top-left of the active area) so a small framebuffer renders
531 * at the panel's origin and the rest stays BG-plane. */
536
540}
541
578
597static void internal_program_out(void)
598{
599 enum : uint32_t {
600 k_bright_mid = 512UL,
601 k_contrast_mid = 128UL,
602 };
608 *ra8_glcdc_reg32(k_ra8_glcdc_off_out_bright2) = (k_bright_mid << 16) | k_bright_mid;
610 (k_contrast_mid << 16) | (k_contrast_mid << 8) | k_contrast_mid;
611}
612
636static void internal_panel_program(uintptr_t fb_addr,
637 uint16_t fb_format,
638 uint16_t fb_w,
639 uint16_t fb_h,
640 const ra8_glcdc_timing_t* tm)
641{
642 const ra8_glcdc_panel_timing_t t = {
643 .h_active = (uint32_t)tm->h_active,
644 .h_back = (uint32_t)tm->h_back,
645 .h_sync = (uint32_t)tm->h_sync,
646 .h_total =
647 (uint32_t)tm->h_active + (uint32_t)tm->h_front + (uint32_t)tm->h_back + (uint32_t)tm->h_sync,
648 .v_active = (uint32_t)tm->v_active,
649 .v_back = (uint32_t)tm->v_back,
650 .v_sync = (uint32_t)tm->v_sync,
651 .v_total =
652 (uint32_t)tm->v_active + (uint32_t)tm->v_front + (uint32_t)tm->v_back + (uint32_t)tm->v_sync,
653 };
656 internal_program_gr1(&t, fb_addr, fb_format, fb_w, fb_h);
659}
660
661/* HUM Ch 63 "Graphics LCD Controller (GLCDC)" p 3744 */
663{
664 RA8_CHECK_NULL_PTR(cfg, s_tag, "cfg must not be nullptr");
665
666 /* HUM Ch 11.2.14 "PDCTRGD" p 452 + HUM Ch 9.2.58 "LCDCKCR" p 373.
667 * Power on the Graphics domain and route LCDCLK to PLL2P. Without
668 * this the GLCDC peripheral bus is unreachable. */
670
671 /* HUM Ch 11.2.8 "MSTPCRC : Module Stop Control Register C", p 446 */
673 /* GCOVR_EXCL_BR_START -- MSTP HW readback: ra8_mstp_enable only fails when
674 * the MSTPCR readback disagrees, which the host register file cannot stage. */
675 RA8_RETURN_ON_ERROR(mst_err, s_tag, "glcdc_init: mstp enable");
676 /* GCOVR_EXCL_BR_STOP */
677
678 /* HUM Ch 63 "BG_EN.SWRST" p 3759 + FSP r_glcdc_open step 2. Single
679 * write of SWRST=1. FSP uses a bit-field write (read-modify-write
680 * leaving other bits at their reset values, which are all 0) -- a
681 * plain `*reg = SWRST_MASK` is equivalent on a register that was
682 * just out of reset. */
683 *ra8_glcdc_reg32(k_ra8_glcdc_off_bg_en) = (uint32_t)(1UL << 16);
684
685 /* HUM Ch 63 "SYSCNT_PANEL_CLK" p 3813. CLKSEL=LCDCLK, CLKEN=1,
686 * DCDR=/5 -> 240 MHz / 5 = 48 MHz pixel clock. */
687 enum : uint32_t {
688 k_panel_clk_clksel_lcdclk = 1U << 8,
689 k_panel_clk_clken = 1U << 6,
690 k_panel_clk_dcdr_div2 = 0x02U,
691 };
692 /* LCDCLK = 100 MHz (PLL1R / 4), DCDR /2 -> pixel clock = 50 MHz.
693 * Matches the LVGL EK-RA8D2 reference for the ER-TFT070-6 panel. */
694 *ra8_glcdc_reg32(k_ra8_glcdc_off_panel_clk) = (uint32_t)k_panel_clk_clksel_lcdclk |
695 (uint32_t)k_panel_clk_clken |
696 (uint32_t)k_panel_clk_dcdr_div2;
697
698 /* Programme every other panel-side register in the FSP-documented order. */
700 (uint16_t)cfg->format,
701 cfg->width_px,
702 cfg->height_px,
703 &cfg->timing);
704
705 ra8_log_info_val(s_tag, "glcdc_init fb", cfg->framebuffer_addr);
706 return k_ra8_ok;
707}
708
710{
711 enum : uint32_t {
712 k_bit_en = 1U << 0,
713 k_bit_ven = 1U << 8,
714 k_bit_swrst = 1U << 16,
715 };
716
717 if (!enable) {
718 /* Drop everything to disabled but keep SWRST high so register
719 * reads keep working (writing SWRST=0 re-enters reset). */
720 *ra8_glcdc_reg32(k_ra8_glcdc_off_bg_en) = (uint32_t)k_bit_swrst;
722 return k_ra8_ok;
723 }
724
725 /* Match FSP's R_GLCDC_Start exactly: bit-field-style sequential writes
726 * so SWRST stays high while we add VEN then EN. Using read-modify-
727 * write rather than full-word writes avoids momentarily clearing
728 * SWRST or putting the controller in an undefined transition. */
729 uint32_t bg_en = *ra8_glcdc_reg32(k_ra8_glcdc_off_bg_en);
730
731 /* Step 1: VEN = 1 -- enable register value reflection on next VS. */
732 bg_en |= (uint32_t)k_bit_ven;
734
735 /* Step 2: EN = 1 -- background plane operation enable. */
736 bg_en |= (uint32_t)k_bit_en;
738
739 /* Step 3: SYSCNT.DTCTEN.VPOSDTC = 1 -- line-detect IRQ source. */
741
742 /* Step 4: OUT_VLATCH.VEN = 1 -- commit the OUT_SET / OUT_PDTHA /
743 * brightness / contrast shadow registers to the output stage's
744 * working registers. Without this the output-bus format we wrote
745 * in init never reaches the pixel pipeline. */
747
748 /* Step 5: GR1.VEN + GR2.VEN -- commit graphics-layer shadow regs.
749 *
750 * Both layers MUST be VEN-asserted, even if only one carries a
751 * framebuffer. See bring-up finding in internal_panel_program:
752 * without GR2's shadow registers committed, the output pipeline's
753 * lower-layer slot stays in reset and the panel sees solid black.
754 * FSP r_glcdc_open writes PVEN on every layer it configured. */
757
758 return k_ra8_ok;
759}
760
761/* =============================================================================
762 * Output stage: dithering / brightness / contrast
763 * =============================================================================
764 */
765
767{
768 uint32_t sel;
769 switch (mode) {
770 case k_ra8_dither_off: {
771 sel = 0U;
772 break;
773 }
775 sel = 2U;
776 break;
777 }
778 case k_ra8_dither_2x2: {
779 sel = 3U;
780 break;
781 }
782 default: {
784 }
785 }
786 /* HUM Ch 63 "OUT_PDTHA.SEL" p 3744 */ /* panel dither selector. */
788 return k_ra8_ok;
789}
790
791ra8_err_t ra8_glcdc_set_brightness(uint8_t r, uint8_t g, uint8_t b)
792{
793 /* HUM Ch 63 "OUT_BRIGHT1.BRTG" p 3744 */ /* green offset. */
795
796 /* HUM Ch 63 "OUT_BRIGHT2.BRTB/BRTR" p 3744 */ /* blue + red offsets. */
798 ((uint32_t)b << k_ra8_glcdc_word_shift) | (uint32_t)r;
799 return k_ra8_ok;
800}
801
802ra8_err_t ra8_glcdc_set_contrast(uint8_t r, uint8_t g, uint8_t b)
803{
804 /* HUM Ch 63 "OUT_CONTRAST.CONTG/CONTB/CONTR" p 3744 */
806 ((uint32_t)g << k_ra8_glcdc_g_shift) | ((uint32_t)b << k_ra8_glcdc_b_shift) | (uint32_t)r;
807 return k_ra8_ok;
808}
809
810/* =============================================================================
811 * lifecycle + IRQ + power transition
812 * =============================================================================
813 */
814
816static void* s_glcdc_ctx;
817
827
829{
830 RA8_CHECK_NULL_PTR(out_mask, s_tag, "out_mask must not be nullptr");
832 return k_ra8_ok;
833}
834
836{
837 volatile uint32_t* reg = ra8_glcdc_reg32(k_ra8_glcdc_off_sys_stat);
838 *reg = *reg & ~mask;
839 return k_ra8_ok;
840}
841
843{
844 s_glcdc_fn = fn;
845 s_glcdc_ctx = ctx;
846 return k_ra8_ok;
847}
848
851{
852 volatile uint32_t* reg = ra8_glcdc_reg32(k_ra8_glcdc_off_sys_stat);
853 const uint32_t mask = *reg;
855 void* const ctx = s_glcdc_ctx;
856 *reg = 0U;
857 if (fn != nullptr) {
858 fn(ctx, mask);
859 }
860}
861
867
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
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
ra8_err_t ra8_glcdc_set_brightness(uint8_t r, uint8_t g, uint8_t b)
Programme per-channel output brightness.
Definition ra8_glcdc.c:791
ra8_err_t ra8_glcdc_attach_handler(ra8_glcdc_event_fn_t fn, void *ctx)
Attach a GLCDC event callback.
Definition ra8_glcdc.c:842
ra8_err_t ra8_glcdc_init(const ra8_glcdc_config_t *cfg)
Initialise GLCDC with the EK-RA8D2 1024x600 timings and the supplied graphics layer 1 framebuffer.
Definition ra8_glcdc.c:662
ra8_err_t ra8_glcdc_enter_stop(void)
Put GLCDC into MSTP-gated stop.
Definition ra8_glcdc.c:862
static void internal_program_tcon(const ra8_glcdc_panel_timing_t *t)
Program TCON sync-signal registers for parallel-RGB output.
Definition ra8_glcdc.c:426
@ k_prcr_relock
Prcr relock.
Definition ra8_glcdc.c:138
@ k_prcr_unlock_cgc
Prcr unlock cgc.
Definition ra8_glcdc.c:137
@ k_prcr_unlock_lpm
Prcr unlock lpm.
Definition ra8_glcdc.c:136
ra8_err_t ra8_glcdc_start(bool enable)
Start or stop the panel output.
Definition ra8_glcdc.c:709
ra8_err_t ra8_glcdc_clear_status(uint32_t mask)
Clear GLCDC status flags.
Definition ra8_glcdc.c:835
ra8_err_t ra8_glcdc_set_contrast(uint8_t r, uint8_t g, uint8_t b)
Programme per-channel output contrast gain.
Definition ra8_glcdc.c:802
ra8_glcdc_tcon_sel_t
Definition ra8_glcdc.c:349
@ k_glcdc_sel_de
GLCDC sel de.
Definition ra8_glcdc.c:353
@ k_glcdc_sel_stva
GLCDC sel stva.
Definition ra8_glcdc.c:350
@ k_glcdc_sel_stha
GLCDC sel stha.
Definition ra8_glcdc.c:352
@ k_glcdc_sel_stvb
GLCDC sel stvb.
Definition ra8_glcdc.c:351
ra8_glcdc_layout_priv_t
Definition ra8_glcdc.c:337
@ k_glcdc_shift_arcdef
GLCDC shift arcdef.
Definition ra8_glcdc.c:342
@ k_glcdc_shift_outset_fmt
GLCDC shift outset fmt.
Definition ra8_glcdc.c:340
@ k_glcdc_shift_high
GLCDC shift high.
Definition ra8_glcdc.c:338
@ k_glcdc_shift_pdtha_fmt
GLCDC shift pdtha fmt.
Definition ra8_glcdc.c:341
@ k_glcdc_axi_burst_bytes
GLCDC axi burst bytes.
Definition ra8_glcdc.c:343
@ k_glcdc_bpp_rgb565
GLCDC bpp rgb565.
Definition ra8_glcdc.c:344
@ k_glcdc_sync_pos_min
HUM 63 BG_SYNC.HP / VP min = 1.
Definition ra8_glcdc.c:345
@ k_glcdc_shift_flm6_fmt
GLCDC shift flm6 fmt.
Definition ra8_glcdc.c:339
ra8_glcdc_pdtha_fmt_t
Definition ra8_glcdc.c:382
@ k_glcdc_pdtha_rgb666
GLCDC pdtha rgb666.
Definition ra8_glcdc.c:384
@ k_glcdc_pdtha_rgb565
GLCDC pdtha rgb565.
Definition ra8_glcdc.c:385
@ k_glcdc_pdtha_rgb888
GLCDC pdtha rgb888.
Definition ra8_glcdc.c:383
static void internal_graphics_power_on(void)
Bring up the GLCDC graphics power domain and clock tree.
Definition ra8_glcdc.c:311
@ k_addr_lcdckcr
Address lcdckcr.
Definition ra8_glcdc.c:132
@ k_addr_lcdckdivcr
Address lcdckdivcr.
Definition ra8_glcdc.c:131
@ k_addr_prcr
Address prcr.
Definition ra8_glcdc.c:129
@ k_addr_hococr
Address hococr.
Definition ra8_glcdc.c:133
@ k_addr_pdctrgd
Address pdctrgd.
Definition ra8_glcdc.c:130
static void internal_hoco_enable(void)
Enable HOCO via PRC0-protected HOCOCR.
Definition ra8_glcdc.c:169
glcdc_clut_t
CLUT entry count (16-bit address space).
Definition ra8_glcdc.c:62
@ k_glcdc_clut_size
GLCDC CLUT size.
Definition ra8_glcdc.c:63
ra8_err_t ra8_glcdc_get_status(uint32_t *out_mask)
Read GLCDC status register (VSYNC/HSYNC/underflow).
Definition ra8_glcdc.c:828
void ra8_glcdc_dispatch(void)
Dispatch a GLCDC event – snapshot + fire callback.
Definition ra8_glcdc.c:850
static void internal_program_gr2(const ra8_glcdc_panel_timing_t *t)
Program graphics layer 2 (lower blend layer).
Definition ra8_glcdc.c:568
ra8_glcdc_out_set_fmt_t
Definition ra8_glcdc.c:375
@ k_glcdc_out_set_rgb666
GLCDC out set rgb666.
Definition ra8_glcdc.c:377
@ k_glcdc_out_set_rgb565
GLCDC out set rgb565.
Definition ra8_glcdc.c:378
@ k_glcdc_out_set_rgb888
GLCDC out set rgb888.
Definition ra8_glcdc.c:376
static void * s_glcdc_ctx
Definition ra8_glcdc.c:816
ra8_glcdc_clut_const_t
Definition ra8_glcdc.c:79
@ k_ra8_glcdc_clut_entries
Entries per CLUT plane.
Definition ra8_glcdc.c:80
static ra8_glcdc_event_fn_t s_glcdc_fn
Definition ra8_glcdc.c:815
ra8_glcdc_priv_const_t
Definition ra8_glcdc.c:66
@ k_ra8_glcdc_word_shift
16-bit field shift.
Definition ra8_glcdc.c:74
@ k_ra8_glcdc_pdtha_shift
PDTHA.SEL bit shift.
Definition ra8_glcdc.c:73
@ k_ra8_glcdc_dispsel_above
AB1.DISPSEL = upper layer.
Definition ra8_glcdc.c:70
@ k_ra8_glcdc_clutsel_shift
CLUTINT.SEL bit position.
Definition ra8_glcdc.c:72
@ k_ra8_glcdc_layer_count
Number of graphics layers.
Definition ra8_glcdc.c:67
@ k_ra8_glcdc_arcdef_shift
AB7.ARCDEF bit shift.
Definition ra8_glcdc.c:71
@ k_ra8_glcdc_b_shift
Blue-channel byte shift.
Definition ra8_glcdc.c:76
@ k_ra8_glcdc_g_shift
Green-channel byte shift.
Definition ra8_glcdc.c:75
@ k_ra8_glcdc_dispsel_below
AB1.DISPSEL = lower layer.
Definition ra8_glcdc.c:69
@ k_ra8_glcdc_layer1
Layer index for GR[0].
Definition ra8_glcdc.c:68
ra8_err_t ra8_glcdc_set_dithering(ra8_glcdc_dither_mode_t mode)
Programme the output dithering mode (PDTHA.SEL).
Definition ra8_glcdc.c:766
ra8_glcdc_alpha_priv_t
Definition ra8_glcdc.c:365
@ k_glcdc_alpha_opaque
Fully opaque (constant alpha).
Definition ra8_glcdc.c:366
ra8_err_t ra8_glcdc_deinit(void)
Tear down GLCDC (stop + MSTP release).
Definition ra8_glcdc.c:818
static void internal_program_bg(const ra8_glcdc_panel_timing_t *t)
Program the GLCDC background-plane registers.
Definition ra8_glcdc.c:471
static void internal_lcdclk_switch_pll1r(void)
Switch LCDCLK source to PLL1R / 4 via the SREQ/SRDY handshake.
Definition ra8_glcdc.c:251
static void internal_panel_program(uintptr_t fb_addr, uint16_t fb_format, uint16_t fb_w, uint16_t fb_h, const ra8_glcdc_timing_t *tm)
Program every GLCDC register required to drive the panel.
Definition ra8_glcdc.c:636
ra8_glcdc_priv_mask_t
Definition ra8_glcdc.c:83
@ k_ra8_glcdc_clutsel_mask
CLUTINT.SEL bit mask.
Definition ra8_glcdc.c:84
@ k_ra8_glcdc_arcon_mask
AB1.ARCON bit mask.
Definition ra8_glcdc.c:85
static void internal_program_out(void)
Program the OUT stage (output format, brightness, contrast).
Definition ra8_glcdc.c:597
ra8_glcdc_dispsel_priv_t
Definition ra8_glcdc.c:359
@ k_glcdc_dispsel_non_transparent
GLCDC dispsel non transparent.
Definition ra8_glcdc.c:361
@ k_glcdc_dispsel_transparent
GLCDC dispsel transparent.
Definition ra8_glcdc.c:360
@ k_lcdck_sreq
Lcdck sreq.
Definition ra8_glcdc.c:145
@ k_lcdckdivcr_div4
LCDCLK = PLL1R / 4 = 100 MHz.
Definition ra8_glcdc.c:148
@ k_pdctrgd_pdcsf
bit 6: control-in-progress status.
Definition ra8_glcdc.c:142
@ k_pdctrgd_pdpgsf
bit 7: gated status.
Definition ra8_glcdc.c:143
@ k_pdctrgd_status
both status bits.
Definition ra8_glcdc.c:144
@ k_hococr_run
Hococr run.
Definition ra8_glcdc.c:149
@ k_pdctrgd_on
Pdctrgd on.
Definition ra8_glcdc.c:141
@ k_lcdck_sel_pll1r
HUM 9.2.58 LCDCKSEL[3:0] = 1000b.
Definition ra8_glcdc.c:147
@ k_lcdck_srdy_mask
Lcdck srdy mask.
Definition ra8_glcdc.c:146
ra8_err_t ra8_glcdc_exit_stop(void)
Exit MSTP-gated stop.
Definition ra8_glcdc.c:868
static void internal_program_gr1(const ra8_glcdc_panel_timing_t *t, uintptr_t fb_addr, uint16_t fb_format, uint16_t fb_w, uint16_t fb_h)
Program graphics layer 1 (top blend layer).
Definition ra8_glcdc.c:509
static void internal_graphics_domain_power_on(void)
Power on the Graphics power domain via PRC1-protected PDCTRGD.
Definition ra8_glcdc.c:198
Graphics LCD Controller driver (two-layer with alpha blending).
void(* ra8_glcdc_event_fn_t)(void *ctx, uint32_t status_mask)
GLCDC event callback (VSYNC / line detect / underflow).
Definition ra8_glcdc.h:122
ra8_glcdc_dither_mode_t
Output-stage dithering mode for 24bpp -> 18/16bpp panels.
Definition ra8_glcdc.h:99
@ k_ra8_dither_off
No dithering (PDTHA.SEL=0).
Definition ra8_glcdc.h:100
@ k_ra8_dither_truncate
Round/truncate (PDTHA.SEL=2).
Definition ra8_glcdc.h:101
@ k_ra8_dither_2x2
2x2 ordered dither (PDTHA.SEL=3).
Definition ra8_glcdc.h:102
Graphics LCD Controller (GLCDC) register layout for the RA8D2.
@ k_ra8_glcdc_off_tcon_stha1
TCON.STHA1.
@ k_ra8_glcdc_off_gr2_ab5
GR[1].AB5: alpha rect H size+pos.
@ k_ra8_glcdc_off_out_set
OUT.SET: output interface.
@ k_ra8_glcdc_off_gr2_ab2
GR[1].AB2: graphics V size + pos.
@ k_ra8_glcdc_off_panel_clk
SYSCNT.PANEL_CLK.
@ k_ra8_glcdc_off_gr1_ab1
GR[0].AB1: alpha blend ctrl 1.
@ k_ra8_glcdc_off_sys_stat
SYSCNT.STMON.
@ k_ra8_glcdc_off_bg_vsize
BG.VSIZE: vertical valid size.
@ k_ra8_glcdc_off_bg_en
BG.EN: module enable.
@ k_ra8_glcdc_off_out_contrast
OUT.CONTRAST.
@ k_ra8_glcdc_off_gr2_ab1
GR[1].AB1.
@ k_ra8_glcdc_off_bg_per
BG.PERI: free-running period.
@ k_ra8_glcdc_off_gr1_saddr
GR[0].FLM2.BASE: framebuffer addr.
@ k_ra8_glcdc_off_gr1_ab7
GR[0].AB7: chroma-key on, def alf.
@ k_ra8_glcdc_off_gr1_ab4
GR[0].AB4: alpha rect V size+pos.
@ k_ra8_glcdc_off_gr1_ab2
GR[0].AB2: graphics V size + pos.
@ k_ra8_glcdc_off_gr1_line
GR[0].FLM5: datanum + lnnum.
@ k_ra8_glcdc_off_gr1_en
GR[0].VEN: register update ctrl.
@ k_ra8_glcdc_off_gr1_ab5
GR[0].AB5: alpha rect H size+pos.
@ k_ra8_glcdc_off_tcon_de
TCON.DE.
@ k_ra8_glcdc_off_gr2_ab4
GR[1].AB4: alpha rect V size+pos.
@ k_ra8_glcdc_off_gr1_fmt
GR[0].FLM6.FORMAT: pixel format.
@ k_ra8_glcdc_off_tcon_tim
TCON.TIM: reference timing.
@ k_ra8_glcdc_off_bg_sync
BG.SYNC: sync position.
@ k_ra8_glcdc_off_gr2_flmrd
GR[1].FLMRD.
@ k_ra8_glcdc_off_out_vlatch
OUT.VLATCH.
@ k_ra8_glcdc_off_bg_hsize
BG.HSIZE: horizontal valid size.
@ k_ra8_glcdc_off_panel_dtha
OUT.PDTHA: panel dither.
@ k_ra8_glcdc_off_out_bright2
OUT.BRIGHT2.
@ k_ra8_glcdc_off_tcon_sthb2
TCON.STHB2.
@ k_ra8_glcdc_off_gr2_en
GR[1].VEN.
@ k_ra8_glcdc_off_tcon_stha2
TCON.STHA2.
@ k_ra8_glcdc_off_tcon_stvb2
TCON.STVB2.
@ k_ra8_glcdc_off_gr2_size
GR[1].AB3: graphics H size + pos.
@ k_ra8_glcdc_off_gr1_size
GR[0].AB3: graphics H size + pos.
@ k_ra8_glcdc_off_sys_cfg
SYSCNT.DTCTEN (state detection).
@ k_ra8_glcdc_off_tcon_stvb1
TCON.STVB1.
@ k_ra8_glcdc_off_out_bright1
OUT.BRIGHT1.
@ k_ra8_glcdc_off_tcon_stva2
TCON.STVA2.
@ k_ra8_glcdc_off_gr1_flmrd
GR[0].FLMRD: frame buffer read en.
@ k_ra8_glcdc_off_out_clkphase
OUT.CLKPHASE.
@ k_ra8_glcdc_off_bg_bgc
BG.BGC: background colour.
@ k_ra8_glcdc_off_tcon_stva1
TCON.STVA1.
@ k_ra8_glcdc_off_gr2_ab7
GR[1].AB7: chroma-key on, def alf.
@ k_ra8_glcdc_off_gr1_flm3
GR[0].FLM3: line offset bytes.
@ k_ra8_glcdc_off_tcon_sthb1
TCON.STHB1.
static volatile uint32_t * ra8_glcdc_reg32(ra8_glcdc_block_off_t offset)
Pointer to a 32-bit register inside the GLCDC block.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
Definition ra8_mstp.c:343
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
Definition ra8_mstp.c:382
@ k_ra8_mstp_glcdc
MSTPC4 GLCDC.
Minimal GLCDC configuration for a single-layer panel.
Definition ra8_glcdc.h:55
ra8_glcdc_pixel_fmt_t format
Pixel format code.
Definition ra8_glcdc.h:59
uint32_t framebuffer_addr
SRAM or SDRAM address.
Definition ra8_glcdc.h:56
ra8_glcdc_timing_t timing
Panel timing (from BSP).
Definition ra8_glcdc.h:60
uint16_t width_px
Visible width.
Definition ra8_glcdc.h:57
uint16_t height_px
Visible height.
Definition ra8_glcdc.h:58
Panel timing parameters shared by the per-stage helpers.
Definition ra8_glcdc.c:396
uint32_t h_active
Active pixels per line.
Definition ra8_glcdc.c:397
uint32_t v_total
Frame period (lines).
Definition ra8_glcdc.c:404
uint32_t v_back
Vertical back porch (lines).
Definition ra8_glcdc.c:402
uint32_t h_total
Line period = active + back + sync + fp.
Definition ra8_glcdc.c:400
uint32_t h_sync
HSYNC pulse width (pixel clocks).
Definition ra8_glcdc.c:399
uint32_t h_back
Back-porch pixel count.
Definition ra8_glcdc.c:398
uint32_t v_sync
VSYNC pulse width (lines).
Definition ra8_glcdc.c:403
uint32_t v_active
Active lines per frame.
Definition ra8_glcdc.c:401
Panel RGB timing the driver programs (accessory parameters).
Definition ra8_glcdc.h:35
uint16_t v_sync
VSYNC pulse width (lines).
Definition ra8_glcdc.h:43
uint16_t v_front
Vertical front porch (lines).
Definition ra8_glcdc.h:41
uint16_t v_active
Active lines per frame.
Definition ra8_glcdc.h:40
uint16_t h_front
Horizontal front porch (px).
Definition ra8_glcdc.h:37
uint16_t h_sync
HSYNC pulse width (px clocks).
Definition ra8_glcdc.h:39
uint16_t h_active
Active pixels per line.
Definition ra8_glcdc.h:36
uint16_t h_back
Horizontal back porch (px).
Definition ra8_glcdc.h:38
uint16_t v_back
Vertical back porch (lines).
Definition ra8_glcdc.h:42