From 6ab4b7f0bc1a49440198302c83f877d66999b5a5 Mon Sep 17 00:00:00 2001 From: IanSB Date: Tue, 7 Dec 2021 13:52:39 +0000 Subject: [PATCH] Fix display list issue stopping resolutions 1024x768 & lower from working at 16bpp --- src/rgb_to_hdmi.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/rgb_to_hdmi.c b/src/rgb_to_hdmi.c index 24b55967..48a5251a 100644 --- a/src/rgb_to_hdmi.c +++ b/src/rgb_to_hdmi.c @@ -278,6 +278,7 @@ static int ppm_range_count = 0; static int powerup = 1; static int hsync_threshold_switch = 0; static int resolution_status = 0; +static int display_list_offset = 5; static volatile uint32_t display_list_index = 0; volatile uint32_t* display_list; volatile uint32_t* pi4_hdmi0_regs; @@ -536,7 +537,7 @@ unsigned int framebuffer = 0; capinfo->fb = (unsigned char *)(framebuffer & 0x3fffffff); } - log_info("Size: %dx%d (req %dx%d). Addr: %8.8X (%8.8X)", width, height, capinfo->width, capinfo->height, (unsigned int)capinfo->fb, framebuffer); + //Initialize the palette osd_update_palette(); @@ -545,10 +546,6 @@ unsigned int framebuffer = 0; //have to wait for field sync for display list to be updated wait_for_pi_fieldsync(); wait_for_pi_fieldsync(); - //delay_in_arm_cycles_cpu_adjust(30000000); // little extra delay - //read the index pointer into the display list RAM - display_list_index = (uint32_t) *SCALER_DISPLIST1; - /* volatile uint32_t d; volatile uint32_t dlist_start; @@ -560,15 +557,33 @@ unsigned int framebuffer = 0; log_info("%08X", d); } while (d != 0x80000000); */ - int dli; + //delay_in_arm_cycles_cpu_adjust(30000000); // little extra delay + //read the index pointer into the display list RAM + display_list_index = (uint32_t) *SCALER_DISPLIST1; + unsigned int dli; + display_list_offset = 0; + for(int i = 6; i > 3; i--) { + do { + dli = display_list[display_list_index + i]; + } while (dli == 0xff000000); + if (dli == framebuffer) { //start of frame buffer moves in position depending on scaling and resolution so search for it + display_list_offset = i; + } + } + if (display_list_offset == 0) { +#ifdef RPI4 + display_list_offset = 6; //default +#else + display_list_offset = 5; //default +#endif + } do { dli = display_list[display_list_index]; } while (dli == 0xFF000000); display_list[display_list_index] = (dli & ~0x600f) | (PIXEL_ORDER << 13) | PIXEL_FORMAT; //log_info("Modified display list word at %08X = %08X", display_list_index, display_list[display_list_index]); - + log_info("Size: %dx%d (req %dx%d). Addr: %8.8X (%8.8X) Offset = %d", width, height, capinfo->width, capinfo->height, (unsigned int)capinfo->fb, framebuffer, display_list_offset); } - } #else @@ -2485,13 +2500,8 @@ void swapBuffer(int buffer) { // directly manipulate the display list in 16BPP mode otherwise display list gets reconstructed int dli = ((int)capinfo->fb | 0xc0000000) + (buffer * capinfo->height * capinfo->pitch); do { -#ifdef RPI4 - display_list[display_list_index + 6] = dli; - } while (dli != display_list[display_list_index + 6]); -#else - display_list[display_list_index + 5] = dli; - } while (dli != display_list[display_list_index + 5]); -#endif + display_list[display_list_index + display_list_offset] = dli; + } while (dli != display_list[display_list_index + display_list_offset]); } else { RPI_PropertyInit();