cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vga-Start-cutting-out-non-32bpp-conversion-support.patch

5d360b
From 08caae6c10ff9769921e408b0faa41f8c952f653 Mon Sep 17 00:00:00 2001
12e206
From: Gerd Hoffmann <kraxel@redhat.com>
12e206
Date: Thu, 5 Oct 2017 14:51:15 +0200
5d360b
Subject: [PATCH 19/27] vga: Start cutting out non-32bpp conversion support
12e206
12e206
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
12e206
Message-id: <20171005145119.15277-4-kraxel@redhat.com>
12e206
Patchwork-id: 76825
12e206
O-Subject: [RHEL-7.5 qemu-kvm PATCH 3/7] vga: Start cutting out non-32bpp conversion support
5d360b
Bugzilla: 1486642
12e206
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
12e206
RH-Acked-by: Thomas Huth <thuth@redhat.com>
12e206
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12e206
12e206
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12e206
12e206
Nowadays, we either share a surface with the host, or we create
12e206
a 32bpp ARGB console surface.
12e206
12e206
So we only need to draw/convert to 32bpp, enabling us to remove
12e206
all but one instance of vga_template.h inclusion (to be further
12e206
cleaned up), rgb_to_pixel_* etc...
12e206
12e206
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12e206
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12e206
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
12e206
(cherry picked from commit 9e057c0b09c3018cd24c7a49995f8b66d5b3d1eb)
12e206
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
12e206
---
12e206
 hw/display/vga.c | 258 +++++--------------------------------------------------
12e206
 1 file changed, 22 insertions(+), 236 deletions(-)
12e206
12e206
diff --git a/hw/display/vga.c b/hw/display/vga.c
12e206
index 4e3c3f3..dab75a3 100644
12e206
--- a/hw/display/vga.c
12e206
+++ b/hw/display/vga.c
12e206
@@ -1044,81 +1044,12 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
12e206
     }
12e206
 }
12e206
 
12e206
-typedef void vga_draw_glyph8_func(uint8_t *d, int linesize,
12e206
-                             const uint8_t *font_ptr, int h,
12e206
-                             uint32_t fgcol, uint32_t bgcol);
12e206
-typedef void vga_draw_glyph9_func(uint8_t *d, int linesize,
12e206
-                                  const uint8_t *font_ptr, int h,
12e206
-                                  uint32_t fgcol, uint32_t bgcol, int dup9);
12e206
 typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d,
12e206
                                 const uint8_t *s, int width);
12e206
 
12e206
-#define DEPTH 8
12e206
-#include "vga_template.h"
12e206
-
12e206
-#define DEPTH 15
12e206
-#include "vga_template.h"
12e206
-
12e206
-#define BGR_FORMAT
12e206
-#define DEPTH 15
12e206
-#include "vga_template.h"
12e206
-
12e206
-#define DEPTH 16
12e206
-#include "vga_template.h"
12e206
-
12e206
-#define BGR_FORMAT
12e206
-#define DEPTH 16
12e206
-#include "vga_template.h"
12e206
-
12e206
 #define DEPTH 32
12e206
 #include "vga_template.h"
12e206
 
12e206
-#define BGR_FORMAT
12e206
-#define DEPTH 32
12e206
-#include "vga_template.h"
12e206
-
12e206
-static unsigned int rgb_to_pixel8_dup(unsigned int r, unsigned int g, unsigned b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel8(r, g, b);
12e206
-    col |= col << 8;
12e206
-    col |= col << 16;
12e206
-    return col;
12e206
-}
12e206
-
12e206
-static unsigned int rgb_to_pixel15_dup(unsigned int r, unsigned int g, unsigned b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel15(r, g, b);
12e206
-    col |= col << 16;
12e206
-    return col;
12e206
-}
12e206
-
12e206
-static unsigned int rgb_to_pixel15bgr_dup(unsigned int r, unsigned int g,
12e206
-                                          unsigned int b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel15bgr(r, g, b);
12e206
-    col |= col << 16;
12e206
-    return col;
12e206
-}
12e206
-
12e206
-static unsigned int rgb_to_pixel16_dup(unsigned int r, unsigned int g, unsigned b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel16(r, g, b);
12e206
-    col |= col << 16;
12e206
-    return col;
12e206
-}
12e206
-
12e206
-static unsigned int rgb_to_pixel16bgr_dup(unsigned int r, unsigned int g,
12e206
-                                          unsigned int b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel16bgr(r, g, b);
12e206
-    col |= col << 16;
12e206
-    return col;
12e206
-}
12e206
 
12e206
 static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b)
