Skip to content

Commit 9e05861

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 9e05861

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

modules/lvgl/Kconfig.memory

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ 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 "Place LVGL memory pool in a Zephyr memory-region"
57+
depends on LV_Z_MEM_POOL_SYS_HEAP
58+
depends on !LV_Z_MEMORY_POOL_CUSTOM_SECTION
59+
help
60+
Place LVGL memory pool in a section, automatically
61+
created from a 'zephyr,memory-region' compatible node,
62+
whose name is specified in LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME.
63+
64+
config LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME
65+
string "Name of the zephyr memory-region for memory pool"
66+
depends on LV_Z_MEMORY_POOL_ZEPHYR_REGION
67+
help
68+
Name of the Zephyr memory-region where LVGL memory pool is placed.
69+
5570
config LV_Z_VDB_SIZE
5671
int "Rendering buffer size"
5772
default 100 if LV_Z_FULL_REFRESH
@@ -92,6 +107,21 @@ config LV_Z_VDB_CUSTOM_SECTION
92107
rendering buffers to a custom location, such as tightly coupled or
93108
external memory.
94109

110+
config LV_Z_VDB_ZEPHYR_REGION
111+
bool "Place LVGL rendering buffers in a Zephyr memory-region"
112+
depends on LV_Z_BUFFER_ALLOC_STATIC
113+
depends on !LV_Z_VDB_CUSTOM_SECTION
114+
help
115+
Place LVGL rendering buffers in a section, automatically
116+
created from a 'zephyr,memory-region' compatible node,
117+
whose name is specified in LV_Z_VDB_ZEPHYR_REGION_NAME.
118+
119+
config LV_Z_VDB_ZEPHYR_REGION_NAME
120+
string "Name of the Zephyr memory-region for rendering buffers"
121+
depends on LV_Z_VDB_ZEPHYR_REGION
122+
help
123+
Name of the Zephyr memory-region where LVGL rendering buffers are placed.
124+
95125
config LV_Z_MONOCHROME_CONVERSION_BUFFER
96126
bool "Use intermediate conversion buffer for monochrome displays"
97127
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)