Skip to content

Commit

Permalink
Handle reserved display mode correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed May 22, 2024
1 parent 4727c75 commit f63697f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions core/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ static inline int32_t panel_ram_col(void) {
return panel.col + panel.horizBackPorch - 17;
}

static inline bool panel_next_dm_is_mcu(void) {
return panel.params.RAMCTRL.DM == PANEL_DM_MCU || panel.params.RAMCTRL.DM == PANEL_DM_RESERVED;
}

static inline uint32_t panel_reverse_addr(uint32_t addr, uint32_t upperBound, uint32_t dirMask) {
assert(dirMask == 0 || dirMask == ~0);
return (addr ^ dirMask) + (upperBound & dirMask);
Expand Down Expand Up @@ -502,7 +506,7 @@ static uint32_t panel_start_frame() {
panel.topArea = panel.params.VSCRDEF.TFA & PANEL_ADDR_MASK;
panel.bottomArea = (PANEL_LAST_ROW - panel.params.VSCRDEF.BFA) & PANEL_ADDR_MASK;
panel.scrollStart = panel.params.VSCRSADD.VSP & PANEL_ADDR_MASK;
panel.displayMode = panel.params.RAMCTRL.DM;
panel.displayMode = panel.params.RAMCTRL.DM != PANEL_DM_RESERVED ? panel.params.RAMCTRL.DM : PANEL_DM_MCU;

panel_generate_luts();

Expand Down Expand Up @@ -607,7 +611,7 @@ static void panel_event(enum sched_item_id id) {
panel_scan_until(0);

/* If the new display mode is MCU, start the next frame now */
if (panel.params.RAMCTRL.DM == PANEL_DM_MCU) {
if (panel_next_dm_is_mcu()) {
sched_repeat(id, panel_start_frame());
}
}
Expand Down Expand Up @@ -1065,7 +1069,7 @@ static void panel_write_param(uint8_t value) {
((uint8_t*)&panel.params)[index] = value;
if (unlikely(index == offsetof(panel_params_t, RAMCTRL))) {
/* Handle display mode switch from RGB to MCU */
if (unlikely(panel.params.RAMCTRL.DM == PANEL_DM_MCU) &&
if (unlikely(panel_next_dm_is_mcu()) &&
panel.displayMode == PANEL_DM_RGB) {
sched_set(SCHED_PANEL, panel_start_frame());
}
Expand Down
3 changes: 2 additions & 1 deletion core/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ enum panel_mode {
enum panel_display_mode {
PANEL_DM_MCU = 0,
PANEL_DM_RGB = 1,
PANEL_DM_VSYNC = 2
PANEL_DM_VSYNC = 2,
PANEL_DM_RESERVED = 3
};

typedef struct panel_mem_ptr {
Expand Down

0 comments on commit f63697f

Please sign in to comment.