12e206
 {
12e206
@@ -1127,13 +1058,6 @@ static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned
12e206
     return col;
12e206
 }
12e206
 
12e206
-static unsigned int rgb_to_pixel32bgr_dup(unsigned int r, unsigned int g, unsigned b)
12e206
-{
12e206
-    unsigned int col;
12e206
-    col = rgb_to_pixel32bgr(r, g, b);
12e206
-    return col;
12e206
-}
12e206
-
12e206
 /* return true if the palette was modified */
12e206
 static int update_palette16(VGACommonState *s)
12e206
 {
12e206
@@ -1240,56 +1164,6 @@ static int update_basic_params(VGACommonState *s)
12e206
     return full_update;
12e206
 }
12e206
 
12e206
-#define NB_DEPTHS 7
12e206
-
12e206
-static inline int get_depth_index(DisplaySurface *s)
12e206
-{
12e206
-    switch (surface_bits_per_pixel(s)) {
12e206
-    default:
12e206
-    case 8:
12e206
-        return 0;
12e206
-    case 15:
12e206
-        return 1;
12e206
-    case 16:
12e206
-        return 2;
12e206
-    case 32:
12e206
-        if (is_surface_bgr(s)) {
12e206
-            return 4;
12e206
-        } else {
12e206
-            return 3;
12e206
-        }
12e206
-    }
12e206
-}
12e206
-
12e206
-static vga_draw_glyph8_func * const vga_draw_glyph8_table[NB_DEPTHS] = {
12e206
-    vga_draw_glyph8_8,
12e206
-    vga_draw_glyph8_16,
12e206
-    vga_draw_glyph8_16,
12e206
-    vga_draw_glyph8_32,
12e206
-    vga_draw_glyph8_32,
12e206
-    vga_draw_glyph8_16,
12e206
-    vga_draw_glyph8_16,
12e206
-};
12e206
-
12e206
-static vga_draw_glyph8_func * const vga_draw_glyph16_table[NB_DEPTHS] = {
12e206
-    vga_draw_glyph16_8,
12e206
-    vga_draw_glyph16_16,
12e206
-    vga_draw_glyph16_16,
12e206
-    vga_draw_glyph16_32,
12e206
-    vga_draw_glyph16_32,
12e206
-    vga_draw_glyph16_16,
12e206
-    vga_draw_glyph16_16,
12e206
-};
12e206
-
12e206
-static vga_draw_glyph9_func * const vga_draw_glyph9_table[NB_DEPTHS] = {
12e206
-    vga_draw_glyph9_8,
12e206
-    vga_draw_glyph9_16,
12e206
-    vga_draw_glyph9_16,
12e206
-    vga_draw_glyph9_32,
12e206
-    vga_draw_glyph9_32,
12e206
-    vga_draw_glyph9_16,
12e206
-    vga_draw_glyph9_16,
12e206
-};
12e206
 
12e206
 static const uint8_t cursor_glyph[32 * 4] = {
12e206
     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
12e206
@@ -1341,18 +1215,6 @@ static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight
12e206
     *pcheight = cheight;
12e206
 }
12e206
 
12e206
-typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b);
12e206
-
12e206
-static rgb_to_pixel_dup_func * const rgb_to_pixel_dup_table[NB_DEPTHS] = {
12e206
-    rgb_to_pixel8_dup,
12e206
-    rgb_to_pixel15_dup,
12e206
-    rgb_to_pixel16_dup,
12e206
-    rgb_to_pixel32_dup,
12e206
-    rgb_to_pixel32bgr_dup,
12e206
-    rgb_to_pixel15bgr_dup,
12e206
-    rgb_to_pixel16bgr_dup,
12e206
-};
12e206
-
12e206
 /*
12e206
  * Text mode update
12e206
  * Missing:
12e206
@@ -1369,11 +1231,9 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
     uint32_t offset, fgcol, bgcol, v, cursor_offset;
12e206
     uint8_t *d1, *d, *src, *dest, *cursor_ptr;
12e206
     const uint8_t *font_ptr, *font_base[2];
12e206
-    int dup9, line_offset, depth_index;
12e206
+    int dup9, line_offset;
12e206
     uint32_t *palette;
12e206
     uint32_t *ch_attr_ptr;
12e206
-    vga_draw_glyph8_func *vga_draw_glyph8;
12e206
-    vga_draw_glyph9_func *vga_draw_glyph9;
12e206
     int64_t now = qemu_get_clock_ms(vm_clock);
12e206
 
12e206
     /* compute font data address (in plane 2) */
12e206
@@ -1425,8 +1285,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
         s->last_cw = cw;
12e206
         full_update = 1;
