feat(draw): add configurable thread priority for all drawing units (#8162)

Co-authored-by: Liam Howatt <30486941+liamHowatt@users.noreply.github.com>
This commit is contained in:
MootSeeker
2025-05-15 14:08:45 +02:00
committed by GitHub
parent 3a33caa62c
commit c23ee47f7a
11 changed files with 62 additions and 8 deletions
+17
View File
@@ -207,6 +207,23 @@ menu "LVGL configuration"
help
If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more.
config LV_DRAW_THREAD_PRIO
int "Thread priority for the drawing thread"
range 0 4
default 3
depends on LV_USE_OS > 0
help
Thread priority controls the relative importance of the drawing threads.
Values correspond to lv_thread_prio_t enum in lv_os.h:
0: LV_THREAD_PRIO_LOWEST
1: LV_THREAD_PRIO_LOW
2: LV_THREAD_PRIO_MID (default)
3: LV_THREAD_PRIO_HIGH
4: LV_THREAD_PRIO_HIGHEST
Higher priority can improve rendering performance but might cause
starvation of lower priority tasks.
config LV_USE_DRAW_SW
bool "Enable software rendering"
default y
@@ -113,6 +113,19 @@ For an example of how draw-unit cration and initialization is done, see
:cpp:func:`lv_draw_sw_init` in lv_draw_sw.c_ or the other draw units whose ``init``
functions are optionally called in :cpp:func:`lv_init`.
Thread Priority
---------------
All draw units operate with a configurable thread priority which can be set using the
:c:macro:`LV_DRAW_THREAD_PRIO` configuration option in ``lv_conf.h``. This allows you
to fine-tune the priority level across all drawing units, which is especially useful for
systems with limited priority levels.
By default, draw units use :c:macro:`LV_THREAD_PRIO_HIGH` as their thread priority.
This consistent approach ensures that all drawing units (software rendering, hardware
accelerators like STM32 DMA2D, NXP VGLite, etc.) use the same priority level unless
explicitly configured otherwise.
.. _lv_draw_sw.c: https://github.com/lvgl/lvgl/blob/master/src/draw/sw/lv_draw_sw.c
@@ -196,4 +209,4 @@ API
lv_draw_task_t
LV_DRAW_TRANSFORM_USE_MATRIX
lv_draw_unit_t
LV_USE_DRAW_OPENGLES
LV_USE_DRAW_OPENGLES
+9
View File
@@ -156,6 +156,15 @@
*/
#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /**< [bytes]*/
/** Thread priority of the drawing task.
* Higher values mean higher priority.
* Can use values from lv_thread_prio_t enum in lv_os.h: LV_THREAD_PRIO_LOWEST,
* LV_THREAD_PRIO_LOW, LV_THREAD_PRIO_MID, LV_THREAD_PRIO_HIGH, LV_THREAD_PRIO_HIGHEST
* Make sure the priority value aligns with the OS-specific priority levels.
* On systems with limited priority levels (e.g., FreeRTOS), a higher value can improve
* rendering performance but might cause other tasks to starve. */
#define LV_DRAW_THREAD_PRIO LV_THREAD_PRIO_HIGH
#define LV_USE_DRAW_SW 1
#if LV_USE_DRAW_SW == 1
/*
+1 -1
View File
@@ -69,7 +69,7 @@ void lv_draw_dma2d_init(void)
#if LV_DRAW_DMA2D_ASYNC
g_unit = draw_dma2d_unit;
lv_result_t res = lv_thread_init(&draw_dma2d_unit->thread, "dma2d", LV_THREAD_PRIO_HIGH, thread_cb, 2 * 1024,
lv_result_t res = lv_thread_init(&draw_dma2d_unit->thread, "dma2d", LV_DRAW_THREAD_PRIO, thread_cb, 2 * 1024,
draw_dma2d_unit);
LV_ASSERT(res == LV_RESULT_OK);
#endif
+1 -1
View File
@@ -119,7 +119,7 @@ void lv_draw_nema_gfx_init(void)
#if LV_USE_OS
lv_thread_init(&draw_nema_gfx_unit->thread, "nemagfx", LV_THREAD_PRIO_HIGH, nema_gfx_render_thread_cb, 2 * 1024,
lv_thread_init(&draw_nema_gfx_unit->thread, "nemagfx", LV_DRAW_THREAD_PRIO, nema_gfx_render_thread_cb, 2 * 1024,
draw_nema_gfx_unit);
#endif
}
+1 -1
View File
@@ -78,7 +78,7 @@ void lv_draw_g2d_init(void)
LV_LOG_ERROR("g2d_open fail.\n");
}
#if LV_USE_G2D_DRAW_THREAD
lv_thread_init(&draw_g2d_unit->thread, "g2ddraw", LV_THREAD_PRIO_HIGH, _g2d_render_thread_cb, 2 * 1024, draw_g2d_unit);
lv_thread_init(&draw_g2d_unit->thread, "g2ddraw", LV_DRAW_THREAD_PRIO, _g2d_render_thread_cb, 2 * 1024, draw_g2d_unit);
#endif
}
+1 -1
View File
@@ -95,7 +95,7 @@ void lv_draw_pxp_init(void)
draw_pxp_unit->base_unit.name = "NXP_PXP";
#if LV_USE_PXP_DRAW_THREAD
lv_thread_init(&draw_pxp_unit->thread, "pxpdraw", LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
lv_thread_init(&draw_pxp_unit->thread, "pxpdraw", LV_DRAW_THREAD_PRIO, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
#endif
#endif /*LV_USE_DRAW_PXP*/
}
+1 -1
View File
@@ -118,7 +118,7 @@ void lv_draw_vglite_init(void)
draw_vglite_unit->base_unit.name = "NXP_VGLITE";
#if LV_USE_VGLITE_DRAW_THREAD
lv_thread_init(&draw_vglite_unit->thread, "vglitedraw", LV_THREAD_PRIO_HIGHEST, _vglite_render_thread_cb, 4 * 1024,
lv_thread_init(&draw_vglite_unit->thread, "vglitedraw", LV_DRAW_THREAD_PRIO, _vglite_render_thread_cb, 4 * 1024,
draw_vglite_unit);
#endif
}
+1 -1
View File
@@ -99,7 +99,7 @@ void lv_draw_dave2d_init(void)
lv_ll_init(&_ll_Dave2D_Tasks, 4);
#if LV_USE_OS
lv_thread_init(&draw_dave2d_unit->thread, "dave2d", LV_THREAD_PRIO_HIGH, _dave2d_render_thread_cb, 8 * 1024,
lv_thread_init(&draw_dave2d_unit->thread, "dave2d", LV_DRAW_THREAD_PRIO, _dave2d_render_thread_cb, 8 * 1024,
draw_dave2d_unit);
#endif
+1 -1
View File
@@ -91,7 +91,7 @@ void lv_draw_sw_init(void)
lv_draw_sw_thread_dsc_t * thread_dsc = &draw_sw_unit->thread_dscs[i];
thread_dsc->idx = i;
thread_dsc->draw_unit = (void *) draw_sw_unit;
lv_thread_init(&thread_dsc->thread, "swdraw", LV_THREAD_PRIO_HIGH, render_thread_cb,
lv_thread_init(&thread_dsc->thread, "swdraw", LV_DRAW_THREAD_PRIO, render_thread_cb,
LV_DRAW_THREAD_STACK_SIZE, thread_dsc);
}
#endif
+15
View File
@@ -377,6 +377,21 @@
#endif
#endif
/** Thread priority of the drawing task.
* Higher values mean higher priority.
* Can use values from lv_thread_prio_t enum in lv_os.h: LV_THREAD_PRIO_LOWEST,
* LV_THREAD_PRIO_LOW, LV_THREAD_PRIO_MID, LV_THREAD_PRIO_HIGH, LV_THREAD_PRIO_HIGHEST
* Make sure the priority value aligns with the OS-specific priority levels.
* On systems with limited priority levels (e.g., FreeRTOS), a higher value can improve
* rendering performance but might cause other tasks to starve. */
#ifndef LV_DRAW_THREAD_PRIO
#ifdef CONFIG_LV_DRAW_THREAD_PRIO
#define LV_DRAW_THREAD_PRIO CONFIG_LV_DRAW_THREAD_PRIO
#else
#define LV_DRAW_THREAD_PRIO LV_THREAD_PRIO_HIGH
#endif
#endif
#ifndef LV_USE_DRAW_SW
#ifdef LV_KCONFIG_PRESENT
#ifdef CONFIG_LV_USE_DRAW_SW