Skip to content

Commit 26534a2

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 26534a2

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

modules/lvgl/Kconfig.memory

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ 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_CUSTOM_GENERIC_SECTION
56+
bool "Link memory pool to custom generic section"
57+
depends on LV_Z_MEM_POOL_SYS_HEAP
58+
help
59+
Place LVGL memory pool in custom generic section automatically
60+
created by Zephyr when compatible zephyr,memory-region is used.
61+
LV_Z_MEMORY_POOL_CUSTOM_SECTION must be disabled in order to use
62+
generic section.
63+
64+
config LV_Z_MEMORY_POOL_CUSTOM_GENERIC_SECTION_NAME
65+
string "Name of the memory pool custom generic section"
66+
depends on LV_Z_MEMORY_POOL_CUSTOM_GENERIC_SECTION
67+
help
68+
Name of the generic section to be used to store memory-pool.
69+
The name must match with the name of a zephyr,memory-region.
70+
5571
config LV_Z_VDB_SIZE
5672
int "Rendering buffer size"
5773
default 100 if LV_Z_FULL_REFRESH
@@ -92,6 +108,22 @@ config LV_Z_VDB_CUSTOM_SECTION
92108
rendering buffers to a custom location, such as tightly coupled or
93109
external memory.
94110

111+
config LV_Z_VDB_CUSTOM_GENERIC_SECTION
112+
bool "Link rendering buffers to custom generic section"
113+
depends on LV_Z_BUFFER_ALLOC_STATIC
114+
help
115+
Place LVGL rendering buffers in custom generic section automatically
116+
created by Zephyr when compatible zephyr,memory-region is used.
117+
LV_Z_MEMORY_POOL_CUSTOM_SECTION must be disabled in order to use
118+
generic section.
119+
120+
config LV_Z_VDB_CUSTOM_GENERIC_SECTION_NAME
121+
string "Link rendering buffers to custom generic section"
122+
depends on LV_Z_VDB_CUSTOM_GENERIC_SECTION
123+
help
124+
Name of the generic section to be used to store rendering buffers.
125+
The name must match with the name of a zephyr,memory-region.
126+
95127
config LV_Z_MONOCHROME_CONVERSION_BUFFER
96128
bool "Use intermediate conversion buffer for monochrome displays"
97129
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_CUSTOM_GENERIC_SECTION)
84+
#define LV_BUF_SECTION Z_GENERIC_SECTION(CONFIG_LV_Z_VDB_CUSTOM_GENERIC_SECTION_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_CUSTOM_GENERIC_SECTION)
19+
#define HEAP_MEM_ATTRIBUTES Z_GENERIC_SECTION(CONFIG_LV_Z_MEMORY_POOL_CUSTOM_GENERIC_SECTION_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)