12e206
     }
12e206
-    s->rgb_to_pixel =
12e206
-        rgb_to_pixel_dup_table[get_depth_index(surface)];
12e206
+    s->rgb_to_pixel = rgb_to_pixel32_dup;
12e206
     full_update |= update_palette16(s);
12e206
     palette = s->last_palette;
12e206
     x_incr = cw * surface_bytes_per_pixel(surface);
12e206
@@ -1460,13 +1319,6 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
         s->cursor_visible_phase = !s->cursor_visible_phase;
12e206
     }
12e206
 
12e206
-    depth_index = get_depth_index(surface);
12e206
-    if (cw == 16)
12e206
-        vga_draw_glyph8 = vga_draw_glyph16_table[depth_index];
12e206
-    else
12e206
-        vga_draw_glyph8 = vga_draw_glyph8_table[depth_index];
12e206
-    vga_draw_glyph9 = vga_draw_glyph9_table[depth_index];
12e206
-
12e206
     dest = surface_data(surface);
12e206
     linesize = surface_stride(surface);
12e206
     ch_attr_ptr = s->last_ch_attr;
12e206
@@ -1496,17 +1348,20 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
                 font_ptr += 32 * 4 * ch;
12e206
                 bgcol = palette[cattr >> 4];
12e206
                 fgcol = palette[cattr & 0x0f];
