dev: Using Configurable image writer in HDLcd
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Thu, 28 Sep 2017 10:50:07 +0000 (11:50 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 31 Oct 2017 11:17:29 +0000 (11:17 +0000)
The fixed image writer (which was dumping .bmp images only) has been
replaced by the configurable one in HDLcd device.  Default format is
Auto, which gives gem5 the freedom to choose the format it prefers.

Change-Id: I0643266556bb10b43cdebd628f6daa2cd5e105dd
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/5183
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/dev/arm/RealView.py
src/dev/arm/hdlcd.cc
src/dev/arm/hdlcd.hh

index 51aa1cf3c0d9fc815c93f4eb73964d934a930e1b..08145bf661d20151fe790f1ee9d1686ead5a48e0 100644 (file)
@@ -56,6 +56,7 @@ from Gic import *
 from EnergyCtrl import EnergyCtrl
 from ClockDomain import SrcClockDomain
 from SubSystem import SubSystem
+from Graphics import ImageFormat
 
 # Platforms with KVM support should generally use in-kernel GIC
 # emulation. Use a GIC model that automatically switches between
@@ -298,7 +299,10 @@ class HDLcd(AmbaDmaDevice):
                                     "selector order in some kernels")
     workaround_dma_line_count = Param.Bool(True, "Workaround incorrect "
                                            "DMA line count (off by 1)")
-    enable_capture = Param.Bool(True, "capture frame to system.framebuffer.bmp")
+    enable_capture = Param.Bool(True, "capture frame to "
+                                      "system.framebuffer.{extension}")
+    frame_format = Param.ImageFormat("Auto",
+                                     "image format of the captured frame")
 
     pixel_buffer_size = Param.MemorySize32("2kB", "Size of address range")
 
index 98f2a3d44c5708f71e80409f863fa90aa0c9c9c8..20dc7d44ef4a75a80bba2b50bf09efeb0ad19565 100644 (file)
@@ -47,6 +47,7 @@
 #include "debug/HDLcd.hh"
 #include "dev/arm/amba_device.hh"
 #include "dev/arm/base_gic.hh"
+#include "enums/ImageFormat.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
 #include "params/HDLcd.hh"
@@ -85,11 +86,13 @@ HDLcd::HDLcd(const HDLcdParams *p)
 
       virtRefreshEvent([this]{ virtRefresh(); }, name()),
       // Other
-      bmp(&pixelPump.fb), pic(NULL), conv(PixelConverter::rgba8888_le),
+      imgFormat(p->frame_format), pic(NULL), conv(PixelConverter::rgba8888_le),
       pixelPump(*this, *p->pxl_clk, p->pixel_chunk)
 {
     if (vnc)
         vnc->setFrameBuffer(&pixelPump.fb);
+
+    imgWriter = createImgWriter(imgFormat, &pixelPump.fb);
 }
 
 HDLcd::~HDLcd()
@@ -572,13 +575,14 @@ HDLcd::pxlFrameDone()
     if (enableCapture) {
         if (!pic) {
             pic = simout.create(
-                csprintf("%s.framebuffer.bmp", sys->name()),
+                csprintf("%s.framebuffer.%s",
+                         sys->name(), imgWriter->getImgExtension()),
                 true);
         }
 
         assert(pic);
         pic->stream()->seekp(0);
-        bmp.write(*pic->stream());
+        imgWriter->write(*pic->stream());
     }
 }
 
index dd52e202cfbc6d4b2a0467b1a67ce6c40e4ad906..f737710bdf73f9f3bfc9aeffec9856a279901f84 100644 (file)
@@ -79,8 +79,8 @@
 #include <fstream>
 #include <memory>
 
-#include "base/bmpwriter.hh"
 #include "base/framebuffer.hh"
+#include "base/imgwriter.hh"
 #include "base/output.hh"
 #include "dev/arm/amba_device.hh"
 #include "dev/pixelpump.hh"
@@ -350,7 +350,10 @@ class HDLcd: public AmbaDmaDevice
     EventFunctionWrapper virtRefreshEvent;
 
     /** Helper to write out bitmaps */
-    BmpWriter bmp;
+    std::unique_ptr<ImgWriter> imgWriter;
+
+    /** Image Format */
+    Enums::ImageFormat imgFormat;
 
     /** Picture of what the current frame buffer looks like */
     OutputStream *pic;