Skip to content

Commit 1df3b9f

Browse files
author
Alain Volmat
committed
modules: lvgl: allow usage of zephyr memory-region for mem / vdb
Allow selection of a custom section for memory-poll and / or VDB based on zephyr memory-regions. This takes advantages that zephyr,memory-region automatically have sections being created, hence allowing to easily indicate into which memory-region to store data. Signed-off-by: Alain Volmat <[email protected]>
1 parent 9e42f0c commit 1df3b9f

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

modules/lvgl/Kconfig.memory

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ config LV_Z_MEMORY_POOL_CUSTOM_SECTION
5252
memory pool to a custom location, such as tightly coupled or
5353
external memory.
5454

55+
config LV_Z_MEMORY_POOL_ZEPHYR_REGION
56+
bool "Link memory pool to zephyr memory-region"
57+
depends on LV_Z_MEM_POOL_SYS_HEAP && !LV_Z_MEMORY_POOL_CUSTOM_SECTION
58+
help
59+
Place LVGL memory pool in section automatically
60+
created by Zephyr when compatible zephyr,memory-region is used.
61+
62+
config LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME
63+
string "Name of the zephyr memory-region for memory pool"
64+
depends on LV_Z_MEMORY_POOL_ZEPHYR_REGION
65+
help
66+
Name of the zephyr memory-region to be used to store memory-pool.
67+
5568
config LV_Z_VDB_SIZE
5669
int "Rendering buffer size"
5770
default 100 if LV_Z_FULL_REFRESH
@@ -92,6 +105,19 @@ config LV_Z_VDB_CUSTOM_SECTION
92105
rendering buffers to a custom location, such as tightly coupled or
93106
external memory.
94107

108+
config LV_Z_VDB_ZEPHYR_REGION
109+
bool "Link rendering buffers to zephyr memory-region"
110+
depends on LV_Z_BUFFER_ALLOC_STATIC && !LV_Z_VDB_CUSTOM_SECTION
111+
help
112+
Place LVGL rendering buffers in section automatically
113+
created by Zephyr when compatible zephyr,memory-region is used.
114+
115+
config LV_Z_VDB_ZEPHYR_REGION_NAME
116+
string "Name of the Zephyr memory-region for rendering buffers"
117+
depends on LV_Z_VDB_ZEPHYR_REGION
118+
help
119+
Name of the zephyr memory-region to be used to store rendering buffers.
120+
95121
config LV_Z_MONOCHROME_CONVERSION_BUFFER
96122
bool "Use intermediate conversion buffer for monochrome displays"
97123
default y

modules/lvgl/lvgl.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,27 @@ static uint8_t *mono_vtile_buf_p[DT_ZEPHYR_DISPLAYS_COUNT] = {NULL};
7878
/* uint16_t * or uint32_t *, therefore buffer needs to be aligned accordingly to */
7979
/* prevent unaligned memory accesses. */
8080

81+
#if defined(CONFIG_LV_Z_VDB_CUSTOM_SECTION)
82+
#define LV_BUF_SECTION Z_GENERIC_SECTION(.lvgl_buf)
83+
#elif defined(CONFIG_LV_Z_VDB_ZEPHYR_REGION)
84+
#define LV_BUF_SECTION Z_GENERIC_SECTION(CONFIG_LV_Z_VDB_ZEPHYR_REGION_NAME)
85+
#else
86+
#define LV_BUF_SECTION
87+
#endif
88+
8189
/* clang-format off */
8290
#define LV_BUFFERS_DEFINE(n) \
8391
static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf0_##n[BUFFER_SIZE(n)] \
84-
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
85-
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
92+
LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \
8693
\
8794
IF_ENABLED(CONFIG_LV_Z_DOUBLE_VDB, ( \
8895
static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf1_##n[BUFFER_SIZE(n)] \
89-
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
90-
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
96+
LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \
9197
)) \
9298
\
9399
IF_ENABLED(ALLOC_MONOCHROME_CONV_BUFFER, ( \
94100
static uint8_t mono_vtile_buf_##n[BUFFER_SIZE(n)] \
95-
IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \
96-
__aligned(CONFIG_LV_Z_VDB_ALIGN); \
101+
LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \
97102
))
98103

99104
FOR_EACH(LV_BUFFERS_DEFINE, (), LV_DISPLAYS_IDX_LIST);

modules/lvgl/lvgl_mem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ LOG_MODULE_DECLARE(lvgl, CONFIG_LV_Z_LOG_LEVEL);
1515

1616
#ifdef CONFIG_LV_Z_MEMORY_POOL_CUSTOM_SECTION
1717
#define HEAP_MEM_ATTRIBUTES Z_GENERIC_SECTION(.lvgl_heap) __aligned(8)
18+
#elif defined(CONFIG_LV_Z_MEMORY_POOL_ZEPHYR_REGION)
19+
#define HEAP_MEM_ATTRIBUTES Z_GENERIC_SECTION(CONFIG_LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME)
20+
__aligned(8)
1821
#else
1922
#define HEAP_MEM_ATTRIBUTES __aligned(8)
2023
#endif /* CONFIG_LV_Z_MEMORY_POOL_CUSTOM_SECTION */

0 commit comments

Comments
 (0)