From 8009614c16e84dc0d4258ceee52045be8e7c2f69 Mon Sep 17 00:00:00 2001 From: Fabian Blatz Date: Tue, 22 Apr 2025 10:52:52 +0200 Subject: [PATCH] drivers: display: sdl: Ensure task thread is run once on init Adds taking of the task semaphore after creating the display thread to ensure that the thread is run once, executing the SDL init. Adjust the threads priority to match the main thread. Signed-off-by: Fabian Blatz --- drivers/display/Kconfig.sdl | 2 +- drivers/display/display_sdl.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/display/Kconfig.sdl b/drivers/display/Kconfig.sdl index 3c41b2848ab..db14ed8eaf4 100644 --- a/drivers/display/Kconfig.sdl +++ b/drivers/display/Kconfig.sdl @@ -90,7 +90,7 @@ config SDL_DISPLAY_TRANSPARENCY_GRID_CELL_COLOR_2 config SDL_DISPLAY_THREAD_PRIORITY int "SDL display thread priority" - default NUM_PREEMPT_PRIORITIES + default MAIN_THREAD_PRIORITY help Drawing thread priority. diff --git a/drivers/display/display_sdl.c b/drivers/display/display_sdl.c index e24e6ea6692..e03232da905 100644 --- a/drivers/display/display_sdl.c +++ b/drivers/display/display_sdl.c @@ -125,6 +125,8 @@ static void sdl_task_thread(void *p1, void *p2, void *p3) CONFIG_SDL_DISPLAY_TRANSPARENCY_GRID_CELL_COLOR_2, CONFIG_SDL_DISPLAY_TRANSPARENCY_GRID_CELL_SIZE); + k_sem_give(&disp_data->task_sem); + if (rc != 0) { nsi_print_error_and_exit("Failed to create SDL display"); return; @@ -169,6 +171,8 @@ static int sdl_display_init(const struct device *dev) K_KERNEL_STACK_SIZEOF(disp_data->sdl_thread_stack), sdl_task_thread, (void *)dev, NULL, NULL, CONFIG_SDL_DISPLAY_THREAD_PRIORITY, 0, K_NO_WAIT); + /* Ensure task thread has performed the init */ + k_sem_take(&disp_data->task_sem, K_FOREVER); return 0; }