Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LVGL module to 9.2.0 #68168

Merged
merged 15 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions boards/st/stm32h7b3i_dk/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ if LVGL
config CACHE_MANAGEMENT
default y

config LV_USE_GPU_STM32_DMA2D
config LV_USE_DRAW_DMA2D
default y

config LV_GPU_DMA2D_CMSIS_INCLUDE
config LV_DRAW_DMA2D_HAL_INCLUDE
default "stm32h7xx.h"
Comment on lines -28 to 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We'll need to move this to soc/st/stm32/stm32h7x/Kconfig.defconfig as it's common to whole STM32H7 series so it doesn't make sense to put in board config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this part of this PR or a susequent one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to address that now as this is not related with this change. It can wait.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DMA2D support in LVGL 9.2 might need extra code to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be removed from the board then ?
@CharlesDias Did you had a try ?

Copy link
Collaborator

@GeorgeCGV GeorgeCGV Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand dma2d-support correctly - to benefit from dma2d we need to use LV_USE_DRAW_DMA2D_INTERRUPT with LV_USE_OS and call lv_draw_dma2d_transfer_complete_interrupt_handler when "DMA2D "transfer complete" global interrupt is received". Therefore, extra interrupt setup and handling code is required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling LV_Z_USE_OSAL is already possible and together with dma2d should already give some performance improvement. Its true that the interrupt setup is needed to avoid actively polling for completion.

Since I do not own a device with chromart I can not test this easily. If someone wants to help out on this I appreciate every bit :^)


config STM32_LTDC_FB_NUM
Expand Down
334 changes: 214 additions & 120 deletions modules/lvgl/CMakeLists.txt

Large diffs are not rendered by default.

45 changes: 42 additions & 3 deletions modules/lvgl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ choice LV_COLOR_DEPTH

config LV_COLOR_DEPTH_32
bool "32: ARGB8888"
config LV_COLOR_DEPTH_24
bool "24: RGB888"
config LV_COLOR_DEPTH_16
bool "16: RGB565"
config LV_COLOR_DEPTH_8
Expand All @@ -86,7 +88,7 @@ choice LV_COLOR_DEPTH
endchoice

config LV_COLOR_16_SWAP
bool
bool "Swap the 2 bytes of RGB565 color."
depends on LV_COLOR_DEPTH_16

config LV_Z_FLUSH_THREAD
Expand Down Expand Up @@ -128,15 +130,52 @@ config LV_Z_AREA_Y_ALIGNMENT_WIDTH
the current frame dimensions to meet display and/or LCD host
controller requirements. The value must be power of 2.

config LV_USE_GPU_STM32_DMA2D
config LV_Z_AUTO_INIT
bool "Initialize LVGL before application startup"
default y
help
Configure LVGL callbacks and display initialization before the application starts.
This can be useful to disable if you need to change a display's pixel format
prior to initialization. If using static allocation, ensure that LV_Z_BITS_PER_PIXEL
is set correctly.

config LV_Z_INIT_PRIORITY
int "Default init priority for LVGL"
default 90
depends on LV_Z_AUTO_INIT
help
Priority used for the automatic initialization of LVGL.
faxe1008 marked this conversation as resolved.
Show resolved Hide resolved

config LV_USE_DRAW_DMA2D
bool

config LV_GPU_DMA2D_CMSIS_INCLUDE
config LV_DRAW_DMA2D_HAL_INCLUDE
string
help
Must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h"

config LV_Z_USE_OSAL
bool "Use OSAL enabling parallel rendering"
depends on DYNAMIC_THREAD
help
Use the Zephyr LVGL OSAL to enable parallel rendering
pipelines.

config LV_USE_PXP
bool
pdgendt marked this conversation as resolved.
Show resolved Hide resolved

config LV_USE_GPU_NXP_PXP
bool
default y if LV_USE_PXP

config LV_Z_PXP_INTERRUPT_PRIORITY
int "PXP interrupt priority"
depends on LV_USE_PXP
default 3
help
Sets the interrupt priority for PXP

