695a56c
From e026859e9aecf8635daf06e9fc2325239f458959 Mon Sep 17 00:00:00 2001
695a56c
From: Gerd Hoffmann <kraxel@redhat.com>
695a56c
Date: Tue, 26 Apr 2016 14:11:34 +0200
695a56c
Subject: [PATCH 2/5] vga: add vbe_enabled() helper
695a56c
695a56c
Makes code a bit easier to read.
695a56c
695a56c
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
695a56c
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
695a56c
---
695a56c
 tools/qemu-xen/hw/display/vga.c | 13 +++++++++----
695a56c
 1 file changed, 9 insertions(+), 4 deletions(-)
695a56c
695a56c
diff --git a/tools/qemu-xen/hw/display/vga.c b/tools/qemu-xen/hw/display/vga.c
695a56c
index b577712..ebf63ff 100644
695a56c
--- a/tools/qemu-xen/hw/display/vga.c
695a56c
+++ b/tools/qemu-xen/hw/display/vga.c
695a56c
@@ -140,6 +140,11 @@ static uint32_t expand4[256];
695a56c
 static uint16_t expand2[256];
695a56c
 static uint8_t expand4to8[16];
695a56c
 
695a56c
+static inline bool vbe_enabled(VGACommonState *s)
695a56c
+{
695a56c
+    return s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED;
695a56c
+}
695a56c
+
695a56c
 static void vga_update_memory_access(VGACommonState *s)
695a56c
 {
695a56c
     hwaddr base, offset, size;
695a56c
@@ -563,7 +568,7 @@ static void vbe_fixup_regs(VGACommonState *s)
695a56c
     uint16_t *r = s->vbe_regs;
695a56c
     uint32_t bits, linelength, maxy, offset;
695a56c
 
695a56c
-    if (!(r[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
695a56c
+    if (!vbe_enabled(s)) {
695a56c
         /* vbe is turned off -- nothing to do */
695a56c
         return;
695a56c
     }
695a56c
@@ -1057,7 +1062,7 @@ static void vga_get_offsets(VGACommonState *s,
695a56c
 {
695a56c
     uint32_t start_addr, line_offset, line_compare;
695a56c
 
695a56c
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
695a56c
+    if (vbe_enabled(s)) {
695a56c
         line_offset = s->vbe_line_offset;
695a56c
         start_addr = s->vbe_start_addr;
695a56c
         line_compare = 65535;
695a56c
@@ -1382,7 +1387,7 @@ static int vga_get_bpp(VGACommonState *s)
695a56c
 {
695a56c
     int ret;
695a56c
 
695a56c
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
695a56c
+    if (vbe_enabled(s)) {
695a56c
         ret = s->vbe_regs[VBE_DISPI_INDEX_BPP];
695a56c
     } else {
695a56c
         ret = 0;
695a56c
@@ -1394,7 +1399,7 @@ static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight)
695a56c
 {
695a56c
     int width, height;
695a56c
 
695a56c
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
695a56c
+    if (vbe_enabled(s)) {
695a56c
         width = s->vbe_regs[VBE_DISPI_INDEX_XRES];
695a56c
         height = s->vbe_regs[VBE_DISPI_INDEX_YRES];
695a56c
     } else {
695a56c
-- 
695a56c
1.9.1
695a56c