summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-02-07 10:29:20 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-02-07 10:29:29 +0200
commit06d7074474af00ed4b697318dbc526847744365c (patch)
tree48c95cebe74648ce90cb2ab2f57aaeafa07f4f44 /tests
parent86186b1cbbd531843b13f592924da0e774149f29 (diff)
add fbtestpat
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/fbtestpat.cpp59
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e18081a..181ff78 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -12,3 +12,6 @@ target_link_libraries(kmsview kms++ kmstest ${LIBDRM_LIBRARIES})
add_executable (kmsprint kmsprint.cpp)
target_link_libraries(kmsprint kms++ kmstest ${LIBDRM_LIBRARIES})
+
+add_executable (fbtestpat fbtestpat.cpp)
+target_link_libraries(fbtestpat kmstest)
diff --git a/tests/fbtestpat.cpp b/tests/fbtestpat.cpp
new file mode 100644
index 0000000..9607757
--- /dev/null
+++ b/tests/fbtestpat.cpp
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include <linux/fb.h>
+
+#include "test.h"
+#include "mappedbuffer.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");
+
+ void* ptr = mmap(NULL,
+ var.yres_virtual * fix.line_length,
+ PROT_WRITE | PROT_READ,
+ MAP_SHARED, fd, 0);
+
+ FAIL_IF(ptr == MAP_FAILED, "mmap failed");
+
+ MappedCPUBuffer buf(var.xres_virtual, var.yres_virtual, PixelFormat::XRGB8888);
+
+ 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);
+
+ memcpy(ptr, buf.map(0), buf.size(0));
+
+ close(fd);
+
+ return 0;
+}