modules: lvgl: support the frame buffer address and stride alignment
Add support for the frame buffer address and stride alignment. If user set the CONFIG_LV_DRAW_BUF_ALIGN to not be 4, the buffers shall be allocated aoocrdingly. If user set the CONFIG_LV_DRAW_BUF_STRIDE_ALIGN to not be 1, the methods of flushing the display shall set the pitch accordingly. Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
This commit is contained in:
@@ -27,6 +27,8 @@ struct lvgl_disp_data disp_data[DT_ZEPHYR_DISPLAYS_COUNT] = {{
|
||||
.blanking_on = false,
|
||||
}};
|
||||
|
||||
#define DISPLAY_BUFFER_ALIGN(alignbytes) __aligned(alignbytes)
|
||||
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(zephyr_displays)
|
||||
#define DISPLAY_NODE(n) DT_ZEPHYR_DISPLAY(n)
|
||||
#elif DT_HAS_CHOSEN(zephyr_display)
|
||||
@@ -77,21 +79,21 @@ static uint8_t *mono_vtile_buf_p[DT_ZEPHYR_DISPLAYS_COUNT] = {NULL};
|
||||
/* prevent unaligned memory accesses. */
|
||||
|
||||
/* clang-format off */
|
||||
#define LV_BUFFERS_DEFINE(n) \
|
||||
static uint8_t buf0_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
\
|
||||
IF_ENABLED(CONFIG_LV_Z_DOUBLE_VDB, ( \
|
||||
static uint8_t buf1_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
)) \
|
||||
\
|
||||
IF_ENABLED(ALLOC_MONOCHROME_CONV_BUFFER, ( \
|
||||
static uint8_t mono_vtile_buf_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
#define LV_BUFFERS_DEFINE(n) \
|
||||
static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf0_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
\
|
||||
IF_ENABLED(CONFIG_LV_Z_DOUBLE_VDB, ( \
|
||||
static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf1_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
)) \
|
||||
\
|
||||
IF_ENABLED(ALLOC_MONOCHROME_CONV_BUFFER, ( \
|
||||
static uint8_t mono_vtile_buf_##n[BUFFER_SIZE(n)] \
|
||||
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
|
||||
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
|
||||
))
|
||||
|
||||
FOR_EACH(LV_BUFFERS_DEFINE, (), LV_DISPLAYS_IDX_LIST);
|
||||
|
||||
@@ -20,7 +20,7 @@ void lvgl_flush_cb_16bit(lv_display_t *display, const lv_area_t *area, uint8_t *
|
||||
flush.y = area->y1;
|
||||
flush.desc.buf_size = w * 2U * h;
|
||||
flush.desc.width = w;
|
||||
flush.desc.pitch = w;
|
||||
flush.desc.pitch = ROUND_UP(w * 2U, LV_DRAW_BUF_STRIDE_ALIGN) / 2U;
|
||||
flush.desc.height = h;
|
||||
flush.buf = (void *)px_map;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ void lvgl_flush_cb_24bit(lv_display_t *display, const lv_area_t *area, uint8_t *
|
||||
flush.y = area->y1;
|
||||
flush.desc.buf_size = w * 3U * h;
|
||||
flush.desc.width = w;
|
||||
flush.desc.pitch = w;
|
||||
flush.desc.pitch = ROUND_UP(w * 3U, LV_DRAW_BUF_STRIDE_ALIGN) / 3U;
|
||||
flush.desc.height = h;
|
||||
flush.buf = (void *)px_map;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ void lvgl_flush_cb_32bit(lv_display_t *display, const lv_area_t *area, uint8_t *
|
||||
flush.y = area->y1;
|
||||
flush.desc.buf_size = w * 4U * h;
|
||||
flush.desc.width = w;
|
||||
flush.desc.pitch = w;
|
||||
flush.desc.pitch = ROUND_UP(w * 4U, LV_DRAW_BUF_STRIDE_ALIGN) / 4U;
|
||||
flush.desc.height = h;
|
||||
flush.buf = (void *)px_map;
|
||||
lvgl_flush_display(&flush);
|
||||
|
||||
@@ -19,7 +19,7 @@ void lvgl_flush_cb_8bit(lv_display_t *display, const lv_area_t *area, uint8_t *p
|
||||
flush.y = area->y1;
|
||||
flush.desc.buf_size = w * h;
|
||||
flush.desc.width = w;
|
||||
flush.desc.pitch = w;
|
||||
flush.desc.pitch = ROUND_UP(w, LV_DRAW_BUF_STRIDE_ALIGN);
|
||||
flush.desc.height = h;
|
||||
flush.buf = (void *)px_map;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user