Re: [kmsxx] [PATCH 2/2] utils: Add a dump_framebuffer() method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Laurent,

On 24/08/2020 01:11, Laurent Pinchart wrote:
> 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@xxxxxxxxxxxxxxxx>
> ---
>  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));
> +}
> +

Well, my first thought was that it's c++, we should use ostream or such. I don't know how that plays
with pybind11, though.

I guess on the py side you need to use os.open & co here, not the normal file operations? Or I guess
you can get the fd with fileno(), but it's still "odd" to do it in python. So using fd here is kind
of not really c++, and not really python.

That said, it's simple and works, so maybe it's fine until someone wants to put more effort to it.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux