diff mbox

screendump + vexpress: screendump for pl110 not implemented

Message ID CAHYLta4H0M_SvreBnX2k4USSVcOKmS70SAofhkFfBBX6BLLc=A@mail.gmail.com
State New
Headers show

Commit Message

Quentin Deldycke Nov. 9, 2011, 2:04 p.m. UTC
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,

Comments

Paul Brook Nov. 9, 2011, 2:15 p.m. UTC | #1
> 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.

Why do we need any device specfic code for this?
Surely the console layer is the only thing that needs to care, and should just 
make the appropriate set of invalidate/updage calls.

Paul
diff mbox

Patch

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);