12e206
-                if (cw != 9) {
12e206
-                    vga_draw_glyph8(d1, linesize,
12e206
-                                    font_ptr, cheight, fgcol, bgcol);
12e206
+                if (cw == 16) {
12e206
+                    vga_draw_glyph16_32(d1, linesize,
12e206
+                                        font_ptr, cheight, fgcol, bgcol);
12e206
+                } else if (cw != 9) {
12e206
+                    vga_draw_glyph8_32(d1, linesize,
12e206
+                                       font_ptr, cheight, fgcol, bgcol);
12e206
                 } else {
12e206
                     dup9 = 0;
12e206
                     if (ch >= 0xb0 && ch <= 0xdf &&
12e206
                         (s->ar[VGA_ATC_MODE] & 0x04)) {
12e206
                         dup9 = 1;
12e206
                     }
12e206
-                    vga_draw_glyph9(d1, linesize,
12e206
-                                    font_ptr, cheight, fgcol, bgcol, dup9);
12e206
+                    vga_draw_glyph9_32(d1, linesize,
12e206
+                                       font_ptr, cheight, fgcol, bgcol, dup9);
12e206
                 }
12e206
                 if (src == cursor_ptr &&
12e206
                     !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) &&
12e206
@@ -1521,12 +1376,15 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
                     if (line_last >= line_start && line_start < cheight) {
12e206
                         h = line_last - line_start + 1;
12e206
                         d = d1 + linesize * line_start;
12e206
-                        if (cw != 9) {
12e206
-                            vga_draw_glyph8(d, linesize,
12e206
-                                            cursor_glyph, h, fgcol, bgcol);
12e206
+                        if (cw == 16) {
12e206
+                            vga_draw_glyph16_32(d, linesize,
12e206
+                                               cursor_glyph, h, fgcol, bgcol);
12e206
+                        } else if (cw != 9) {
12e206
+                            vga_draw_glyph8_32(d, linesize,
12e206
+                                              cursor_glyph, h, fgcol, bgcol);
12e206
                         } else {
12e206
-                            vga_draw_glyph9(d, linesize,
12e206
-                                            cursor_glyph, h, fgcol, bgcol, 1);
12e206
+                            vga_draw_glyph9_32(d, linesize,
12e206
+                                              cursor_glyph, h, fgcol, bgcol, 1);
12e206
                         }
12e206
                     }
12e206
                 }
12e206
@@ -1563,86 +1421,17 @@ enum {
12e206
     VGA_DRAW_LINE_NB,
12e206
 };
12e206
 
12e206
-static vga_draw_line_func * const vga_draw_line_table[NB_DEPTHS * VGA_DRAW_LINE_NB] = {
12e206
-    vga_draw_line2_8,
12e206
-    vga_draw_line2_16,
12e206
-    vga_draw_line2_16,
12e206
-    vga_draw_line2_32,
12e206
+static vga_draw_line_func * const vga_draw_line_table[VGA_DRAW_LINE_NB] = {
12e206
     vga_draw_line2_32,
12e206
-    vga_draw_line2_16,
12e206
-    vga_draw_line2_16,
12e206
-
12e206
-    vga_draw_line2d2_8,
12e206
-    vga_draw_line2d2_16,
12e206
-    vga_draw_line2d2_16,
12e206
-    vga_draw_line2d2_32,
12e206
     vga_draw_line2d2_32,
12e206
-    vga_draw_line2d2_16,
12e206
-    vga_draw_line2d2_16,
12e206
-
12e206
-    vga_draw_line4_8,
12e206
-    vga_draw_line4_16,
12e206
-    vga_draw_line4_16,
12e206
     vga_draw_line4_32,
12e206
-    vga_draw_line4_32,
12e206
-    vga_draw_line4_16,
12e206
-    vga_draw_line4_16,
12e206
-
12e206
-    vga_draw_line4d2_8,
12e206
-    vga_draw_line4d2_16,
12e206
-    vga_draw_line4d2_16,
12e206
     vga_draw_line4d2_32,
12e206
-    vga_draw_line4d2_32,
12e206
-    vga_draw_line4d2_16,
12e206
-    vga_draw_line4d2_16,
12e206
-
12e206
-    vga_draw_line8d2_8,
12e206
-    vga_draw_line8d2_16,
12e206
-    vga_draw_line8d2_16,
12e206
-    vga_draw_line8d2_32,
12e206
     vga_draw_line8d2_32,
12e206
-    vga_draw_line8d2_16,
12e206
-    vga_draw_line8d2_16,
12e206
-
12e206
-    vga_draw_line8_8,
12e206
-    vga_draw_line8_16,
12e206
-    vga_draw_line8_16,
12e206
-    vga_draw_line8_32,
12e206
     vga_draw_line8_32,
12e206
-    vga_draw_line8_16,
12e206
-    vga_draw_line8_16,
12e206
-
12e206
-    vga_draw_line15_8,
12e206
-    vga_draw_line15_15,
12e206
-    vga_draw_line15_16,
12e206
     vga_draw_line15_32,
12e206
-    vga_draw_line15_32bgr,
12e206
-    vga_draw_line15_15bgr,
12e206
-    vga_draw_line15_16bgr,
12e206
-
12e206
-    vga_draw_line16_8,
12e206
-    vga_draw_line16_15,
12e206
-    vga_draw_line16_16,
12e206
     vga_draw_line16_32,
12e206
-    vga_draw_line16_32bgr,
12e206
-    vga_draw_line16_15bgr,
12e206
-    vga_draw_line16_16bgr,
12e206
-
12e206
-    vga_draw_line24_8,
12e206
-    vga_draw_line24_15,
12e206
-    vga_draw_line24_16,
12e206
     vga_draw_line24_32,
12e206
-    vga_draw_line24_32bgr,
12e206
-    vga_draw_line24_15bgr,
12e206
-    vga_draw_line24_16bgr,
12e206
-
12e206
-    vga_draw_line32_8,
12e206
-    vga_draw_line32_15,
12e206
-    vga_draw_line32_16,
12e206
     vga_draw_line32_32,
12e206
-    vga_draw_line32_32bgr,
12e206
-    vga_draw_line32_15bgr,
12e206
-    vga_draw_line32_16bgr,
12e206
 };
12e206
 
12e206
 static int vga_get_bpp(VGACommonState *s)
12e206
@@ -1787,8 +1576,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
12e206
         dpy_gfx_replace_surface(s->con, surface);
12e206
     }
12e206
 
12e206
-    s->rgb_to_pixel =
12e206
-        rgb_to_pixel_dup_table[get_depth_index(surface)];
12e206
+    s->rgb_to_pixel = rgb_to_pixel32_dup;
12e206
 
12e206
     if (shift_control == 0) {
12e206
         full_update |= update_palette16(s);
12e206
@@ -1837,8 +1625,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
12e206
             break;
12e206
         }
12e206
     }
12e206
-    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS +
12e206
-                                        get_depth_index(surface)];
12e206
+    vga_draw_line = vga_draw_line_table[v];
12e206
 
12e206
     if (!is_buffer_shared(surface) && s->cursor_invalidate) {
12e206
         s->cursor_invalidate(s);
12e206
@@ -1936,8 +1723,7 @@ static void vga_draw_blank(VGACommonState *s, int full_update)
12e206
     if (s->last_scr_width <= 0 || s->last_scr_height <= 0)
12e206
         return;
12e206
 
12e206
-    s->rgb_to_pixel =
12e206
-        rgb_to_pixel_dup_table[get_depth_index(surface)];
12e206
+    s->rgb_to_pixel = rgb_to_pixel32_dup;
12e206
     if (surface_bits_per_pixel(surface) == 8) {
12e206
         val = s->rgb_to_pixel(0, 0, 0);
12e206
     } else {
12e206
-- 
12e206
1.8.3.1
12e206