summaryrefslogtreecommitdiff
path: root/utils/fbtest.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-08-16 15:38:44 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-08-16 15:38:44 +0300
commit227830e15bc192f26c82a0cfe4a3ded358f0c074 (patch)
tree6257dab9b193e4f386e20389cecd4ea2461d96c7 /utils/fbtest.cpp
parenta7797a1361e72860072d84139bed316975572517 (diff)
rename testpat and fbtestpat
Diffstat (limited to 'utils/fbtest.cpp')
-rw-r--r--utils/fbtest.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/utils/fbtest.cpp b/utils/fbtest.cpp
new file mode 100644
index 0000000..1c9a5f1
--- /dev/null
+++ b/utils/fbtest.cpp
@@ -0,0 +1,58 @@
+#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 <kms++util/kms++util.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, PixelFormat::XRGB8888,
+ ptr, var.yres_virtual * fix.line_length, fix.line_length, 0);
+
+ 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);
+ draw_text(buf, buf.width() / 2, 0, fbdev, RGB(255, 255, 255));
+
+ close(fd);
+
+ return 0;
+}