handle framebuffer the same for 640x480

This commit is contained in:
Liz 2025-08-07 20:25:26 -04:00
parent 561ddc2b0c
commit 871f7d9853
2 changed files with 23 additions and 26 deletions

View file

@ -124,8 +124,20 @@ static void copy_framebuffer() {
uint32_t *src = (uint32_t*)(umac_ram + umac_get_fb_offset());
#if DISP_WIDTH==640 && DISP_HEIGHT==480
uint32_t *dest = umac_framebuffer_mirror;
for(int i=0; i<640*480/32; i++) {
*dest++ = *src++;
memset(umac_framebuffer_mirror, 0xff, sizeof(uint32_t) * 640 * 480 / 32);
#define MAC_WIDTH 512
#define MAC_HEIGHT 342
#define DISP_XOFFSET ((640 - MAC_WIDTH) / 32 / 2)
#define DISP_YOFFSET ((480 - MAC_HEIGHT) / 2)
#define LONGS_PER_INPUT_ROW (MAC_WIDTH / 32)
#define LONGS_PER_OUTPUT_ROW (640 / 32)
for(int i=0; i<MAC_HEIGHT; i++) {
dest = umac_framebuffer_mirror + (DISP_YOFFSET * LONGS_PER_OUTPUT_ROW + DISP_XOFFSET) + LONGS_PER_OUTPUT_ROW * i;
for(int j=0; j<LONGS_PER_INPUT_ROW; j++) {
*dest++ = *src++ ^ 0xffffffff; // Include the inversion
}
}
#elif DISP_WIDTH==512 && DISP_HEIGHT==342
#define DISP_XOFFSET ((640 - DISP_WIDTH) / 32 / 2)

View file

@ -261,30 +261,15 @@ void video_init(uint32_t *framebuffer) {
const int pinout[] = { HSTX_D0P, HSTX_D1P, HSTX_D2P };
#if defined(DISP_WIDTH) && DISP_WIDTH == 640 && !defined(USE_PSRAM)
// 640x480 without PSRAM - no mirroring, need inversion
#define NEED_HSTX_INVERSION 1
#else
// All other cases use mirroring which already inverts
#define NEED_HSTX_INVERSION 0
#endif
for(uint lane = 0; lane < 3; lane++ ) {
int bit = pinout[lane];
uint32_t lane_data_sel_bits =
(lane * 10 ) << HSTX_CTRL_BIT0_SEL_P_LSB |
(lane * 10 + 1) << HSTX_CTRL_BIT0_SEL_N_LSB;
#if NEED_HSTX_INVERSION
// Invert the data when not using framebuffer mirroring
hstx_ctrl_hw->bit[(bit ) - HSTX_FIRST_PIN] = lane_data_sel_bits | HSTX_CTRL_BIT0_INV_BITS;
hstx_ctrl_hw->bit[(bit ^ 1) - HSTX_FIRST_PIN] = lane_data_sel_bits;
#else
// Normal polarity when framebuffer mirroring handles inversion
// The two halves of each pair get identical data, but one pin is inverted.
hstx_ctrl_hw->bit[(bit ) - HSTX_FIRST_PIN] = lane_data_sel_bits;
hstx_ctrl_hw->bit[(bit ^ 1) - HSTX_FIRST_PIN] = lane_data_sel_bits | HSTX_CTRL_BIT0_INV_BITS;
#endif
}
for (int i = 12; i <= 19; ++i) {