rsource "Kconfig.memory"
rsource "Kconfig.input"
rsource "Kconfig.shell"
Expand Down
13 changes: 12 additions & 1 deletion modules/lvgl/Kconfig.memory
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ menu "Memory manager settings"
config LV_Z_BITS_PER_PIXEL
int "Bits per pixel"
default 32
default 32 if LV_COLOR_DEPTH_32
default 24 if LV_COLOR_DEPTH_24
default 16 if LV_COLOR_DEPTH_16
default 8 if LV_COLOR_DEPTH_8
default 1 if LV_COLOR_DEPTH_1
range 1 32
depends on LV_Z_BUFFER_ALLOC_STATIC
help
Number of bits per pixel.

Expand Down Expand Up @@ -88,6 +92,13 @@ config LV_Z_VBD_CUSTOM_SECTION
rendering buffers to a custom location, such as tightly coupled or
external memory.

config LV_Z_MONOCHROME_CONVERSION_BUFFER
bool "Use intermediate conversion buffer for monochrome displays"
default y
help
When using a monochrome display an intermediate buffer with LV_Z_VDB_SIZE
is needed to perform the conversion.

choice LV_Z_RENDERING_BUFFER_ALLOCATION
prompt "Rendering Buffer Allocation"
default LV_Z_BUFFER_ALLOC_STATIC
Expand Down
47 changes: 22 additions & 25 deletions modules/lvgl/include/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,38 @@

/* Memory manager settings */

#define LV_MEMCPY_MEMSET_STD 1
#define LV_MEM_CUSTOM 1
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM

#if defined(CONFIG_LV_Z_MEM_POOL_HEAP_LIB_C)

#define LV_MEM_CUSTOM_INCLUDE "stdlib.h"
#define LV_MEM_CUSTOM_ALLOC malloc
#define LV_MEM_CUSTOM_REALLOC realloc
#define LV_MEM_CUSTOM_FREE free

#define LV_STDLIB_INCLUDE "stdlib.h"
#define lv_malloc_core malloc
#define lv_realloc_core realloc
#define lv_free_core free
#else

#define LV_MEM_CUSTOM_INCLUDE "lvgl_mem.h"
#define LV_MEM_CUSTOM_ALLOC lvgl_malloc
#define LV_MEM_CUSTOM_REALLOC lvgl_realloc
#define LV_MEM_CUSTOM_FREE lvgl_free

#define LV_STDLIB_INCLUDE "lvgl_mem.h"
#define lv_malloc_core lvgl_malloc
#define lv_realloc_core lvgl_realloc
#define lv_free_core lvgl_free
#endif

/* HAL settings */

#define LV_TICK_CUSTOM 1
#define LV_TICK_CUSTOM_INCLUDE <zephyr/kernel.h>
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (k_uptime_get_32())

/* Misc settings */

#define LV_SPRINTF_CUSTOM 1
#define LV_SPRINTF_INCLUDE "stdio.h"
#define lv_snprintf snprintf
#define lv_vsnprintf vsnprintf
#define lv_snprintf snprintf
#define lv_vsnprintf vsnprintf
#define LV_ASSERT_HANDLER __ASSERT_NO_MSG(false);
#define LV_ASSERT_HANDLER_INCLUDE "zephyr/sys/__assert.h"

/* Provide definition to align LVGL buffers */
#define LV_ATTRIBUTE_MEM_ALIGN __aligned(CONFIG_LV_ATTRIBUTE_MEM_ALIGN_SIZE)

#ifdef CONFIG_LV_COLOR_16_SWAP
#define LV_COLOR_16_SWAP 1
#endif /* CONFIG_LV_COLOR_16_SWAP */

#ifdef CONFIG_LV_Z_USE_OSAL
#define LV_USE_OS LV_OS_CUSTOM
#define LV_OS_CUSTOM_INCLUDE "lvgl_zephyr_osal.h"
#endif /* CONFIG_LV_Z_USE_OSAL */
faxe1008 marked this conversation as resolved.
Show resolved Hide resolved

