From patchwork Fri Mar 26 16:06:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 48679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 95C79B7CE7 for ; Sat, 27 Mar 2010 04:26:09 +1100 (EST) Received: from localhost ([127.0.0.1]:34262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NvDHt-0004bq-3C for incoming@patchwork.ozlabs.org; Fri, 26 Mar 2010 13:25:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NvC5Y-0004BP-S4 for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:08:49 -0400 Received: from [140.186.70.92] (port=41652 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NvC5I-0003hG-Ks for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:08:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NvC4J-0006yt-RR for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:08:19 -0400 Received: from afflict.kos.to ([92.243.29.197]:33633) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NvC4F-0006vB-Pz for qemu-devel@nongnu.org; Fri, 26 Mar 2010 12:07:29 -0400 Received: by afflict.kos.to (Postfix, from userid 1000) id 11DF9265C0; Fri, 26 Mar 2010 16:07:22 +0000 (UTC) From: Riku Voipio To: qemu-devel@nongnu.org Date: Fri, 26 Mar 2010 16:06:45 +0000 Message-Id: <74d2cd81de940830b8cc54068584beba00326139.1269617186.git.riku.voipio@nokia.com> X-Mailer: git-send-email 1.6.5 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Riku Voipio , =?UTF-8?q?Juha=20Riihim=C3=A4ki?= Subject: [Qemu-devel] [PATCH 25/48] blizzard: fix for non-32bpp host displays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Riku Voipio Signed-Off-By: Riku Voipio Signed-Off-By: Juha Riihimäki --- hw/blizzard.c | 102 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 53 insertions(+), 49 deletions(-) diff --git a/hw/blizzard.c b/hw/blizzard.c index 7cbb358..d110eec 100644 --- a/hw/blizzard.c +++ b/hw/blizzard.c @@ -71,7 +71,6 @@ typedef struct { uint8_t iformat; uint8_t source; DisplayState *state; - blizzard_fn_t *line_fn_tab[2]; void *fb; uint8_t hssi_config[3]; @@ -117,7 +116,6 @@ typedef struct { uint16_t *ptr; int angle; int pitch; - blizzard_fn_t line_fn; } data; } BlizzardState; @@ -135,6 +133,17 @@ static const int blizzard_iformat_bpp[0x10] = { 0, 0, 0, 0, 0, 0, }; +#define DEPTH 8 +#include "blizzard_template.h" +#define DEPTH 15 +#include "blizzard_template.h" +#define DEPTH 16 +#include "blizzard_template.h" +#define DEPTH 24 +#include "blizzard_template.h" +#define DEPTH 32 +#include "blizzard_template.h" + static inline void blizzard_rgb2yuv(int r, int g, int b, int *y, int *u, int *v) { @@ -149,8 +158,43 @@ static void blizzard_window(BlizzardState *s) int bypp[2]; int bypl[3]; int y; - blizzard_fn_t fn = s->data.line_fn; - + blizzard_fn_t fn = 0; + + /* FIXME: this is a hack - but nseries.c will use this function + * before correct DisplayState is initialized so we need a way to + * avoid drawing something when we actually have no clue about host bpp */ + if (!s->state->listeners) + return; + + switch (ds_get_bits_per_pixel(s->state)) { + case 8: + fn = s->data.angle + ? blizzard_draw_fn_r_8[s->iformat] + : blizzard_draw_fn_8[s->iformat]; + break; + case 15: + fn = s->data.angle + ? blizzard_draw_fn_r_15[s->iformat] + : blizzard_draw_fn_15[s->iformat]; + break; + case 16: + fn = s->data.angle + ? blizzard_draw_fn_r_16[s->iformat] + : blizzard_draw_fn_16[s->iformat]; + break; + case 24: + fn = s->data.angle + ? blizzard_draw_fn_r_24[s->iformat] + : blizzard_draw_fn_24[s->iformat]; + break; + case 32: + fn = s->data.angle + ? blizzard_draw_fn_r_32[s->iformat] + : blizzard_draw_fn_32[s->iformat]; + break; + default: + break; + } if (!fn) return; if (s->mx[0] > s->data.x) @@ -181,7 +225,6 @@ static int blizzard_transfer_setup(BlizzardState *s) return 0; s->data.angle = s->effect & 3; - s->data.line_fn = s->line_fn_tab[!!s->data.angle][s->iformat]; s->data.x = s->ix[0]; s->data.y = s->iy[0]; s->data.dx = s->ix[1] - s->ix[0] + 1; @@ -941,58 +984,19 @@ static void blizzard_screen_dump(void *opaque, const char *filename) { ppm_save(filename, s->state->surface); } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" -#define DEPTH 32 -#include "blizzard_template.h" - void *s1d13745_init(qemu_irq gpio_int) { BlizzardState *s = (BlizzardState *) qemu_mallocz(sizeof(*s)); s->fb = qemu_malloc(0x180000); - + /* Fill the framebuffer with white color here because the corresponding + * code in nseries.c is broken since the DisplayState change in QEMU. + * This is supposedly ok since nseries.c is the only user of blizzard.c */ + memset(s->fb, 0xff, 0x180000); + s->state = graphic_console_init(blizzard_update_display, blizzard_invalidate_display, blizzard_screen_dump, NULL, s); - - switch (ds_get_bits_per_pixel(s->state)) { - case 0: - s->line_fn_tab[0] = s->line_fn_tab[1] = - qemu_mallocz(sizeof(blizzard_fn_t) * 0x10); - break; - case 8: - s->line_fn_tab[0] = blizzard_draw_fn_8; - s->line_fn_tab[1] = blizzard_draw_fn_r_8; - break; - case 15: - s->line_fn_tab[0] = blizzard_draw_fn_15; - s->line_fn_tab[1] = blizzard_draw_fn_r_15; - break; - case 16: - s->line_fn_tab[0] = blizzard_draw_fn_16; - s->line_fn_tab[1] = blizzard_draw_fn_r_16; - break; - case 24: - s->line_fn_tab[0] = blizzard_draw_fn_24; - s->line_fn_tab[1] = blizzard_draw_fn_r_24; - break; - case 32: - s->line_fn_tab[0] = blizzard_draw_fn_32; - s->line_fn_tab[1] = blizzard_draw_fn_r_32; - break; - default: - fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__); - exit(1); - } - blizzard_reset(s); - return s; }