From 6735728340b0854fec9ace3b20b34bb75a4e7f29 Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Tue, 26 Mar 2024 20:22:58 +1000 Subject: [PATCH 1/2] sim/video: Change pixel format to RGBA --- litex/build/sim/core/modules/video/sim_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litex/build/sim/core/modules/video/sim_fb.c b/litex/build/sim/core/modules/video/sim_fb.c index 79c5c10f5..3535985a7 100644 --- a/litex/build/sim/core/modules/video/sim_fb.c +++ b/litex/build/sim/core/modules/video/sim_fb.c @@ -17,7 +17,7 @@ bool fb_init(unsigned width, unsigned height, bool vsync, fb_handle_t *handle) if (!handle->renderer) return false; - handle->texture = SDL_CreateTexture(handle->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_TARGET, width, height); + handle->texture = SDL_CreateTexture(handle->renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height); if (!handle->texture) return false; From 1895dd36e2b96ac7969481b492b9e7e18bbbed44 Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Tue, 26 Mar 2024 20:23:51 +1000 Subject: [PATCH 2/2] tools/litex_sim: Add --with-video-colorbars option --- litex/tools/litex_sim.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/litex/tools/litex_sim.py b/litex/tools/litex_sim.py index 1e412b87c..5444ad449 100755 --- a/litex/tools/litex_sim.py +++ b/litex/tools/litex_sim.py @@ -178,6 +178,7 @@ class SimSoC(SoCCore): with_gpio = False, with_video_framebuffer = False, with_video_terminal = False, + with_video_colorbars = False, sim_debug = False, trace_reset_on = False, with_jtag = False, @@ -313,6 +314,11 @@ class SimSoC(SoCCore): self.submodules.videophy = VideoGenericPHY(platform.request("vga")) self.add_video_terminal(phy=self.videophy, timings="640x480@60Hz") + # Video test pattern ----------------------------------------------------------------------- + if with_video_colorbars: + self.submodules.videophy = VideoGenericPHY(platform.request("vga")) + self.add_video_colorbars(phy=self.videophy, timings="640x480@60Hz") + # Simulation debugging ---------------------------------------------------------------------- if sim_debug: platform.add_debug(self, reset=1 if trace_reset_on else 0) @@ -428,6 +434,7 @@ def sim_args(parser): # Video. parser.add_argument("--with-video-framebuffer", action="store_true", help="Enable Video Framebuffer.") parser.add_argument("--with-video-terminal", action="store_true", help="Enable Video Terminal.") + parser.add_argument("--with-video-colorbars", action="store_true", help="Enable Video test pattern.") # Debug/Waveform. parser.add_argument("--sim-debug", action="store_true", help="Add simulation debugging modules.") @@ -510,7 +517,7 @@ def main(): sim_config.add_module("jtagremote", "jtag", args={'port': 44853}) # Video. - if args.with_video_framebuffer or args.with_video_terminal: + if args.with_video_framebuffer or args.with_video_terminal or args.with_video_colorbars: sim_config.add_module("video", "vga") # SoC ------------------------------------------------------------------------------------------ @@ -528,6 +535,7 @@ def main(): with_gpio = args.with_gpio, with_video_framebuffer = args.with_video_framebuffer, with_video_terminal = args.with_video_terminal, + with_video_colorbars = args.with_video_colorbars, sim_debug = args.sim_debug, trace_reset_on = int(float(args.trace_start)) > 0 or int(float(args.trace_end)) > 0, spi_flash_init = None if args.spi_flash_init is None else get_mem_data(args.spi_flash_init, endianness="big"), @@ -551,7 +559,7 @@ def main(): builder.build( sim_config = sim_config, interactive = not args.non_interactive, - video = args.with_video_framebuffer or args.with_video_terminal, + video = args.with_video_framebuffer or args.with_video_terminal or args.with_video_colorbars, pre_run_callback = pre_run_callback, **parser.toolchain_argdict, )