]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: Add work-around for SDL2 display
authorSimon Glass <sjg@chromium.org>
Mon, 5 Jul 2021 22:32:46 +0000 (16:32 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 21 Jul 2021 16:27:34 +0000 (10:27 -0600)
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 <sjg@chromium.org>
arch/sandbox/cpu/sdl.c

index 8102649be3a4ae21c9174c0e617d42113de16366..e2649494818d2ee0523d6f404b2e80130f54dd4c 100644 (file)
@@ -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();