The common code decides that the display is blanked by looking at bit 5
of the attribute controller index register. A device which instead gates
the sync signals through vendor specific registers has no way to express
that, and keeps scanning out the last image after its CRTC was disabled.

Add an optional is_blanked() callback for such a device to report it.
Devices which leave it unset are unaffected.

Signed-off-by: Jamin Lin <[email protected]>
---
 hw/display/vga_int.h | 1 +
 hw/display/vga.c     | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 5664317ecd..68f082acba 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -99,6 +99,7 @@ typedef struct VGACommonState {
     uint8_t palette[768];
     int32_t bank_offset;
     int (*get_bpp)(struct VGACommonState *s);
+    bool (*is_blanked)(struct VGACommonState *s);
     void (*get_params)(struct VGACommonState *s, VGADisplayParams *params);
     void (*get_resolution)(struct VGACommonState *s,
                         int *pwidth,
diff --git a/hw/display/vga.c b/hw/display/vga.c
index da0c331486..b273244cd5 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -1811,7 +1811,7 @@ static bool vga_update_display(void *opaque)
         /* nothing to do */
     } else {
         full_update = 0;
-        if (!(s->ar_index & 0x20)) {
+        if (!(s->ar_index & 0x20) || (s->is_blanked && s->is_blanked(s))) {
             graphic_mode = GMODE_BLANK;
         } else {
             graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
@@ -1929,7 +1929,7 @@ static void vga_update_text(void *opaque, uint32_t 
*chardata)
 
     qemu_flush_coalesced_mmio_buffer();
 
-    if (!(s->ar_index & 0x20)) {
+    if (!(s->ar_index & 0x20) || (s->is_blanked && s->is_blanked(s))) {
         graphic_mode = GMODE_BLANK;
     } else {
         graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
-- 
2.53.0

Reply via email to