yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
e96cb2
From 0f24daf4c35cace529ae8441aa8b101ba53660ea Mon Sep 17 00:00:00 2001
e96cb2
From: Gerd Hoffmann <kraxel@redhat.com>
e96cb2
Date: Fri, 29 Apr 2016 07:02:48 +0200
e96cb2
Subject: [PATCH 3/6] vga: add vbe_enabled() helper
e96cb2
e96cb2
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
e96cb2
Message-id: <1461913371-3145-4-git-send-email-kraxel@redhat.com>
e96cb2
Patchwork-id: 70303
e96cb2
O-Subject: [virt-devel] [RHEL-7.2.z qemu-kvm PATCH 3/6] vga: add vbe_enabled() helper
e96cb2
Bugzilla: 1331412
e96cb2
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
e96cb2
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
e96cb2
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
e96cb2
e96cb2
Makes code a bit easier to read.
e96cb2
e96cb2
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
e96cb2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
e96cb2
---
e96cb2
 hw/display/vga.c | 15 ++++++++++-----
e96cb2
 1 file changed, 10 insertions(+), 5 deletions(-)
e96cb2
e96cb2
diff --git a/hw/display/vga.c b/hw/display/vga.c
e96cb2
index ba171ba..b694a26 100644
e96cb2
--- a/hw/display/vga.c
e96cb2
+++ b/hw/display/vga.c
e96cb2
@@ -166,6 +166,11 @@ static uint32_t expand4[256];
e96cb2
 static uint16_t expand2[256];
e96cb2
 static uint8_t expand4to8[16];
e96cb2
 
e96cb2
+static inline bool vbe_enabled(VGACommonState *s)
e96cb2
+{
e96cb2
+    return s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED;
e96cb2
+}
e96cb2
+
e96cb2
 static void vga_update_memory_access(VGACommonState *s)
e96cb2
 {
e96cb2
     MemoryRegion *region, *old_region = s->chain4_alias;
e96cb2
@@ -591,7 +596,7 @@ static void vbe_fixup_regs(VGACommonState *s)
e96cb2
     uint16_t *r = s->vbe_regs;
e96cb2
     uint32_t bits, linelength, maxy, offset;
e96cb2
 
e96cb2
-    if (!(r[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
e96cb2
+    if (!vbe_enabled(s)) {
e96cb2
         /* vbe is turned off -- nothing to do */
e96cb2
         return;
e96cb2
     }
e96cb2
@@ -775,7 +780,7 @@ void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
e96cb2
                 /* width */
e96cb2
                 s->cr[VGA_CRTC_H_DISP] =
e96cb2
                     (s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
e96cb2
-                /* height (only meaningful if < 1024) */
e96cb2
+                 /* height (only meaningful if < 1024) */
e96cb2
                 h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
e96cb2
                 s->cr[VGA_CRTC_V_DISP_END] = h;
e96cb2
                 s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
e96cb2
@@ -1170,7 +1175,7 @@ static void vga_get_offsets(VGACommonState *s,
e96cb2
 {
e96cb2
     uint32_t start_addr, line_offset, line_compare;
e96cb2
 
e96cb2
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
e96cb2
+    if (vbe_enabled(s)) {
e96cb2
         line_offset = s->vbe_line_offset;
e96cb2
         start_addr = s->vbe_start_addr;
e96cb2
         line_compare = 65535;
e96cb2
@@ -1623,7 +1628,7 @@ static int vga_get_bpp(VGACommonState *s)
e96cb2
 {
e96cb2
     int ret;
e96cb2
 
e96cb2
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
e96cb2
+    if (vbe_enabled(s)) {
e96cb2
         ret = s->vbe_regs[VBE_DISPI_INDEX_BPP];
e96cb2
     } else {
e96cb2
         ret = 0;
e96cb2
@@ -1635,7 +1640,7 @@ static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight)
e96cb2
 {
e96cb2
     int width, height;
e96cb2
 
e96cb2
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
e96cb2
+    if (vbe_enabled(s)) {
e96cb2
         width = s->vbe_regs[VBE_DISPI_INDEX_XRES];
e96cb2
         height = s->vbe_regs[VBE_DISPI_INDEX_YRES];
e96cb2
     } else {
e96cb2
-- 
e96cb2
1.8.3.1
e96cb2