bdk: display: add useful functions

- Window disable
- Window framebuffer address set
- Window framebuffer move to new address
This commit is contained in:
CTCaer 2024-06-06 06:27:30 +03:00
parent 14c482ddce
commit 4a24fe0b35
3 changed files with 68 additions and 14 deletions

View file

@ -902,6 +902,53 @@ u32 *display_init_window_d_console()
return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR)); return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
} }
void display_window_disable(u32 window)
{
// Select window C.
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = BIT(WINDOW_SELECT + window);
// Disable window C.
DISPLAY_A(_DIREG(DC_WIN_WIN_OPTIONS)) = 0;
// Arm and activate changes.
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | BIT(WIN_UPDATE + window);
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | BIT(WIN_ACT_REQ + window);
}
void display_set_framebuffer(u32 window, void *fb)
{
// Select window.
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = BIT(WINDOW_SELECT + window);
// Set new fb address.
DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR)) = (u32)fb;
// Arm and activate changes.
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | BIT(WIN_UPDATE + window);
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | BIT(WIN_ACT_REQ + window);
}
void display_move_framebuffer(u32 window, void *fb)
{
// Select window.
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = BIT(WINDOW_SELECT + window);
// Get current framebuffer address.
void *fb_curr = (void *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
u32 win_size = DISPLAY_A(_DIREG(DC_WIN_PRESCALED_SIZE));
win_size = (win_size & 0x7FFF) * ((win_size >> 16) & 0x1FFF);
// Copy fb over.
memcpy(fb, fb_curr, win_size);
// Set new fb address.
DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR)) = (u32)fb;
// Arm and activate changes.
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | BIT(WIN_UPDATE + window);
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | BIT(WIN_ACT_REQ + window);
}
void display_window_d_console_enable() void display_window_d_console_enable()
{ {
// Only update active registers on vsync. // Only update active registers on vsync.
@ -935,9 +982,6 @@ void display_window_d_console_enable()
// Arm and activate changes. // Arm and activate changes.
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
// Re-select window A.
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = WINDOW_A_SELECT;
} }
void display_window_d_console_disable() void display_window_d_console_disable()
@ -964,9 +1008,6 @@ void display_window_d_console_disable()
// Arm and activate changes. // Arm and activate changes.
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
// Re-select window A.
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = WINDOW_A_SELECT;
} }
void display_cursor_init(void *crs_fb, u32 size) void display_cursor_init(void *crs_fb, u32 size)

View file

