Skip to content

Commit 8009614

Browse files
faxe1008kartben
authored andcommitted
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 <[email protected]>
1 parent ebd8803 commit 8009614

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/display/Kconfig.sdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ config SDL_DISPLAY_TRANSPARENCY_GRID_CELL_COLOR_2
9090

9191
config SDL_DISPLAY_THREAD_PRIORITY
9292
int "SDL display thread priority"
93-
default NUM_PREEMPT_PRIORITIES
93+
default MAIN_THREAD_PRIORITY
9494
help
9595
Drawing thread priority.
9696

drivers/display/display_sdl.c

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ static void sdl_task_thread(void *p1, void *p2, void *p3)
125125
CONFIG_SDL_DISPLAY_TRANSPARENCY_GRID_CELL_COLOR_2,
126126
CONFIG_SDL_DISPLAY_TRANSPARENCY_GRID_CELL_SIZE);
127127

128+
k_sem_give(&disp_data->task_sem);
129+
128130
if (rc != 0) {
129131
nsi_print_error_and_exit("Failed to create SDL display");
130132
return;
@@ -169,6 +171,8 @@ static int sdl_display_init(const struct device *dev)
169171
K_KERNEL_STACK_SIZEOF(disp_data->sdl_thread_stack),
170172
sdl_task_thread, (void *)dev, NULL, NULL,
171173
CONFIG_SDL_DISPLAY_THREAD_PRIORITY, 0, K_NO_WAIT);
174+
/* Ensure task thread has performed the init */
175+
k_sem_take(&disp_data->task_sem, K_FOREVER);
172176

173177
return 0;
174178
}

0 commit comments

Comments
 (0)