/*
* Needed because of a workaround for a GCC bug,
* see https://github.com/lvgl/lvgl/issues/3078
Expand Down
1 change: 0 additions & 1 deletion modules/lvgl/include/lvgl_common_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct lvgl_common_input_config {
};

struct lvgl_common_input_data {
lv_indev_drv_t indev_drv;
lv_indev_t *indev;
lv_indev_data_t pending_event;
lv_indev_data_t previous_event;
Expand Down
26 changes: 9 additions & 17 deletions modules/lvgl/include/lvgl_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,27 @@ struct lvgl_disp_data {
};

struct lvgl_display_flush {
lv_disp_drv_t *disp_drv;
lv_display_t *display;
uint16_t x;
uint16_t y;
struct display_buffer_descriptor desc;
void *buf;
};

void lvgl_flush_cb_mono(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
void lvgl_flush_cb_16bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
void lvgl_flush_cb_24bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
void lvgl_flush_cb_32bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
void lvgl_flush_cb_mono(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
void lvgl_flush_cb_16bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
void lvgl_flush_cb_24bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
void lvgl_flush_cb_32bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);

void lvgl_set_px_cb_mono(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y, lv_color_t color, lv_opa_t opa);
void lvgl_set_px_cb_16bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y, lv_color_t color, lv_opa_t opa);
void lvgl_set_px_cb_24bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y, lv_color_t color, lv_opa_t opa);
void lvgl_set_px_cb_32bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y, lv_color_t color, lv_opa_t opa);
void lvgl_rounder_cb_mono(lv_event_t *e);
void lvgl_set_mono_conversion_buffer(uint8_t *buffer, uint32_t buffer_size);

void lvgl_rounder_cb_mono(lv_disp_drv_t *disp_drv, lv_area_t *area);

int set_lvgl_rendering_cb(lv_disp_drv_t *disp_drv);
int set_lvgl_rendering_cb(lv_display_t *display);

void lvgl_flush_display(struct lvgl_display_flush *request);

#ifdef CONFIG_LV_Z_USE_ROUNDER_CB
void lvgl_rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area);
void lvgl_rounder_cb(lv_event_t *e);
#endif

#ifdef __cplusplus
Expand Down
3 changes: 3 additions & 0 deletions modules/lvgl/include/lvgl_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <stdlib.h>
#include <stdbool.h>
#include <zephyr/sys/mem_stats.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -22,6 +23,8 @@ void lvgl_free(void *ptr);

void lvgl_print_heap_info(bool dump_chunks);

void lvgl_heap_stats(struct sys_memory_stats *stats);

void lvgl_heap_init(void);

#ifdef __cplusplus
Expand Down
17 changes: 17 additions & 0 deletions modules/lvgl/include/lvgl_support.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2023 Fabian Blatz <fabianblatz@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_MODULES_LVGL_LVGL_SUPPORT_H_
#define ZEPHYR_MODULES_LVGL_LVGL_SUPPORT_H_

#include <zephyr/cache.h>

static ALWAYS_INLINE void DEMO_CleanInvalidateCacheByAddr(void *addr, uint16_t size)
{
sys_cache_data_invd_range(addr, size);
}

#endif /* ZEPHYR_MODULES_LVGL_LVGL_SUPPORT_H_ */
30 changes: 30 additions & 0 deletions modules/lvgl/include/lvgl_zephyr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Fabian Blatz <fabianblatz@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_MODULES_LVGL_ZEPHYR_H_
#define ZEPHYR_MODULES_LVGL_ZEPHYR_H_

#include <zephyr/kernel.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Initialize the LittlevGL library
*
* This function initializes the LittlevGL library and setups the display and input devices.
* If `LV_Z_AUTO_INIT` is disabled it must be called before any other LittlevGL function.
*
* @return 0 on success, negative errno code on failure
*/
int lvgl_init(void);

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_MODULES_LVGL_ZEPHYR_H_ */
30 changes: 30 additions & 0 deletions modules/lvgl/include/lvgl_zephyr_osal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Fabian Blatz <fabianblatz@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_MODULES_LVGL_ZEPHYR_OSAL_H_
#define ZEPHYR_MODULES_LVGL_ZEPHYR_OSAL_H_

