From fcb7e31082c8abf77f5efac5920093f3bcb5d8ca Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 5 Jul 2021 16:32:46 -0600 Subject: sandbox: Add work-around for SDL2 display At present the display does not show on some machines, e.g. Ubunutu 20.04 but the reason is unknown. Add a work-around until this can be determined. Also include more error checking just in case. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'arch/sandbox/cpu/sdl.c') diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index 8102649be3..e264949481 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -164,8 +164,29 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, int sandbox_sdl_sync(void *lcd_base) { + struct SDL_Rect rect; + int ret; + + if (!sdl.texture) + return 0; + SDL_RenderClear(sdl.renderer); SDL_UpdateTexture(sdl.texture, NULL, lcd_base, sdl.pitch); - SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL); + ret = SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL); + if (ret) { + printf("SDL copy %d: %s\n", ret, SDL_GetError()); + return -EIO; + } + + /* + * On some machines this does not appear. Draw an empty rectangle which + * seems to fix that. + */ + rect.x = 0; + rect.y = 0; + rect.w = 0; + rect.h = 0; + SDL_RenderDrawRect(sdl.renderer, &rect); + SDL_RenderPresent(sdl.renderer); sandbox_sdl_poll_events(); -- cgit v1.2.3 From 350b1d3b6830bf7383b7df051521526eb2c0d8c4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 5 Jul 2021 16:32:47 -0600 Subject: sandbox: Use hinting with the display SDL provides a hinting feature which provides a higher-quality image with the double-display option (-K). Enable it. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/sandbox/cpu/sdl.c') diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index e264949481..bef5abd039 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -123,6 +123,9 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, sdl.vis_height = sdl.height; } + if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) + printf("Unable to init hinting: %s", SDL_GetError()); + sdl.depth = 1 << log2_bpp; sdl.pitch = sdl.width * sdl.depth / 8; SDL_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, -- cgit v1.2.3