Skip to content

Commit

Permalink
Fix display list issue stopping resolutions 1024x768 & lower from wor…
Browse files Browse the repository at this point in the history
…king at 16bpp
  • Loading branch information
IanSB committed Dec 7, 2021
1 parent d9b5671 commit 6ab4b7f
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/rgb_to_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand All @@ -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

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6ab4b7f

Please sign in to comment.