Skip to content

Commit ec0ccd2

Browse files
committed
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
1 parent ac66da2 commit ec0ccd2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ports/raspberrypi/common-hal/picodvi/Framebuffer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
143143

144144
bool color_framebuffer = color_depth >= 8;
145145
const struct dvi_timing *timing = NULL;
146-
if ((width == 640 && height == 480) ||
147-
(width == 320 && height == 240)) {
146+
if ((width == 640 && height == 240)) {
147+
timing = &dvi_timing_640x480p_60hz;
148+
} else if ((width == 800 && height == 240)) {
149+
timing = &dvi_timing_800x480p_60hz;
150+
} else if ((width == 640 && height == 480) ||
151+
(width == 320 && height == 240)) {
148152
timing = &dvi_timing_640x480p_60hz;
149153
} else if ((width == 800 && height == 480) ||
150154
(width == 400 && height == 240)) {
@@ -223,16 +227,15 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
223227
size_t tmds_bufs_per_scanline;
224228
size_t scanline_width = width;
225229
if (color_framebuffer) {
226-
dvi_vertical_repeat = 2;
227230
dvi_monochrome_tmds = false;
228231
tmds_bufs_per_scanline = 3;
229232
scanline_width *= 2;
230233
} else {
231-
dvi_vertical_repeat = 1;
232234
dvi_monochrome_tmds = true;
233235
// One tmds buffer is used for all three color outputs.
234236
tmds_bufs_per_scanline = 1;
235237
}
238+
dvi_vertical_repeat = timing->v_active_lines / self->height;
236239
self->pitch = (self->width * color_depth) / 8;
237240
// Align each row to words.
238241
if (self->pitch % sizeof(uint32_t) != 0) {

0 commit comments

Comments
 (0)