All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-renesas-soc@vger.kernel.org
Subject: [kmsxx] [PATCH 2/2] utils: Add a dump_framebuffer() method
Date: Mon, 24 Aug 2020 01:11:52 +0300	[thread overview]
Message-ID: <20200823221152.31978-3-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20200823221152.31978-1-laurent.pinchart@ideasonboard.com>

Add a new method to write the contents of a framebuffer to a file
descriptor. This can be used to capture frames from writeback
connectors.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 kms++util/inc/kms++util/kms++util.h | 2 ++
 kms++util/src/drawing.cpp           | 7 +++++++
 py/pykms/pykmsutil.cpp              | 6 +++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h
index 8fc6c8b81e48..58ad7e6ef39f 100644
--- a/kms++util/inc/kms++util/kms++util.h
+++ b/kms++util/inc/kms++util/kms++util.h
@@ -29,6 +29,8 @@ void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str
 void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width);
 
 void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim);
+
+void dump_framebuffer(IFramebuffer &fb, int fd);
 }
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 3752f94695e0..24a995489a9e 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -1,5 +1,6 @@
 
 #include <cmath>
+#include <unistd.h>
 
 #include <kms++/kms++.h>
 #include <kms++util/kms++util.h>
@@ -569,4 +570,10 @@ void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const string& str, RGB
 		draw_char(buf, (x + 8 * i), y, str[i], color);
 }
 
+void dump_framebuffer(IFramebuffer &fb, int fd)
+{
+	for (unsigned int i = 0; i < fb.num_planes(); ++i)
+		::write(fd, fb.map(i), fb.size(i));
+}
+
 }
diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
index d5d7fde4a4e1..92d8ebc684b9 100644
--- a/py/pykms/pykmsutil.cpp
+++ b/py/pykms/pykmsutil.cpp
@@ -61,5 +61,9 @@ void init_pykmstest(py::module &m)
 		draw_circle(fb, xCenter, yCenter, radius, color);
 	} );
 	m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) {
-		draw_text(fb, x, y, str, color); } );
+		draw_text(fb, x, y, str, color);
+	} );
+	m.def("dump_framebuffer", [](Framebuffer& fb, int fd) {
+		dump_framebuffer(fb, fd);
+	} );
 }
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2020-08-23 22:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-23 22:11 [kmsxx] [PATCH 0/2] Support writeback connectors Laurent Pinchart
2020-08-23 22:11 ` [kmsxx] [PATCH 1/2] card: Add support for " Laurent Pinchart
2020-08-24  6:30   ` Tomi Valkeinen
2020-08-24 14:27     ` Laurent Pinchart
2020-08-24 14:57       ` Tomi Valkeinen
2020-08-23 22:11 ` Laurent Pinchart [this message]
2020-08-24 13:19   ` [kmsxx] [PATCH 2/2] utils: Add a dump_framebuffer() method Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200823221152.31978-3-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.