#include <zephyr/kernel.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
k_tid_t tid;
k_thread_stack_t *stack;
struct k_thread thread;
} lv_thread_t;

typedef struct k_mutex lv_mutex_t;

typedef struct k_sem lv_thread_sync_t;

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_MODULES_LVGL_ZEPHYR_OSAL_H_ */
7 changes: 3 additions & 4 deletions modules/lvgl/input/lvgl_button_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct lvgl_button_input_config {
struct lvgl_common_input_config common_config; /* Needs to be first member */
const uint16_t *input_codes;
uint8_t num_codes;
const lv_coord_t *coordinates;
const int32_t *coordinates;
};

static void lvgl_button_process_event(struct input_event *evt, void *user_data)
Expand All @@ -39,7 +39,7 @@ static void lvgl_button_process_event(struct input_event *evt, void *user_data)
}

data->pending_event.btn_id = i;
data->pending_event.state = evt->value ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
data->pending_event.state = evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;

if (k_msgq_put(cfg->common_config.event_msgq, &data->pending_event, K_NO_WAIT) != 0) {
LOG_WRN("Could not put input data into queue");
Expand Down Expand Up @@ -72,8 +72,7 @@ int lvgl_button_input_init(const struct device *dev)
LVGL_INPUT_DEFINE(inst, button, CONFIG_LV_Z_BUTTON_INPUT_MSGQ_COUNT, \
lvgl_button_process_event); \
static const uint16_t lvgl_button_input_codes_##inst[] = DT_INST_PROP(inst, input_codes); \
static const lv_coord_t lvgl_button_coordinates_##inst[] = \
DT_INST_PROP(inst, coordinates); \
static const int32_t lvgl_button_coordinates_##inst[] = DT_INST_PROP(inst, coordinates); \
static const struct lvgl_button_input_config lvgl_button_input_config_##inst = { \
.common_config.event_msgq = &LVGL_INPUT_EVENT_MSGQ(inst, button), \
.input_codes = lvgl_button_input_codes_##inst, \
Expand Down
16 changes: 8 additions & 8 deletions modules/lvgl/input/lvgl_common_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ lv_indev_t *lvgl_input_get_indev(const struct device *dev)
return common_data->indev;
}

static void lvgl_input_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data)
static void lvgl_input_read_cb(lv_indev_t *indev, lv_indev_data_t *data)
{
const struct device *dev = drv->user_data;
const struct device *dev = lv_indev_get_user_data(indev);
const struct lvgl_common_input_config *cfg = dev->config;
struct lvgl_common_input_data *common_data = dev->data;

if (k_msgq_get(cfg->event_msgq, data, K_NO_WAIT) != 0) {
memcpy(data, &common_data->previous_event, sizeof(lv_indev_data_t));
if (drv->type == LV_INDEV_TYPE_ENCODER) {
if (lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
data->enc_diff = 0; /* For encoders, clear last movement */
}
data->continue_reading = false;
Expand All @@ -54,16 +54,16 @@ int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *
return -EINVAL;
}

lv_indev_drv_init(&common_data->indev_drv);
common_data->indev_drv.type = indev_type;
common_data->indev_drv.read_cb = lvgl_input_read_cb;
common_data->indev_drv.user_data = (void *)dev;
common_data->indev = lv_indev_drv_register(&common_data->indev_drv);
common_data->indev = lv_indev_create();

if (common_data->indev == NULL) {
return -EINVAL;
}

lv_indev_set_type(common_data->indev, indev_type);
lv_indev_set_read_cb(common_data->indev, lvgl_input_read_cb);
lv_indev_set_user_data(common_data->indev, (void *)dev);

return 0;
}

Expand Down
Loading
Loading