perf(EVE): buffered writes (#9051)

This commit is contained in:
Liam Howatt
2025-10-14 21:33:17 +02:00
committed by GitHub
parent 848444d597
commit 352a64b79e
9 changed files with 83 additions and 42 deletions
+5
View File
@@ -543,6 +543,11 @@ menu "LVGL configuration"
range 2 4
depends on LV_USE_DRAW_EVE
config LV_DRAW_EVE_WRITE_BUFFER_SIZE
int "Max bytes to buffer for each SPI transmission"
default 2048
depends on LV_USE_DRAW_EVE
endmenu
menu "Feature Configuration"
+3
View File
@@ -394,6 +394,9 @@
#if LV_USE_DRAW_EVE
/* EVE_GEN value: 2, 3, or 4 */
#define LV_DRAW_EVE_EVE_GENERATION 4
/* the maximum number of bytes to buffer before a single SPI transmission */
#define LV_DRAW_EVE_WRITE_BUFFER_SIZE 2048
#endif
/*=======================
-9
View File
@@ -127,13 +127,6 @@ static void eve_execute_drawing(lv_draw_eve_unit_t * u)
{
lv_draw_task_t * t = u->task_act;
uint8_t coprocessor_status;
do {
coprocessor_status = EVE_busy();
} while(coprocessor_status != E_OK && coprocessor_status != EVE_FIFO_HALF_EMPTY);
EVE_start_cmd_burst();
switch(t->type) {
case LV_DRAW_TASK_TYPE_LINE:
lv_draw_eve_line(t, t->draw_dsc);
@@ -159,8 +152,6 @@ static void eve_execute_drawing(lv_draw_eve_unit_t * u)
default:
break;
}
EVE_end_cmd_burst();
}
static void disp_delete_cb(lv_event_t * e)
+2
View File
@@ -60,6 +60,8 @@ struct _lv_draw_eve_unit_t {
lv_draw_eve_ramg_t ramg;
lv_draw_eve_parameters_t params;
lv_draw_eve_operation_cb_t op_cb;
uint32_t lv_eve_write_buf_len;
uint8_t lv_eve_write_buf[LV_DRAW_EVE_WRITE_BUFFER_SIZE];
};
/**********************
+19 -12
View File
@@ -32,6 +32,8 @@
static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map);
static void resolution_changed_cb(lv_event_t * e);
static void render_start_cb(lv_event_t * e);
static void render_ready_cb(lv_event_t * e);
static void touch_read_cb(lv_indev_t * indev, lv_indev_data_t * data);
/**********************
@@ -57,6 +59,8 @@ lv_display_t * lv_draw_eve_display_create(const lv_draw_eve_parameters_t * param
params->hor_res * params->ver_res * LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_NATIVE),
LV_DISPLAY_RENDER_MODE_FULL); /* recreate the full display list each refresh */
lv_display_add_event_cb(disp, resolution_changed_cb, LV_EVENT_RESOLUTION_CHANGED, NULL);
lv_display_add_event_cb(disp, render_start_cb, LV_EVENT_RENDER_START, NULL);
lv_display_add_event_cb(disp, render_ready_cb, LV_EVENT_RENDER_READY, NULL);
lv_display_set_driver_data(disp, user_data);
lv_draw_eve_set_display_data(disp, params, op_cb);
@@ -64,13 +68,6 @@ lv_display_t * lv_draw_eve_display_create(const lv_draw_eve_parameters_t * param
EVE_init();
EVE_memWrite8(REG_PWM_DUTY, EVE_BACKLIGHT_PWM); /* 0 = off, 0x80 = max */
EVE_start_cmd_burst();
EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */
EVE_cmd_dl_burst(DL_CLEAR_COLOR_RGB | 0x000000);
EVE_cmd_dl_burst(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
EVE_cmd_dl_burst(VERTEX_FORMAT(0));
EVE_end_cmd_burst();
return disp;
}
@@ -199,7 +196,6 @@ void lv_draw_eve_memwrite32(lv_display_t * disp, uint32_t address, uint32_t data
static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
{
if(lv_display_flush_is_last(disp)) {
EVE_start_cmd_burst();
EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */
EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */
EVE_end_cmd_burst();
@@ -207,10 +203,6 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_m
EVE_execute_cmd();
EVE_start_cmd_burst();
EVE_cmd_dl_burst(CMD_DLSTART);
EVE_cmd_dl_burst(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
EVE_cmd_dl_burst(VERTEX_FORMAT(0));
EVE_end_cmd_burst();
}
lv_display_flush_ready(disp);
@@ -245,6 +237,21 @@ static void resolution_changed_cb(lv_event_t * e)
EVE_memWrite8(REG_ROTATE, cmd_value);
}
static void render_start_cb(lv_event_t * e)
{
EVE_start_cmd_burst();
EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */
EVE_cmd_dl_burst(DL_CLEAR_COLOR_RGB | 0x000000);
EVE_cmd_dl_burst(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
EVE_cmd_dl_burst(VERTEX_FORMAT(0));
}
static void render_ready_cb(lv_event_t * e)
{
EVE_end_cmd_burst();
}
static void touch_read_cb(lv_indev_t * indev, lv_indev_data_t * data)
{
lv_display_t * disp = lv_indev_get_display(indev);
+8 -18
View File
@@ -285,12 +285,7 @@ void EVE_memWrite_flash_buffer(uint32_t const ft_address, const uint8_t *p_data,
spi_transmit((uint8_t) (ft_address >> 8U));
spi_transmit((uint8_t) (ft_address & 0x000000ffUL));
// uint32_t length = (len + 3U) & (~3U);
for (uint32_t count = 0U; count < len; count++)
{
spi_transmit(fetch_flash_byte(&p_data[count]));
}
lv_eve_target_spi_transmit_buf(p_data, len);
EVE_cs_clear();
}
@@ -308,12 +303,7 @@ void EVE_memWrite_sram_buffer(uint32_t const ft_address, const uint8_t *p_data,
spi_transmit((uint8_t) (ft_address >> 8U));
spi_transmit((uint8_t) (ft_address & 0x000000ffUL));
// uint32_t length = (len + 3U) & (~3U);
for (uint32_t count = 0U; count < len; count++)
{
spi_transmit(p_data[count]);
}
lv_eve_target_spi_transmit_buf(p_data, len);
EVE_cs_clear();
}
@@ -454,9 +444,9 @@ static void eve_begin_cmd(uint32_t command)
spi_transmit_32(command);
}
void private_block_write(const uint8_t *p_data, uint16_t len); /* prototype to comply with MISRA */
static void private_block_write(const uint8_t *p_data, uint16_t len); /* prototype to comply with MISRA */
void private_block_write(const uint8_t *p_data, uint16_t len)
static void private_block_write(const uint8_t *p_data, uint16_t len)
{
uint8_t padding;
@@ -476,9 +466,9 @@ void private_block_write(const uint8_t *p_data, uint16_t len)
}
}
void block_transfer(const uint8_t *p_data, uint32_t len); /* prototype to comply with MISRA */
static void block_transfer(const uint8_t *p_data, uint32_t len); /* prototype to comply with MISRA */
void block_transfer(const uint8_t *p_data, uint32_t len)
static void block_transfer(const uint8_t *p_data, uint32_t len)
{
uint32_t bytes_left;
uint32_t offset = 0U;
@@ -1391,9 +1381,9 @@ uint8_t EVE_init_flash(void)
#endif
#endif
void use_gt911(void);
static void use_gt911(void);
void use_gt911(void)
static void use_gt911(void)
{
#if EVE_GEN > 2
EVE_memWrite16(REG_TOUCH_CONFIG, 0x05d0U); /* switch to Goodix touch controller */
+36 -2
View File
@@ -4,6 +4,12 @@
#include "../../draw/eve/lv_draw_eve_private.h"
#include "../../tick/lv_tick.h"
#include "../../misc/lv_utils.h"
#include "../../core/lv_global.h"
#define lv_eve_write_buf (LV_GLOBAL_DEFAULT()->draw_eve_unit->lv_eve_write_buf)
#define lv_eve_write_buf_len (LV_GLOBAL_DEFAULT()->draw_eve_unit->lv_eve_write_buf_len)
static inline void lv_eve_target_flush_write_buf(void);
static inline void DELAY_MS(uint16_t ms)
{
@@ -17,6 +23,7 @@ static inline void EVE_cs_set(void)
static inline void EVE_cs_clear(void)
{
lv_eve_target_flush_write_buf();
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_CS_DEASSERT, NULL, 0);
}
@@ -32,7 +39,10 @@ static inline void EVE_pdn_clear(void)
static inline void spi_transmit(uint8_t data)
{
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_SPI_SEND, &data, 1);
if(lv_eve_write_buf_len == sizeof(lv_eve_write_buf)) {
lv_eve_target_flush_write_buf();
}
lv_eve_write_buf[lv_eve_write_buf_len++] = data;
}
static inline void spi_transmit_32(uint32_t data)
@@ -40,7 +50,29 @@ static inline void spi_transmit_32(uint32_t data)
#if LV_BIG_ENDIAN_SYSTEM
data = lv_swap_bytes_32(data);
#endif
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_SPI_SEND, &data, 4);
if(lv_eve_write_buf_len + 4 > sizeof(lv_eve_write_buf)) {
lv_eve_target_flush_write_buf();
}
uint8_t * buf4 = (uint8_t *) &data;
lv_eve_write_buf[lv_eve_write_buf_len++] = buf4[0];
lv_eve_write_buf[lv_eve_write_buf_len++] = buf4[1];
lv_eve_write_buf[lv_eve_write_buf_len++] = buf4[2];
lv_eve_write_buf[lv_eve_write_buf_len++] = buf4[3];
}
static inline void lv_eve_target_spi_transmit_buf(const void * data, uint32_t size)
{
lv_eve_target_flush_write_buf();
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_SPI_SEND, (void *) data, size);
}
static inline void lv_eve_target_flush_write_buf(void)
{
if(lv_eve_write_buf_len == 0) {
return;
}
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_SPI_SEND, lv_eve_write_buf, lv_eve_write_buf_len);
lv_eve_write_buf_len = 0;
}
static inline void spi_transmit_burst(uint32_t data)
@@ -53,6 +85,8 @@ static inline uint8_t spi_receive(uint8_t data)
/* `data` is 0 everywhere `spi_receive` is called in the FT800-FT813 library */
LV_UNUSED(data);
lv_eve_target_flush_write_buf();
uint8_t byte;
lv_draw_eve_unit_g->op_cb(lv_draw_eve_unit_g->disp, LV_DRAW_EVE_OPERATION_SPI_RECEIVE, &byte, 1);
+9
View File
@@ -1121,6 +1121,15 @@
#define LV_DRAW_EVE_EVE_GENERATION 4
#endif
#endif
/* the maximum number of bytes to buffer before a single SPI transmission */
#ifndef LV_DRAW_EVE_WRITE_BUFFER_SIZE
#ifdef CONFIG_LV_DRAW_EVE_WRITE_BUFFER_SIZE
#define LV_DRAW_EVE_WRITE_BUFFER_SIZE CONFIG_LV_DRAW_EVE_WRITE_BUFFER_SIZE
#else
#define LV_DRAW_EVE_WRITE_BUFFER_SIZE 2048
#endif
#endif
#endif
/*=======================
+1 -1
View File
@@ -106,7 +106,7 @@ typedef enum {
LV_EVENT_REFR_START, /**< Sent before a refreshing cycle starts. Sent even if there is nothing to redraw. */
LV_EVENT_REFR_READY, /**< Sent when refreshing has been completed (after rendering and calling flush callback). Sent even if no redraw happened. */
LV_EVENT_RENDER_START, /**< Sent just before rendering begins. */
LV_EVENT_RENDER_READY, /**< Sent after rendering has been completed (before calling flush callback) */
LV_EVENT_RENDER_READY, /**< Sent after rendering has been completed. */
LV_EVENT_FLUSH_START, /**< Sent before flush callback is called. */
LV_EVENT_FLUSH_FINISH, /**< Sent after flush callback call has returned. */
LV_EVENT_FLUSH_WAIT_START, /**< Sent before flush wait callback is called. */