|
|
9ae3a8 |
From 445ec835479fd06142078a59f1a88f2b30708930 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 28 Apr 2016 16:07:30 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 25/27] vga: factor out vga register setup
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1461859652-20918-5-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 70295
|
|
|
9ae3a8 |
O-Subject: [virt-devel] [RHEL-7.3 qemu-kvm PATCH 4/6] vga: factor out vga register setup
|
|
|
9ae3a8 |
Bugzilla: 1331413
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
When enabling vbe mode qemu will setup a bunch of vga registers to make
|
|
|
9ae3a8 |
sure the vga emulation operates in correct mode for a linear
|
|
|
9ae3a8 |
framebuffer. Move that code to a separate function so we can call it
|
|
|
9ae3a8 |
from other places too.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/display/vga.c | 78 ++++++++++++++++++++++++++++++++------------------------
|
|
|
9ae3a8 |
1 file changed, 44 insertions(+), 34 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/display/vga.c b/hw/display/vga.c
|
|
|
9ae3a8 |
index b694a26..4cc0df5 100644
|
|
|
9ae3a8 |
--- a/hw/display/vga.c
|
|
|
9ae3a8 |
+++ b/hw/display/vga.c
|
|
|
9ae3a8 |
@@ -671,6 +671,49 @@ static void vbe_fixup_regs(VGACommonState *s)
|
|
|
9ae3a8 |
s->vbe_start_addr = offset / 4;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+/* we initialize the VGA graphic mode */
|
|
|
9ae3a8 |
+static void vbe_update_vgaregs(VGACommonState *s)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ int h, shift_control;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (!vbe_enabled(s)) {
|
|
|
9ae3a8 |
+ /* vbe is turned off -- nothing to do */
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* graphic mode + memory map 1 */
|
|
|
9ae3a8 |
+ s->gr[VGA_GFX_MISC] = (s->gr[VGA_GFX_MISC] & ~0x0c) | 0x04 |
|
|
|
9ae3a8 |
+ VGA_GR06_GRAPHICS_MODE;
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_MODE] |= 3; /* no CGA modes */
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_OFFSET] = s->vbe_line_offset >> 3;
|
|
|
9ae3a8 |
+ /* width */
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_H_DISP] =
|
|
|
9ae3a8 |
+ (s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
|
|
|
9ae3a8 |
+ /* height (only meaningful if < 1024) */
|
|
|
9ae3a8 |
+ h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_V_DISP_END] = h;
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
|
|
|
9ae3a8 |
+ ((h >> 7) & 0x02) | ((h >> 3) & 0x40);
|
|
|
9ae3a8 |
+ /* line compare to 1023 */
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_LINE_COMPARE] = 0xff;
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_OVERFLOW] |= 0x10;
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_MAX_SCAN] |= 0x40;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
|
|
|
9ae3a8 |
+ shift_control = 0;
|
|
|
9ae3a8 |
+ s->sr[VGA_SEQ_CLOCK_MODE] &= ~8; /* no double line */
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ shift_control = 2;
|
|
|
9ae3a8 |
+ /* set chain 4 mode */
|
|
|
9ae3a8 |
+ s->sr[VGA_SEQ_MEMORY_MODE] |= VGA_SR04_CHN_4M;
|
|
|
9ae3a8 |
+ /* activate all planes */
|
|
|
9ae3a8 |
+ s->sr[VGA_SEQ_PLANE_WRITE] |= VGA_SR02_ALL_PLANES;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ s->gr[VGA_GFX_MODE] = (s->gr[VGA_GFX_MODE] & ~0x60) |
|
|
|
9ae3a8 |
+ (shift_control << 5);
|
|
|
9ae3a8 |
+ s->cr[VGA_CRTC_MAX_SCAN] &= ~0x9f; /* no double scan */
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
VGACommonState *s = opaque;
|
|
|
9ae3a8 |
@@ -757,52 +800,19 @@ void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
|
|
|
9ae3a8 |
case VBE_DISPI_INDEX_ENABLE:
|
|
|
9ae3a8 |
if ((val & VBE_DISPI_ENABLED) &&
|
|
|
9ae3a8 |
!(s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
|
|
|
9ae3a8 |
- int h, shift_control;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->vbe_regs[VBE_DISPI_INDEX_VIRT_WIDTH] = 0;
|
|
|
9ae3a8 |
s->vbe_regs[VBE_DISPI_INDEX_X_OFFSET] = 0;
|
|
|
9ae3a8 |
s->vbe_regs[VBE_DISPI_INDEX_Y_OFFSET] = 0;
|
|
|
9ae3a8 |
s->vbe_regs[VBE_DISPI_INDEX_ENABLE] |= VBE_DISPI_ENABLED;
|
|
|
9ae3a8 |
vbe_fixup_regs(s);
|
|
|
9ae3a8 |
+ vbe_update_vgaregs(s);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* clear the screen */
|
|
|
9ae3a8 |
if (!(val & VBE_DISPI_NOCLEARMEM)) {
|
|
|
9ae3a8 |
memset(s->vram_ptr, 0,
|
|
|
9ae3a8 |
s->vbe_regs[VBE_DISPI_INDEX_YRES] * s->vbe_line_offset);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- /* we initialize the VGA graphic mode */
|
|
|
9ae3a8 |
- /* graphic mode + memory map 1 */
|
|
|
9ae3a8 |
- s->gr[VGA_GFX_MISC] = (s->gr[VGA_GFX_MISC] & ~0x0c) | 0x04 |
|
|
|
9ae3a8 |
- VGA_GR06_GRAPHICS_MODE;
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_MODE] |= 3; /* no CGA modes */
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_OFFSET] = s->vbe_line_offset >> 3;
|
|
|
9ae3a8 |
- /* width */
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_H_DISP] =
|
|
|
9ae3a8 |
- (s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
|
|
|
9ae3a8 |
- /* height (only meaningful if < 1024) */
|
|
|
9ae3a8 |
- h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_V_DISP_END] = h;
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
|
|
|
9ae3a8 |
- ((h >> 7) & 0x02) | ((h >> 3) & 0x40);
|
|
|
9ae3a8 |
- /* line compare to 1023 */
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_LINE_COMPARE] = 0xff;
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_OVERFLOW] |= 0x10;
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_MAX_SCAN] |= 0x40;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
|
|
|
9ae3a8 |
- shift_control = 0;
|
|
|
9ae3a8 |
- s->sr[VGA_SEQ_CLOCK_MODE] &= ~8; /* no double line */
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- shift_control = 2;
|
|
|
9ae3a8 |
- /* set chain 4 mode */
|
|
|
9ae3a8 |
- s->sr[VGA_SEQ_MEMORY_MODE] |= VGA_SR04_CHN_4M;
|
|
|
9ae3a8 |
- /* activate all planes */
|
|
|
9ae3a8 |
- s->sr[VGA_SEQ_PLANE_WRITE] |= VGA_SR02_ALL_PLANES;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- s->gr[VGA_GFX_MODE] = (s->gr[VGA_GFX_MODE] & ~0x60) |
|
|
|
9ae3a8 |
- (shift_control << 5);
|
|
|
9ae3a8 |
- s->cr[VGA_CRTC_MAX_SCAN] &= ~0x9f; /* no double scan */
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
s->bank_offset = 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|