Skip to content

Commit

Permalink
Voodoo: Update VGA update frequency if required after timing change.
Browse files Browse the repository at this point in the history
Added bool return value at Voodoo update() to indicate a timing change.
VGA core then calls set_update_timer() in vsync update mode.
Voodoo no longer reports mode and frequency if invalid.
This should fix issue #434.
  • Loading branch information
vruppert committed Dec 27, 2024
1 parent f35eaca commit b14605d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
5 changes: 3 additions & 2 deletions bochs/iodev/display/banshee.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ bool bx_banshee_c::chromakey_check(Bit32u color, Bit8u bpp)
return pass;
}

void bx_banshee_c::update(void)
bool bx_banshee_c::update(void)
{
Bit32u start;
unsigned iHeight, iWidth, riHeight, riWidth;
Expand Down Expand Up @@ -689,7 +689,7 @@ void bx_banshee_c::update(void)
if ((start + pitch * (riHeight - 1) + riWidth) > (v->fbi.mask + 1)) {
BX_ERROR(("skip address wrap during update() (start = 0x%08x)", start));
BX_UNLOCK(render_mutex);
return;
return false;
}
if (bx_gui->graphics_tile_info_common(&info)) {
if (info.snapshot_mode) {
Expand Down Expand Up @@ -985,6 +985,7 @@ void bx_banshee_c::update(void)
} else {
bx_voodoo_base_c::update();
}
return false;
}

Bit32u bx_banshee_c::get_retrace(bool hv)
Expand Down
6 changes: 5 additions & 1 deletion bochs/iodev/display/vgacore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,11 @@ void bx_vgacore_c::vga_timer_handler(void *this_ptr)
bx_vgacore_c *vgadev = (bx_vgacore_c *) this_ptr;
#if BX_SUPPORT_PCI
if (vgadev->s.vga_override && (vgadev->s.nvgadev != NULL)) {
vgadev->s.nvgadev->update();
if (vgadev->s.nvgadev->update()) {
if (vgadev->update_mode_vsync) {
vgadev->set_update_timer(0);
}
}
}
else
#endif
Expand Down
2 changes: 1 addition & 1 deletion bochs/iodev/display/vgacore.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class bx_nonvga_device_c : public bx_pci_device_c {
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height) {}
virtual void refresh_display(void *this_ptr, bool redraw) {}
virtual void update(void) {}
virtual bool update(void) {return false;}
virtual Bit32u get_vtotal_usec(void) {return 0;}
};
#endif
Expand Down
19 changes: 12 additions & 7 deletions bochs/iodev/display/voodoo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ void bx_voodoo_base_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
}
}

void bx_voodoo_base_c::update(void)
bool bx_voodoo_base_c::update(void)
{
Bit32u start;
unsigned iHeight, iWidth, riHeight, riWidth;
Expand All @@ -567,9 +567,11 @@ void bx_voodoo_base_c::update(void)
bx_svga_tileinfo_t info;

BX_LOCK(render_mutex);
bool retval = s.vdraw.vfreq_update;
s.vdraw.vfreq_update = false;
if (!s.vdraw.gui_update_pending) {
BX_UNLOCK(render_mutex);
return;
return retval;
}
BX_LOCK(fifo_mutex);
if (s.model >= VOODOO_BANSHEE) {
Expand Down Expand Up @@ -601,7 +603,7 @@ void bx_voodoo_base_c::update(void)
if ((start + pitch * (riHeight - 1) + riWidth) > (v->fbi.mask + 1)) {
BX_ERROR(("skip address wrap during update() (start = 0x%08x)", start));
BX_UNLOCK(render_mutex);
return;
return retval;
}
if (bx_gui->graphics_tile_info_common(&info)) {
if (info.snapshot_mode) {
Expand Down Expand Up @@ -672,6 +674,7 @@ void bx_voodoo_base_c::update(void)
}
s.vdraw.gui_update_pending = 0;
BX_UNLOCK(render_mutex);
return retval;
}

void bx_voodoo_base_c::reg_write(Bit32u reg, Bit32u value)
Expand Down Expand Up @@ -948,7 +951,7 @@ void bx_voodoo_1_2_c::mode_change_timer()
bool bx_voodoo_1_2_c::update_timing(void)
{
int htotal, vtotal, hsync, vsync;
float hfreq;
float hfreq, old_vertfreq = v->vertfreq;

if (!s.vdraw.clock_enabled || !s.vdraw.output_on)
return 0;
Expand All @@ -970,6 +973,7 @@ bool bx_voodoo_1_2_c::update_timing(void)
hfreq /= 2;
}
v->vertfreq = hfreq / (float)vtotal;
s.vdraw.vfreq_update = (v->vertfreq != old_vertfreq);
s.vdraw.htotal_usec = (unsigned)(1000000.0 / hfreq);
s.vdraw.vtotal_usec = (unsigned)(1000000.0 / v->vertfreq);
s.vdraw.htime_to_pixel = (double)htotal / (1000000.0 / hfreq);
Expand All @@ -982,11 +986,12 @@ bool bx_voodoo_1_2_c::update_timing(void)
bx_gui->dimension_update(v->fbi.width, v->fbi.height, 0, 0, 16);
vertical_timer_handler(this);
}
BX_INFO(("Voodoo output %dx%d@%uHz", v->fbi.width, v->fbi.height, (unsigned)v->vertfreq));
v->fbi.swaps_pending = 0;
v->vtimer_running = 1;
if (v->vidclk != 0.0)
if (v->vidclk != 0.0) {
BX_INFO(("Voodoo output %dx%d@%uHz", v->fbi.width, v->fbi.height, (unsigned)v->vertfreq));
bx_virt_timer.activate_timer(s.vertical_timer_id, (Bit32u)s.vdraw.vtotal_usec, 1);
v->vtimer_running = 1;
}
return 1;
}

Expand Down
5 changes: 3 additions & 2 deletions bochs/iodev/display/voodoo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {
Bit64u vsync_usec;
double htime_to_pixel;
Bit64u frame_start;
bool vfreq_update;
bool clock_enabled;
bool output_on;
bool override_on;
Expand Down Expand Up @@ -66,7 +67,7 @@ class bx_voodoo_base_c : public bx_nonvga_device_c {
virtual void refresh_display(void *this_ptr, bool redraw);
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height);
virtual void update(void);
virtual bool update(void);
virtual bool update_timing(void) {return 0;}
virtual Bit32u get_retrace(bool hv) {return 0;}
virtual Bit32u get_vtotal_usec(void) {return 0;}
Expand Down Expand Up @@ -127,7 +128,7 @@ class bx_banshee_c : public bx_voodoo_base_c {
virtual void register_state(void);
virtual void after_restore_state(void);

virtual void update(void);
virtual bool update(void);
virtual bool update_timing(void);
virtual Bit32u get_retrace(bool hv);

Expand Down

0 comments on commit b14605d

Please sign in to comment.