From patchwork Wed Nov 9 14:04:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Deldycke X-Patchwork-Id: 124555 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 D96AB1007D9 for ; Thu, 10 Nov 2011 01:04:36 +1100 (EST) Received: from localhost ([::1]:35723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8lS-0001CW-ND for incoming@patchwork.ozlabs.org; Wed, 09 Nov 2011 09:04:30 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8lA-0001CF-Ae for qemu-devel@nongnu.org; Wed, 09 Nov 2011 09:04:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RO8l7-0004sP-Ei for qemu-devel@nongnu.org; Wed, 09 Nov 2011 09:04:12 -0500 Received: from mail-yx0-f173.google.com ([209.85.213.173]:51727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8l6-0004sH-TV for qemu-devel@nongnu.org; Wed, 09 Nov 2011 09:04:09 -0500 Received: by yenr8 with SMTP id r8so791890yen.4 for ; Wed, 09 Nov 2011 06:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8/FVYQ4wAk5YX2GGhIowOPCZjnh/Mufgtb8bo7wLkRw=; b=ChOyPb5l/+27IEcv8+rBKyrEzm3Bl4rkqj+l4mVJaGjM2/HOD9yJ8NPzbVefbmbii4 A1vQkeLPJoOVGEuNjZ9/sUoXZs63v3PGpguvpbnGa/MrzppwG/ZZ4tm/vVG41Pvr6o8n aSsOvZi/EBh++l8IDP621YnB5ByT3HW9aQkV8= MIME-Version: 1.0 Received: by 10.146.173.19 with SMTP id v19mr567282yae.4.1320847447571; Wed, 09 Nov 2011 06:04:07 -0800 (PST) Received: by 10.147.114.11 with HTTP; Wed, 9 Nov 2011 06:04:07 -0800 (PST) In-Reply-To: References: Date: Wed, 9 Nov 2011 15:04:07 +0100 Message-ID: From: Quentin Deldycke To: qemu-devel , paul@codesourcery.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.173 Subject: Re: [Qemu-devel] [PATCH] screendump + vexpress: screendump for pl110 not implemented 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 Just realised i made the patch a bit too fast and added a caracter on top of console.c when reviewing code... here is the correct patch. Regards, Quentin Signed-off-by: Quentin Deldycke --- console.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ console.h | 2 ++ hw/omap_lcdc.c | 4 ++-- hw/pl110.c | 12 +++++++++++- hw/vga.c | 45 --------------------------------------------- hw/vga_int.h | 1 - 6 files changed, 60 insertions(+), 49 deletions(-) void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, int poffset, int w, diff --git a/console.c b/console.c index f6fe441..f06061d 100644 --- a/console.c +++ b/console.c @@ -173,6 +173,51 @@ void vga_hw_invalidate(void) active_console->hw_invalidate(active_console->hw); } +int ppm_save(const char *filename, struct DisplaySurface *ds) +{ + FILE *f; + uint8_t *d, *d1; + uint32_t v; + int y, x; + uint8_t r, g, b; + int ret; + char *linebuf, *pbuf; + + f = fopen(filename, "wb"); + if (!f) + return -1; + fprintf(f, "P6\n%d %d\n%d\n", + ds->width, ds->height, 255); + linebuf = g_malloc(ds->width * 3); + d1 = ds->data; + for (y = 0; y < ds->height; y++) { + d = d1; + pbuf = linebuf; + for (x = 0; x < ds->width; x++) { + if (ds->pf.bits_per_pixel == 32) + v = *(uint32_t *)d; + else + v = (uint32_t) (*(uint16_t *)d); + r = ((v >> ds->pf.rshift) & ds->pf.rmax) * 256 / + (ds->pf.rmax + 1); + g = ((v >> ds->pf.gshift) & ds->pf.gmax) * 256 / + (ds->pf.gmax + 1); + b = ((v >> ds->pf.bshift) & ds->pf.bmax) * 256 / + (ds->pf.bmax + 1); + *pbuf++ = r; + *pbuf++ = g; + *pbuf++ = b; + d += ds->pf.bytes_per_pixel; + } + d1 += ds->linesize; + ret = fwrite(linebuf, 1, pbuf - linebuf, f); + (void)ret; + } + g_free(linebuf); + fclose(f); + return 0; +} + void vga_hw_screen_dump(const char *filename) { TextConsole *previous_active_console; diff --git a/console.h b/console.h index 6ac4ed3..1308390 100644 --- a/console.h +++ b/console.h @@ -352,6 +352,8 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update, vga_hw_text_update_ptr text_update, void *opaque); +int ppm_save(const char *filename, struct DisplaySurface *ds); + void vga_hw_update(void); void vga_hw_invalidate(void); void vga_hw_screen_dump(const char *filename); diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c index 29e6048..cb148d4 100644 --- a/hw/omap_lcdc.c +++ b/hw/omap_lcdc.c @@ -222,7 +222,7 @@ static void omap_update_display(void *opaque) omap_lcd->invalidate = 0; } -static int ppm_save(const char *filename, uint8_t *data, +static int omap_ppm_save(const char *filename, uint8_t *data, int w, int h, int linesize) { FILE *f; @@ -266,7 +266,7 @@ static void omap_screen_dump(void *opaque, const char *filename) { struct omap_lcd_panel_s *omap_lcd = opaque; omap_update_display(opaque); if (omap_lcd && ds_get_data(omap_lcd->state)) - ppm_save(filename, ds_get_data(omap_lcd->state), + omap_ppm_save(filename, ds_get_data(omap_lcd->state), omap_lcd->width, omap_lcd->height, ds_get_linesize(omap_lcd->state)); } diff --git a/hw/pl110.c b/hw/pl110.c index 4ac710a..48fe73b 100644 --- a/hw/pl110.c +++ b/hw/pl110.c @@ -416,6 +416,15 @@ static void pl110_write(void *opaque, target_phys_addr_t offset, } } +static void pl110_screen_dump(void *opaque, const char *filename) +{ + pl110_state *s = (pl110_state *)opaque; + + pl110_update_display(opaque); + if (s && s->ds && s->ds->surface) + ppm_save(filename, s->ds->surface); +} + static CPUReadMemoryFunc * const pl110_readfn[] = { pl110_read, pl110_read, @@ -447,7 +456,8 @@ static int pl110_init(SysBusDevice *dev) qdev_init_gpio_in(&s->busdev.qdev, pl110_mux_ctrl_set, 1); s->ds = graphic_console_init(pl110_update_display, pl110_invalidate_display, - NULL, NULL, s); + pl110_screen_dump, + NULL, s); return 0; } diff --git a/hw/vga.c b/hw/vga.c index ca79aa1..3c9310a 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -2345,51 +2345,6 @@ static void vga_save_dpy_refresh(DisplayState *s) { } -int ppm_save(const char *filename, struct DisplaySurface *ds) -{ - FILE *f; - uint8_t *d, *d1; - uint32_t v; - int y, x; - uint8_t r, g, b; - int ret; - char *linebuf, *pbuf; - - f = fopen(filename, "wb"); - if (!f) - return -1; - fprintf(f, "P6\n%d %d\n%d\n", - ds->width, ds->height, 255); - linebuf = g_malloc(ds->width * 3); - d1 = ds->data; - for(y = 0; y < ds->height; y++) { - d = d1; - pbuf = linebuf; - for(x = 0; x < ds->width; x++) { - if (ds->pf.bits_per_pixel == 32) - v = *(uint32_t *)d; - else - v = (uint32_t) (*(uint16_t *)d); - r = ((v >> ds->pf.rshift) & ds->pf.rmax) * 256 / - (ds->pf.rmax + 1); - g = ((v >> ds->pf.gshift) & ds->pf.gmax) * 256 / - (ds->pf.gmax + 1); - b = ((v >> ds->pf.bshift) & ds->pf.bmax) * 256 / - (ds->pf.bmax + 1); - *pbuf++ = r; - *pbuf++ = g; - *pbuf++ = b; - d += ds->pf.bytes_per_pixel; - } - d1 += ds->linesize; - ret = fwrite(linebuf, 1, pbuf - linebuf, f); - (void)ret; - } - g_free(linebuf); - fclose(f); - return 0; -} - static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds) { DisplayChangeListener *dcl; diff --git a/hw/vga_int.h b/hw/vga_int.h index c1e700f..2529012 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -203,7 +203,6 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val); uint32_t vga_mem_readb(VGACommonState *s, target_phys_addr_t addr); 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);