9ae3a8
From 6e615e8fbbd979134868bcd63150365d48d12137 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Thu, 28 Apr 2016 16:07:29 +0200
9ae3a8
Subject: [PATCH 24/27] vga: add vbe_enabled() helper
9ae3a8
9ae3a8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Message-id: <1461859652-20918-4-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 70294
9ae3a8
O-Subject: [virt-devel] [RHEL-7.3 qemu-kvm PATCH 3/6] vga: add vbe_enabled() helper
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
Makes code a bit easier to read.
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 | 15 ++++++++++-----
9ae3a8
 1 file changed, 10 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/display/vga.c b/hw/display/vga.c
9ae3a8
index ba171ba..b694a26 100644
9ae3a8
--- a/hw/display/vga.c
9ae3a8
+++ b/hw/display/vga.c
9ae3a8
@@ -166,6 +166,11 @@ static uint32_t expand4[256];
9ae3a8
 static uint16_t expand2[256];
9ae3a8
 static uint8_t expand4to8[16];
9ae3a8
 
9ae3a8
+static inline bool vbe_enabled(VGACommonState *s)
9ae3a8
+{
9ae3a8
+    return s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED;
9ae3a8
+}
9ae3a8
+
9ae3a8
 static void vga_update_memory_access(VGACommonState *s)
9ae3a8
 {
9ae3a8
     MemoryRegion *region, *old_region = s->chain4_alias;
9ae3a8
@@ -591,7 +596,7 @@ static void vbe_fixup_regs(VGACommonState *s)
9ae3a8
     uint16_t *r = s->vbe_regs;
9ae3a8
     uint32_t bits, linelength, maxy, offset;
9ae3a8
 
9ae3a8
-    if (!(r[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
9ae3a8
+    if (!vbe_enabled(s)) {
9ae3a8
         /* vbe is turned off -- nothing to do */
9ae3a8
         return;
9ae3a8
     }
9ae3a8
@@ -775,7 +780,7 @@ void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
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
+                 /* 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
@@ -1170,7 +1175,7 @@ static void vga_get_offsets(VGACommonState *s,
9ae3a8
 {
9ae3a8
     uint32_t start_addr, line_offset, line_compare;
9ae3a8
 
9ae3a8
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
9ae3a8
+    if (vbe_enabled(s)) {
9ae3a8
         line_offset = s->vbe_line_offset;
9ae3a8
         start_addr = s->vbe_start_addr;
9ae3a8
         line_compare = 65535;
9ae3a8
@@ -1623,7 +1628,7 @@ static int vga_get_bpp(VGACommonState *s)
9ae3a8
 {
9ae3a8
     int ret;
9ae3a8
 
9ae3a8
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
9ae3a8
+    if (vbe_enabled(s)) {
9ae3a8
         ret = s->vbe_regs[VBE_DISPI_INDEX_BPP];
9ae3a8
     } else {
9ae3a8
         ret = 0;
9ae3a8
@@ -1635,7 +1640,7 @@ static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight)
9ae3a8
 {
9ae3a8
     int width, height;
9ae3a8
 
9ae3a8
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
9ae3a8
+    if (vbe_enabled(s)) {
9ae3a8
         width = s->vbe_regs[VBE_DISPI_INDEX_XRES];
9ae3a8
         height = s->vbe_regs[VBE_DISPI_INDEX_YRES];
9ae3a8
     } else {
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8