From 8a65ee328ef81ebc77730a2cc3b2bc756268874e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Jun 2019 02:34:29 +0300 Subject: utils: Add a dump_framebuffer() method 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 --- kms++util/inc/kms++util/kms++util.h | 2 ++ kms++util/src/drawing.cpp | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'kms++util') diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h index 8fc6c8b..58ad7e6 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 3752f94..24a9954 100644 --- a/kms++util/src/drawing.cpp +++ b/kms++util/src/drawing.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -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)); +} + } -- cgit v1.2.3