From ec0ccd2919f7ef548e4b6d9b79497e760f6dd00d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Mar 2024 10:49:37 -0500 Subject: [PATCH 1/3] pico_dvi: support 640x240 (tested @1bpp) and 800x240 (not tested) and dynamically calculate dvi_vertical_repeat the 640x240 mode was useful for a little project of mine --- ports/raspberrypi/common-hal/picodvi/Framebuffer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c index c166b7221e612..ce59001f15117 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c @@ -143,8 +143,12 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, bool color_framebuffer = color_depth >= 8; const struct dvi_timing *timing = NULL; - if ((width == 640 && height == 480) || - (width == 320 && height == 240)) { + if ((width == 640 && height == 240)) { + timing = &dvi_timing_640x480p_60hz; + } else if ((width == 800 && height == 240)) { + timing = &dvi_timing_800x480p_60hz; + } else if ((width == 640 && height == 480) || + (width == 320 && height == 240)) { timing = &dvi_timing_640x480p_60hz; } else if ((width == 800 && height == 480) || (width == 400 && height == 240)) { @@ -223,16 +227,15 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, size_t tmds_bufs_per_scanline; size_t scanline_width = width; if (color_framebuffer) { - dvi_vertical_repeat = 2; dvi_monochrome_tmds = false; tmds_bufs_per_scanline = 3; scanline_width *= 2; } else { - dvi_vertical_repeat = 1; dvi_monochrome_tmds = true; // One tmds buffer is used for all three color outputs. tmds_bufs_per_scanline = 1; } + dvi_vertical_repeat = timing->v_active_lines / self->height; self->pitch = (self->width * color_depth) / 8; // Align each row to words. if (self->pitch % sizeof(uint32_t) != 0) { From 1e2eb1055ce975baeaf370ab81909c6586b67223 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Mar 2024 12:20:02 -0500 Subject: [PATCH 2/3] simplify the conditional tests for resolution modes --- ports/raspberrypi/common-hal/picodvi/Framebuffer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c index ce59001f15117..1b1ec9f402336 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c @@ -143,15 +143,15 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, bool color_framebuffer = color_depth >= 8; const struct dvi_timing *timing = NULL; - if ((width == 640 && height == 240)) { - timing = &dvi_timing_640x480p_60hz; - } else if ((width == 800 && height == 240)) { - timing = &dvi_timing_800x480p_60hz; - } else if ((width == 640 && height == 480) || - (width == 320 && height == 240)) { + if ((width == 640 && height == 480) || + (width == 320 && height == 240) || + (width == 640 && height == 240) + ) { timing = &dvi_timing_640x480p_60hz; } else if ((width == 800 && height == 480) || - (width == 400 && height == 240)) { + (width == 400 && height == 240) || + (width == 800 && height == 240) || + ) { timing = &dvi_timing_800x480p_60hz; } else { if (height != 480 && height != 240) { From 4a08387c42ae2fa876363c3deddf979b30ccf534 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Mar 2024 09:41:06 -0500 Subject: [PATCH 3/3] Fix syntax error --- ports/raspberrypi/common-hal/picodvi/Framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c index 1b1ec9f402336..81f312b0e4de4 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c @@ -150,7 +150,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, timing = &dvi_timing_640x480p_60hz; } else if ((width == 800 && height == 480) || (width == 400 && height == 240) || - (width == 800 && height == 240) || + (width == 800 && height == 240) ) { timing = &dvi_timing_800x480p_60hz; } else {