@ -24,6 +24,11 @@
#define DSI_VIDEO_DISABLED 0 #define DSI_VIDEO_DISABLED 0
#define DSI_VIDEO_ENABLED 1 #define DSI_VIDEO_ENABLED 1
#define WINDOW_A 0
#define WINDOW_B 1
#define WINDOW_C 2
#define WINDOW_D 3
/*! Display registers. */ /*! Display registers. */
#define _DIREG(reg) ((reg) * 4) #define _DIREG(reg) ((reg) * 4)
@ -87,12 +92,14 @@
#define DC_CMD_STATE_CONTROL 0x41 #define DC_CMD_STATE_CONTROL 0x41
#define GENERAL_ACT_REQ BIT(0) #define GENERAL_ACT_REQ BIT(0)
#define WIN_ACT_REQ 1
#define WIN_A_ACT_REQ BIT(1) #define WIN_A_ACT_REQ BIT(1)
#define WIN_B_ACT_REQ BIT(2) #define WIN_B_ACT_REQ BIT(2)
#define WIN_C_ACT_REQ BIT(3) #define WIN_C_ACT_REQ BIT(3)
#define WIN_D_ACT_REQ BIT(4) #define WIN_D_ACT_REQ BIT(4)
#define CURSOR_ACT_REQ BIT(7) #define CURSOR_ACT_REQ BIT(7)
#define GENERAL_UPDATE BIT(8) #define GENERAL_UPDATE BIT(8)
#define WIN_UPDATE 9
#define WIN_A_UPDATE BIT(9) #define WIN_A_UPDATE BIT(9)
#define WIN_B_UPDATE BIT(10) #define WIN_B_UPDATE BIT(10)
#define WIN_C_UPDATE BIT(11) #define WIN_C_UPDATE BIT(11)
@ -101,6 +108,7 @@
#define NC_HOST_TRIG BIT(24) #define NC_HOST_TRIG BIT(24)
#define DC_CMD_DISPLAY_WINDOW_HEADER 0x42 #define DC_CMD_DISPLAY_WINDOW_HEADER 0x42
#define WINDOW_SELECT 4
#define WINDOW_A_SELECT BIT(4) #define WINDOW_A_SELECT BIT(4)
#define WINDOW_B_SELECT BIT(5) #define WINDOW_B_SELECT BIT(5)
#define WINDOW_C_SELECT BIT(6) #define WINDOW_C_SELECT BIT(6)
@ -860,6 +868,12 @@ void display_wait_interrupt(u32 intr);
u16 display_get_decoded_panel_id(); u16 display_get_decoded_panel_id();
void display_set_decoded_panel_id(u32 id); void display_set_decoded_panel_id(u32 id);
/*! MIPI DCS register management */
int display_dsi_read(u8 cmd, u32 len, void *data);
int display_dsi_vblank_read(u8 cmd, u32 len, void *data);
void display_dsi_write(u8 cmd, u32 len, void *data);
void display_dsi_vblank_write(u8 cmd, u32 len, void *data);
/*! Show one single color on the display. */ /*! Show one single color on the display. */
void display_color_screen(u32 color); void display_color_screen(u32 color);
@ -874,6 +888,11 @@ u32 *display_init_window_a_pitch_inv();
u32 *display_init_window_a_block(); u32 *display_init_window_a_block();
u32 *display_init_window_d_console(); u32 *display_init_window_d_console();
void display_window_disable(u32 window);
void display_set_framebuffer(u32 window, void *fb);
void display_move_framebuffer(u32 window, void *fb);
void display_window_d_console_enable(); void display_window_d_console_enable();
void display_window_d_console_disable(); void display_window_d_console_disable();
@ -881,9 +900,4 @@ void display_cursor_init(void *crs_fb, u32 size);
void display_cursor_set_pos(u32 x, u32 y); void display_cursor_set_pos(u32 x, u32 y);
void display_cursor_deinit(); void display_cursor_deinit();
int display_dsi_read(u8 cmd, u32 len, void *data);
int display_dsi_vblank_read(u8 cmd, u32 len, void *data);
void display_dsi_write(u8 cmd, u32 len, void *data);
void display_dsi_vblank_write(u8 cmd, u32 len, void *data);
#endif #endif

View file

@ -304,7 +304,7 @@ static const reg_cfg_t _di_dc_video_enable_config[] = {
{DC_CMD_GENERAL_INCR_SYNCPT, SYNCPT_GENERAL_COND(COND_REG_WR_SAFE) | SYNCPT_GENERAL_INDX(1)}, {DC_CMD_GENERAL_INCR_SYNCPT, SYNCPT_GENERAL_COND(COND_REG_WR_SAFE) | SYNCPT_GENERAL_INDX(1)},
{DC_CMD_STATE_CONTROL, GENERAL_UPDATE}, {DC_CMD_STATE_CONTROL, GENERAL_UPDATE},
{DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ}, {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ},
{DC_DISP_DISP_CLOCK_CONTROL, PIXEL_CLK_DIVIDER_PCD1 | SHIFT_CLK_DIVIDER(4)}, {DC_DISP_DISP_CLOCK_CONTROL, PIXEL_CLK_DIVIDER_PCD1 | SHIFT_CLK_DIVIDER(4)}, // 4: div3.
}; };
// Display A disable config. // Display A disable config.
@ -551,5 +551,4 @@ static const reg_cfg_t _di_winD_log[] = {
{DC_WINBUF_BLEND_MATCH_SELECT, WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1 | WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1}, {DC_WINBUF_BLEND_MATCH_SELECT, WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1 | WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1},
{DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_D_UPDATE}, {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_D_UPDATE},
{DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_D_ACT_REQ}, {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_D_ACT_REQ},
{DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT},
}; };