From patchwork Wed Jan 25 18:59:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 137836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2CEF3B6F7E for ; Thu, 26 Jan 2012 06:15:33 +1100 (EST) Received: from localhost ([::1]:48441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq84N-00013D-MI for incoming@patchwork.ozlabs.org; Wed, 25 Jan 2012 13:59:43 -0500 Received: from eggs.gnu.org ([140.186.70.92]:32872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq84E-00011n-Gu for qemu-devel@nongnu.org; Wed, 25 Jan 2012 13:59:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq84C-00087u-9O for qemu-devel@nongnu.org; Wed, 25 Jan 2012 13:59:34 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:57254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq84B-00087o-Lm for qemu-devel@nongnu.org; Wed, 25 Jan 2012 13:59:32 -0500 Received: by iahk25 with SMTP id k25so6850244iah.4 for ; Wed, 25 Jan 2012 10:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=RmdFscsIzvbf6XG3VPch68QNjdetXFrqY9TQCvlchKw=; b=N4Rvq4X1mzu7iJETEL/IoGSPWnkWzx+1yKAiDwiySWbnuRhKiRiJVcxhkXWeu3Iswu A6DLtW/aD4PkyLyl6PlkKIuaEmqsKsATaICuPWZ370SIPdft5IZbMFn4CLT7x2yXqwzY RqVFw/nzSlmpRvRCfuc6jH4scURJ0/Io18kso= Received: by 10.42.144.2 with SMTP id z2mr2722522icu.57.1327517971176; Wed, 25 Jan 2012 10:59:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.193.229 with HTTP; Wed, 25 Jan 2012 10:59:10 -0800 (PST) From: Blue Swirl Date: Wed, 25 Jan 2012 18:59:10 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.173 Subject: [Qemu-devel] [PATCH 2/3] vga: move Cirrus VGA template to its own file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Standard VGA does not use vga_draw_cursor_line_* functions. Move the template to cirrus_vga_template.h. Signed-off-by: Blue Swirl --- hw/cirrus_vga.c | 9 ++++ hw/cirrus_vga_template.h | 102 ++++++++++++++++++++++++++++++++++++++++++++++ hw/vga_int.h | 13 ------ hw/vga_template.h | 66 ----------------------------- 4 files changed, 111 insertions(+), 79 deletions(-) create mode 100644 hw/cirrus_vga_template.h From 1d8b648fe8b8022ddf2968ff081566494e865249 Mon Sep 17 00:00:00 2001 Message-Id: <1d8b648fe8b8022ddf2968ff081566494e865249.1327517853.git.blauwirbel@gmail.com> In-Reply-To: <8c140f88d10a2220a699e6c2e4df5e290a5546cc.1327517853.git.blauwirbel@gmail.com> References: <8c140f88d10a2220a699e6c2e4df5e290a5546cc.1327517853.git.blauwirbel@gmail.com> From: Blue Swirl Date: Wed, 25 Jan 2012 16:10:44 +0000 Subject: [PATCH 2/3] vga: move Cirrus VGA template to its own file Standard VGA does not use vga_draw_cursor_line_* functions. Move the template to cirrus_vga_template.h. Signed-off-by: Blue Swirl --- hw/cirrus_vga.c | 9 ++++ hw/cirrus_vga_template.h | 102 ++++++++++++++++++++++++++++++++++++++++++++++ hw/vga_int.h | 13 ------ hw/vga_template.h | 66 ----------------------------- 4 files changed, 111 insertions(+), 79 deletions(-) create mode 100644 hw/cirrus_vga_template.h diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 7ce35ec..f2ab0e0 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -2164,6 +2164,15 @@ static void cirrus_cursor_invalidate(VGACommonState *s1) } } +#define DEPTH 8 +#include "cirrus_vga_template.h" + +#define DEPTH 16 +#include "cirrus_vga_template.h" + +#define DEPTH 32 +#include "cirrus_vga_template.h" + static void cirrus_cursor_draw_line(VGACommonState *s1, uint8_t *d1, int scr_y) { CirrusVGAState *s = container_of(s1, CirrusVGAState, vga); diff --git a/hw/cirrus_vga_template.h b/hw/cirrus_vga_template.h new file mode 100644 index 0000000..3b28280 --- /dev/null +++ b/hw/cirrus_vga_template.h @@ -0,0 +1,102 @@ +/* + * QEMU Cirrus VGA Emulator templates + * + * Copyright (c) 2003 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#if DEPTH == 8 +#define BPP 1 +#elif DEPTH == 15 || DEPTH == 16 +#define BPP 2 +#elif DEPTH == 32 +#define BPP 4 +#else +#error unsupported depth +#endif + +static void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1, + const uint8_t *src1, + int poffset, int w, + unsigned int color0, + unsigned int color1, + unsigned int color_xor) +{ + const uint8_t *plane0, *plane1; + int x, b0, b1; + uint8_t *d; + + d = d1; + plane0 = src1; + plane1 = src1 + poffset; + for (x = 0; x < w; x++) { + b0 = (plane0[x >> 3] >> (7 - (x & 7))) & 1; + b1 = (plane1[x >> 3] >> (7 - (x & 7))) & 1; +#if DEPTH == 8 + switch (b0 | (b1 << 1)) { + case 0: + break; + case 1: + d[0] ^= color_xor; + break; + case 2: + d[0] = color0; + break; + case 3: + d[0] = color1; + break; + } +#elif DEPTH == 16 + switch (b0 | (b1 << 1)) { + case 0: + break; + case 1: + ((uint16_t *)d)[0] ^= color_xor; + break; + case 2: + ((uint16_t *)d)[0] = color0; + break; + case 3: + ((uint16_t *)d)[0] = color1; + break; + } +#elif DEPTH == 32 + switch (b0 | (b1 << 1)) { + case 0: + break; + case 1: + ((uint32_t *)d)[0] ^= color_xor; + break; + case 2: + ((uint32_t *)d)[0] = color0; + break; + case 3: + ((uint32_t *)d)[0] = color1; + break; + } +#else +#error unsupported depth +#endif + d += BPP; + } +} + +#undef DEPTH +#undef BPP diff --git a/hw/vga_int.h b/hw/vga_int.h index c1e700f..f755582 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -205,19 +205,6 @@ void vga_mem_writeb(VGACommonState *s, target_phys_addr_t addr, uint32_t val); void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2); int ppm_save(const char *filename, struct DisplaySurface *ds); -void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, - int poffset, int w, - unsigned int color0, unsigned int color1, - unsigned int color_xor); -void vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1, - int poffset, int w, - unsigned int color0, unsigned int color1, - unsigned int color_xor); -void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1, - int poffset, int w, - unsigned int color0, unsigned int color1, - unsigned int color_xor); - int vga_ioport_invalid(VGACommonState *s, uint32_t addr); void vga_init_vbe(VGACommonState *s, MemoryRegion *address_space); diff --git a/hw/vga_template.h b/hw/vga_template.h index 681425f..7150573 100644 --- a/hw/vga_template.h +++ b/hw/vga_template.h @@ -340,72 +340,6 @@ static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d, } } -void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1, - const uint8_t *src1, - int poffset, int w, - unsigned int color0, - unsigned int color1, - unsigned int color_xor) -{ - const uint8_t *plane0, *plane1; - int x, b0, b1; - uint8_t *d; - - d = d1; - plane0 = src1; - plane1 = src1 + poffset; - for(x = 0; x < w; x++) { - b0 = (plane0[x >> 3] >> (7 - (x & 7))) & 1; - b1 = (plane1[x >> 3] >> (7 - (x & 7))) & 1; -#if DEPTH == 8 - switch(b0 | (b1 << 1)) { - case 0: - break; - case 1: - d[0] ^= color_xor; - break; - case 2: - d[0] = color0; - break; - case 3: - d[0] = color1; - break; - } -#elif DEPTH == 16 - switch(b0 | (b1 << 1)) { - case 0: - break; - case 1: - ((uint16_t *)d)[0] ^= color_xor; - break; - case 2: - ((uint16_t *)d)[0] = color0; - break; - case 3: - ((uint16_t *)d)[0] = color1; - break; - } -#elif DEPTH == 32 - switch(b0 | (b1 << 1)) { - case 0: - break; - case 1: - ((uint32_t *)d)[0] ^= color_xor; - break; - case 2: - ((uint32_t *)d)[0] = color0; - break; - case 3: - ((uint32_t *)d)[0] = color1; - break; - } -#else -#error unsupported depth -#endif - d += BPP; - } -} - #endif /* DEPTH != 15 */ -- 1.7.2.5