Commit 8009614c authored by Fabian Blatz's avatar Fabian Blatz Committed by Benjamin Cabé
Browse files

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: default avatarFabian Blatz <fabianblatz@gmail.com>
parent ebd8803b
Loading
Loading
Loading
Loading
+1 −1
Changes for drivers/display/Kconfig.sdl: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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.

+4 −0
Changes for drivers/display/display_sdl.c: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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;
}