cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
5d360b
From b97bdaf62f567d661feaf69662cb176e43ceba60 Mon Sep 17 00:00:00 2001
12e206
From: Gerd Hoffmann <kraxel@redhat.com>
12e206
Date: Thu, 5 Oct 2017 14:51:18 +0200
5d360b
Subject: [PATCH 22/27] vga: Rename vga_template.h to vga-helpers.h
12e206
12e206
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
12e206
Message-id: <20171005145119.15277-7-kraxel@redhat.com>
12e206
Patchwork-id: 76822
12e206
O-Subject: [RHEL-7.5 qemu-kvm PATCH 6/7] vga: Rename vga_template.h to vga-helpers.h
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
It's no longer a template, we only instanciate the file once.
12e206
12e206
Keep it a #included file so the functions remain static.
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 e657d8ef3c810c4c46d3a61bb76103f77bdb499b)
12e206
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
12e206
---
12e206
 hw/display/vga-helpers.h  | 439 ++++++++++++++++++++++++++++++++++++++++++++++
12e206
 hw/display/vga.c          |   2 +-
12e206
 hw/display/vga_template.h | 439 ----------------------------------------------
12e206
 3 files changed, 440 insertions(+), 440 deletions(-)
12e206
 create mode 100644 hw/display/vga-helpers.h
12e206
 delete mode 100644 hw/display/vga_template.h
12e206
12e206
diff --git a/hw/display/vga-helpers.h b/hw/display/vga-helpers.h
12e206
new file mode 100644
12e206
index 0000000..94f6de2
12e206
--- /dev/null
12e206
+++ b/hw/display/vga-helpers.h
12e206
@@ -0,0 +1,439 @@
12e206
+/*
12e206
+ * QEMU VGA Emulator templates
12e206
+ *
12e206
+ * Copyright (c) 2003 Fabrice Bellard
12e206
+ *
12e206
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12e206
+ * of this software and associated documentation files (the "Software"), to deal
12e206
+ * in the Software without restriction, including without limitation the rights
12e206
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12e206
+ * copies of the Software, and to permit persons to whom the Software is
12e206
+ * furnished to do so, subject to the following conditions:
12e206
+ *
12e206
+ * The above copyright notice and this permission notice shall be included in
12e206
+ * all copies or substantial portions of the Software.
12e206
+ *
12e206
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12e206
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12e206
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12e206
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12e206
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12e206
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
12e206
+ * THE SOFTWARE.
12e206
+ */
12e206
+
12e206
+static inline void vga_draw_glyph_line(uint8_t *d, uint32_t font_data,
12e206
+                                       uint32_t xorcol, uint32_t bgcol)
12e206
+{
12e206
+        ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
12e206
+}
12e206
+
12e206
+static void vga_draw_glyph8(uint8_t *d, int linesize,
12e206
+                            const uint8_t *font_ptr, int h,
12e206
+                            uint32_t fgcol, uint32_t bgcol)
12e206
+{
12e206
+    uint32_t font_data, xorcol;
12e206
+
12e206
+    xorcol = bgcol ^ fgcol;
12e206
+    do {
12e206
+        font_data = font_ptr[0];
12e206
+        vga_draw_glyph_line(d, font_data, xorcol, bgcol);
12e206
+        font_ptr += 4;
12e206
+        d += linesize;
12e206
+    } while (--h);
12e206
+}
12e206
+
12e206
+static void vga_draw_glyph16(uint8_t *d, int linesize,
12e206
+                                          const uint8_t *font_ptr, int h,
12e206
+                                          uint32_t fgcol, uint32_t bgcol)
12e206
+{
12e206
+    uint32_t font_data, xorcol;
12e206
+
12e206
+    xorcol = bgcol ^ fgcol;
12e206
+    do {
12e206
+        font_data = font_ptr[0];
12e206
+        vga_draw_glyph_line(d, expand4to8[font_data >> 4],
12e206
+                            xorcol, bgcol);
12e206
+        vga_draw_glyph_line(d + 32, expand4to8[font_data & 0x0f],
12e206
+                            xorcol, bgcol);
12e206
+        font_ptr += 4;
12e206
+        d += linesize;
12e206
+    } while (--h);
12e206
+}
12e206
+
12e206
+static void vga_draw_glyph9(uint8_t *d, int linesize,
12e206
+                            const uint8_t *font_ptr, int h,
12e206
+                            uint32_t fgcol, uint32_t bgcol, int dup9)
12e206
+{
12e206
+    uint32_t font_data, xorcol, v;
12e206
+
12e206
+    xorcol = bgcol ^ fgcol;
12e206
+    do {
12e206
+        font_data = font_ptr[0];
12e206
+        ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
12e206
+        v = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
12e206
+        ((uint32_t *)d)[7] = v;
12e206
+        if (dup9)
12e206
+            ((uint32_t *)d)[8] = v;
12e206
+        else
12e206
+            ((uint32_t *)d)[8] = bgcol;
12e206
+        font_ptr += 4;
12e206
+        d += linesize;
12e206
+    } while (--h);
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 4 color mode
12e206
+ */
12e206
+static void vga_draw_line2(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t plane_mask, *palette, data, v;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        data = ((uint32_t *)s)[0];
12e206
+        data &= plane_mask;
12e206
+        v = expand2[GET_PLANE(data, 0)];
12e206
+        v |= expand2[GET_PLANE(data, 2)] << 2;
12e206
+        ((uint32_t *)d)[0] = palette[v >> 12];
12e206
+        ((uint32_t *)d)[1] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[2] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[3] = palette[(v >> 0) & 0xf];
12e206
+
12e206
+        v = expand2[GET_PLANE(data, 1)];
12e206
+        v |= expand2[GET_PLANE(data, 3)] << 2;
12e206
+        ((uint32_t *)d)[4] = palette[v >> 12];
12e206
+        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
+        d += 32;
12e206
+        s += 4;
12e206
+    }
12e206
+}
12e206
+
12e206
+#define PUT_PIXEL2(d, n, v) \
12e206
+((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v)
12e206
+
12e206
+/*
12e206
+ * 4 color mode, dup2 horizontal
12e206
+ */
12e206
+static void vga_draw_line2d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t plane_mask, *palette, data, v;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        data = ((uint32_t *)s)[0];
12e206
+        data &= plane_mask;
12e206
+        v = expand2[GET_PLANE(data, 0)];
12e206
+        v |= expand2[GET_PLANE(data, 2)] << 2;
12e206
+        PUT_PIXEL2(d, 0, palette[v >> 12]);
12e206
+        PUT_PIXEL2(d, 1, palette[(v >> 8) & 0xf]);
12e206
+        PUT_PIXEL2(d, 2, palette[(v >> 4) & 0xf]);
12e206
+        PUT_PIXEL2(d, 3, palette[(v >> 0) & 0xf]);
12e206
+
12e206
+        v = expand2[GET_PLANE(data, 1)];
12e206
+        v |= expand2[GET_PLANE(data, 3)] << 2;
12e206
+        PUT_PIXEL2(d, 4, palette[v >> 12]);
12e206
+        PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
+        PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
+        PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
+        d += 64;
12e206
+        s += 4;
12e206
+    }
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 16 color mode
12e206
+ */
12e206
+static void vga_draw_line4(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t plane_mask, data, v, *palette;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        data = ((uint32_t *)s)[0];
12e206
+        data &= plane_mask;
12e206
+        v = expand4[GET_PLANE(data, 0)];
12e206
+        v |= expand4[GET_PLANE(data, 1)] << 1;
12e206
+        v |= expand4[GET_PLANE(data, 2)] << 2;
12e206
+        v |= expand4[GET_PLANE(data, 3)] << 3;
12e206
+        ((uint32_t *)d)[0] = palette[v >> 28];
12e206
+        ((uint32_t *)d)[1] = palette[(v >> 24) & 0xf];
12e206
+        ((uint32_t *)d)[2] = palette[(v >> 20) & 0xf];
12e206
+        ((uint32_t *)d)[3] = palette[(v >> 16) & 0xf];
12e206
+        ((uint32_t *)d)[4] = palette[(v >> 12) & 0xf];
12e206
+        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
+        d += 32;
12e206
+        s += 4;
12e206
+    }
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 16 color mode, dup2 horizontal
12e206
+ */
12e206
+static void vga_draw_line4d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t plane_mask, data, v, *palette;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        data = ((uint32_t *)s)[0];
12e206
+        data &= plane_mask;
12e206
+        v = expand4[GET_PLANE(data, 0)];
12e206
+        v |= expand4[GET_PLANE(data, 1)] << 1;
12e206
+        v |= expand4[GET_PLANE(data, 2)] << 2;
12e206
+        v |= expand4[GET_PLANE(data, 3)] << 3;
12e206
+        PUT_PIXEL2(d, 0, palette[v >> 28]);
12e206
+        PUT_PIXEL2(d, 1, palette[(v >> 24) & 0xf]);
12e206
+        PUT_PIXEL2(d, 2, palette[(v >> 20) & 0xf]);
12e206
+        PUT_PIXEL2(d, 3, palette[(v >> 16) & 0xf]);
12e206
+        PUT_PIXEL2(d, 4, palette[(v >> 12) & 0xf]);
12e206
+        PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
+        PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
+        PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
+        d += 64;
12e206
+        s += 4;
12e206
+    }
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 256 color mode, double pixels
12e206
+ *
12e206
+ * XXX: add plane_mask support (never used in standard VGA modes)
12e206
+ */
12e206
+static void vga_draw_line8d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t *palette;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        PUT_PIXEL2(d, 0, palette[s[0]]);
12e206
+        PUT_PIXEL2(d, 1, palette[s[1]]);
12e206
+        PUT_PIXEL2(d, 2, palette[s[2]]);
12e206
+        PUT_PIXEL2(d, 3, palette[s[3]]);
12e206
+        d += 32;
12e206
+        s += 4;
12e206
+    }
12e206
+}
12e206
+
12e206
+/*
12e206
+ * standard 256 color mode
12e206
+ *
12e206
+ * XXX: add plane_mask support (never used in standard VGA modes)
12e206
+ */
12e206
+static void vga_draw_line8(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
+{
12e206
+    uint32_t *palette;
12e206
+    int x;
12e206
+
12e206
+    palette = s1->last_palette;
12e206
+    width >>= 3;
12e206
+    for(x = 0; x < width; x++) {
12e206
+        ((uint32_t *)d)[0] = palette[s[0]];
12e206
+        ((uint32_t *)d)[1] = palette[s[1]];
12e206
+        ((uint32_t *)d)[2] = palette[s[2]];
12e206
+        ((uint32_t *)d)[3] = palette[s[3]];
12e206
+        ((uint32_t *)d)[4] = palette[s[4]];
12e206
+        ((uint32_t *)d)[5] = palette[s[5]];
12e206
+        ((uint32_t *)d)[6] = palette[s[6]];
12e206
+        ((uint32_t *)d)[7] = palette[s[7]];
12e206
+        d += 32;
12e206
+        s += 8;
12e206
+    }
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 15 bit color
12e206
+ */
12e206
+static void vga_draw_line15_le(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t v, r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        v = lduw_le_p((void *)s);
12e206
+        r = (v >> 7) & 0xf8;
12e206
+        g = (v >> 2) & 0xf8;
12e206
+        b = (v << 3) & 0xf8;
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 2;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+static void vga_draw_line15_be(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t v, r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        v = lduw_be_p((void *)s);
12e206
+        r = (v >> 7) & 0xf8;
12e206
+        g = (v >> 2) & 0xf8;
12e206
+        b = (v << 3) & 0xf8;
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 2;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 16 bit color
12e206
+ */
12e206
+static void vga_draw_line16_le(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t v, r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        v = lduw_le_p((void *)s);
12e206
+        r = (v >> 8) & 0xf8;
12e206
+        g = (v >> 3) & 0xfc;
12e206
+        b = (v << 3) & 0xf8;
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 2;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+static void vga_draw_line16_be(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t v, r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        v = lduw_be_p((void *)s);
12e206
+        r = (v >> 8) & 0xf8;
12e206
+        g = (v >> 3) & 0xfc;
12e206
+        b = (v << 3) & 0xf8;
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 2;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 24 bit color
12e206
+ */
12e206
+static void vga_draw_line24_le(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        b = s[0];
12e206
+        g = s[1];
12e206
+        r = s[2];
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 3;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+static void vga_draw_line24_be(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+    int w;
12e206
+    uint32_t r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        r = s[0];
12e206
+        g = s[1];
12e206
+        b = s[2];
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 3;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+}
12e206
+
12e206
+/*
12e206
+ * 32 bit color
12e206
+ */
12e206
+static void vga_draw_line32_le(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+#ifndef HOST_WORDS_BIGENDIAN
12e206
+    memcpy(d, s, width * 4);
12e206
+#else
12e206
+    int w;
12e206
+    uint32_t r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        b = s[0];
12e206
+        g = s[1];
12e206
+        r = s[2];
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 4;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+#endif
12e206
+}
12e206
+
12e206
+static void vga_draw_line32_be(VGACommonState *s1, uint8_t *d,
12e206
+                               const uint8_t *s, int width)
12e206
+{
12e206
+#ifdef HOST_WORDS_BIGENDIAN
12e206
+    memcpy(d, s, width * 4);
12e206
+#else
12e206
+    int w;
12e206
+    uint32_t r, g, b;
12e206
+
12e206
+    w = width;
12e206
+    do {
12e206
+        r = s[1];
12e206
+        g = s[2];
12e206
+        b = s[3];
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
+        s += 4;
12e206
+        d += 4;
12e206
+    } while (--w != 0);
12e206
+#endif
12e206
+}
12e206
diff --git a/hw/display/vga.c b/hw/display/vga.c
12e206
index 50999ee..4618823 100644
12e206
--- a/hw/display/vga.c
12e206
+++ b/hw/display/vga.c
12e206
@@ -1047,7 +1047,7 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
12e206
 typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d,
12e206
                                 const uint8_t *s, int width);
12e206
 
12e206
-#include "vga_template.h"
12e206
+#include "vga-helpers.h"
12e206
 
12e206
 static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b)
12e206
 {
12e206
diff --git a/hw/display/vga_template.h b/hw/display/vga_template.h
12e206
deleted file mode 100644
12e206
index 94f6de2..0000000
12e206
--- a/hw/display/vga_template.h
12e206
+++ /dev/null
12e206
@@ -1,439 +0,0 @@
12e206
-/*
12e206
- * QEMU VGA Emulator templates
12e206
- *
12e206
- * Copyright (c) 2003 Fabrice Bellard
12e206
- *
12e206
- * Permission is hereby granted, free of charge, to any person obtaining a copy
12e206
- * of this software and associated documentation files (the "Software"), to deal
12e206
- * in the Software without restriction, including without limitation the rights
12e206
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12e206
- * copies of the Software, and to permit persons to whom the Software is
12e206
- * furnished to do so, subject to the following conditions:
12e206
- *
12e206
- * The above copyright notice and this permission notice shall be included in
12e206
- * all copies or substantial portions of the Software.
12e206
- *
12e206
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12e206
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12e206
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12e206
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12e206
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12e206
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
12e206
- * THE SOFTWARE.
12e206
- */
12e206
-
12e206
-static inline void vga_draw_glyph_line(uint8_t *d, uint32_t font_data,
12e206
-                                       uint32_t xorcol, uint32_t bgcol)
12e206
-{
12e206
-        ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
12e206
-}
12e206
-
12e206
-static void vga_draw_glyph8(uint8_t *d, int linesize,
12e206
-                            const uint8_t *font_ptr, int h,
12e206
-                            uint32_t fgcol, uint32_t bgcol)
12e206
-{
12e206
-    uint32_t font_data, xorcol;
12e206
-
12e206
-    xorcol = bgcol ^ fgcol;
12e206
-    do {
12e206
-        font_data = font_ptr[0];
12e206
-        vga_draw_glyph_line(d, font_data, xorcol, bgcol);
12e206
-        font_ptr += 4;
12e206
-        d += linesize;
12e206
-    } while (--h);
12e206
-}
12e206
-
12e206
-static void vga_draw_glyph16(uint8_t *d, int linesize,
12e206
-                                          const uint8_t *font_ptr, int h,
12e206
-                                          uint32_t fgcol, uint32_t bgcol)
12e206
-{
12e206
-    uint32_t font_data, xorcol;
12e206
-
12e206
-    xorcol = bgcol ^ fgcol;
12e206
-    do {
12e206
-        font_data = font_ptr[0];
12e206
-        vga_draw_glyph_line(d, expand4to8[font_data >> 4],
12e206
-                            xorcol, bgcol);
12e206
-        vga_draw_glyph_line(d + 32, expand4to8[font_data & 0x0f],
12e206
-                            xorcol, bgcol);
12e206
-        font_ptr += 4;
12e206
-        d += linesize;
12e206
-    } while (--h);
12e206
-}
12e206
-
12e206
-static void vga_draw_glyph9(uint8_t *d, int linesize,
12e206
-                            const uint8_t *font_ptr, int h,
12e206
-                            uint32_t fgcol, uint32_t bgcol, int dup9)
12e206
-{
12e206
-    uint32_t font_data, xorcol, v;
12e206
-
12e206
-    xorcol = bgcol ^ fgcol;
12e206
-    do {
12e206
-        font_data = font_ptr[0];
12e206
-        ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
12e206
-        v = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[7] = v;
12e206
-        if (dup9)
12e206
-            ((uint32_t *)d)[8] = v;
12e206
-        else
12e206
-            ((uint32_t *)d)[8] = bgcol;
12e206
-        font_ptr += 4;
12e206
-        d += linesize;
12e206
-    } while (--h);
12e206
-}
12e206
-
12e206
-/*
12e206
- * 4 color mode
12e206
- */
12e206
-static void vga_draw_line2(VGACommonState *s1, uint8_t *d,
12e206
-                           const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t plane_mask, *palette, data, v;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        data = ((uint32_t *)s)[0];
12e206
-        data &= plane_mask;
12e206
-        v = expand2[GET_PLANE(data, 0)];
12e206
-        v |= expand2[GET_PLANE(data, 2)] << 2;
12e206
-        ((uint32_t *)d)[0] = palette[v >> 12];
12e206
-        ((uint32_t *)d)[1] = palette[(v >> 8) & 0xf];
12e206
-        ((uint32_t *)d)[2] = palette[(v >> 4) & 0xf];
12e206
-        ((uint32_t *)d)[3] = palette[(v >> 0) & 0xf];
12e206
-
12e206
-        v = expand2[GET_PLANE(data, 1)];
12e206
-        v |= expand2[GET_PLANE(data, 3)] << 2;
12e206
-        ((uint32_t *)d)[4] = palette[v >> 12];
12e206
-        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
-        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
-        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
-        d += 32;
12e206
-        s += 4;
12e206
-    }
12e206
-}
12e206
-
12e206
-#define PUT_PIXEL2(d, n, v) \
12e206
-((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v)
12e206
-
12e206
-/*
12e206
- * 4 color mode, dup2 horizontal
12e206
- */
12e206
-static void vga_draw_line2d2(VGACommonState *s1, uint8_t *d,
12e206
-                             const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t plane_mask, *palette, data, v;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        data = ((uint32_t *)s)[0];
12e206
-        data &= plane_mask;
12e206
-        v = expand2[GET_PLANE(data, 0)];
12e206
-        v |= expand2[GET_PLANE(data, 2)] << 2;
12e206
-        PUT_PIXEL2(d, 0, palette[v >> 12]);
12e206
-        PUT_PIXEL2(d, 1, palette[(v >> 8) & 0xf]);
12e206
-        PUT_PIXEL2(d, 2, palette[(v >> 4) & 0xf]);
12e206
-        PUT_PIXEL2(d, 3, palette[(v >> 0) & 0xf]);
12e206
-
12e206
-        v = expand2[GET_PLANE(data, 1)];
12e206
-        v |= expand2[GET_PLANE(data, 3)] << 2;
12e206
-        PUT_PIXEL2(d, 4, palette[v >> 12]);
12e206
-        PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
-        PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
-        PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
-        d += 64;
12e206
-        s += 4;
12e206
-    }
12e206
-}
12e206
-
12e206
-/*
12e206
- * 16 color mode
12e206
- */
12e206
-static void vga_draw_line4(VGACommonState *s1, uint8_t *d,
12e206
-                           const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t plane_mask, data, v, *palette;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        data = ((uint32_t *)s)[0];
12e206
-        data &= plane_mask;
12e206
-        v = expand4[GET_PLANE(data, 0)];
12e206
-        v |= expand4[GET_PLANE(data, 1)] << 1;
12e206
-        v |= expand4[GET_PLANE(data, 2)] << 2;
12e206
-        v |= expand4[GET_PLANE(data, 3)] << 3;
12e206
-        ((uint32_t *)d)[0] = palette[v >> 28];
12e206
-        ((uint32_t *)d)[1] = palette[(v >> 24) & 0xf];
12e206
-        ((uint32_t *)d)[2] = palette[(v >> 20) & 0xf];
12e206
-        ((uint32_t *)d)[3] = palette[(v >> 16) & 0xf];
12e206
-        ((uint32_t *)d)[4] = palette[(v >> 12) & 0xf];
12e206
-        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
-        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
-        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
-        d += 32;
12e206
-        s += 4;
12e206
-    }
12e206
-}
12e206
-
12e206
-/*
12e206
- * 16 color mode, dup2 horizontal
12e206
- */
12e206
-static void vga_draw_line4d2(VGACommonState *s1, uint8_t *d,
12e206
-                             const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t plane_mask, data, v, *palette;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        data = ((uint32_t *)s)[0];
12e206
-        data &= plane_mask;
12e206
-        v = expand4[GET_PLANE(data, 0)];
12e206
-        v |= expand4[GET_PLANE(data, 1)] << 1;
12e206
-        v |= expand4[GET_PLANE(data, 2)] << 2;
12e206
-        v |= expand4[GET_PLANE(data, 3)] << 3;
12e206
-        PUT_PIXEL2(d, 0, palette[v >> 28]);
12e206
-        PUT_PIXEL2(d, 1, palette[(v >> 24) & 0xf]);
12e206
-        PUT_PIXEL2(d, 2, palette[(v >> 20) & 0xf]);
12e206
-        PUT_PIXEL2(d, 3, palette[(v >> 16) & 0xf]);
12e206
-        PUT_PIXEL2(d, 4, palette[(v >> 12) & 0xf]);
12e206
-        PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
-        PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
-        PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
-        d += 64;
12e206
-        s += 4;
12e206
-    }
12e206
-}
12e206
-
12e206
-/*
12e206
- * 256 color mode, double pixels
12e206
- *
12e206
- * XXX: add plane_mask support (never used in standard VGA modes)
12e206
- */
12e206
-static void vga_draw_line8d2(VGACommonState *s1, uint8_t *d,
12e206
-                             const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t *palette;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        PUT_PIXEL2(d, 0, palette[s[0]]);
12e206
-        PUT_PIXEL2(d, 1, palette[s[1]]);
12e206
-        PUT_PIXEL2(d, 2, palette[s[2]]);
12e206
-        PUT_PIXEL2(d, 3, palette[s[3]]);
12e206
-        d += 32;
12e206
-        s += 4;
12e206
-    }
12e206
-}
12e206
-
12e206
-/*
12e206
- * standard 256 color mode
12e206
- *
12e206
- * XXX: add plane_mask support (never used in standard VGA modes)
12e206
- */
12e206
-static void vga_draw_line8(VGACommonState *s1, uint8_t *d,
12e206
-                           const uint8_t *s, int width)
12e206
-{
12e206
-    uint32_t *palette;
12e206
-    int x;
12e206
-
12e206
-    palette = s1->last_palette;
12e206
-    width >>= 3;
12e206
-    for(x = 0; x < width; x++) {
12e206
-        ((uint32_t *)d)[0] = palette[s[0]];
12e206
-        ((uint32_t *)d)[1] = palette[s[1]];
12e206
-        ((uint32_t *)d)[2] = palette[s[2]];
12e206
-        ((uint32_t *)d)[3] = palette[s[3]];
12e206
-        ((uint32_t *)d)[4] = palette[s[4]];
12e206
-        ((uint32_t *)d)[5] = palette[s[5]];
12e206
-        ((uint32_t *)d)[6] = palette[s[6]];
12e206
-        ((uint32_t *)d)[7] = palette[s[7]];
12e206
-        d += 32;
12e206
-        s += 8;
12e206
-    }
12e206
-}
12e206
-
12e206
-/*
12e206
- * 15 bit color
12e206
- */
12e206
-static void vga_draw_line15_le(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t v, r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        v = lduw_le_p((void *)s);
12e206
-        r = (v >> 7) & 0xf8;
12e206
-        g = (v >> 2) & 0xf8;
12e206
-        b = (v << 3) & 0xf8;
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 2;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-static void vga_draw_line15_be(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t v, r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        v = lduw_be_p((void *)s);
12e206
-        r = (v >> 7) & 0xf8;
12e206
-        g = (v >> 2) & 0xf8;
12e206
-        b = (v << 3) & 0xf8;
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 2;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-/*
12e206
- * 16 bit color
12e206
- */
12e206
-static void vga_draw_line16_le(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t v, r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        v = lduw_le_p((void *)s);
12e206
-        r = (v >> 8) & 0xf8;
12e206
-        g = (v >> 3) & 0xfc;
12e206
-        b = (v << 3) & 0xf8;
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 2;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-static void vga_draw_line16_be(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t v, r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        v = lduw_be_p((void *)s);
12e206
-        r = (v >> 8) & 0xf8;
12e206
-        g = (v >> 3) & 0xfc;
12e206
-        b = (v << 3) & 0xf8;
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 2;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-/*
12e206
- * 24 bit color
12e206
- */
12e206
-static void vga_draw_line24_le(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        b = s[0];
12e206
-        g = s[1];
12e206
-        r = s[2];
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 3;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-static void vga_draw_line24_be(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-    int w;
12e206
-    uint32_t r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        r = s[0];
12e206
-        g = s[1];
12e206
-        b = s[2];
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 3;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-}
12e206
-
12e206
-/*
12e206
- * 32 bit color
12e206
- */
12e206
-static void vga_draw_line32_le(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-#ifndef HOST_WORDS_BIGENDIAN
12e206
-    memcpy(d, s, width * 4);
12e206
-#else
12e206
-    int w;
12e206
-    uint32_t r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        b = s[0];
12e206
-        g = s[1];
12e206
-        r = s[2];
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 4;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-#endif
12e206
-}
12e206
-
12e206
-static void vga_draw_line32_be(VGACommonState *s1, uint8_t *d,
12e206
-                               const uint8_t *s, int width)
12e206
-{
12e206
-#ifdef HOST_WORDS_BIGENDIAN
12e206
-    memcpy(d, s, width * 4);
12e206
-#else
12e206
-    int w;
12e206
-    uint32_t r, g, b;
12e206
-
12e206
-    w = width;
12e206
-    do {
12e206
-        r = s[1];
12e206
-        g = s[2];
12e206
-        b = s[3];
12e206
-        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
-        s += 4;
12e206
-        d += 4;
12e206
-    } while (--w != 0);
12e206
-#endif
12e206
-}
12e206
-- 
12e206
1.8.3.1
12e206