@@ -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;
@@ -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);
@@ -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));
}
@@ -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;
}
@@ -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;
@@ -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);
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(-) void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, int poffset, int w,