* Re: [Qemu-devel] [PATCH] screendump + vexpress: screendump for pl110 not implemented
2011-11-09 12:42 [Qemu-devel] [PATCH] screendump + vexpress: screendump for pl110 not implemented Quentin Deldycke
@ 2011-11-09 14:04 ` Quentin Deldycke
2011-11-09 14:15 ` Paul Brook
0 siblings, 1 reply; 3+ messages in thread
From: Quentin Deldycke @ 2011-11-09 14:04 UTC (permalink / raw)
To: qemu-devel, paul
[-- Attachment #1: Type: text/plain, Size: 14312 bytes --]
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 <quentindeldycke@gmail.com>
---
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(-)
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);
void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
int poffset, int w,
--
1.7.7.2
On 9 November 2011 13:42, Quentin Deldycke <quentindeldycke@gmail.com>wrote:
> I usually use qemu-system-arm only binary, and use the vexpress board.
>
> Screendump wasn't implemented for the pl110 lcd driver of vexpress board.
> So I implemented this. I simply make a call to ppm_save. It is simple, and it works.
>
> The bad point is that in qemu, actually, there is 2 functions ppm_save. One on vga.c,
> one on omap_lcdc.c. Both are different and their behaviour is not the same. I used in
> my patch the one from vga.c.
>
> After i tested this stuff, i didn't wanted to have a double of the same function in 2 files.
>
> I spoke fastly with Stefan on IRC, and we think the best solution is to put the ppm_save
> function into a common file. We used for this console.c. To avoid compilation error on
> omap_ldlc file, i renamed this particular ppm_save to omap_ppm_save.
>
> Regards,
> Quentin
>
> Signed-off-by: Quentin Deldycke <quentindeldycke@gmail.com>
> ---
> console.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
>
> console.h | 2 ++
> hw/omap_lcdc.c | 4 ++--
> hw/pl110.c | 12 +++++++++++-
> hw/vga.c | 45 ---------------------------------------------
> hw/vga_int.h | 1 -
> 6 files changed, 61 insertions(+), 50 deletions(-)
>
> diff --git a/console.c b/console.c
> index f6fe441..de41bcc 100644
> --- a/console.c
> +++ b/console.c
> @@ -1,4 +1,4 @@
> -/*
> +s/*
> * QEMU graphical console
> *
> * Copyright (c) 2004 Fabrice Bellard
>
> @@ -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);
>
> void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
> int poffset, int w,
> --
> 1.7.7.2
>
>
>
[-- Attachment #2: Type: text/html, Size: 16393 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread