From a5c28bcb2ead34e921617711ebf94ffcb5d72878 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 23 May 2016 09:54:08 +0300 Subject: File/dir renames --- utils/fbtestpat.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 utils/fbtestpat.cpp (limited to 'utils/fbtestpat.cpp') diff --git a/utils/fbtestpat.cpp b/utils/fbtestpat.cpp new file mode 100644 index 0000000..d82f3e4 --- /dev/null +++ b/utils/fbtestpat.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "test.h" +#include "extcpuframebuffer.h" + +using namespace kms; + +int main(int argc, char** argv) +{ + const char* fbdev = "/dev/fb0"; + int r; + + int fd = open(fbdev, O_RDWR); + FAIL_IF(fd < 0, "open %s failed\n", fbdev); + + struct fb_var_screeninfo var; + + r = ioctl(fd, FBIOGET_VSCREENINFO, &var); + FAIL_IF(r, "FBIOGET_VSCREENINFO failed"); + + struct fb_fix_screeninfo fix; + + r = ioctl(fd, FBIOGET_FSCREENINFO, &fix); + FAIL_IF(r, "FBIOGET_FSCREENINFO failed"); + + uint8_t* ptr = (uint8_t*)mmap(NULL, + var.yres_virtual * fix.line_length, + PROT_WRITE | PROT_READ, + MAP_SHARED, fd, 0); + + FAIL_IF(ptr == MAP_FAILED, "mmap failed"); + + ExtCPUFramebuffer buf(var.xres, var.yres_virtual, PixelFormat::XRGB8888, ptr, fix.line_length); + + printf("%s: res %dx%d, virtual %dx%d, line_len %d\n", + fbdev, + var.xres, var.yres, + var.xres_virtual, var.yres_virtual, + fix.line_length); + + draw_test_pattern(buf); + + for (unsigned y = 0; y < var.yres_virtual; ++y) + memcpy(ptr + fix.line_length * y, buf.map(0) + buf.stride(0) * y, buf.stride(0)); + + close(fd); + + return 0; +} -- cgit v1.2.3