diff mbox series

[05/10] macfb: set initial value of mode control registers in macfb_common_realize()

Message ID 20220228222527.8234-6-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show
Series q800: migration fixes | expand

Commit Message

Mark Cave-Ayland Feb. 28, 2022, 10:25 p.m. UTC
If booting Linux directly in the q800 machine using -kernel rather than using a
MacOS toolbox ROM, the mode control registers are never initialised,
causing macfb_mode_write() to fail to determine the current resolution after
migration. Resolve this by always setting the initial values of the mode control
registers based upon the initial macfb properties during realize.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/display/macfb.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/hw/display/macfb.c b/hw/display/macfb.c
index f9ceea532e..bcfb2d0dab 100644
--- a/hw/display/macfb.c
+++ b/hw/display/macfb.c
@@ -647,6 +647,14 @@  static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp)
         return false;
     }
 
+    /*
+     * Set mode control registers to match the mode found above so that
+     * macfb_mode_write() does the right thing if no MacOS toolbox ROM
+     * is present to initialise them
+     */
+    s->regs[DAFB_MODE_CTRL1 >> 2] = s->mode->mode_ctrl1;
+    s->regs[DAFB_MODE_CTRL2 >> 2] = s->mode->mode_ctrl2;
+
     s->con = graphic_console_init(dev, 0, &macfb_ops, s);
     surface = qemu_console_surface(s->con);